tvm-张量操作算子实现文件代码分析 头文件引入+反射注册

6 阅读1分钟

#include "manipulate.h" 引入用户自定义头文件(双引号""是标识),manipulate.h是当前项目内的头文件,提供该源文件所需的自定义声明(如函数、宏、结构体等)。

#include <tvm/ffi/reflection/registry.h> 引入系统 / 第三方库头文件(尖括号<>是标识),属于 TVM 框架的 FFI(外部函数接口)反射模块,提供注册表相关的功能声明。

#include 引入 C++ 标准库的算法头文件,提供排序、查找、遍历等通用算法(如std::sort、std::find)

#include 引入C+标准库得数值算法头文件,提供数值相关得累积 求和等算法 比如std::accumulate

#include 解析:引入 C++ 标准库的字符串头文件,提供std::string类及相关字符串操作方法

#include 引入 C++ 标准库的通用工具头文件,提供通用工具类 / 函数(如std::pair、std::move)。

#include 引入 C++ 标准库的向量容器头文件,提供std::vector动态数组容器及相关操作方法。

#include "tvm/runtime/data_type.h" 再次引入 TVM 框架的自定义头文件(双引号标识),属于 TVM 运行时模块,提供数据类型相关的声明(如 TVM 中的张量数据类型定义)。

上面是头文件部分,均为引入使用

TVM_FFI_STATIC_INIT_BLOCK() { tvm里面定义的宏块

ConcatAttrs::RegisterReflection(); 拼接

ExpandDimsAttrs::RegisterReflection(); 拓展维度

LayoutTransformAttrs::RegisterReflection(); 布局转换

PermuteDimsAttrs::RegisterReflection(); 维度置换

SplitAttrs::RegisterReflection(); 分割

SqueezeAttrs::RegisterReflection(); 压缩

StackAttrs::RegisterReflection(); 张量堆叠

RepeatAttrs::RegisterReflection(); 重复

TileAttrs::RegisterReflection(); 张量分块

FlipAttrs::RegisterReflection(); 张量翻转

GatherElementsAttrs::RegisterReflection(); 元素收集

GatherNDAttrs::RegisterReflection(); N维收集

IndexPutAttrs::RegisterReflection(); 索引赋值

MeshgridAttrs::RegisterReflection(); 网格生成

ScatterElementsAttrs::RegisterReflection(); 元素散射

ScatterNDAttrs::RegisterReflection(); N维散射

SliceScatterAttrs::RegisterReflection(); 切片散射

OneHotAttrs::RegisterReflection(); 独热

    反射注册

}