Skip to content

[tfjs-tflite] Model (that works fine with Python TFLite interpreter) freezes browser with infinite loop if cross-origin isolated, or throws error if not #7055

Open
@josephrocca

Description

@josephrocca

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 20.04
  • TensorFlow.js installed from (npm or script link): 3.20.0
  • Browser version: Chrome v106

Describe the current behavior
This TFLite model freezes the browser (if cross-origin isolated = tfjs-tflite runtime has threads) or throws an error (if not cross-origin isolated) when I try to inference it in the browser, but it works fine in Python.

Describe the expected behavior
If it works in Python TFLite, it should work in TFjs TFLite.

Standalone code to reproduce the issue

Here's the error thrown when not using COEP/COOP header (i.e. when not cross-origin isolated):

tflite_web_api_cc_simd.js:580 Uncaught (in promise) RuntimeError: Aborted(native code called abort())
    at abort (tflite_web_api_cc_simd.js:580:10)
    at _abort (tflite_web_api_cc_simd.js:2865:2)
    at std::__2::__throw_system_error(int, char const*) (tflite_web_api_cc_simd.wasm:0x349723)
    at TfLiteStatus tflite::ops::builtin::conv::Eval<(tflite::ops::builtin::conv::KernelType)2>(TfLiteContext*, TfLiteNode*) (tflite_web_api_cc_simd.wasm:0x12eed9)
    at tflite::Subgraph::Invoke() (tflite_web_api_cc_simd.wasm:0x262d3c)
    at tflite::Interpreter::Invoke() (tflite_web_api_cc_simd.wasm:0x25559c)
    at tfweb::generic::TFLiteWebModelRunner::Infer() (tflite_web_api_cc_simd.wasm:0xcd194)
    at emscripten::internal::MethodInvoker<unsigned long (std::__2::vector<tflite::task::core::Category, std::__2::allocator<tflite::task::core::Category>>::*)() const, unsigned long, std::__2::vector<tflite::task::core::Category, std::__2::allocator<tflite::task::core::Category>> const*>::invoke(unsigned long (std::__2::vector<tflite::task::core::Category, std::__2::allocator<tflite::task::core::Category>>::* const&)() const, std::__2::vector<tflite::task::core::Category, std::__2::allocator<tflite::task::core::Category>> const*) (tflite_web_api_cc_simd.wasm:0x7f3a)
    at TFLiteWebModelRunner.TFLiteWebModelRunner$Infer [as Infer] (eval at new_ (tflite_web_api_cc_simd.js:1821:22), <anonymous>:8:10)
    at module$exports$google3$third_party$tensorflow_lite_support$web$tflite_web_api_client.TFLiteWebModelRunner.infer (tflite_web_api_client.js:2731:188)

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions