matmul method
Matrix multiplication for 2D tensors.
this is (M, K) and other is (K, N), result is (M, N).
Implementation
Tensor matmul(Tensor other) {
if (ndim == 2 && other.ndim == 2) {
return _matmul2d(this, other);
}
if (ndim >= 3 && other.ndim == 2) {
return _batchMatmul2d(this, other);
}
if (ndim >= 3 && other.ndim >= 3) {
return _batchMatmulBoth(this, other);
}
throw ArgumentError(
'matmul not supported for shapes $shape and ${other.shape}');
}