ReduceLogSum#

  • Domain: ai.onnx

  • Since version: 18

Computes the log sum of the input tensor’s elements along the provided axes. The resulting tensor has the same rank as the input if keepdims equals 1. If keepdims equals 0, then the resulting tensor has the reduced dimension pruned. The axes are provided as an optional second input tensor. Negative axes are supported. If axes is not provided or is empty and noop_with_empty_axes is set to 1, the input tensor is returned unchanged. If axes is not provided or is empty and noop_with_empty_axes is not set, all dimensions are reduced. Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.

Inputs

  • data (T): An input tensor.

  • axes (tensor(int64)): Optional input list of integers, along which to reduce. The default is to reduce over all the dimensions of the input tensor if noop_with_empty_axes is false, else act as an Identity op when noop_with_empty_axes is true. Accepted range is [-r, r-1] where r = rank(data).

Outputs

  • reduced (T): Reduced output tensor.

Attributes

  • keepdims (int): Keep the reduced dimension or not, default 1 means keep reduced dimension.

  • noop_with_empty_axes (int): Defines behavior if ‘axes’ is empty. Default behavior with ‘false’ is to reduce all axes. When axes is empty and this attribute is set to true, input tensor will not be reduced, and the output tensor would be equivalent to input tensor.

Type Constraints

  • T: Constrain input and output types to high-precision numeric tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16), tensor(int32), tensor(int64), tensor(uint32), tensor(uint64).

Examples#

test_cc_reducelogsum_default_axes_keepdims

Node:
  ReduceLogSum(data) -> (reduced)
  Attributes:
    keepdims = 1
Inputs:
  data: shape=(3, 2, 2), dtype=float32
    [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]],

     [[ 9., 10.],
      [11., 12.]]]

Outputs:
  reduced: shape=(1, 1, 1), dtype=float32
    [[[4.356709]]]

test_cc_reducelogsum_do_not_keepdims

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 0
Inputs:
  data: shape=(3, 2, 2), dtype=float32
    [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]],

     [[ 9., 10.],
      [11., 12.]]]
  axes: shape=(1,), dtype=int64
    [1]

Outputs:
  reduced: shape=(3, 2), dtype=float32
    [[1.3862944, 1.7917595],
     [2.4849067, 2.6390574],
     [2.9957323, 3.0910425]]

test_cc_reducelogsum_double

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 1
Inputs:
  data: shape=(3, 2, 2), dtype=float64
    [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]],

     [[ 9., 10.],
      [11., 12.]]]
  axes: shape=(1,), dtype=int64
    [1]

Outputs:
  reduced: shape=(3, 1, 2), dtype=float64
    [[[1.38629436, 1.79175947]],

     [[2.48490665, 2.63905733]],

     [[2.99573227, 3.09104245]]]

test_cc_reducelogsum_empty_axes_input_noop

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 1
    noop_with_empty_axes = 1
Inputs:
  data: shape=(3, 2, 2), dtype=float32
    [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]],

     [[ 9., 10.],
      [11., 12.]]]
  axes: shape=(0,), dtype=int64
    []

Outputs:
  reduced: shape=(3, 2, 2), dtype=float32
    [[[0.       , 0.6931472],
      [1.0986123, 1.3862944]],

     [[1.609438 , 1.7917595],
      [1.9459101, 2.0794415]],

     [[2.1972246, 2.3025851],
      [2.3978953, 2.4849067]]]

test_cc_reducelogsum_empty_set

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 1
Inputs:
  data: shape=(2, 0, 4), dtype=float32
    []
  axes: shape=(1,), dtype=int64
    [1]

Outputs:
  reduced: shape=(2, 1, 4), dtype=float32
    [[[-inf, -inf, -inf, -inf]],

     [[-inf, -inf, -inf, -inf]]]

test_cc_reducelogsum_empty_set_non_reduced_axis_zero

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 1
Inputs:
  data: shape=(2, 0, 4), dtype=float32
    []
  axes: shape=(1,), dtype=int64
    [2]

Outputs:
  reduced: shape=(2, 0, 1), dtype=float32
    []

test_cc_reducelogsum_keepdims

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 1
Inputs:
  data: shape=(3, 2, 2), dtype=float32
    [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]],

     [[ 9., 10.],
      [11., 12.]]]
  axes: shape=(1,), dtype=int64
    [1]

