license import { KernelConfig , SparseToDense , SparseToDenseAttrs , SparseToDenseInputs , tensor1d } from '@tensorflow/tfjs' ; import { createTensorsTypeOpAttr , NodeJSKernelBackend } from '../nodejs_kernel_backend' ; export const sparseToDenseConfig = { kernelName : SparseToDense , backendName : 'tensorflow' , kernelFunc : ( args ) => { const { sparseIndices , sparseValues , defaultValue } = args . inputs as SparseToDenseInputs ; const backend = args . backend as NodeJSKernelBackend ; const { outputShape } = args . attrs as { } as SparseToDenseAttrs ; const opAttrs = [ { name : 'validate_indices' , type : backend . binding . TF_ATTR_BOOL , value : true } , createTensorsTypeOpAttr ( 'T' , sparseValues . dtype ) , createTensorsTypeOpAttr ( 'Tindices' , sparseIndices . dtype ) ] ; const outputShapeTensor = tensor1d ( outputShape , 'int32' ) ; const res = backend . executeSingleOutput ( SparseToDense , opAttrs , [ sparseIndices , outputShapeTensor , sparseValues , defaultValue ] ) ; outputShapeTensor . dispose ( ) ; return res ; } } ;