Hi,
I am working with aten in c++. I would like to cast one value of a tensor to integer, I was looking for in the aten documentation but I didn’t see anything related. Is it possible to do it?
I am trying to convert this piece of python code to cpp aten:
Python:
k = 0
for i in range(startd, startd+numd):
if self._degs[i]>0:
torch.mean(products.narrow(0,k,self._degs[i]), 0, out=output[i])
else:
output[i].fill_(0)
k = k + self._degs[i]
aten/cpp:
#include <torch/torch.h>
at::Tensor aggregate(int startd, int starte, int numd, at::Tensor degs, at::Tensor products, at::Tensor output){
int k = 0;
for(int i = startd; i < (startd+numd); i = i+1){
if (degs[i] > 0){
output[i] = at::mean(products.narrow(0,k,int(degs[i])));
}else{
output[i].fill_(0);
}
k = k + degs[i];
}
return output;
}
The intention of this code is work in a gpu and also be part of my main code in python. I would like to use this function for the forward pass of one of my custom layers.