From dc76fa1c38e702318a6583fa0c7feeb219d2e920 Mon Sep 17 00:00:00 2001 From: lmj01 Date: Fri, 12 Jan 2024 16:54:22 +0800 Subject: [PATCH] update --- ai/model.md | 30 ++++++++- articles/2024/trend.md | 14 ++++ cg/opengl.md | 124 ++++-------------------------------- cpl/cplusplus.md | 36 ++++++++++- cpl/polymorphism.md | 19 ++++-- cpl/programming.paradigm.md | 4 ++ index/article.md | 4 ++ index/computerScience.md | 4 ++ nodejs/frp.md | 16 ++++- 9 files changed, 133 insertions(+), 118 deletions(-) create mode 100644 articles/2024/trend.md diff --git a/ai/model.md b/ai/model.md index 10569bf..5f83541 100644 --- a/ai/model.md +++ b/ai/model.md @@ -1,7 +1,35 @@ # 模型 +## Model +How AI models are made: Data is a crucial component + +data is upstream in process of developing good models + +- Data prep, select data to train model on, across various sources +- Data evaluation & curation, clean & curate to improve dataset quality +- Model training + - create custom model architecture using training frameworks + - train & iterate models to improve performance +- Model deployment, deploy models & continueously evaluate to fine-tun models + +[BLOOM]() +[LLAMA-1]() +[LIaMA-2]() +[Mistral-7B]() +[OpenAI]() +[Codegen]() +[Stable Diffusion 1.0]() +[CodeV1]() + ## [DSD(Dense-Sparse-Dense)](https://arxiv.org/pdf/1607.04381.pdf) - [模型数据下载](https://songhan.github.io/DSD/) -如何通过改进训练过程提高传统模型的准确率 \ No newline at end of file +如何通过改进训练过程提高传统模型的准确率 + +## [onnx](https://onnx.ai/) +> Open Neural Network Exchange (ONNX) is an open ecosystem that empowers AI developers to choose the right tools as their project evolves. + +[microsoft的版本](https://github.com/onnx/onnx)和[ORT--ONNX Runtime: cross-platform, high performance ML inferencing and training accelerator](https://github.com/Microsoft/onnxruntime) +[可参考大致流程](https://github.com/microsoft/onnxjs) +[onnx example中可以找到一个例子,找到模型,把模型参数传入就可以得到结果了](https://github.com/microsoft/onnxruntime-inference-examples) \ No newline at end of file diff --git a/articles/2024/trend.md b/articles/2024/trend.md new file mode 100644 index 0000000..a34a5f7 --- /dev/null +++ b/articles/2024/trend.md @@ -0,0 +1,14 @@ +# 趋势 + +## platform + +- IaaS, Infrastructure as a service +- PaaS, Platform as a service +- SaaS, Software as a service +- IQaaS, Intelligence as a service + +## AI + +## 参考 + +- [The Ai Revolution]() diff --git a/cg/opengl.md b/cg/opengl.md index 593a5a0..9566428 100644 --- a/cg/opengl.md +++ b/cg/opengl.md @@ -43,127 +43,28 @@ FBO(Frame Buffer Object)帧缓冲区对象,它并不是内存块,不实际 上面说的是骨架,动笔绘画时就是绘制过程,针对没有索引提供了glDrawArrays绘制,有索引的提供了glDrawElements. ### Buffer Object +> 这里只考虑有shader的流程,较老的api存在部分差异,[glBindVertexArray在3.1后才支持的](https://registry.khronos.org/OpenGL-Refpages/gl4/html/glBindVertexArray.xhtml),流程上有些API的差异。因为随着GPU硬件的改进,只会越来越使用shader的了 + +VAO(Vertex Array Object)顶点数组对象,与FBO一样的概念,更像容器一样的感觉,它们都不是BufferObject,是为了管理数据而抽象成更高一层的概念,是一个状态容器。 ```c -glGenBuffers(GLsizei n, GLuint *buffers); -glBindBuffer(GLenum target, GLuint buffer); -glBufferData(target, ...); - -// update one -glBufferData(target, ...); -// update two -glBufferSubData(target, ...); -// update three -glMapBufferRange(target, ...); -glUnmapBuffer(target, ...); +// 关联VAO,从CPU端可上传到GPU显存中 +glBindVertexArray(VAO); +// 绑定VBO到VAO对象下 +// 关闭VAO +glBindVertexArray(0); ``` - -Target有 +VA(Vertex Array),VA是client客户端的,是在CPU内存中,需要传输到服务端GPU显存中 +VBO(Vertex Buffer Object)类型有 - GL_ARRAY_BUFFER顶点属性 - GL_ELEMENT_ARRAY_BUFFER 顶点索引 - GL_TEXTURE_BUFFER 纹理 - GL_PIXEL_UNPACK_BUFFER - GL_PIXEL_PACK_BUFFER 像素数据,PBO(Pixel Buffer Object), 可通过DMA(Direct Memory Access)快速在显卡上传输 -从glVertex的glBegin和glEnd升级到VA(Vertex Array),VA是client客户端的,是在内存中,还需要传输到服务端GPU显存中,glCallList列表一旦设置后就不能更改,在固定管线中还可以,在可编程管线中就没有优势了,为了解决这些问题就是VBO(Vertex Buffer Object)产生的原因 - -数据的准备 -```c -glGenBuffers(1, &vboPos); -glBufferData(GL_ARRAY_BUFFER, sizeof(dataPos), dataPos, GL_STREAM_DRAW); - -glGenBuffers(1, &vboTex); -glBufferData(GL_ARRAY_BUFFER, sizeof(dataTex), dataTex, GL_STREAM_DRAW); - -glGenBuffers(1, &vboIdx); -glBufferData(GL_ARRAY_BUFFER, sizeof(dataIdx), dataIdx, GL_STREAM_DRAW); -``` - -没有shader的流程 -```c -glBindBuffer(GL_ARRAY_BUFFER, vboPos); -glEnableClientState(GL_VERTEX_ARRAY); -glVertexPointer(2, GL_FLOAT, 0, NULL); - -glBindBuffer(GL_ARRAY_BUFFER, vboTex); -glEnableClientState(GL_TEXTURE_COORD_ARRAY); -glTexCoordPointer(2, GL_FLOAT, 0, NULL); - -glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIdx); -glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, NULL); -glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - -glDisableClientState(GL_TEXTURE_COORD_ARRAY); -glDisableClientState(GL_VERTEX_ARRAY); - -glBindBuffer(GL_ARRAY_BUFFER, 0); -``` - -有shader的流程 -```c -glBindBuffer(GL_ARRAY_BUFFER, vboPos); -glEnableVertexAttribArray(location1) -glVertexAttribDivisor(location1); // 多实例技术 -glVertexAttribPointer(location1, 2, GL_INT, GL_FALSE, 0, 0); - -glBindBuffer(GL_ARRAY_BUFFER, vboTex); -glEnableVertexAttribArray(location2) -glVertexAttribPointer(location2, 2, GL_INT, GL_FALSE, 0, 0); - -glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIdx); -glDrawArrays(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); - -glDisableVertexAttribArray(location1); -glDisableVertexAttribArray(location2); +Context负责切换时,也只需要切换不同的VAO就可以了,数据都在VAO初始化完成,渲染只关联对应的VAO并获取对应的Buffer就可以渲染了,或者每个Mesh一个VAO也方便数据的管理。 -glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -glBindBuffer(GL_ARRAY_BUFFER, 0); -``` - -通过上面的分析可以指定,从最初的单个数据的传输到现在的块传输,都是与硬件相关的,现在的GPU并行是很强的,所以一块块的传输数据就是性能的关键,上面的数据还不够紧凑,还可以进行优化。 - -VAO(Vertex Array Object)顶点数组对象 -> 与FBO一样的概念,更抽象容器一样的描述 - -它不是Buffer-Object, 是为了管理数据而引入的。可以看到它是一个状态容器,关联了VBO的状态。这样处理是因为VBO把数据放在了GPU服务器端,一个渲染流程有多份不同渲染逻辑时,Context负责进行切换,为了数据共享,这就是VAO的作用,把数据都放在初始化阶段,每个渲染逻辑关联不同的Buffer Object就更高效了。 - -```c -glGenBuffers(1, &vboPos); -glBingBuffer(GL_ARRAY_BUFFER, vboPos); -glBufferData(GL_ARRAY_BUFFER, sizeof(dataPos), dataPos, GL_STREAM_DRAW); - -glGenBuffers(1, &vboTex); -glBingBuffer(GL_ARRAY_BUFFER, vboTex); -glBufferData(GL_ARRAY_BUFFER, sizeof(dataTex), dataTex, GL_STREAM_DRAW); - -glGenBuffers(1, &vboIdx); -glBingBuffer(GL_ARRAY_BUFFER, vboIdx); -glBufferData(GL_ARRAY_BUFFER, sizeof(dataIdx), dataIdx, GL_STREAM_DRAW); - -// -glGenVertexArrays(1, &vao); -glBindVertexArray(vao); - -glBindBuffer(GL_ARRAY_BUFFER, vboPos); -glEnableVertexAttribArray(location1) -glVertexAttribPointer(location1, 2, GL_INT, GL_FALSE, 0, 0); -glBindBuffer(GL_ARRAY_BUFFER, vboTex); -glEnableVertexAttribArray(location2) -glVertexAttribPointer(location2, 2, GL_INT, GL_FALSE, 0, 0); - -glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIdx); - -glBindVertexArray(0); - -glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); -glBindBuffer(GL_ARRAY_BUFFER, 0); - -// use -glBindVertexArray(vao); -glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, 0); -glBindVertexArray(0); -``` FBO(Frame Buffer Object) @@ -273,11 +174,14 @@ glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); ``` ## UI库 + - [NanoGUI is a a minimalistic cross-platform widget library for OpenGL 3.x. It supports automatic layout generation, stateful C++11 lambdas callbacks, a variety of useful widget types and Retina-capable rendering on Apple devices thanks to NanoVG by Mikko Mononen. Python bindings of all functionality are provided using pybind11. ](https://github.com/wjakob/nanogui) + ## oglplus - [OGLplus's Documentation!](https://matus-chochlik.github.io/oglplu2/sphinx/index.html) - [github](https://github.com/matus-chochlik/oglplus) + ## 参考 - [OpenGL基础,一个韩国人写的基础知识](http://www.songho.ca/opengl/index.html) diff --git a/cpl/cplusplus.md b/cpl/cplusplus.md index 611dc60..6da5533 100644 --- a/cpl/cplusplus.md +++ b/cpl/cplusplus.md @@ -135,7 +135,7 @@ int main() { 在一些数据范围小答案可以枚举,且时间上较为苛刻的,使用暴力枚举得出答案,将答案写入数组中。是指先生成一些数据可直接使用,减少运行的时间,对计算量大的可以这样优化。别人把特定计算放在一些文件中,部署出去的程序就跑得飞快,其他人还好奇为什么你的就这么快。 -### Template +### NTTP NTTP-non-type template parameters ```c++ @@ -149,6 +149,40 @@ struct string_literal { } ``` +### 解耦 +模板用来解耦, +如果send函数的逻辑复制,需要抽离出来复用,这时候就可以考虑使用模板来解耦,还可以避免相互依赖问题 +```c++ +// +class Connection { +public: + void send() { + Helper helper(this); + helper.send(); + } +private: + friend class Helper; // 为了Helper访问私有对象 + std::string buf; +} +``` +```c++ +// helper.hpp +template +class Helper { +public: + Helper(T *t) : buf(t->buf) {} + void send() { std::cout << buf << std::endl; } +private: + std::string& buf; +} +// 因为模板类,需要填写模板参数,可以使用C++17的deduction guide来消除这个模板参数 +template +Helper(T *t) -> Helper; // deduction guide c++17 +``` + +[**Deduction Guide**推断指引,CTAD-class template argument deduction](https://en.cppreference.com/w/cpp/language/class_template_argument_deduction)是C++17的新语法,当用类模板新建一个类时,希望编译器通过给定的规则创建与构造器传入参数对应的模板类型时, +给定的规则就是推断指引。当模板名称显示为推导类类型的类型说明符时,使用推断指引。 + ## 其他 ### Fiber diff --git a/cpl/polymorphism.md b/cpl/polymorphism.md index 8d4a86e..b2b7183 100644 --- a/cpl/polymorphism.md +++ b/cpl/polymorphism.md @@ -1,17 +1,18 @@ -# polymmorphism +# OOP(Object-Orientation Programming) +> + +## polymmorphism 多态是高级编程语言的一个重要特性,它影响着代码的组织和复用程度 也是泛型的基础,减少代码的臃肿,丰富程序语言本身的表达能力 -## 多态类型 - ### 动态型 C++中使用cast转换,以父类作为接口,在运行期动态决定调用具体的子类对象。 ### 静态型 C++中的模板,在编译期就决定了那个函数的调用。 -## 泛型 +### 泛型 它是程序设计语言的一种风格或范式,是强类型程序设计语言中编写代码时使用一些稍后才能指定的类型,在实例化(instantiate)时作为参数指明这些类型 Ada,Delphi,Eiffel, Java, C#, F#, Swift, Visual Basic .Net等称为泛型generics @@ -35,4 +36,12 @@ C++,D等称模板template 就像JIT(just-in-time compiler)即时编译器一样 -type system和meta type system \ No newline at end of file +type system和meta type system + +### C++的多态 + +实现多态的类型 + +- 虚函数,传统的方式就是虚函数,使用基类和派生类技术 +- std::variant, c++17增加,实现了一种无需继承的多态性 +- CRTP(curiously recurring template pattern), 通过模板的奇异递归模式实现多态性 \ No newline at end of file diff --git a/cpl/programming.paradigm.md b/cpl/programming.paradigm.md index 916a24c..fbe6104 100644 --- a/cpl/programming.paradigm.md +++ b/cpl/programming.paradigm.md @@ -6,6 +6,10 @@ Language design guidelines - 分层语言设计,严格的函数式核心,紧接着是声明式并发,然后是异步消息传递,最后是全局命名状态. +什么是编程范式, 它是一个分类学和基因组学的问题。避免形态学morphology的干扰,重点关注程序结构中自我表达的基因上。编程的基因组学是类型理论type theory,是计算的系统研究,其最初制定为一种数学基础,其中命题是统一了语言语义、程序验证和编译器实现的程序设计语言研究中心组织原则的类型和证明。 + +类型理论与逻辑学、代数、拓扑学有着深刻联系,是编程语言中真理的试金石,隔离和澄清计算的核心概念。Paradigms are clades. Types are genes.范式是进化树,而类型是基因。Each paradigm has its own 'soul' that can only be understood by actually using the paradigm. We recommend that you explore the paradigms by actually programming in them. + ## Declarative Paradigm ### Declarative concurrency diff --git a/index/article.md b/index/article.md index 36835fe..0bc51b5 100644 --- a/index/article.md +++ b/index/article.md @@ -64,6 +64,10 @@ ### [openmesh](https://www.graphics.rwth-aachen.de/software/openmesh/) +## 2024 + +- [2024趋势](../articles/2024/trend.md) + ## 2023 - [app 2023](../articles/2023/app.md) diff --git a/index/computerScience.md b/index/computerScience.md index 1ed4978..ceeb60a 100644 --- a/index/computerScience.md +++ b/index/computerScience.md @@ -58,6 +58,8 @@ - [CAD相关笔记](../cg/tools/CAD.md) - [FreeCAD is an open-source parametric 3D modeler made primarily to design real-life objects of any size](https://github.com/FreeCAD/FreeCAD) +- [Analysis Situs, Analysis Situs is the open-source application and SDK for CAD feature recognition and more](https://analysissitus.org/index.html) +- [Yet another modeling kernel? Hell, no.关于是否要从0开发一个新的几何内核](https://quaoar.su/blog/page/modeling-kernel-no-thanks) ### api @@ -106,6 +108,8 @@ ### 动画 - [快速生成3D动画模型 Magical 3D motion studio with AI Generate production-ready animations in a minute, offering endless possibilities](https://mootion.com/landing) +- [Tracking Everything Everywhere All at Once](https://omnimotion.github.io/) + - [PyTorch Implementation for paper Tracking Everything Everywhere All at Once, ICCV 2023.](https://github.com/qianqianwang68/omnimotion) ### Tool diff --git a/nodejs/frp.md b/nodejs/frp.md index e70d585..a96fe98 100644 --- a/nodejs/frp.md +++ b/nodejs/frp.md @@ -20,11 +20,25 @@ fromEvent(el, 'click').piep(throttleTime(3000)).subscribe(()=>{ }) ``` -RxJS最核心概念是stream,相比数组多了一个时间维度的概念,Rxjs通过Observable(可观测对象)来具象化stream, +RxJS最核心概念是stream,相比数组多了一个时间维度的概念,Rxjs通过Observable(可观测对象)来具象化stream。 + +RxJS可以做防腐层,抽离一个层来,对上就是对接Service和Mock一些数据和不同入口的处理;对下只对View层负责更新。这种View只对UI负责。整个框架就变得非常清晰了。 + +与前端状态管理最理想的框架是基于Flux实现的Redux,但Redux有种种问题,通过RxJS这种思路可以有更好的替换,如[CycleJS--A functional and reactive JavaScript framework for predictable code](https://github.com/cyclejs/cyclejs). Redux单向数据流,操作非常复杂,RxJS完全在于数据流stream的提供和操作,不关心细节上的细分。 + +### 操作符 + +- [tap](https://rxjs.dev/api/index/function/tap), 一个不影响的纯操作,常用来在stream中间态拿到当前的数据事件来修改外部状态或一些通知。最重要的是方便调试代码逻辑。 ### [Marbles](https://rxmarbles.com/) 可视化RxJS的stream,也叫弹珠Marbles,所有的RxJS相关内容和Operators都可以用Marbles来表示 +### 调试工具 + +[rxjs-spy](https://github.com/cartant/rxjs-spy) +[rxjs-devtools](https://github.com/ardoq/rxjs-devtools) + + ## 参考 - [rxjs 源码分析1-(fromEvent)](https://juejin.cn/post/6844903730425364494)