license import { backend_util , KernelConfig , KernelFunc , SparseToDense , SparseToDenseAttrs , SparseToDenseInputs , TensorInfo } from '@tensorflow/tfjs-core' ; import { MathBackendCPU } from '../backend_cpu' ; import { scatterImpl } from './Scatter_impl' ; export function sparseToDense ( args ) { const { inputs , backend , attrs } = args ; const { sparseIndices , sparseValues , defaultValue } = inputs ; const { outputShape } = attrs ; const { sliceRank , numUpdates , sliceSize , strides , outputSize } = backend_util . calculateShapes ( sparseValues , sparseIndices , outputShape ) ; const sumDupeIndices = false ; const indicesBuf = backend . bufferSync ( sparseIndices ) ; const updatesBuf = backend . bufferSync ( sparseValues ) ; const $defaultValue = backend . data . get ( defaultValue . dataId ) . values [ 0 ] as number ; const outBuf = scatterImpl ( indicesBuf , updatesBuf , outputShape , outputSize , sliceSize , numUpdates , sliceRank , strides , $defaultValue , sumDupeIndices ) ; return backend . makeTensorInfo ( outputShape , outBuf . dtype , outBuf . values ) ; } export const sparseToDenseConfig = { kernelName : SparseToDense , backendName : 'cpu' , kernelFunc : sparseToDense as { } as KernelFunc } ;