FilesLast commitLast update
19 days ago
2 months ago
19 days ago
12 days ago
12 days ago
12 days ago
1 month ago
19 days ago
9 days ago
README

SparseBincount

English | 简体中文

Product Support Status

Product Supported
Ascend 950PR&950DT products √
Atlas A3 products √
Atlas A2 products √
Atlas 200I/500 A2 inference products ×
Atlas inference products ×
Atlas training products ×

Function Description

  • Operator function: counts the occurrences or weighted accumulated sum of each value (bin index) in a sparse tensor. Both the 1D and multi-dimensional modes are supported, and the binary_output mode is supported.

  • Computation formula:

1D: output[v]+=wi(if v<size)\text{1D: } output[v] += w_i \quad (\text{if } v < size)

Multi-dim: output[batch][v]+=wi(if v<size and batch<dense_shape[0])\text{Multi-dim: } output[batch][v] += w_i \quad (\text{if } v < size \text{ and } batch < dense\_shape[0])

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
indices Input Indices of the sparse tensor, a 2D tensor with shape (N, R). INT64 ND
values Input Values of the sparse tensor (bin index), a 1D tensor with shape (N,). INT32, INT64 ND
dense_shape Input Dense shape of the sparse tensor, a 1D tensor with shape (R,). INT64 ND
size Input Number of bins (scalar tensor) with shape (1,). INT32, INT64 ND
weights Input Weights, a 1D tensor with shape (N,) or (0,). If empty, each occurrence is counted as 1. FLOAT ND
binary_output Optional attribute Whether to output binary values. The default value is false. If True, bins that have appeared are set to 1. If False, the count or weighted accumulation is output. BOOL -
output Output Statistics result. In 1D mode, the shape is [size]. In multi-dimensional mode, the shape is [dense_shape[0], size]. FLOAT ND

Constraint Description

  • indices is a 2D tensor with shape (N, R); values, dense_shape, size, and weights are all 1D tensors
  • The number of rows of indices (N) must be equal to the number of elements of values (N)
  • The number of columns of indices (R) must be equal to the number of elements of dense_shape (R), and the number of elements of dense_shape (R) must be at least 1 (dense_shape is not empty)
  • indices[:, j] must be in the range [0, dense_shape[j])
  • values[i] must be in the range [0, size)
  • If weights is not empty, the number of elements must be equal to the number of elements of values (N)
  • size is a non-negative scalar with shape (1,)
  • If weights is empty (the number of elements is 0), each occurrence is counted as 1.0
  • If binary_output = True, bins that have appeared are set to 1.0 and weights are ignored

Invocation Description

Invocation Method Sample Code Description
GE graph mode test_geir_sparse_bincount Invokes the SparseBincount operator by building a graph through the operator IR.