license import { ENGINE } from '../engine' ; import { OneHot , OneHotAttrs , OneHotInputs } from '../kernel_names' ; import { NamedAttrMap } from '../kernel_registry' ; import { Tensor } from '../tensor' ; import { NamedTensorMap } from '../tensor_types' ; import { convertToTensor } from '../tensor_util_env' ; import { TensorLike } from '../types' ; import { op } from './operation' ; param indices param depth param onValue param offValue doc function oneHot_ ( indices , depth , onValue = 1 , offValue = 0 ) { if ( depth < 2 ) { throw new Error ( `Error in oneHot: depth must be >=2, but it is ${ depth }` ) ; } const $indices = convertToTensor ( indices , 'indices' , 'oneHot' , 'int32' ) ; const inputs = { indices : $indices } ; const attrs = { depth , onValue , offValue } ; return ENGINE . runKernel ( OneHot , inputs as unknown as NamedTensorMap , attrs as unknown as NamedAttrMap ) ; } export const oneHot = op ( { oneHot_ } ) ;