(args: {
backend: BackendWasm,
inputs: SparseToDenseInputs,
attrs: SparseToDenseAttrs
})
| 44 | } |
| 45 | |
| 46 | function sparseToDense(args: { |
| 47 | backend: BackendWasm, |
| 48 | inputs: SparseToDenseInputs, |
| 49 | attrs: SparseToDenseAttrs |
| 50 | }): TensorInfo { |
| 51 | const {backend, inputs, attrs} = args; |
| 52 | const {sparseIndices, sparseValues, defaultValue} = inputs; |
| 53 | const {outputShape} = attrs; |
| 54 | |
| 55 | const out = backend.makeOutput(outputShape, defaultValue.dtype); |
| 56 | if (util.sizeFromShape(outputShape) === 0) { |
| 57 | return out; |
| 58 | } |
| 59 | |
| 60 | const {sliceRank, numUpdates, sliceSize, strides, outputSize} = |
| 61 | backend_util.calculateShapes(sparseValues, sparseIndices, outputShape); |
| 62 | |
| 63 | const sparseIndicesId = backend.dataIdMap.get(sparseIndices.dataId).id; |
| 64 | const sparseValuesId = backend.dataIdMap.get(sparseValues.dataId).id; |
| 65 | const defaultValueId = backend.dataIdMap.get(defaultValue.dataId).id; |
| 66 | |
| 67 | const stridesBytes = new Uint8Array(new Int32Array(strides).buffer); |
| 68 | |
| 69 | const outId = backend.dataIdMap.get(out.dataId).id; |
| 70 | |
| 71 | wasmSparseToDense( |
| 72 | sparseIndicesId, sparseValuesId, sparseValues.shape.length, |
| 73 | defaultValueId, CppDType[defaultValue.dtype], sliceRank, numUpdates, |
| 74 | sliceSize, stridesBytes, outputSize, outId); |
| 75 | |
| 76 | return out; |
| 77 | } |
| 78 | |
| 79 | export const sparseToDenseConfig: KernelConfig = { |
| 80 | kernelName: SparseToDense, |
nothing calls this directly
no test coverage detected
searching dependent graphs…