2. Tensor Functions¶
2.1. Basic Math¶
-
add(lhs:Tensor<S>, rhs:Tensor<S>, result:Tensor<S>)¶ -
add(lhs:Tensor<S>, rhs:NumericType, result:Tensor<S>) -
add(lhs:NumericType, rhs:Tensor<S>, result:Tensor<S>) -
+(lhs:Tensor<S>, rhs:Tensor<S>) -> Tensor<S> -
+(lhs:Tensor<S>, rhs:NumericType) -> Tensor<S> -
+(lhs:NumericType, rhs:Tensor<S>) -> Tensor<S> Adds
lhsandrhstogether, either place results inresultor returning its value. If the shape oflhsandrhsdo not match, will either usebroadcastto match their size, or use optimized methods to accomplish the same purpose.
-
sub(lhs:Tensor<S>, rhs:Tensor<S>, result:Tensor<S>)¶ -
sub(lhs:Tensor<S>, rhs:NumericType, result:Tensor<S>) -
sub(lhs:NumericType, rhs:Tensor<S>, result:Tensor<S>) -
-(lhs:Tensor<S>, rhs:Tensor<S>) -> Tensor<S> -
-(lhs:Tensor<S>, rhs:NumericType) -> Tensor<S> -
-(lhs:NumericType, rhs:Tensor<S>) -> Tensor<S> Subtracts
lhsfromrhs, either place results inresultor returning its value. If the shape oflhsandrhsdo not match, will either usebroadcastto match their size, or use optimized methods to accomplish the same purpose.
-
mul(lhs:Tensor<S>, rhs:Tensor<S>, result:Tensor<S>)¶ -
mul(lhs:Tensor<S>, rhs:NumericType, result:Tensor<S>) -
mul(lhs:NumericType, rhs:Tensor<S>, result:Tensor<S>) -
*(lhs:Tensor<S>, rhs:Tensor<S>) -> Tensor<S> -
*(lhs:Tensor<S>, rhs:NumericType) -> Tensor<S> -
*(lhs:NumericType, rhs:Tensor<S>) -> Tensor<S> Performs element-wise multiplication between
lhsandrhs, either place results inresultor returning its value. If the shape oflhsandrhsdo not match, will either usebroadcastto match their size, or use optimized methods to accomplish the same purpose.
-
div(lhs:Tensor<S>, rhs:Tensor<S>, result:Tensor<S>)¶ -
div(lhs:Tensor<S>, rhs:NumericType, result:Tensor<S>) -
div(lhs:NumericType, rhs:Tensor<S>, result:Tensor<S>) -
/(lhs:Tensor<S>, rhs:Tensor<S>) -> Tensor<S> -
/(lhs:Tensor<S>, rhs:NumericType) -> Tensor<S> -
/(lhs:NumericType, rhs:Tensor<S>) -> Tensor<S> Performs element-wise division between
lhsandrhs, either place results inresultor returning its value. If the shape oflhsandrhsdo not match, will either usebroadcastto match their size, or use optimized methods to accomplish the same purpose.
-
iadd(lhs:Tensor<S>, rhs:Tensor<S>)¶ -
iadd(lhs:Tensor<S>, rhs:NumericType) -
iadd(lhs:NumericType, rhs:Tensor<S>) -
+=(lhs:Tensor<S>, rhs:Tensor<S>) -
+=(lhs:Tensor<S>, rhs:NumericType) -
+=(lhs:NumericType, rhs:Tensor<S>) Adds
lhstorhsand stores result inlhs, either place results inresultor returning its value. If the shape oflhsandrhsdo not match, will either usebroadcastto match their size, or use optimized methods to accomplish the same purpose.
-
isub(lhs:Tensor<S>, rhs:Tensor<S>)¶ -
isub(lhs:Tensor<S>, rhs:NumericType) -
isub(lhs:NumericType, rhs:Tensor<S>) -
-=(lhs:Tensor<S>, rhs:Tensor<S>) -
-=(lhs:Tensor<S>, rhs:NumericType) -
-=(lhs:NumericType, rhs:Tensor<S>) Subtracts
rhsfromlhsand stores result inlhs, either place results inresultor returning its value. If the shape oflhsandrhsdo not match, will either usebroadcastto match their size, or use optimized methods to accomplish the same purpose.
-
imul(lhs:Tensor<S>, rhs:Tensor<S>)¶ -
imul(lhs:Tensor<S>, rhs:NumericType) -
imul(lhs:NumericType, rhs:Tensor<S>) -
*=(lhs:Tensor<S>, rhs:Tensor<S>) -
*=(lhs:Tensor<S>, rhs:NumericType) -
*=(lhs:NumericType, rhs:Tensor<S>) Multiplies
lhsbyrhsand stores result inlhs, either place results inresultor returning its value. If the shape oflhsandrhsdo not match, will either usebroadcastto match their size, or use optimized methods to accomplish the same purpose.
-
idiv(lhs:Tensor<S>, rhs:Tensor<S>)¶ -
idiv(lhs:Tensor<S>, rhs:NumericType) -
idiv(lhs:NumericType, rhs:Tensor<S>) -
/=(lhs:Tensor<S>, rhs:Tensor<S>) -
/=(lhs:Tensor<S>, rhs:NumericType) -
/=(lhs:NumericType, rhs:Tensor<S>) Divides
lhsbyrhsand stores results inlhs, either place results inresultor returning its value. If the shape oflhsandrhsdo not match, will either usebroadcastto match their size, or use optimized methods to accomplish the same purpose.
-
pow(lhs:Tensor<S>, exp:NumericType) → Tensor<S>¶ -
**(lhs:Tensor<S>, exp:NumericType) -> Tensor<S> Raises every element of
lhsbyexp.
-
exp(op::Tensor<S>) → Tensor<S>¶ Returns an element-wise exponentiation of
op.
-
abs(op:Tensor<S>) → Tensor<S>¶ Performs an elementwise
abson Tensor.
-
sum(op:Tensor<S>, axis:Int) → Tensor<S>¶ -
sum(op:Tensor<S>) → NumericType When
axisis specified, sumsopalongaxisand returns resulting Tensor. When noaxisis specified, returns entire Tensor summed.
-
max(op:Tensor<S>, axis:Int) → Tensor<S>¶ -
max(op:Tensor<S>) → NumericType When
axisis specified, find the maximum valueopacrossaxisand returns resulting Tensor. When noaxisis specified, returns maximum value of entire Tensor.
-
min(op:Tensor<S>, axis:Int) → Tensor<S>¶ -
min(op:Tensor<S>) → NumericType When
axisis specified, find the minimum valueopacrossaxisand returns resulting Tensor. When noaxisis specified, returns minimum value of entire Tensor.
2.2. Linear Algerbra¶
-
dot(lhs:Tensor<S>, rhs:Tensor<S>) → NumericType¶ -
⊙(lhs:Tensor<S>, rhs:Tensor<S>) -> NumericType Returns the dot product between two vectors. Both
lhsandrhsmust be vectors.
-
outer(lhs:Tensor<S>, rhs:Tensor<S>) → NumericType¶ -
⊗(lhs:Tensor<S>, rhs:Tensor<S>) -> NumericType Returns the outer product between two vectors. Both
lhsandrhsmust be vectors.
2.3. Tensor Manipulation¶
-
fill(op:Tensor<S>, value:NumericType)¶ Sets all elements of
optovalue.
-
copy(op:Tensor<S>) → Tensor<S>¶ -
copy(from:Tensor<S>, to:Tensor<S>) First form creates a new Tensor and copies
opinto it. The second form copiesopinto an already existing Tensor.
-
map(op:Tensor<S>, fn:(NumericType) -> NumericType) → Tensor<S>¶ Applies
fnto each element of Tensor and returns resulting Tensor.
-
reduce(op:Tensor<S>, fn:(Tensor<S>, Tensor<S>) -> NumericType) → NumericType¶ Applies
fnto elements of Tensor, returns a scalar.
-
concat(op1:Tensor<S>, op2:Tensor<S>, ..., opN:Tensor<S>, axis:Int)¶ Concats N Tensors along
axis.
-
vstack(op1:Tensor<S>, op2:Tensor<S>) → Tensor<S>¶ Returns a new Tensor that is a composite of
op1andop2vertically stacked.
-
hstack(op1:Tensor<S>, op2:Tensor<S>) → Tensor<S>¶ Returns a new Tensor that is a composite of
op1andop2horizontally stacked.
-
broadcast(op1:Tensor<S>, op2:Tensor<S>) -> (Tensor<S>, Tensor<S>)¶ Returns two Tensors of the same shape broadcasted from
op1andop2. Need to go into much more detail about broadcasting.