in this particular case, could use dot or matmul.
e.g. in python
>>> g=torch.manual_seed(0)
>>> a=torch.rand(3)
>>> b=torch.rand(3)
>>> torch.matmul(a,b)
tensor(0.3578)
>>> torch.dot(a,b)
tensor(0.3578)
in c++, maybe something like:
#include “ATen/ATen.h”
using namespace at;
int main(void) {
Generator &gen = globalContext().defaultGenerator(Backend::CPU);
gen.manualSeed(0);
auto a=CPU(kFloat).rand(3);
auto b=CPU(kFloat).rand(3);
auto c=matmul(a,b);
auto d=dot(a,b);
std::cout <<“Dimension of c:” << c.dim() << “, value:” << c.toCDouble() << std::endl;
std::cout <<“Dimension of d:” << d.dim() << “, value:” << d.toCDouble() << std::endl;
}
Dimension of c:0, value:0.357792
Dimension of d:0, value:0.357792