TensorCore.jl

This package is intended as a lightweight foundation for tensor operations across the Julia ecosystem. Currently it exports two core operations, hadamard and tensor, and corresponding unicode operators and , respectively.

API

TensorCore.hadamardFunction
hadamard(a, b)
a ⊙ b

For arrays a and b, perform elementwise multiplication. a and b must have identical axes.

can be passed as an operator to higher-order functions.

Examples

julia> a = [2, 3]; b = [5, 7];

julia> a ⊙ b
2-element Array{Int64,1}:
 10
 21

julia> a ⊙ [5]
ERROR: DimensionMismatch("Axes of `A` and `B` must match, got (Base.OneTo(2),) and (Base.OneTo(1),)")
[...]

See also hadamard!(y, a, b).

source
TensorCore.hadamard!Function
hadamard!(dest, A, B)

Similar to hadamard(A, B) (which can also be written A ⊙ B), but stores its results in the pre-allocated array dest.

source
TensorCore.tensorFunction
tensor(A, B)
A ⊗ B

Compute the tensor product of A and B. If C = A ⊗ B, then C[i1, ..., im, j1, ..., jn] = A[i1, ... im] * B[j1, ..., jn].

For vectors v and w, the Kronecker product is related to the tensor product by kron(v,w) == vec(w ⊗ v) or w ⊗ v == reshape(kron(v,w), (length(w), length(v))).

Examples

julia> a = [2, 3]; b = [5, 7, 11];

julia> a ⊗ b
2×3 Array{Int64,2}:
 10  14  22
 15  21  33

See also tensor!(Y,A,B).

source
TensorCore.tensor!Function
tensor!(dest, A, B)

Similar to tensor(A, B) (which can also be written A ⊗ B), but stores its results in the pre-allocated array dest.

source