arithmetic
Defines an arithmetic operator to the pipeline. An arithmetic operator takes in an array of PipelineTensor (size of which must be no more than 10), and write the arithmetic result into result. The arithmetic expression to be executed is defined by expression.
Parameters
The arithmetic expression to be executed. It has the following requirements:
Use {IDX} to refer to the No. IDX input tensor, where IDX is the index among the operands parameter.
The following arithmetic symbols are allowed:
+,-,*(matrix multiplication),/(elementwise division),^(power, the right operand to which must be a constant or 1x1 tensor),sin,cos,tan,asin,acos,atan,sinh,cosh,tanhandinv( matrix inverse, for matrix division). Parentheses(and)are also supported.Constants are allowed in the expression, but they cannot appear on both sides of the arithmetic symbols listed above, such as
5.0 + 1.0is not valid, because the callers are required to pre-compute these arithmetic operations between constants. i.e., don't call the method with expression ={0} * (5.0 + 1.0), but{0} * 6.0instead.In terms of the computation priority ambiguity between trigonometry functions and power, we make the following rules:
sin {0} ^ 2means the sine of {0} ^ 2, whereas(sin {0}) ^ 2means the power 2 of sine of operand 0.
Valid examples are:
{0} + {1} * 2,sin (( {0} * 3.1415926 ) / 180),{0} * {1}note this is matrix multiplication,{0} * inv {1}.
the input operand to the arithmetic expression. The tensor indexed IDX in this array will replace the symbol {IDX} in expression. The size of this array must not exceed 10. All the tensors in this array must:
created use Tensor.MultiDimensionalInitInfo as initialization config, i.e., must be multi-dimensional tensor with no special usage;
has exactly two dimensions (current limitation, we will support multi-dimensional arithmetic operations shortly afterwards).
the tensor to store the result of the arithmetic operation.
Throws
If the usage is not allowed by the SpatialML run-time Framework, or if the framework encounter internal error and cannot perform the requested behavior.