license import { ENGINE } from '../engine' ; import { Bincount , BincountAttrs , BincountInputs } from '../kernel_names' ; import { NamedAttrMap } from '../kernel_registry' ; import { Tensor1D } 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 doc function bincount_ < T extends Tensor1D > ( x , weights , size ) { const $x = convertToTensor ( x , 'x' , 'bincount' ) ; const $weights = convertToTensor ( weights , 'weights' , 'bincount' ) ; util . assert ( $x . dtype === 'int32' , ( ) => `Error in bincount: input ` + `dtype must be int32, but got ${ $x . dtype }` ) ; util . assert ( size >= 0 , ( ) => `size must be non-negative, but got ${ size }.` ) ; util . assert ( $weights . size === $x . size || $weights . size === 0 , ( ) => `Error in bincount: weights must have the same size as input or` + `0-length, but got input shape: ${ $x . shape }, weights shape: ` + `${ $weights . shape }.` ) ; const inputs = { x : $x , weights : $weights } ; const attrs = { size } ; return ENGINE . runKernel ( Bincount , inputs as { } as NamedTensorMap , attrs as { } as NamedAttrMap ) ; } export const bincount = op ( { bincount_ } ) ;