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

regression: tensor is disposed early #7504

Closed
vladmandic opened this issue Mar 21, 2023 · 2 comments · Fixed by #7505
Closed

regression: tensor is disposed early #7504

vladmandic opened this issue Mar 21, 2023 · 2 comments · Fixed by #7505
Assignees
Labels
RELEASE BLOCKER These issues must be resolved before the next release. type:bug Something isn't working

Comments

@vladmandic
Copy link
Contributor

vladmandic commented Mar 21, 2023

upgrade to tfjs 4.3.0 from tfjs 4.2.0 and immediately hit a regression issue.
tested in browser using webgl and in nodejs using tensorflow backends, both have same problem.

basically, some tensors are disposed immediately after model execution.

simple reproduction

const tf = require('@tensorflow/tfjs-node');

async function main() {
  console.log(`tfjs: ${tf.version_core} backend: ${tf.getBackend()}`);
  const model = await tf.loadGraphModel('https://vladmandic.github.io/human/models/faceres.json');
  const inputShape = model.inputs[0].shape?.map((x) => Math.abs(x));
  const input = tf.randomUniform(inputShape, 0, 1, model.inputs[0].dtype);
  const res = model.execute(input);
  for (const t of res) console.log(t.shape, t.isDisposed);
}

main();

result:

tfjs: 4.3.0 backend: tensorflow
[ 1, 1 ] false
[ 1, 1024 ] true
[ 1, 100 ] false

likely introduced via #7392 and attempted to fix via #7445 (but issue still exists)
also related issue #7431

i've tried a workaround by explicitly listing output tensors, but it does not help:

      const outputs = model?.outputs.map((o) => o.name);
      const res = model.execute(input, outputs);

runtime error is obvious, but just to make it easily searchable by other users here's a stack trace:

node_modules/.pnpm/@[email protected]/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:3882
            throw new Error("Tensor is disposed.");
                  ^

Error: Tensor is disposed.
    at Tensor.throwIfDisposed (node_modules/.pnpm/@[email protected]/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:3882:19)
    at Tensor.<anonymous> (node_modules/.pnpm/@[email protected]/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:3761:30)
    at step (node_modules/.pnpm/@[email protected]/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:140:27)
    at Object.next (.pnpm/@[email protected]/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:89:53)
    at node_modules/.pnpm/@[email protected]/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:82:71
    at new Promise (<anonymous>)
    at __awaiter (node_modules/.pnpm/@[email protected]/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:68:12)
    at Tensor.data (node_modules/.pnpm/@[email protected]/node_modules/@tensorflow/tfjs-core/dist/tf-core.node.js:3756:16)
@vladmandic vladmandic added the type:bug Something isn't working label Mar 21, 2023
@mattsoulanille mattsoulanille added the RELEASE BLOCKER These issues must be resolved before the next release. label Mar 21, 2023
@chunnienc chunnienc self-assigned this Mar 21, 2023
@mattsoulanille
Copy link
Member

Thank you for reporting this issue. We are looking into it. In the meantime, we will deprecate the 4.3.0 npm release.

@google-ml-butler
Copy link

Are you satisfied with the resolution of your issue?
Yes
No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RELEASE BLOCKER These issues must be resolved before the next release. type:bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants