尹成人工智能Pytorch1.9
libtorch新算子導(dǎo)出.so,python調(diào)用
index_add.cpp
#include <torch/extension.h> ? ? ? ? ? ? ? ? ? ?// 頭文件引用部分 torch::Tensor index_add(torch::Tensor &left, torch::Tensor &index, torch::Tensor &right) {
? ?
? ?for (int i = 0; i < index.size(0); i++){
? ? ? ?left[index[i]] = left[index[i]] + right[i];
? ?}
標(biāo)簽: