license import { ENGINE } from '../engine' ; import { DenseBincount , DenseBincountAttrs , DenseBincountInputs } from '../kernel_names' ; import { NamedAttrMap } from '../kernel_registry' ; import { Tensor1D , Tensor2D } from '../tensor' ; import { NamedTensorMap } from '../tensor_types' ; import { convertToTensor } from '../tensor_util_env' ; import { TensorLike } from '../types' ; import * as util from '../util' ; import { op } from './operation' ; param x param weights param size param binaryOutput doc function denseBincount_ < T extends Tensor1D | Tensor2D > ( x , weights , size , binaryOutput = false ) { const $x = convertToTensor ( x , 'x' , 'denseBincount' ) ; const $weights = convertToTensor ( weights , 'weights' , 'denseBincount' ) ; util . assert ( $x . dtype === 'int32' , ( ) => `Error in denseBincount: input ` + `dtype must be int32, but got ${ $x . dtype }` ) ; util . assert ( $x . rank <= 2 , ( ) => `Error in denseBincount: input must be at most rank 2, but got ` + `rank ${ $x . rank }.` ) ; util . assert ( size >= 0 , ( ) => `size must be non-negative, but got ${ size }.` ) ; util . assert ( $weights . size === $x . size || $weights . size === 0 , ( ) => `Error in denseBincount: weights must have the same shape as x or ` + `0-length, but got x shape: ${ $x . shape }, weights shape: ` + `${ $weights . shape }.` ) ; const inputs = { x : $x , weights : $weights } ; const attrs = { size , binaryOutput } ; return ENGINE . runKernel ( DenseBincount , inputs as { } as NamedTensorMap , attrs as { } as NamedAttrMap ) ; } export const denseBincount = op ( { denseBincount_ } ) ;