Outputs:
  reduced: shape=(3, 1, 2), dtype=float32
    [[[1.3862944, 1.7917595]],

     [[2.4849067, 2.6390574]],

     [[2.9957323, 3.0910425]]]

test_cc_reducelogsum_negative_axes_keepdims

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 1
Inputs:
  data: shape=(3, 2, 2), dtype=float32
    [[[ 1.,  2.],
      [ 3.,  4.]],

     [[ 5.,  6.],
      [ 7.,  8.]],

     [[ 9., 10.],
      [11., 12.]]]
  axes: shape=(1,), dtype=int64
    [-2]

Outputs:
  reduced: shape=(3, 1, 2), dtype=float32
    [[[1.3862944, 1.7917595]],

     [[2.4849067, 2.6390574]],

     [[2.9957323, 3.0910425]]]

test_reduce_log_sum_asc_axes

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 0
Inputs:
  data: shape=(3, 4, 5), dtype=float32
    [[[0.1       , 0.11      , 0.12      , 0.13      , 0.14      ],
      [0.15      , 0.16      , 0.17      , 0.18      , 0.19      ],
      [0.19999999, 0.21000001, 0.22      , 0.22999999, 0.24000001],
      [0.25      , 0.26      , 0.27      , 0.28      , 0.29      ]],

     [[0.29999998, 0.31      , 0.32      , 0.32999998, 0.34      ],
      [0.35      , 0.35999998, 0.36999997, 0.38      , 0.39      ],
      [0.39999998, 0.41      , 0.42      , 0.42999998, 0.44      ],
      [0.45      , 0.45999998, 0.47      , 0.48      , 0.48999998]],

     [[0.49999997, 0.51      , 0.52      , 0.53      , 0.54      ],
      [0.55      , 0.56      , 0.57      , 0.58      , 0.59      ],
      [0.6       , 0.61      , 0.62      , 0.63      , 0.64      ],
      [0.65000004, 0.66      , 0.67      , 0.68      , 0.69      ]]]
  axes: shape=(2,), dtype=int64
    [0, 1]

Outputs:
  reduced: shape=(5,), dtype=float32
    [1.5040774, 1.5303947, 1.5560371, 1.5810384, 1.6054299]

test_reduce_log_sum_default

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 1
Inputs:
  data: shape=(3, 4, 5), dtype=float32
    [[[0.1       , 0.11      , 0.12      , 0.13      , 0.14      ],
      [0.15      , 0.16      , 0.17      , 0.18      , 0.19      ],
      [0.19999999, 0.21000001, 0.22      , 0.22999999, 0.24000001],
      [0.25      , 0.26      , 0.27      , 0.28      , 0.29      ]],

     [[0.29999998, 0.31      , 0.32      , 0.32999998, 0.34      ],
      [0.35      , 0.35999998, 0.36999997, 0.38      , 0.39      ],
      [0.39999998, 0.41      , 0.42      , 0.42999998, 0.44      ],
      [0.45      , 0.45999998, 0.47      , 0.48      , 0.48999998]],

     [[0.49999997, 0.51      , 0.52      , 0.53      , 0.54      ],
      [0.55      , 0.56      , 0.57      , 0.58      , 0.59      ],
      [0.6       , 0.61      , 0.62      , 0.63      , 0.64      ],
      [0.65000004, 0.66      , 0.67      , 0.68      , 0.69      ]]]
  axes: shape=(0,), dtype=int64
    []

Outputs:
  reduced: shape=(1, 1, 1), dtype=float32
    [[[3.1654751]]]

test_reduce_log_sum_desc_axes

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 0
Inputs:
  data: shape=(3, 4, 5), dtype=float32
    [[[0.1       , 0.11      , 0.12      , 0.13      , 0.14      ],
      [0.15      , 0.16      , 0.17      , 0.18      , 0.19      ],
      [0.19999999, 0.21000001, 0.22      , 0.22999999, 0.24000001],
      [0.25      , 0.26      , 0.27      , 0.28      , 0.29      ]],

     [[0.29999998, 0.31      , 0.32      , 0.32999998, 0.34      ],
      [0.35      , 0.35999998, 0.36999997, 0.38      , 0.39      ],
      [0.39999998, 0.41      , 0.42      , 0.42999998, 0.44      ],
      [0.45      , 0.45999998, 0.47      , 0.48      , 0.48999998]],

     [[0.49999997, 0.51      , 0.52      , 0.53      , 0.54      ],
      [0.55      , 0.56      , 0.57      , 0.58      , 0.59      ],
      [0.6       , 0.61      , 0.62      , 0.63      , 0.64      ],
      [0.65000004, 0.66      , 0.67      , 0.68      , 0.69      ]]]
  axes: shape=(2,), dtype=int64
    [2, 1]

