Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Unknown op 'StringJoin'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp() #7946

Open
jordanburke opened this issue Sep 5, 2023 · 2 comments

Comments

@jordanburke
Copy link

jordanburke commented Sep 5, 2023

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js): Yes, Slightly modified USE npm class.
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 11
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: N/A
  • TensorFlow.js installed from (npm or script link): 4.10.0
  • TensorFlow.js version (use command below): 4.10.0
  • Browser version: N/A
  • Tensorflow.js Converter Version: v3.18.0

Describe the current behavior

We converted this recently : https://tfhub.dev/google/universal-sentence-encoder-large/5 and got around to hooking it up today. First ran into a StaticRegexReplace issue that I did a temp workaround, but even after that I soon ran into this:

    "TypeError: Unknown op 'StringJoin'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()\n" +
      '    at E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\tfjs-converter\\src\\operations\\operation_executor.ts:114:19\n' +
      '    at executeOp (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\tfjs-converter\\src\\operations\\operation_executor.ts:119:8)\n' +
      '    at _loop_1 (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\tfjs-converter\\src\\executor\\graph_executor.ts:630:13)\n' +
      '    at GraphExecutor.processStack (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\node_modules\\@tensorflow\\tfjs-converter\\dist\\tf-converter.node.js:31365:13)\n' +
      '    at GraphExecutor.<anonymous> (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\tfjs-converter\\src\\executor\\graph_executor.ts:576:29)\n' +
      '    at step (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\node_modules\\tslib\\tslib.es6.js:102:23)\n' +
      '    at Object.next (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\node_modules\\tslib\\tslib.es6.js:83:53)\n' +
      '    at E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\node_modules\\tslib\\tslib.es6.js:76:71\n' +
      '    at new Promise (<anonymous>)\n' +
      '    at __awaiter (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\node_modules\\tslib\\tslib.es6.js:72:12)'
  ]

I did a search against the repo and found no case of this function, so have to assume it's a valid missing function/exec.

Describe the expected behavior

tfjs would be able to consume and execute the StringJoin function.

Standalone code to reproduce the issue
Provide a reproducible test case that is the bare minimum necessary to generate
the problem. If possible, please share a link to Colab/CodePen/any notebook.

Modified Universal Sentence Encorder class (from NPM):

  async embed(inputs: string[] | string): Promise<tf.Tensor2D> {
    if (typeof inputs === "string") {
      inputs = [inputs]
    }

    const encodings = inputs.map((d) => this.tokenizer.encode(d))

    const indicesArr = encodings.map((arr, i) => arr.map((d, index) => [i, index]))

    let flattenedIndicesArr: Array<[number, number]> = []
    for (let i = 0; i < indicesArr.length; i++) {
      flattenedIndicesArr = flattenedIndicesArr.concat(indicesArr[i] as Array<[number, number]>)
    }
    const newInput = tf.tensor1d(inputs, "string")
    const modelInputs: ModelInputs2 = { inputs: newInput }

    const embeddings = await this.model.executeAsync(modelInputs)
    newInput.dispose()

    return embeddings as tf.Tensor2D
  }

Have a copy of the model here:
https://huggingface.co/heliogroup/tfUniversalSELargeJS

Other info / logs Include any logs or source code that would be helpful to
diagnose the problem. If including tracebacks, please include the full
traceback. Large logs and files should be attached.

    "TypeError: Unknown op 'StringJoin'. File an issue at https://github.com/tensorflow/tfjs/issues so we can add it, or register a custom execution with tf.registerOp()\n" +
      '    at E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\tfjs-converter\\src\\operations\\operation_executor.ts:114:19\n' +
      '    at executeOp (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\tfjs-converter\\src\\operations\\operation_executor.ts:119:8)\n' +
      '    at _loop_1 (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\tfjs-converter\\src\\executor\\graph_executor.ts:630:13)\n' +
      '    at GraphExecutor.processStack (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\node_modules\\@tensorflow\\tfjs-converter\\dist\\tf-converter.node.js:31365:13)\n' +
      '    at GraphExecutor.<anonymous> (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\tfjs-converter\\src\\executor\\graph_executor.ts:576:29)\n' +
      '    at step (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\node_modules\\tslib\\tslib.es6.js:102:23)\n' +
      '    at Object.next (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\node_modules\\tslib\\tslib.es6.js:83:53)\n' +
      '    at E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\node_modules\\tslib\\tslib.es6.js:76:71\n' +
      '    at new Promise (<anonymous>)\n' +
      '    at __awaiter (E:\\Helio\\helio-router-api\\node_modules\\.pnpm\\@tensorflow+tfjs-converter@4.10.0_@tensorflow+tfjs-core@4.10.0\\node_modules\\tslib\\tslib.es6.js:72:12)'
  ]

Thanks!

@jordanburke jordanburke added the type:bug Something isn't working label Sep 5, 2023
@gaikwadrahul8 gaikwadrahul8 self-assigned this Sep 6, 2023
@gaikwadrahul8
Copy link
Contributor

Hi, @jordanburke

Thank you for bringing this issue to our attention. Based on the error message, the StringJoin Op is not yet part of the core TensorFlow.js library if I'm not wrong. We will implement the StringJoin Op and will consider this issue as a feature request.

Alternatively, you can register a custom execution for the operation yourself using the tf.registerOp function. Please refer to this example for more information. If you or someone else would like to contribute to the StringJoin Op, please refer to the official documentation and the instructions on How to Contribute, How to Contribute a New op to TF.js Repository.

Please let me know if I have missed anything here. Thank you!

@jordanburke
Copy link
Author

Sounds great from my end. I think that cover it all @gaikwadrahul8, thanks!

@gaikwadrahul8 gaikwadrahul8 added type:feature New feature or request and removed type:bug Something isn't working labels Oct 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants