mirror of https://github.com/Jittor/Jittor
doc: binary and unary ops
This commit is contained in:
parent
b5d5bafd69
commit
4db4a93110
|
@ -28,45 +28,347 @@ static auto make_number = get_op_info("number")
|
||||||
.get_constructor<VarPtr, float, Var*>();
|
.get_constructor<VarPtr, float, Var*>();
|
||||||
|
|
||||||
unordered_set<string> binary_ops = {
|
unordered_set<string> binary_ops = {
|
||||||
|
/**
|
||||||
|
* computes x^y, element-wise.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x ** y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
// @pybind(pow, __pow__)
|
// @pybind(pow, __pow__)
|
||||||
"pow",
|
"pow",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the element-wise maximum of x and y.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
"maximum",
|
"maximum",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the element-wise minimum of x and y.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
"minimum",
|
"minimum",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* element-wise adds x and y and returns a new Var.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x + y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
// @pybind(add, __add__)
|
// @pybind(add, __add__)
|
||||||
"add",
|
"add",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* element-wise subtract y from x and returns a new Var.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x - y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
// @pybind(subtract, __sub__)
|
// @pybind(subtract, __sub__)
|
||||||
"subtract",
|
"subtract",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* element-wise muliplies x with y and returns a new Var.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x * y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
// @pybind(multiply, __mul__)
|
// @pybind(multiply, __mul__)
|
||||||
"multiply",
|
"multiply",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* element-wise divide x by y and returns a new Var.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x / y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* >>> a = jt.empty((3,), dtype=jt.int32)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([707406378 707406378 707406378], dtype=int32)
|
||||||
|
* >>> b = jt.empty((3,), dtype=jt.int32)
|
||||||
|
* >>> b
|
||||||
|
* jt.Var([674510453 171649398 538976288], dtype=int32)
|
||||||
|
* >>> jt.divide(a, b)
|
||||||
|
* jt.Var([1.0487701 4.1212287 1.3125001], dtype=float32)
|
||||||
|
* >>> a / b
|
||||||
|
* jt.Var([1.0487701 4.1212287 1.3125001], dtype=float32)
|
||||||
|
*
|
||||||
|
* .. note ::
|
||||||
|
* returns float value even if the dtype of input Vars are both integers.
|
||||||
|
* @see jt.ops.floor_divide() for floor division.
|
||||||
|
*/
|
||||||
// @pybind(divide, __truediv__)
|
// @pybind(divide, __truediv__)
|
||||||
"divide",
|
"divide",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* element-wise divide x by y and returns the floor of the result.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x // y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* >>> a = jt.randint(1, 10, (3,), dtype=jt.int32)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([9 2 7], dtype=int32)
|
||||||
|
* >>> b = jt.randint(1, 10, (3,), dtype=jt.int32)
|
||||||
|
* >>> b
|
||||||
|
* jt.Var([6 4 6], dtype=int32)
|
||||||
|
* >>> jt.floor_divide(a, b)
|
||||||
|
* jt.Var([1 0 1], dtype=int32)
|
||||||
|
* >>> a // b
|
||||||
|
* jt.Var([1 0 1], dtype=int32)
|
||||||
|
*/
|
||||||
// @pybind(floor_divide, __floordiv__)
|
// @pybind(floor_divide, __floordiv__)
|
||||||
"floor_divide",
|
"floor_divide",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the element-wise remainder of division.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x % y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* >>> a = jt.rand(3)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([0.3989529 0.20159635 0.22973768], dtype=float32)
|
||||||
|
* >>> b = jt.rand(3)
|
||||||
|
* >>> b
|
||||||
|
* jt.Var([0.20121202 0.7704864 0.5654395 ], dtype=float32)
|
||||||
|
* >>> jt.mod(a, b)
|
||||||
|
* jt.Var([0.19774088 0.20159635 0.22973768], dtype=float32)
|
||||||
|
* >>> a % b
|
||||||
|
* jt.Var([0.19774088 0.20159635 0.22973768], dtype=float32)
|
||||||
|
*/
|
||||||
// @pybind(mod, __mod__)
|
// @pybind(mod, __mod__)
|
||||||
"mod",
|
"mod",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns x < y element-wise.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x < y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
// @pybind(less, __lt__)
|
// @pybind(less, __lt__)
|
||||||
"less",
|
"less",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns x <= y element-wise.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x <= y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
// @pybind(less_equal, __le__)
|
// @pybind(less_equal, __le__)
|
||||||
"less_equal",
|
"less_equal",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns x > y element-wise.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x > y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
// @pybind(greater, __gt__)
|
// @pybind(greater, __gt__)
|
||||||
"greater",
|
"greater",
|
||||||
// @pybind(greater_equal, __ge__)
|
// @pybind(greater_equal, __ge__)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns x >= y element-wise.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x >= y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
"greater_equal",
|
"greater_equal",
|
||||||
// @pybind(equal, __eq__)
|
// @pybind(equal, __eq__)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns x == y element-wise.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x == y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
"equal",
|
"equal",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns x != y element-wise.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x != y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python number or jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python number or jt.Var.
|
||||||
|
*/
|
||||||
// @pybind(not_equal, __ne__)
|
// @pybind(not_equal, __ne__)
|
||||||
"not_equal",
|
"not_equal",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* shifts the bits of x to the left by y.
|
||||||
|
*
|
||||||
|
* Bits are shifted to the left by appending ``y`` 0s at the right of ``x``.
|
||||||
|
* This operation is equivalent to ``x << y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python integer, or jt.Var (int32 or int64 types).
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python integer, or jt.Var (int32 or int64 types).
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randint(0, 10, shape=(3,))
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([7 6 7], dtype=int32)
|
||||||
|
* >>> b = jt.randint(0, 10, shape=(3,))
|
||||||
|
* >>> b
|
||||||
|
* jt.Var([3 9 8], dtype=int32)
|
||||||
|
* >>> jt.left_shift(a, b)
|
||||||
|
* jt.Var([ 56 3072 1792], dtype=int32)
|
||||||
|
* >>> a << b
|
||||||
|
* jt.Var([ 56 3072 1792], dtype=int32)
|
||||||
|
*/
|
||||||
// @pybind(left_shift, __lshift__)
|
// @pybind(left_shift, __lshift__)
|
||||||
"left_shift",
|
"left_shift",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* shifts the bits of x to the right by y.
|
||||||
|
*
|
||||||
|
* This operation is equivalent to ``x >> y``.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: a python integer, or jt.Var (int32 or int64 types).
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: a python integer, or jt.Var (int32 or int64 types).
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randint(0, 1024, shape=(3,))
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([439 113 92], dtype=int32)
|
||||||
|
* >>> b = jt.randint(0, 10, shape=(3,))
|
||||||
|
* >>> b
|
||||||
|
* jt.Var([6 8 4], dtype=int32)
|
||||||
|
* >>> jt.right_shift(a, b)
|
||||||
|
* jt.Var([6 0 5], dtype=int32)
|
||||||
|
*/
|
||||||
// @pybind(right_shift, __rshift__)
|
// @pybind(right_shift, __rshift__)
|
||||||
"right_shift",
|
"right_shift",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the element-wise logical AND of the inputs.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: jt.Var.
|
||||||
|
*/
|
||||||
"logical_and",
|
"logical_and",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the element-wise logical OR of the inputs.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: jt.Var.
|
||||||
|
*/
|
||||||
"logical_or",
|
"logical_or",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the element-wise logical XOR of the inputs.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: jt.Var.
|
||||||
|
*/
|
||||||
"logical_xor",
|
"logical_xor",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the bitwise AND of x and y.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: jt.Var (integal or boolean types).
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: jt.Var (integal or boolean types).
|
||||||
|
*/
|
||||||
// @pybind(bitwise_and, __and__)
|
// @pybind(bitwise_and, __and__)
|
||||||
"bitwise_and",
|
"bitwise_and",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the bitwise OR of x and y.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: jt.Var (integal or boolean types).
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: jt.Var (integal or boolean types).
|
||||||
|
*/
|
||||||
// @pybind(bitwise_or, __or__)
|
// @pybind(bitwise_or, __or__)
|
||||||
"bitwise_or",
|
"bitwise_or",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the bitwise XOR of x and y.
|
||||||
|
*
|
||||||
|
* :param x: the first input.
|
||||||
|
* :type x: jt.Var (integal or boolean types).
|
||||||
|
* :param y: the second input.
|
||||||
|
* :type y: jt.Var (integal or boolean types).
|
||||||
|
*/
|
||||||
// @pybind(bitwise_xor, __xor__)
|
// @pybind(bitwise_xor, __xor__)
|
||||||
"bitwise_xor",
|
"bitwise_xor",
|
||||||
};
|
};
|
||||||
|
|
|
@ -35,37 +35,370 @@ static unordered_set<string> unary_ops = {
|
||||||
"float32",
|
"float32",
|
||||||
"float64",
|
"float64",
|
||||||
// please keep float64 the last type
|
// please keep float64 the last type
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the absolute value of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> jt.abs(jt.float32([-1, 0, 1]))
|
||||||
|
* jt.Var([1. 0. 1.], dtype=float32)
|
||||||
|
*/
|
||||||
// @pybind(abs, __abs__)
|
// @pybind(abs, __abs__)
|
||||||
"abs",
|
"abs",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the negative value of x.
|
||||||
|
*
|
||||||
|
* This operator is equavilant to ``-x``.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> jt.negative(jt.float32([-1, 0, 1]))
|
||||||
|
* jt.Var([ 1. -0. -1.], dtype=float32)
|
||||||
|
*/
|
||||||
// @pybind(negative, __neg__)
|
// @pybind(negative, __neg__)
|
||||||
"negative",
|
"negative",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the logical NOT of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var (integal or boolean types).
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> jt.logical_not(jt.int32([-1, 0, 1]))
|
||||||
|
* jt.Var([False True False], dtype=bool)
|
||||||
|
*/
|
||||||
"logical_not",
|
"logical_not",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the bitwise NOT of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var (integal or boolean types).
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> jt.bitwise_not(jt.int32([1, 2, -3]))
|
||||||
|
* jt.Var([-2 -3 2], dtype=int32)
|
||||||
|
*/
|
||||||
"bitwise_not",
|
"bitwise_not",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the natural logarithm of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.rand(4) * 2
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([0.02863695 1.30122 1.6048753 1.140261 ], dtype=float32)
|
||||||
|
* >>> jt.log(a)
|
||||||
|
* jt.Var([-3.5530574 0.26330233 0.47304606 0.13125724], dtype=float32)
|
||||||
|
*/
|
||||||
"log",
|
"log",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the exponential of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.rand(4) * 2
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([1.9841381 1.4103996 0.5855549 1.4212812], dtype=float32)
|
||||||
|
* >>> jt.exp(a)
|
||||||
|
* jt.Var([7.2727766 4.0975924 1.7959872 4.1424246], dtype=float32)
|
||||||
|
*/
|
||||||
"exp",
|
"exp",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the square root of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.rand(4) * 2
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([0.81957287 0.5609612 0.07435933 1.7571875 ], dtype=float32)
|
||||||
|
* >>> jt.sqrt(a)
|
||||||
|
* jt.Var([0.90530264 0.7489734 0.27268907 1.3255895 ], dtype=float32)
|
||||||
|
*/
|
||||||
"sqrt",
|
"sqrt",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the closest integer of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 2.101595 0.33055413 -0.44147047 -0.7720668 ], dtype=float32)
|
||||||
|
* >>> jt.round(a)
|
||||||
|
* jt.Var([ 2 0 0 -1], dtype=int32)
|
||||||
|
*/
|
||||||
"round",
|
"round",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the largest integer less than or equal to x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([-1.0339162 -0.7259972 -0.9220003 -0.8449701], dtype=float32)
|
||||||
|
* >>> jt.floor(a)
|
||||||
|
* jt.Var([-2 -1 -1 -1], dtype=int32)
|
||||||
|
*/
|
||||||
"floor",
|
"floor",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the smallest integer greater than or equal to x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([-1.0339162 -0.7259972 -0.9220003 -0.8449701], dtype=float32)
|
||||||
|
* >>> jt.ceil(a)
|
||||||
|
* jt.Var([-1 0 0 0], dtype=int32)
|
||||||
|
*/
|
||||||
"ceil",
|
"ceil",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the sine of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 0.32893723 -0.7112559 -0.872391 1.8001337 ], dtype=float32)
|
||||||
|
* >>> jt.sin(a)
|
||||||
|
* jt.Var([ 0.32303742 -0.6527857 -0.76586854 0.9738172 ], dtype=float32)
|
||||||
|
*/
|
||||||
"sin",
|
"sin",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the arcsine of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 0.09342023 -0.42522037 0.9264933 -0.785264 ], dtype=float32)
|
||||||
|
* >>> jt.asin(a)
|
||||||
|
* jt.Var([ 0.09355665 -0.43920535 1.1849847 -0.9031224 ], dtype=float32)
|
||||||
|
*/
|
||||||
// @pybind(asin, arcsin)
|
// @pybind(asin, arcsin)
|
||||||
"asin",
|
"asin",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the hyperbolic sine of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 0.32893723 -0.7112559 -0.872391 1.8001337 ], dtype=float32)
|
||||||
|
* >>> jt.sinh(a)
|
||||||
|
* jt.Var([ 0.3349012 -0.77276015 -0.9873369 2.9425898 ], dtype=float32)
|
||||||
|
*/
|
||||||
|
// @pybind(asin, arcsin)
|
||||||
"sinh",
|
"sinh",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the inverse hyperbolic sine of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([-1.9749726 -0.52341473 0.8906148 1.0338128 ], dtype=float32)
|
||||||
|
* >>> jt.asinh(a)
|
||||||
|
* jt.Var([-1.4323865 -0.5020559 0.8018747 0.90508187], dtype=float32)
|
||||||
|
*/
|
||||||
// @pybind(asinh, arcsinh)
|
// @pybind(asinh, arcsinh)
|
||||||
"asinh",
|
"asinh",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the tangent of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 0.32893723 -0.7112559 -0.872391 1.8001337 ], dtype=float32)
|
||||||
|
* >>> jt.tan(a)
|
||||||
|
* jt.Var([ 0.34133783 -0.8617148 -1.1910915 -4.283673 ], dtype=float32)
|
||||||
|
*/
|
||||||
"tan",
|
"tan",
|
||||||
// @pybind(atan, arctan)
|
|
||||||
|
/**
|
||||||
|
* returns the inverse tangent of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([-0.85885596 1.187804 0.47249675 0.95933187], dtype=float32)
|
||||||
|
* >>> jt.atan(a)
|
||||||
|
* jt.Var([-0.70961297 0.87102956 0.44140393 0.76464504], dtype=float32)
|
||||||
|
*/
|
||||||
|
// @pybind(asin, arcsin)
|
||||||
"atan",
|
"atan",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the hyperbolic tangent of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([-0.85885596 1.187804 0.47249675 0.95933187], dtype=float32)
|
||||||
|
* >>> jt.tanh(a)
|
||||||
|
* jt.Var([-0.6956678 0.82989657 0.4402144 0.7439787 ], dtype=float32)
|
||||||
|
*/
|
||||||
"tanh",
|
"tanh",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the inverse hyperbolic tangent of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.rand(4) * 2 - 1
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 0.9062414 -0.799802 -0.27219176 -0.7274077 ], dtype=float32)
|
||||||
|
* >>> jt.atanh(a)
|
||||||
|
* jt.Var([ 1.5060828 -1.0980625 -0.27922946 -0.9231999 ], dtype=float32)
|
||||||
|
*/
|
||||||
// @pybind(atanh, arctanh)
|
// @pybind(atanh, arctanh)
|
||||||
"atanh",
|
"atanh",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the cosine of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 0.32893723 -0.7112559 -0.872391 1.8001337 ], dtype=float32)
|
||||||
|
* >>> jt.cos(a)
|
||||||
|
* jt.Var([ 0.9463862 0.7575426 0.6429972 -0.2273323], dtype=float32)
|
||||||
|
*/
|
||||||
"cos",
|
"cos",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the inverse cosine of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.rand(4) * 2 - 1
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 0.5876564 0.740723 -0.667666 0.5371753], dtype=float32)
|
||||||
|
* >>> jt.acos(a)
|
||||||
|
* jt.Var([0.9426371 0.7366504 2.3018656 1.0037117], dtype=float32)
|
||||||
|
*/
|
||||||
// @pybind(acos, arccos)
|
// @pybind(acos, arccos)
|
||||||
"acos",
|
"acos",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the hyperbolic cosine of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 0.32893723 -0.7112559 -0.872391 1.8001337 ], dtype=float32)
|
||||||
|
* >>> jt.cosh(a)
|
||||||
|
* jt.Var([1.0545894 1.2637873 1.405288 3.1078668], dtype=float32)
|
||||||
|
*/
|
||||||
"cosh",
|
"cosh",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the inverse hyperbolic cosine of x.
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.rand(4) + 1
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([1.3609099 1.8137748 1.1146184 1.3911307], dtype=float32)
|
||||||
|
* >>> jt.acosh(a)
|
||||||
|
* jt.Var([0.8259237 1.2020639 0.47432774 0.8579033 ], dtype=float32)
|
||||||
|
*/
|
||||||
// @pybind(acosh, arccosh)
|
// @pybind(acosh, arccosh)
|
||||||
"acosh",
|
"acosh",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* returns the sigmoid of x.
|
||||||
|
*
|
||||||
|
* .. math::
|
||||||
|
* out_i = \frac{1}{1 + e^{x_i}}
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 0.49443012 0.4305426 -1.0364404 -1.2628382 ], dtype=float32)
|
||||||
|
* >>> jt.sigmoid(a)
|
||||||
|
* jt.Var([0.62114954 0.6060032 0.2618374 0.2204857 ], dtype=float32)
|
||||||
|
*/
|
||||||
"sigmoid",
|
"sigmoid",
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Computes the error function of each element. The error function is defined as follows:
|
||||||
|
*
|
||||||
|
* .. math::
|
||||||
|
* erf(x) = \frac{2}{\sqrt{\pi}} \int_0^x e^{-t^2} dt
|
||||||
|
*
|
||||||
|
* :param x: the input.
|
||||||
|
* :type x: jt.Var.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
* >>> a = jt.randn(4)
|
||||||
|
* >>> a
|
||||||
|
* jt.Var([ 0.49443012 0.4305426 -1.0364404 -1.2628382 ], dtype=float32)
|
||||||
|
* >>> jt.erf(a)
|
||||||
|
* jt.Var([ 0.51559156 0.45739546 -0.85728306 -0.9258883 ], dtype=float32)
|
||||||
|
*/
|
||||||
"erf",
|
"erf",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue