Class: ReduceSumFilter


To efficiently calculate the mean along a set of axes for a tensor with any number of channels, we divide the values by their count and sum up the result. The 'reduceSum' operation is performed by recursively applying the reduce filter, which sums up values in a certain window. This window is limited to a maximum size of 30x30 pixels. This allows making use of parallelism even though we're actually just calculating the mean of a large vector. To do so, the input is reshaped to a [inSize, batchSize] format and then fed to the GPU.

As we need to build up our filter stack prior to evaluation, we'll have to calculate the input shape and resulting number of iterations for the ReduceSumFilter beforehand. To do this, we query the reduce filter for the required stack of filters and add them to the graph. Using a ReduceSumFilter directly is not recommended.

new PhotoEditorSDK.Operations.ArtFilterOperation.TensorFilters.ReduceSumFilter()

sdk/operations/art-filter-operation/filters/reduce-sum-filter.js, line 37



staticPhotoEditorSDK.Operations.ArtFilterOperation.TensorFilters.ReduceSumFilter.addFiltersForReduceSumOperationToGraph(graph, inputIndex, axes)

sdk/operations/art-filter-operation/filters/reduce-sum-filter.js, line 45

Creates a stack of ReduceSumFilters that calculate the sum along the given axes for the filter at the given index and adds them to the given graph.

Name Type Description
graph TensorFilterGraph
inputIndex Number
axes Array.<Number>