Comment by adrian_b

21 hours ago

The matrix product is not something specific to matrices, but it is a particular case of the contracted tensor product.

(While now almost everybody uses the names "tensor product" and "contracted tensor product", historically these names are wrong. Better names, which do not misuse the word "tensor", would have been "Zehfuss product" and "Cayley product", after the names of the mathematicians who have introduced them.)

The word "tensor" has become increasingly corrupted over the years. Originally, it had a meaning that matched its etymology, i.e. "tensor" meant "symmetric matrix", because a matrix could be decomposed through the polar decomposition into a tensor and a versor (i.e. a symmetric matrix and a rotation matrix).

Then what is now called tensor theory was created by Ricci, but without ever using the word "tensor". The meaning of the word "tensor" was changed by Einstein in his theory of the general relativity, where for unknown reasons he chose this word to refer to arrays with an arbitrary number of dimensions that satisfy a certain kind of transformation relationships when the systems of coordinates is changed.

After WWII, due to the huge popularity of Einstein, this weird usage of the word has become widespread.

Then for many decades tensors were just a subset of arrays, those that are changed in a certain specific way when the system of coordinates is changed.

Eventually, there was the second corruption of the word "tensor" which is completely unjustified, when "tensor" has become just a synonym for "array".

Vectors are 1-dimensional arrays (though originally, like tensors, vectors were only a subset of 1-dimensional arrays), matrices are 2-dimensional arrays and nowadays "tensors" means just "arrays", i.e. of an arbitrary dimension.

The tensor product and the contracted tensor product are defined for arrays of arbitrary dimensions. For 2-dimensional arrays the contracted tensor product is a.k.a. matrix product, and for 1-dimensional arrays it is a.k.a. scalar product.

yes. do you have a more useful meaning for tensors?

MLIR distinguishes arrays and tensors by allowing array mutation, but not for tensors; which allows a large class of optimizations

though the internal representation is one and the same

i understand it is the same for SIMD aswell (modulo alignment etc)

  • TIL MLIR supports sparse tensors with sparse_tensor.encoding = { dense, compressed, specialized structures for hypersparse regions, and hardware-specific sparse constraints, such as NVIDIA's 2:4 structured sparsity layout }

    But it looks like [MLIR and all other implementations of] SIMD only accept vectors; so there can't be Zero-Copy there because the tensor must (?) be copied to a vector to pass to a SIMD e.g. matmul routine, and then the resultant vector must be copied back into a tensor only if there are subsequent references to the complete tensor instead of just a slice?

    FWIU, AFAICS, GPUs are designed for 3x3 tensors (and affine transformation to 2D) but for greater degrees like for 4x4 tensors (e.g. for SQG) you must implement shaders?

Normed tensor Gaussian splatters are useful too.

From https://news.ycombinator.com/item?id=49855122 re: gravity from QED without any GR spacetime curvature, using the ~amplituhedron to solve n-body gravity with scattering amplitudes, and SQG/DDF:

> normed tensor gaussian splatters work well as a simulation primitive for this too because they do conservation.