Outputs:
  reduced: shape=(3,), dtype=float32
    [1.3609766, 2.0668626, 2.4765384]

test_reduce_log_sum_empty_set

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 1
Inputs:
  data: shape=(2, 0, 4), dtype=float32
    []
  axes: shape=(1,), dtype=int64
    [1]

Outputs:
  reduced: shape=(2, 1, 4), dtype=float32
    [[[-inf, -inf, -inf, -inf]],

     [[-inf, -inf, -inf, -inf]]]

test_reduce_log_sum_negative_axes

Node:
  ReduceLogSum(data, axes) -> (reduced)
  Attributes:
    keepdims = 1
Inputs:
  data: shape=(3, 4, 5), dtype=float32
    [[[0.1       , 0.11      , 0.12      , 0.13      , 0.14      ],
      [0.15      , 0.16      , 0.17      , 0.18      , 0.19      ],
      [0.19999999, 0.21000001, 0.22      , 0.22999999, 0.24000001],
      [0.25      , 0.26      , 0.27      , 0.28      , 0.29      ]],

     [[0.29999998, 0.31      , 0.32      , 0.32999998, 0.34      ],
      [0.35      , 0.35999998, 0.36999997, 0.38      , 0.39      ],
      [0.39999998, 0.41      , 0.42      , 0.42999998, 0.44      ],
      [0.45      , 0.45999998, 0.47      , 0.48      , 0.48999998]],

     [[0.49999997, 0.51      , 0.52      , 0.53      , 0.54      ],
      [0.55      , 0.56      , 0.57      , 0.58      , 0.59      ],
      [0.6       , 0.61      , 0.62      , 0.63      , 0.64      ],
      [0.65000004, 0.66      , 0.67      , 0.68      , 0.69      ]]]
  axes: shape=(1,), dtype=int64
    [-2]

Outputs:
  reduced: shape=(3, 1, 5), dtype=float32
    [[[-0.35667497, -0.30110508, -0.2484614 , -0.19845103, -0.15082288]],

     [[ 0.4054651 ,  0.4317824 ,  0.4574248 ,  0.48242617,  0.50681764]],

     [[ 0.8329091 ,  0.8501509 ,  0.8671004 ,  0.8837675 ,  0.9001614 ]]]

Differences with previous version (13)#

SchemaDiff: ReduceLogSum (domain 'ai.onnx')

  • old version: 13

  • new version: 18

  • breaking: yes

Breaking reasons:

  • input ‘axes’ (added): at position 1; option=Single; type_str=’tensor(int64)’

  • attribute ‘axes’ (removed): type=INTS; required=False

Inputs:

  • [BREAKING] added ‘axes’: at position 1; option=Single; type_str=’tensor(int64)’

Attributes:

  • [BREAKING] removed ‘axes’: type=INTS; required=False

  • added ‘noop_with_empty_axes’: type=INT; required=False; default=0

Documentation:

  • line similarity: 0.62 (+3/-2 lines)

--- ReduceLogSum v13
+++ ReduceLogSum v18
@@ -1,6 +1,7 @@
 Computes the log sum of the input tensor's elements along the provided axes.
 The resulting tensor has the same rank as the input if keepdims equals 1.
 If keepdims equals 0, then the resulting tensor has the reduced dimension pruned.
-The axes attribute specifies which dimensions to reduce. Negative axes are supported.
-If axes is not provided, all dimensions are reduced.
+The axes are provided as an optional second input tensor. Negative axes are supported.
+If axes is not provided or is empty and noop_with_empty_axes is set to 1, the input tensor is returned unchanged.
+If axes is not provided or is empty and noop_with_empty_axes is not set, all dimensions are reduced.
 Reduction over an empty set of values yields minus infinity (if supported by the datatype) or undefined otherwise.

Version History#