摘要: cuBlas API Launch Latency 耗时异常分析记录 一、背景 最近在做 AI 编译器生成 Kernel 支持 Bert 模型训练调优工作,在分析 bert 的timeline中发现,在每个 step 的前两个 cinn_instruction_run 之后,总是固定跟着一个 2.5 ms 左右的空白。但 HOST 端其实很早就 emit 了CUDA 阅读全文
posted @ 2023-05-12 10:44 Aurelius84 阅读(250) 评论(0) 推荐(0) 编辑
摘要: AI 编译器CINN中的OpLowering优化Pass 一、Lower 主逻辑 在 OpLower::Lower() 接口中,主要分为两大类: Elementwise类,主要涉及的 OpPattern 包括:kElementwise 、kBroadcast 、kInjective Reduce 类,主要涉及的OpPattern包括:kReduction 阅读全文
posted @ 2023-05-12 10:17 Aurelius84 阅读(90) 评论(0) 推荐(1) 编辑
摘要: Triton 源码初步研读 一、核心接口形态 def jit( fn: Optional[T] = None, *, version=None, do_not_specialize: Optional[Iterable[int]] = None, debug: Optional[bool] = None, ) -> Union 阅读全文
posted @ 2023-05-06 10:08 Aurelius84 阅读(1403) 评论(0) 推荐(0) 编辑
摘要: TVM 中的 Profiler 设计 一、基本用法 首先看 Profiler 的用法: with ms.Profiler() as profiler: # .... 用户代码 print("Tuning Time:") print(profiler.table()) 二、前端接口设计 其中 Profiler 类的设计是绑定和映射到了 C 阅读全文
posted @ 2023-05-06 09:50 Aurelius84 阅读(155) 评论(0) 推荐(0) 编辑
摘要: CINN 中子图编译缓存机制 采用 「问-答」形式记录研读 CINN 开源框架的笔记 Q:CINN中子图编译的入口是在哪里? for (const auto& node_vec : clusters) { // < 逐个遍历每个子图 // Classify var node to inputs, outputs, and int 阅读全文
posted @ 2023-05-06 09:45 Aurelius84 阅读(56) 评论(0) 推荐(0) 编辑
摘要: CUDA 的随机数算法 API 参考自 Nvidia cuRand 官方 API 文档 一、具体使用场景 如下是是在 dropout 优化中手写的 uniform_random 的 Kernel: #include <cuda_runtime.h> #include <curand_kernel.h> __device__ inl 阅读全文
posted @ 2023-05-06 09:35 Aurelius84 阅读(589) 评论(0) 推荐(0) 编辑
摘要: Tensorflow和飞桨Paddle的控制流算子设计 一、概览 注:整体方案上尚存在技术疑点,需进一步小组内讨论对齐,避免方案设计上存在后期难以扩展(或解决)的局限性 |框架 | TensorFlow 1.x | TensorFlow 2.x | Paddle | |: :|: :|: :|: :| | cond/while| √ | √ | √ | 阅读全文
posted @ 2022-09-27 17:42 Aurelius84 阅读(427) 评论(0) 推荐(0) 编辑
摘要: 飞桨PaddleLite架构研读 一、架构全景图 二、源码详细解读 1. Lite体系下似乎有多种 op_desc/program_desc 的定义,之间的关系是什么?这样设计的背景和好处是什么? model_parser目录下,包含 flatbuffers——结构描述定义在 framework.fbs 文件中,命名空间为paddl 阅读全文
posted @ 2022-09-27 17:35 Aurelius84 阅读(254) 评论(0) 推荐(0) 编辑
摘要: 飞桨动态图PyLayer机制 一、主要用法 如下是官方文档上的使用样例: import paddle from paddle.autograd import PyLayer # Inherit from PyLayer class cus_tanh(PyLayer): @staticmethod def forward(ctx, 阅读全文
posted @ 2022-09-27 17:28 Aurelius84 阅读(146) 评论(0) 推荐(0) 编辑
摘要: 技术书籍 — EffectiveMordenCpp 研读 一、类型推导 PROs: 源码某处的类型修改,可以自动传播其他地方 Cons: 会让代码更复杂(How?) 在模板类型推导时,有引用的实参会被视为无引用,他们的引用会被忽略 template<typename T> void f(T & param); // param 是一个引用 int x = 阅读全文
posted @ 2021-04-11 12:09 Aurelius84 阅读(119) 评论(0) 推荐(0) 编辑