#3fcam回复你完整的添加流程是怎样的?“1.在torch_mlu/tools/mlu_functions.yaml注册这个文件包含了代码生成需要的所有信息,一共需要name,use_mlu_dispatcher,derived_type,schema_string,arguments,return_type六个标记2.在torch_mlu/csrc/aten/operators/op_methods.cpp增加CPU的函数体这个文件目前不能自动生成,仍旧需要手动添加3.在torch_mlu/csrc/aten/operators/cnml/或者torch_mlu/csrc/aten/operators/cnnl/下添加实现cnml_kernel.h以及cnnl_kernel.h已经自动生成了,根据这两个头文件中的声明写xxx.cpp,再在internal文件夹下添加xxx_internal.cpp以及cnml_internal.h(或者cnnl_internal.h),以上3个步骤即可完成算子的注册”
展开 老师这是我的以下步骤:
第一步在torch_mlu/tools/mlu_functions.yaml中声明mlunmsthresh
第二步在torch_mlu/csrc/aten/operators/中op_methods.h与op_methods.cpp进行算子声明与CPU实现如下所示:
2.1op_methods.h声明:
virtual at::Tensor mlunmsthresh(const at::Tensor & source, int64_t num_classes, int64_t num_anchors);
如下所示
2.2op_methods.cpp实现:
第三步在torch_mlu/csrc/aten/operators/cnml中cnml_kernel.h声明与实现。在子目录internal下的声明与实现
3.1在cnml_kernel.h声明
at::Tensor cnml_mlunmsthresh(const at::Tensor & source, int64_t num_classes, int64_t num_anchors);
如下所示:
3.2在torch_mlu/csrc/aten/operators/cnml/mlunmsthresh.cpp进行实现cnml_mlunmsthresh
如下所示:
3.3在torch_mlu/csrc/aten/operators/cnml/internal/cnml_internal.h声明
at::Tensor cnml_mlunmsthresh(const at::Tensor & source, int64_t num_classes, int64_t num_anchors);
如下所示:
3.4torch_mlu/csrc/aten/operators/cnml/inernal/mlunmsthresh_internal.cpp实现
at::Tensor cnml_mlunmsthresh_internal(const at::Tensor & source,int64_t num_classes, int64_t num_anchors)
如下所示:
第四步完成编写返回/catch目录下执行 python setup.py install 重新编译catch
以上就是我的所有完整的添加流程步骤。老师 但是在调用
detect_out = torch.ops.torch_mlu.mlunmsthresh(score,80,8400)
测试还是出现出现(找不到该算子操作)
1