进行算子编译时,开发者需要感知不同架构、不同的AI处理器型号。
...
target_compile_options(demo PRIVATE
// 将dav-xxxx更换为对应NPU架构版本号
$<$<COMPILE_LANGUAGE:ASC>:--npu-arch=dav-xxxx>
)
1 2 | void AddConfig(const char *soc); void AddConfig(const char *soc, OpAICoreConfig &aicore_config); |
通过该接口注册AI处理器型号的样例如下,ascendxxx填写规则请参考算子工程目录下编译配置项文件CMakePresets.json中的ASCEND_COMPUTE_UNIT字段,该字段取值在使用msOpGen创建工程时自动生成。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ... namespace ops { class AddCustom : public OpDef { public: AddCustom(const char* name) : OpDef(name) { ... // 将ascendXXX更换为对应芯片版本 this->AICore().AddConfig("ascendxxx"); } }; OP_ADD(AddCustom); } // namespace ops |