In recent, a pooling extension has been used in my code. But I use a higher version pytorch than introduced in the original repo. The pooling function has used two functions named masked_scatter_
and masked_fill_
. In previous version of pytorch, it could be fine. However, when I use pytorch==1.4.0 the two functions output tens of warning
. It refers to the variable mask
is defined with at::kByte
scalar type while the two function require the mask
to become torch.bool
type. Otherwise the program will output warning when the function is called. So my question is how to convert the type of mask
from at::kByte
to torch.bool
(It is easy in python just using one line var.bool()
). But how to implement that in C++ version. I can not find any reference in doc.
Would tensor.to(at::kBool)
work?
1 Like
single tensor
torch::Tensor t = torch::randn({1});
float f = t.item().toBFloat16();
multi tensor
std::memcpy(dataptr, tensor.data_ptr(), sizeof(torch::kU8/*tensortype*/) * tensor.numel());