Calculate `dot` product of image and vector
I would like to calculate something like dot product of vector and image with shapes:

(3)
(3,1080,1080)

and the output should be (1,1080,1080)
img = torch.rand((3,1080,1080))
R_coefficient=float(0.2126)
G_coefficient=float(0.7152)
B_coefficient=float(0.0722)
Y = img[0,...]*R_coefficient + img[1,...]*G_coefficient img[2,...]*B_coefficient

This code above gives me results, I look for, but I would like to use PyTorch utils like torch.dot, torch.matmul etc.
I have tried these
TensorImage(torch.dot(img[:,...],RGB_vector[:]))
TensorImage(torch.matmul(img,RGB_vector[:]))

These two options give me an errors connecting with shape, I have rejected them.
RGB_vector = torch.tensor([[[0.2126, 0.7152, 0.0722]]], dtype=img.dtype).permute(2,1,0)
    #     torch.t(RGB_vector)
        print(RGB_vector.shape)
        print(img.shape)
        return TensorImage(img[:,...]*RGB_vector)#.unsqueeze_(0)

this sample above works, but I am getting image with shape (3,1080,1080), but I need to get 1 instead of 3 at the first shape's dimension
Current working example
import torch
img = torch.rand((3,1080,1080))
RGB_vector = torch.tensor([[[0.2126, 0.7152, 0.0722]]], dtype=img.dtype).permute(2,1,0)
print(RGB_vector.shape)
print(img.shape)
TensorImage(img[:,...]*RGB_vector).unsqueeze_(0)

Greetings,
DA

(This can delivers the correct shape but Im not sure if that's what you need)
So a tensor multiplication where the second tensor has dim &gt;2 seems to work when the last dimension of the first tensor equals the second dimension of the second tensor.
v = torch.rand(3).unsqueeze(0)
m = torch.rand(3, 1080, 1080).transpose(0, 1)
r = torch.matmul(v, m).transpose(0, 1)

print(r.shape)

&gt;&gt;&gt; torch.Size([1, 1080, 1080])

