| Files | Last commit | Last update |
|---|---|---|
| 1 month ago | ||
| 2 months ago | ||
| 19 days ago | ||
| 19 days ago | ||
| 20 days ago | ||
| 19 days ago | ||
| 20 days ago | ||
| 19 days ago | ||
| 14 days ago |
DenseBincount
English | 简体中文
Product Support Status
| Product | Supported |
|---|---|
| Ascend 950PR&950DT products | √ |
| Atlas A3 training products/Atlas A3 inference products | √ |
| Atlas A2 training products/Atlas A2 inference products | √ |
| Atlas 200I/500 A2 inference products | × |
| Atlas inference products | × |
| Atlas training products | √ |
Function Description
-
Operator function: DenseBincount counts the number of occurrences or the weight sum of each bin row by row for one-dimensional or two-dimensional integer input.
-
Computation formula:
Let the unique element value in
sizebe the number of binsM. For one-dimensional input, the output shape is[M]; for two-dimensional input, the output shape is[N, M], whereN = input.shape[0]. For a valid row numberrand bin subscriptm, the non-binary output is:output[r,m]=∑i∈row(r)1(inputi=m)×{weightsi,numel(weights)>01,numel(weights)=0output[r,m] = \sum_{i \in row(r)} \mathbf{1}(input_i=m) \times \begin{cases} weights_i, & numel(weights)>0 \\ 1, & numel(weights)=0 \end{cases}
When
binary_outputistrue, the output is:output[r,m]=1(∃i∈row(r),inputi=m)output[r,m] = \mathbf{1}(\exists i \in row(r), input_i=m)
Input values greater than or equal to
Mare ignored. Negative values in one-dimensional input are ignored; negative values in two-dimensional input are wrapped to the previous row according to the TensorFlow DenseBincount semantics, and are ignored if the row number or bin subscript is still out of bounds after wrapping. Whenbinary_outputistrue, the values ofweightsare not used.
Parameter Description
| Parameter Name | Input/Output/Attribute | Required | Description | Data Type | Data Format |
|---|---|---|---|---|---|
| input | Input | Yes | A one-dimensional or two-dimensional tensor of bin subscripts. | INT32, INT64 | ND |
| size | Input | Yes | A scalar or a one-dimensional single-element tensor containing one non-negative constant value, where the element value indicates the number of bins. The data type must be the same as that of input. |
INT32, INT64 | ND |
| weights | Input | Yes | The weight tensor. This input cannot be omitted; when no weights exist, pass a zero-element tensor to indicate counting by occurrence. When it is not empty, the number of elements must be the same as that of input, and elements correspond one to one by flattened subscripts. |
FLOAT32 | ND |
| binary_output | Attribute | No | Whether to output only bin hit markers. The default value is false. |
Bool | - |
| output | Output | Yes | The counting result. It corresponds to shape [M] for one-dimensional input, and to shape [input.shape[0], M] for two-dimensional input, where M is the unique element value in size. |
FLOAT32 | ND |
Constraint Description
- The rank of
inputcan only be 1 or 2. sizemust be a scalar or a one-dimensional ND tensor containing only one non-negative constant value, and its data type must be the same as that ofinput.weightscannot be omitted, and its rank cannot exceed 2. Pass a zero-element tensor when no weights exist. When it is not empty, the number of elements must be the same as that ofinput, elements correspond one by one in the flattened order, and the shape is not required to be the same as that ofinputdimension by dimension.- Ascend 950PR&950DT products:
weightsis a FLOAT32 ND tensor whose rank cannot exceed 2. A value of 0 for the number of elements indicates that weights are not used; when it is not empty, the number of elements must be the same as that ofinput.inputwith any dimension of size 0 or withMof 0 is supported. When the shape ofinputis[0], the output shape is[M]; when the shape is[N, 0], the output shape is[N, M]; when the shape is[0, N]or[0, 0], the output shape is[0, M]. WhenMis 0, the last dimension of the output has size 0.- The number of output elements
rows * Mcannot exceed the maximum number of FLOAT32 elements representable by INT64 indexes, and the storage required by the output tensor must be allocatable by the running environment. For one-dimensional input,rowsis 1.
- Atlas A3 training products/Atlas A3 inference products and Atlas A2 training products/Atlas A2 inference products:
- The empty Tensor handling boundary of the existing implementation is retained.
- The rank of
weightscannot exceed 2. A value of 0 for the number of elements indicates that weights are not used; when it is not empty, the number of elements must be the same as that ofinput, and the shape is not required to be the same as that ofinputdimension by dimension. M, input dimension sizes, and the number of input elements must be within the INT32 range.
- This operator supports only the GE graph mode and the TensorFlow graph parsing path, and does not provide a public aclnn API.
Invocation Description
| Invocation Method | Invocation Sample | Description |
|---|---|---|
| Graph-mode invocation | test_geir_dense_bincount.cpp | Invokes the DenseBincount operator by building a graph through the operator IR. |