Ascend / pytorch

Ascend PyTorch adapter (torch_npu). Mirror of https://gitee.com/ascend/pytorch
https://ascend.github.io/docs/
Other
196 stars 10 forks source link

创建一npu上的empty tensor #39

Open nihao1997 opened 3 weeks ago

nihao1997 commented 3 weeks ago

我想要创建一个空的npu tensor给Silu函数,这个Silunpu上的函数。我应该怎么办?

include

include

include

include <torch/extension.h>

include <torch/torch.h>

void Silu(at::Tensor X); int main() { at::Tensor H = torch::empty({2, 2 2}, at::device().dtype());

Silu(H);
return 0;

}

yunyiyun commented 3 weeks ago

如果是在c++侧使用,可以参考该用例 https://github.com/Ascend/pytorch/tree/master/examples/libtorch_resnet