Sum#
Domain:
ai.onnxSince version: 13
Element-wise sum of each of the input tensors (with Numpy-style broadcasting support). All inputs and outputs must have the same data type.
This operator supports multidirectional (i.e., Numpy-style) broadcasting; for more details please check the doc.
Inputs
data_0 (T): List of tensors for sum.
Outputs
sum (T): Output tensor.
Type Constraints
T: Constrain input and output types to float tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16).
Examples#
test_cc_sum_bcast
Node:
Sum(data_0, data_1) -> (sum)
Inputs:
data_0: shape=(2, 2), dtype=float32
[[1., 2.],
[3., 4.]]
data_1: shape=(), dtype=float32
10.
Outputs:
sum: shape=(2, 2), dtype=float32
[[11., 12.],
[13., 14.]]
test_cc_sum_example
Node:
Sum(data_0, data_1, data_2) -> (sum)
Inputs:
data_0: shape=(3,), dtype=float32
[1., 0., 1.]
data_1: shape=(3,), dtype=float32
[3., 4., 5.]
data_2: shape=(3,), dtype=float32
[6., 0., 5.]
Outputs:
sum: shape=(3,), dtype=float32
[10., 4., 11.]
test_cc_sum_one_input
Node:
Sum(data_0) -> (sum)
Inputs:
data_0: shape=(3,), dtype=float32
[1., 2., 3.]
Outputs:
sum: shape=(3,), dtype=float32
[1., 2., 3.]
test_cc_sum_two_inputs
Node:
Sum(data_0, data_1) -> (sum)
Inputs:
data_0: shape=(2, 3), dtype=float32
[[1., 2., 3.],
[4., 5., 6.]]
data_1: shape=(2, 3), dtype=float32
[[10., 20., 30.],
[40., 50., 60.]]
Outputs:
sum: shape=(2, 3), dtype=float32
[[11., 22., 33.],
[44., 55., 66.]]
test_sum_example
Node:
Sum(data_0, data_1, data_2) -> (sum)
Inputs:
data_0: shape=(3, 4, 5), dtype=float32
[[[-1.6207618 , -0.26159498, -1.6894207 , -0.5941726 , 0.23757638],
[-0.77598375, 1.7195183 , 0.87334126, -0.47817174, 0.16062957],
[-1.1535512 , -1.0489278 , -0.8616083 , -0.25931633, 0.1662263 ],
[-1.19579 , -0.09554294, -0.7415066 , 1.8345209 , 0.66055524]],
[[-0.37864083, -1.2763816 , -0.20821808, 0.79001987, -0.305968 ],
[-0.13338329, -0.26947752, -0.68312395, -0.02752227, 1.2929565 ],
[-2.3823667 , -1.3751754 , 0.08531325, -1.0451319 , 0.5773258 ],
[ 0.5335717 , 1.7940854 , -0.25193027, -0.42498377, 0.62358594]],
[[-0.21925525, 0.9713564 , -0.12102764, 0.72468317, -0.30977774],
[ 1.0066974 , 0.20055684, 0.35697085, -0.9946885 , 1.5686967 ],
[-2.015447 , -0.80032647, -1.3453012 , -1.3160369 , 0.09626406],
[ 0.00318402, 1.1699535 , -1.1138605 , -0.72566646, -0.04194619]]]
data_1: shape=(3, 4, 5), dtype=float32
[[[-3.2327610e-01, 5.3205568e-01, 1.5432492e+00, -6.9176567e-01,
1.9503884e+00],
[-1.7234032e+00, -1.0676117e+00, -1.6856503e+00, -3.3474345e-02,
-9.3504351e-01],
[ 8.5077822e-01, 4.7314724e-01, -3.6031015e-02, 1.1229317e+00,
1.0024427e-01],
[-1.3745983e-01, -4.5334585e-02, 4.9413046e-01, 5.0943595e-01,
2.7962857e-01]],
[[ 1.6754329e+00, -1.1071100e+00, 3.6536074e-01, 9.5587057e-01,
9.5825948e-02],
[-3.4379008e+00, -2.1401776e-01, 1.0207568e+00, 1.5230697e-01,
1.7962818e-01],
[ 1.9142120e-01, 1.2306712e-04, -1.4188983e+00, -1.1545553e+00,
-3.6328000e-01],
[-1.1123656e+00, -2.7028066e-01, 1.0528580e+00, -1.3669981e+00,
-1.9538646e+00]],
[[-8.5295737e-01, 1.2235709e+00, -9.7294033e-02, 8.7098098e-01,
3.7720674e-01],
[ 1.0523090e+00, -5.4001397e-01, 5.1259655e-01, 3.2776645e-01,
-2.8144464e-01],
[ 2.0450303e-01, -5.3457934e-01, 7.0617035e-02, -4.4991007e-01,
7.2952157e-01],
[-1.1638440e+00, 6.6377270e-01, -1.4313440e+00, -1.1646674e+00,
-1.5334731e+00]]]
data_2: shape=(3, 4, 5), dtype=float32
[[[-1.9504728 , -0.384003 , 0.6175111 , 0.4860437 , 0.14837483],
[ 0.4243168 , 0.7555941 , 1.2209445 , -0.8658253 , -0.2577181 ],
[-1.1415162 , -0.40477493, -0.87081665, 0.88169414, 0.38555267],
[-1.5191493 , -1.1147851 , -1.6198577 , 0.18040422, -0.61582077]],
[[ 1.0728145 , -0.32273647, -1.4748397 , 1.3682464 , 0.69247085],
[ 1.4945487 , -1.8275837 , 1.1269883 , -1.1244485 , 0.19961263],
[ 0.8090156 , 0.8177859 , -0.01459381, -1.4260765 , 1.5820233 ],
[-1.1409763 , 0.3658983 , 0.5160113 , -1.0337888 , 0.6509004 ]],
[[-0.2102342 , -0.90819484, -0.16215591, -0.6403306 , -0.68816286],
[ 2.1505942 , 0.07699525, -0.6226731 , -0.6401388 , 0.8192693 ],
[-1.3715283 , -0.58853245, 0.3524632 , 0.0612135 , 0.20318082],
[-0.23185334, 0.7497727 , 0.7727014 , 0.7761635 , -0.32464558]]]
Outputs:
sum: shape=(3, 4, 5), dtype=float32
[[[-3.8945107 , -0.11354232, 0.47133964, -0.7998946 , 2.3363397 ],
[-2.0750701 , 1.4075007 , 0.40863544, -1.3774714 , -1.032132 ],
[-1.4442892 , -0.9805554 , -1.768456 , 1.7453096 , 0.6520232 ],
[-2.8523993 , -1.2556626 , -1.8672338 , 2.5243611 , 0.32436305]],
[[ 2.3696065 , -2.706228 , -1.317697 , 3.1141367 , 0.4823288 ],
[-2.0767355 , -2.311079 , 1.4646212 , -0.99966383, 1.6721972 ],
[-1.3819299 , -0.5572664 , -1.348179 , -3.625764 , 1.7960691 ],
[-1.7197702 , 1.889703 , 1.3169391 , -2.8257706 , -0.6793782 ]],
[[-1.2824467 , 1.2867324 , -0.3804776 , 0.95533353, -0.62073386],
[ 4.2096004 , -0.26246187, 0.2468943 , -1.307061 , 2.1065214 ],
[-3.1824722 , -1.9234383 , -0.9222209 , -1.7047335 , 1.0289664 ],
[-1.3925134 , 2.583499 , -1.7725033 , -1.1141703 , -1.900065 ]]]
Differences with previous version (8)#
SchemaDiff: Sum (domain 'ai.onnx')
old version: 8
new version: 13
breaking: no
Type constraints:
changed ‘T’: added types: [‘tensor(bfloat16)’]