Pow#
Pow - 15#
Version
name: Pow (GitHub)
domain: main
since_version: 15
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 15.
Summary
Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.
Inputs
X (heterogeneous) - T: First operand, base of the exponent.
Y (heterogeneous) - T1: Second operand, power of the exponent.
Outputs
Z (heterogeneous) - T: Output tensor
Type Constraints
T in ( tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int32), tensor(int64) ): Constrain input X and output types to float/int tensors.
T1 in ( tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain input Y types to float/int tensors.
Examples
pow_broadcast
node = onnx.helper.make_node(
'Pow',
inputs=['x', 'y'],
outputs=['z'],
)
x = np.array([1, 2, 3]).astype(np.float32)
y = np.array(2).astype(np.float32)
z = pow(x, y) # expected output [1., 4., 9.]
expect(node, inputs=[x, y], outputs=[z],
name='test_pow_bcast_scalar')
node = onnx.helper.make_node(
'Pow',
inputs=['x', 'y'],
outputs=['z'],
)
x = np.array([[1, 2, 3], [4, 5, 6]]).astype(np.float32)
y = np.array([1, 2, 3]).astype(np.float32)
# expected output [[1, 4, 27], [4, 25, 216]]
z = pow(x, y)
expect(node, inputs=[x, y], outputs=[z],
name='test_pow_bcast_array')
types
node = onnx.helper.make_node(
'Pow',
inputs=['x', 'y'],
outputs=['z'],
)
x = np.array([1, 2, 3]).astype(np.float32)
y = np.array([4, 5, 6]).astype(np.int64)
z = pow(x, y) # expected output [1., 32., 729.]
expect(node, inputs=[x, y], outputs=[z],
name='test_pow_types_float32_int64')
x = np.array([1, 2, 3]).astype(np.int64)
y = np.array([4, 5, 6]).astype(np.float32)
z = pow(x, y) # expected output [1, 32, 729]
expect(node, inputs=[x, y], outputs=[z],
name='test_pow_types_int64_float32')
x = np.array([1, 2, 3]).astype(np.float32)
y = np.array([4, 5, 6]).astype(np.int32)
z = pow(x, y) # expected output [1., 32., 729.]
expect(node, inputs=[x, y], outputs=[z],
name='test_pow_types_float32_int32')
x = np.array([1, 2, 3]).astype(np.int32)
y = np.array([4, 5, 6]).astype(np.float32)
z = pow(x, y) # expected output [1, 32, 729]
expect(node, inputs=[x, y], outputs=[z],
name='test_pow_types_int32_float32')
x = np.array([1, 2, 3]).astype(np.float32)
y = np.array([4, 5, 6]).astype(np.uint64)
z = pow(x, y) # expected output [1., 32., 729.]
expect(node, inputs=[x, y], outputs=[z],
name='test_pow_types_float32_uint64')
x = np.array([1, 2, 3]).astype(np.float32)
y = np.array([4, 5, 6]).astype(np.uint32)
z = pow(x, y) # expected output [1., 32., 729.]
expect(node, inputs=[x, y], outputs=[z],
name='test_pow_types_float32_uint32')
x = np.array([1, 2, 3]).astype(np.int64)
y = np.array([4, 5, 6]).astype(np.int64)
z = pow(x, y) # expected output [1, 32, 729]
expect(node, inputs=[x, y], outputs=[z],
name='test_pow_types_int64_int64')
x = np.array([1, 2, 3]).astype(np.int32)
y = np.array([4, 5, 6]).astype(np.int32)
z = pow(x, y) # expected output [1, 32, 729]
expect(node, inputs=[x, y], outputs=[z],
name='test_pow_types_int32_int32')
Differences
0 | 0 | Pow takes input data (Tensor | Pow takes input data (Tensor |
1 | 1 | produces one output data (Tensor | produces one output data (Tensor |
2 | 2 | is applied to the data tensor elementwise. | is applied to the data tensor elementwise. |
3 | 3 | This operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check Broadcasting in ONNX | This operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check Broadcasting in ONNX |
4 | 4 |
|
|
5 | 5 | **Inputs** | **Inputs** |
6 | 6 |
|
|
7 | 7 | * **X** (heterogeneous) - **T**: | * **X** (heterogeneous) - **T**: |
8 | 8 | First operand, base of the exponent. | First operand, base of the exponent. |
9 | 9 | * **Y** (heterogeneous) - **T1**: | * **Y** (heterogeneous) - **T1**: |
10 | 10 | Second operand, power of the exponent. | Second operand, power of the exponent. |
11 | 11 |
|
|
12 | 12 | **Outputs** | **Outputs** |
13 | 13 |
|
|
14 | 14 | * **Z** (heterogeneous) - **T**: | * **Z** (heterogeneous) - **T**: |
15 | 15 | Output tensor | Output tensor |
16 | 16 |
|
|
17 | 17 | **Type Constraints** | **Type Constraints** |
18 | 18 |
|
|
19 | 19 | * **T** in ( | * **T** in ( |
20 | 20 | tensor(bfloat16), | tensor(bfloat16), |
21 | 21 | tensor(double), | tensor(double), |
22 | 22 | tensor(float), | tensor(float), |
23 | 23 | tensor(float16), | tensor(float16), |
24 | 24 | tensor(int32), | tensor(int32), |
25 | 25 | tensor(int64) | tensor(int64) |
26 | 26 | ): | ): |
27 | 27 | Constrain input X and output types to float/int tensors. | Constrain input X and output types to float/int tensors. |
28 | 28 | * **T1** in ( | * **T1** in ( |
29 | tensor(bfloat16), | ||
29 | 30 | tensor(double), | tensor(double), |
30 | 31 | tensor(float), | tensor(float), |
31 | 32 | tensor(float16), | tensor(float16), |
32 | 33 | tensor(int16), | tensor(int16), |
33 | 34 | tensor(int32), | tensor(int32), |
34 | 35 | tensor(int64), | tensor(int64), |
35 | 36 | tensor(int8), | tensor(int8), |
36 | 37 | tensor(uint16), | tensor(uint16), |
37 | 38 | tensor(uint32), | tensor(uint32), |
38 | 39 | tensor(uint64), | tensor(uint64), |
39 | 40 | tensor(uint8) | tensor(uint8) |
40 | 41 | ): | ): |
41 | 42 | Constrain input Y types to float/int tensors. | Constrain input Y types to float/int tensors. |
Pow - 13#
Version
name: Pow (GitHub)
domain: main
since_version: 13
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 13.
Summary
Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.
Inputs
X (heterogeneous) - T: First operand, base of the exponent.
Y (heterogeneous) - T1: Second operand, power of the exponent.
Outputs
Z (heterogeneous) - T: Output tensor
Type Constraints
T in ( tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int32), tensor(int64) ): Constrain input X and output types to float/int tensors.
T1 in ( tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain input Y types to float/int tensors.
Differences
0 | 0 | Pow takes input data (Tensor | Pow takes input data (Tensor |
1 | 1 | produces one output data (Tensor | produces one output data (Tensor |
2 | 2 | is applied to the data tensor elementwise. | is applied to the data tensor elementwise. |
3 | 3 | This operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check Broadcasting in ONNX | This operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check Broadcasting in ONNX |
4 | 4 |
|
|
5 | 5 | **Inputs** | **Inputs** |
6 | 6 |
|
|
7 | 7 | * **X** (heterogeneous) - **T**: | * **X** (heterogeneous) - **T**: |
8 | 8 | First operand, base of the exponent. | First operand, base of the exponent. |
9 | 9 | * **Y** (heterogeneous) - **T1**: | * **Y** (heterogeneous) - **T1**: |
10 | 10 | Second operand, power of the exponent. | Second operand, power of the exponent. |
11 | 11 |
|
|
12 | 12 | **Outputs** | **Outputs** |
13 | 13 |
|
|
14 | 14 | * **Z** (heterogeneous) - **T**: | * **Z** (heterogeneous) - **T**: |
15 | 15 | Output tensor. |
|
16 | 16 |
|
|
17 | 17 | **Type Constraints** | **Type Constraints** |
18 | 18 |
|
|
19 | 19 | * **T** in ( | * **T** in ( |
20 | tensor(bfloat16), | ||
20 | 21 | tensor(double), | tensor(double), |
21 | 22 | tensor(float), | tensor(float), |
22 | 23 | tensor(float16), | tensor(float16), |
23 | 24 | tensor(int32), | tensor(int32), |
24 | 25 | tensor(int64) | tensor(int64) |
25 | 26 | ): | ): |
26 | 27 | Constrain input X and output types to float/int tensors. | Constrain input X and output types to float/int tensors. |
27 | 28 | * **T1** in ( | * **T1** in ( |
28 | 29 | tensor(double), | tensor(double), |
29 | 30 | tensor(float), | tensor(float), |
30 | 31 | tensor(float16), | tensor(float16), |
31 | 32 | tensor(int16), | tensor(int16), |
32 | 33 | tensor(int32), | tensor(int32), |
33 | 34 | tensor(int64), | tensor(int64), |
34 | 35 | tensor(int8), | tensor(int8), |
35 | 36 | tensor(uint16), | tensor(uint16), |
36 | 37 | tensor(uint32), | tensor(uint32), |
37 | 38 | tensor(uint64), | tensor(uint64), |
38 | 39 | tensor(uint8) | tensor(uint8) |
39 | 40 | ): | ): |
40 | 41 | Constrain input Y types to float/int tensors. | Constrain input Y types to float/int tensors. |
Pow - 12#
Version
name: Pow (GitHub)
domain: main
since_version: 12
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 12.
Summary
Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.
Inputs
X (heterogeneous) - T: First operand, base of the exponent.
Y (heterogeneous) - T1: Second operand, power of the exponent.
Outputs
Z (heterogeneous) - T: Output tensor.
Type Constraints
T in ( tensor(double), tensor(float), tensor(float16), tensor(int32), tensor(int64) ): Constrain input X and output types to float/int tensors.
T1 in ( tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8) ): Constrain input Y types to float/int tensors.
Differences
0 | 0 | Pow takes input data (Tensor | Pow takes input data (Tensor |
1 | 1 | produces one output data (Tensor | produces one output data (Tensor |
2 | 2 | is applied to the data tensor elementwise. | is applied to the data tensor elementwise. |
3 | 3 | This operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check Broadcasting in ONNX | This operator supports **multidirectional (i.e., Numpy-style) broadcasting**; for more details please check Broadcasting in ONNX |
4 | 4 |
|
|
5 | 5 | **Inputs** | **Inputs** |
6 | 6 |
|
|
7 | 7 | * **X** (heterogeneous) - **T**: | * **X** (heterogeneous) - **T**: |
8 | 8 | First operand, base of the exponent. | First operand, base of the exponent. |
9 | 9 | * **Y** (heterogeneous) - **T**: |
|
10 | 10 | Second operand, power of the exponent. | Second operand, power of the exponent. |
11 | 11 |
|
|
12 | 12 | **Outputs** | **Outputs** |
13 | 13 |
|
|
14 | 14 | * **Z** (heterogeneous) - **T**: | * **Z** (heterogeneous) - **T**: |
15 | 15 | Output tensor. | Output tensor. |
16 | 16 |
|
|
17 | 17 | **Type Constraints** | **Type Constraints** |
18 | 18 |
|
|
19 | 19 | * **T** in ( | * **T** in ( |
20 | 20 | tensor(double), | tensor(double), |
21 | 21 | tensor(float), | tensor(float), |
22 | 22 | tensor(float16) |
|
23 | tensor(int32), | ||
24 | tensor(int64) | ||
23 | 25 | ): | ): |
24 | 26 | Constrain input and output types to float tensors. |
|
27 | * **T1** in ( | ||
28 | tensor(double), | ||
29 | tensor(float), | ||
30 | tensor(float16), | ||
31 | tensor(int16), | ||
32 | tensor(int32), | ||
33 | tensor(int64), | ||
34 | tensor(int8), | ||
35 | tensor(uint16), | ||
36 | tensor(uint32), | ||
37 | tensor(uint64), | ||
38 | tensor(uint8) | ||
39 | ): | ||
40 | Constrain input Y types to float/int tensors. |
Pow - 7#
Version
name: Pow (GitHub)
domain: main
since_version: 7
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 7.
Summary
Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise. This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check Broadcasting in ONNX.
Inputs
X (heterogeneous) - T: First operand, base of the exponent.
Y (heterogeneous) - T: Second operand, power of the exponent.
Outputs
Z (heterogeneous) - T: Output tensor.
Type Constraints
T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.
Differences
0 | 0 | Pow takes input data (Tensor | Pow takes input data (Tensor |
1 | 1 | produces one output data (Tensor | produces one output data (Tensor |
2 | 2 | is applied to the data tensor elementwise. | is applied to the data tensor elementwise. |
3 |
| ||
4 | 3 | If necessary the right-hand-side argument will be broadcasted to match the |
|
4 |
| ||
5 | 5 | shape of left-hand-side argument. When broadcasting is specified, the second |
|
6 |
| ||
6 | 7 | tensor can either be of element size 1 (including a scalar tensor and any |
|
7 | 8 | tensor with rank equal to or smaller than the first tensor), or having its |
|
8 | 9 | shape as a contiguous subset of the first tensor's shape. The starting of the |
|
9 | 10 | mutually equal shape is specified by the argument "axis", and if it is not set, |
|
10 | suffix matching is assumed. 1-dim expansion doesn't work yet. | ||
11 | 11 |
|
|
12 | For example, the following tensor shapes are supported (with broadcast=1): | ||
13 |
| ||
14 | shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor | ||
15 | shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor | ||
16 | shape(A) = (2, 3, 4, 5), shape(B) = (5,) | ||
17 | shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) | ||
18 | shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 | ||
19 | shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0 | ||
20 |
| ||
21 | Attribute broadcast=1 needs to be passed to enable broadcasting. | ||
22 |
| ||
23 | **Attributes** | ||
24 |
| ||
25 | * **axis**: | ||
26 | If set, defines the broadcast dimensions. See doc for details. | ||
27 | * **broadcast**: | ||
28 | Pass 1 to enable broadcasting Default value is 0. | ||
29 |
| ||
30 | **Inputs** | ||
31 |
| ||
32 | * **X** (heterogeneous) - **T**: | ||
33 | Input tensor of any shape, base of the exponent. | ||
34 | * **Y** (heterogeneous) - **T**: | ||
35 | Input tensor of any shape broadcastable to X shape, the exponent | ||
36 | component. | ||
37 |
| ||
38 | 12 | **Outputs** | **Outputs** |
39 | 13 |
|
|
40 | 14 | * **Z** (heterogeneous) - **T**: | * **Z** (heterogeneous) - **T**: |
41 | 15 | Output tensor (same size as X) |
|
42 | 16 |
|
|
43 | 17 | **Type Constraints** | **Type Constraints** |
44 | 18 |
|
|
45 | 19 | * **T** in ( | * **T** in ( |
46 | 20 | tensor(double), | tensor(double), |
47 | 21 | tensor(float), | tensor(float), |
48 | 22 | tensor(float16) | tensor(float16) |
49 | 23 | ): | ): |
50 | 24 | Constrain input and output types to float tensors. | Constrain input and output types to float tensors. |
Pow - 1#
Version
name: Pow (GitHub)
domain: main
since_version: 1
function: False
support_level: SupportType.COMMON
shape inference: True
This version of the operator has been available since version 1.
Summary
Pow takes input data (Tensor<T>) and exponent Tensor, and produces one output data (Tensor<T>) where the function f(x) = x^exponent, is applied to the data tensor elementwise.
If necessary the right-hand-side argument will be broadcasted to match the shape of left-hand-side argument. When broadcasting is specified, the second tensor can either be of element size 1 (including a scalar tensor and any tensor with rank equal to or smaller than the first tensor), or having its shape as a contiguous subset of the first tensor’s shape. The starting of the mutually equal shape is specified by the argument “axis”, and if it is not set, suffix matching is assumed. 1-dim expansion doesn’t work yet.
For example, the following tensor shapes are supported (with broadcast=1):
shape(A) = (2, 3, 4, 5), shape(B) = (,), i.e. B is a scalar tensor shape(A) = (2, 3, 4, 5), shape(B) = (1, 1), i.e. B is an 1-element tensor shape(A) = (2, 3, 4, 5), shape(B) = (5,) shape(A) = (2, 3, 4, 5), shape(B) = (4, 5) shape(A) = (2, 3, 4, 5), shape(B) = (3, 4), with axis=1 shape(A) = (2, 3, 4, 5), shape(B) = (2), with axis=0
Attribute broadcast=1 needs to be passed to enable broadcasting.
Attributes
axis: If set, defines the broadcast dimensions. See doc for details.
broadcast: Pass 1 to enable broadcasting Default value is
0
.
Inputs
X (heterogeneous) - T: Input tensor of any shape, base of the exponent.
Y (heterogeneous) - T: Input tensor of any shape broadcastable to X shape, the exponent component.
Outputs
Z (heterogeneous) - T: Output tensor (same size as X)
Type Constraints
T in ( tensor(double), tensor(float), tensor(float16) ): Constrain input and output types to float tensors.