Bug report : RuntimeError: /opt/conda/conda-bld/pytorch_1532581333611/work/torch/csrc/autograd/variable.h:127: Variable: Assertionis_variable() || !defined()failed: Tensor that was converted to Variable was not actually a Variable
I guess at::mm need Variable input , so which function should use to do multiplication?at::mm or something else?
thanks for replay , I check col type is Tensor not Variable, and
finally we find :
/// WARNING: In PyTorch, there are `torch::` variants of factory functions,
/// e.g., torch::zeros for at::zeros. These return Variables (while the
/// stock ATen functions return plain Tensors). If you mix these functions
/// up, you WILL BE SAD.
so recreate like , it works at::Tensor col = at::empty(your_shape, weights.options());
@Wu_jiang You should use the torch::mm variant and replace all mentions of at::Tensor to torch::Tensor in your function, because at::Tensor is now an implementation detail and torch::Tensor is the preferred way of representing a tensor.
For in-place setting values of a torch::TensorOptions, here is an example:
auto options =
torch::TensorOptions()
.requires_grad(false)
.is_variable(true)
.device(weights.device())
.dtype(weights.dtype());