Backend WASM does not implement kernel SparseToDense
attempting to run nanodet object detection model
converted from pytorch - conversion notes and example of model usage are at:
https://gist.github.com/vladmandic/d0115e3899860391382d58550bd49b3f
engine.ts:540 Uncaught (in promise) Error: Kernel 'SparseToDense' not registered for backend 'wasm'
at Engine.runKernel (engine.ts:540)
at sparseToDense_ (sparse_to_dense.ts:88)
at sparseToDense__op (operation.ts:51)
at executeOp15 (slice_join_executor.ts:183)
at operation_executor.ts:92
at engine.ts:467
at Engine.scopedRun (engine.ts:478)
at Engine.tidy (engine.ts:465)
at tidy (globals.ts:192)
at operation_executor.ts:91
same graph model works without issues in nodejs with tensorflow backend and browser with webgl backend
environment: tfjs 3.3.0 on ubuntu 20.10 with chrome 88
cc @lina128 @jinjingforever
@rthadur @ahmedsabie A similar thing happened for panoptic segmentation model conversion as well. Any idea where the SparseToDense operation could possibly come from? There is no sparse tensor in the pytorch/onnx models.
Thanks a lot.
Same problem here! I tried to reimplement the operation in a custom way like this:
const customSparseToDense = function(node) {
let sparseIndices = node.inputs[0];
let sparseValues = node.inputs[1];
let outputShape = node.inputs[2].arraySync();
let defaultValue = node.inputs[3].arraySync();
return tf.sparseToDense(sparseIndices, sparseValues, outputShape, defaultValue);
}
tf.registerOp('SparseToDense', customSparseToDense);
But without success: it gives too many error on the input's validation.
Having this problem when using with @tensorflow-models/universal-sentence-encoder.
Evironment: Node 14, Ubuntu 20.04 Package installed:
"@tensorflow-models/universal-sentence-encoder": "^1.3.3",
"@tensorflow/tfjs": "^3.18.0",
"@tensorflow/tfjs-backend-wasm": "^3.18.0",
"@tensorflow/tfjs-core": "^3.18.0",
"@tensorflow/tfjs-node": "^3.18.0",
WASM init:
const tf = require('@tensorflow/tfjs');
import "@tensorflow/tfjs-backend-wasm";
import "@tensorflow/tfjs-backend-webgl";
import "@tensorflow/tfjs-node";
import {getThreadsCount, setThreadsCount} from '@tensorflow/tfjs-backend-wasm';
dotenv.config();
setThreadsCount(2);
async function bootstrap() {
const use = new UniversalSentenceEncoder();
await use.load();
use.embed("string").then(...)
}
tf.setBackend("wasm").then(() => void bootstrap());
Error:
ERROR 2022-07-11T23:44:58.189 middleware/unknown-except:15 | Error: Kernel 'SparseToDense' not registered for backend 'wasm'
at Engine.runKernel (/home/user/Documents/tfjs-core/src/engine.ts:548:13)
at sparseToDense_ (/home/user/Documents/tfjs-core/src/ops/sparse_to_dense.ts:88:17)
at tfOps.sparseToDense (/home/user/Documents/tfjs-core/src/ops/operation.ts:51:24)
at sliceJoin.executeOp (/home/user/Documents/project/tfjs-converter/src/operations/executors/slice_join_executor.ts:183:19)
at /home/user/Documents/project/tfjs-converter/src/operations/operation_executor.ts:94:23
at /home/user/Documents/project/tfjs-core/src/engine.ts:467:20
at Engine.scopedRun (/home/user/Documents/project/tfjs-core/src/engine.ts:478:19)
at Engine.tidy (/home/user/Documents/project/tfjs-core/src/engine.ts:465:17)
at Object.tidy (/home/user/Documents/project/tfjs-core/src/globals.ts:192:17)
at /home/user/Documents/project/tfjs-converter/src/operations/operation_executor.ts:93:24
at executeOp (/home/user/Documents/project/tfjs-converter/src/operations/operation_executor.ts:121:8)
at _loop_1 (/home/user/Documents/project/tfjs-converter/src/executor/graph_executor.ts:551:13)
at GraphExecutor.processStack (/home/user/Documents/project/node_modules/@tensorflow/tfjs-converter/dist/tf-converter.node.js:29831:13)
at GraphExecutor.<anonymous> (/home/user/Documents/project/tfjs-converter/src/executor/graph_executor.ts:497:29)
at step (/home/user/Documents/project/node_modules/tslib/tslib.es6.js:100:23)
at Object.next (/home/user/Documents/project/node_modules/tslib/tslib.es6.js:81:53) (unknown-exceptions)