Open
Description
System information
- Windows 10 22H2
- Brave (Chrome 121 on Windows)
- TensorFlow.js installed from: https://www.npmjs.com/package/@tensorflow/tfjs/v/3.20.0
- TensorFlow.js version: 3.20.0
- TFLite.js version: 0.0.1-alpha.9
I encountered this issue #7893 when using @tensorflow/[email protected]. So I regressed to @tensorflow/[email protected], as suggested in the issue. As a consequence of this downgrade, I had to use @tensorflow/[email protected], as illustrated in #7789.
With this setup, I tried to load a .tfilte
model as follows:
const modelContent: ArrayBuffer = await modelDownloadWithProgress.arrayBuffer();
console.log(`features: ${JSON.stringify(await getWasmFeatures())}`);
const model: TFLiteModel = await loadTFLiteModel(modelContent)
console.log(`model: ${model}`);
The output is the following:
features: {"simd":true,"multiThreading":false}
tflite_web_api_client.js:2710 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading '_malloc')
at $jscomp.generator.Engine_.eval [as program_] (tflite_web_api_client.js:2710:245)
at $jscomp.generator.Engine_.nextStep_ (tflite_web_api_client.js:31:105)
at $jscomp.generator.Engine_.next_ (tflite_web_api_client.js:27:234)
at $jscomp.generator.Generator_.next (tflite_web_api_client.js:32:73)
at b (tflite_web_api_client.js:33:73)
The referenced line is the following:
module$exports$google3$third_party$tensorflow_lite_support$web$tflite_web_api_client.TFLiteWebModelRunner.create = function(a, b) {
b = void 0 === b ? {} : b;
var c, d, e, f, g, h, k, l, m, n, p, q, r;
return $jscomp.asyncExecutePromiseGeneratorProgram(function(t) {
if (1 == t.nextAddress)
return c = module$exports$google3$third_party$tensorflow_lite_support$web$task$codegen$common$emscripten_module_loader.EmscriptenModuleLoader.getInstance(module$contents$google3$third_party$tensorflow_lite_support$web$tflite_web_api_client_wasmModulesPath, "tflite_web_api", '"use strict";var Module={};var initializedJS=false;var pendingNotifiedProxyingQueues=[];function threadPrintErr(){var text=Array.prototype.slice.call(arguments).join(" ");console.error(text)}function threadAlert(){var text=Array.prototype.slice.call(arguments).join(" ");postMessage({cmd:"alert",text:text,threadId:Module["_pthread_self"]()})}var err=threadPrintErr;self.alert=threadAlert;Module["instantiateWasm"]=(info,receiveInstance)=>{var instance=new WebAssembly.Instance(Module["wasmModule"],info);receiveInstance(instance);Module["wasmModule"]=null;return instance.exports};self.onunhandledrejection=e=>{throw e.reason??e};self.onmessage=e=>{try{if(e.data.cmd==="load"){Module["wasmModule"]=e.data.wasmModule;Module["wasmMemory"]=e.data.wasmMemory;Module["buffer"]=Module["wasmMemory"].buffer;Module["ENVIRONMENT_IS_PTHREAD"]=true;if(typeof e.data.urlOrBlob=="string"){importScripts(e.data.urlOrBlob)}else{var objectUrl=URL.createObjectURL(e.data.urlOrBlob);importScripts(objectUrl);URL.revokeObjectURL(objectUrl)}tflite_web_api_ModuleFactory(Module).then(function(instance){Module=instance})}else if(e.data.cmd==="run"){Module["__performance_now_clock_drift"]=performance.now()-e.data.time;Module["__emscripten_thread_init"](e.data.pthread_ptr,0,0,1);Module["establishStackSpace"]();Module["PThread"].receiveObjectTransfer(e.data);Module["PThread"].threadInitTLS();if(!initializedJS){Module["__embind_initialize_bindings"]();pendingNotifiedProxyingQueues.forEach(queue=>{Module["executeNotifiedProxyingQueue"](queue)});pendingNotifiedProxyingQueues=[];initializedJS=true}try{Module["invokeEntryPoint"](e.data.start_routine,e.data.arg)}catch(ex){if(ex!="unwind"){if(ex instanceof Module["ExitStatus"]){if(Module["keepRuntimeAlive"]()){}else{Module["__emscripten_thread_exit"](ex.status)}}else{throw ex}}}}else if(e.data.cmd==="cancel"){if(Module["_pthread_self"]()){Module["__emscripten_thread_exit"](-1)}}else if(e.data.target==="setimmediate"){}else if(e.data.cmd==="processProxyingQueue"){if(initializedJS){Module["executeNotifiedProxyingQueue"](e.data.queue)}else{pendingNotifiedProxyingQueues.push(e.data.queue)}}else{err("worker.js received unknown command "+e.data.cmd);err(e.data)}}catch(ex){if(Module["__emscripten_thread_crashed"]){Module["__emscripten_thread_crashed"]()}throw ex}};\n'),
d = $jscomp,
e = d.makeIterator,
t.yield(Promise.all([c.load(), "string" === typeof a ? fetch(a).then(function(u) {
return u.arrayBuffer()
}) : Promise.resolve(a)]), 2);
f = e.call(d, t.yieldResult);
g = f.next().value;
h = f.next().value;
k = g;
l = h;
m = new Uint8Array(l);
n = k._malloc(m.length); // <== k is undefined
k.HEAPU8.set(m, n);
Perhaps this is a result of using a woefully outdated TensorFlow.js version, so my question would be:
- Will there be a @tensorflow/[email protected] release which resolves npm @tensorflow/tfjs-tflite Can't resolve './tflite_web_api_client' #7893 or
- How can I resolve this issue with version 3.20.0 of TensorFlow.js?
Thanks for any suggestions you can provide!