Dear experts,
I’m trying to multiply my [B, 2, X, Y]
tensor with a (constant_1, constant_2) vector of scalars.
The constraint is that it should export to onnx (opset 9)
I tried
# this won't export to onnx
def forward(self, x):
x[:,0,:,:] *= const_1
x[:,1,:,:] *= const_2
return x
# this does export fine but obviously not doing what I want
def forward(self, x):
x.mul_(const_1)
return x
# this actually doesn't do anything
def forward(self, x):
x[:,0,:,:].mul_(const_1)
x[:,1,:,:].mul_(const_2)
return x
How can I achieve this using torch operators?