Mars tensor 提供通用函数(也被称为 ufunc)来支持各种元素操作。Mars tensor 的通用函数支持 Numpy 的以下功能:
广播
确定输出类型
类型转换规则
Mars 张量通用函数目前不支持包括方法有 accumulate、reduceat、outer 和 at。
accumulate
reduceat
outer
at
mars.tensor.add
按元素相加
mars.tensor.subtract
按元素相减
mars.tensor.multiply
按元素相乘
mars.tensor.divide
按元素相除
mars.tensor.logaddexp
按元素计算以e为底的两个输入指数值之和的对数值
mars.tensor.logaddexp2
按元素计算以2为底的两个输入指数值之和的对数值
mars.tensor.true_divide
按元素计算实数除法
mars.tensor.floor_divide
按元素计算除法并向下取整
mars.tensor.negative
按元素求相反数
mars.tensor.power
按元素求幂,前一个张量中的数值作为底数,后一个张量的数值作为指数
mars.tensor.remainder
按元素返回整数除法的余数
mars.tensor.mod
mars.tensor.fmod
mars.tensor.absolute
按元素计算绝对值
mars.tensor.rint
按元素将张量中的值取整到最接近的整数
mars.tensor.sign
按元素取符号
mars.tensor.exp
计算所有元素的指数值
mars.tensor.exp2
计算所有元素以2为底的指数值
mars.tensor.log
按元素求自然对数
mars.tensor.log2
计算所有元素以2为底的对数值
mars.tensor.log10
计算所有元素以10为底的对数值
mars.tensor.expm1
对张量中的所有元素计算 exp(x) - 1
exp(x) - 1
mars.tensor.log1p
对张量中的所有元素计算 log(1 + x)
log(1 + x)
mars.tensor.sqrt
返回按元素求平方根的结果
mars.tensor.square
返回按元素求平方的结果
mars.tensor.reciprocal
返回按元素求倒数的结果
mars.tensor.sin
Trigonometric sine, element-wise.
mars.tensor.cos
Cosine element-wise.
mars.tensor.tan
Compute tangent element-wise.
mars.tensor.arcsin
Inverse sine, element-wise.
mars.tensor.arccos
Trigonometric inverse cosine, element-wise.
mars.tensor.arctan
Trigonometric inverse tangent, element-wise.
mars.tensor.arctan2
Element-wise arc tangent of x1/x2 choosing the quadrant correctly.
x1/x2
mars.tensor.hypot
Given the “legs” of a right triangle, return its hypotenuse.
mars.tensor.sinh
Hyperbolic sine, element-wise.
mars.tensor.cosh
Hyperbolic cosine, element-wise.
mars.tensor.tanh
Compute hyperbolic tangent element-wise.
mars.tensor.arcsinh
Inverse hyperbolic sine element-wise.
mars.tensor.arccosh
Inverse hyperbolic cosine, element-wise.
mars.tensor.arctanh
Inverse hyperbolic tangent element-wise.
mars.tensor.deg2rad
Convert angles from degrees to radians.
mars.tensor.rad2deg
Convert angles from radians to degrees.
mars.tensor.bitwise_and
Compute the bit-wise AND of two tensors element-wise.
mars.tensor.bitwise_or
Compute the bit-wise OR of two tensors element-wise.
mars.tensor.bitwise_xor
Compute the bit-wise XOR of two arrays element-wise.
mars.tensor.invert
Compute bit-wise inversion, or bit-wise NOT, element-wise.
mars.tensor.left_shift
Shift the bits of an integer to the left.
mars.tensor.right_shift
Shift the bits of an integer to the right.
mars.tensor.greater
Return the truth value of (x1 > x2) element-wise.
mars.tensor.greater_equal
Return the truth value of (x1 >= x2) element-wise.
mars.tensor.less
Return the truth value of (x1 < x2) element-wise.
mars.tensor.less_equal
Return the truth value of (x1 =< x2) element-wise.
mars.tensor.not_equal
Return (x1 != x2) element-wise.
mars.tensor.equal
Return (x1 == x2) element-wise.
mars.tensor.logical_and
Compute the truth value of x1 AND x2 element-wise.
mars.tensor.logical_or
Compute the truth value of x1 OR x2 element-wise.
mars.tensor.logical_xor
Compute the truth value of x1 XOR x2, element-wise.
mars.tensor.logical_not
Compute the truth value of NOT x element-wise.
mars.tensor.maximum
Element-wise maximum of tensor elements.
mars.tensor.minimum
Element-wise minimum of tensor elements.
mars.tensor.fmax
Element-wise maximum of array elements.
mars.tensor.fmin
Element-wise minimum of array elements.
mars.tensor.isfinite
Test element-wise for finiteness (not infinity or not Not a Number).
mars.tensor.isinf
Test element-wise for positive or negative infinity.
mars.tensor.isnan
Test element-wise for NaN and return result as a boolean tensor.
mars.tensor.signbit
Returns element-wise True where signbit is set (less than zero).
mars.tensor.copysign
Change the sign of x1 to that of x2, element-wise.
mars.tensor.nextafter
Return the next floating-point value after x1 towards x2, element-wise.
mars.tensor.modf
Return the fractional and integral parts of a tensor, element-wise.
mars.tensor.ldexp
Returns x1 * 2**x2, element-wise.
mars.tensor.frexp
Decompose the elements of x into mantissa and twos exponent.
mars.tensor.floor
Return the floor of the input, element-wise.
mars.tensor.ceil
Return the ceiling of the input, element-wise.
mars.tensor.trunc
Return the truncated value of the input, element-wise.