Element-wise multiplication between constant tensor and variable tensor

I need to multiply a tensor variable by a tensor constant
(for example, convolution filter multiply by a constant mask)

But, torch.mul() only accept two tensors or two variables.

What I did what was convert constant --> Variable(tensor, requires_grad=False)

Is this the recommended way to do math operation between constant tensor and variable tensor?


Yes this is indeed the recommended way.


Is this way suitable on multiple GPUs?

I use the weighted L1 loss on multiple GPUs, but it failed. The detailed information is shown in Weighted L1 loss in parallel training

Any suggestions?