Looks good. Performance-wise, this won’t compile to AVX instructions, but these are tricky. You may check how dot is calculated in BlasKernel.cpp 6 to get an idea.Otherwise, you can use AT_DISPATCH_FLOATING_TYPES and remove set_num_threads line.