c = a.reshape(-1, b.shape[0]) * b
print(c.flatten())

I’d like to use the broadcast mechanic instead of extend the tensor manually, for I guess the broadcast implement in the torch or numpy will be more efficient.