How to use at::mm?

when I use

std::vector<at::Tensor>  dcnv2_forward(
        at::Tensor im,
        at::Tensor weights,
        at::Tensor Offset,
        at::Tensor Mask,
        int64_t num_deformable_group,
        int64_t kernel,
        int64_t pad,
        int64_t stride,
        int64_t dilation,
        bool use_bias,
        at::Tensor bias
        )
{
....
 at::Tensor out = at::mm(weights,
                        col.reshape(col2d_reshape));
...
}

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?

Could you try to use torch::Tensor and see if it’s working?

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());

when we do somethon like this:

at::TensorOptions options ;
    options.requires_grad(false);
    options.is_variable(true);
    options.device(weights.device());
    options.dtype(weights.dtype());

Error happen :
error: ‘struct at::TensorOptions’ has no member named ‘is_variable

any suggest how change at::TensorOptions.is_variable attribute?
THX

@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());
1 Like