Open itsyoboieltr opened 7 months ago
When i run this file
import { tensor } from '@tensorflow/tfjs-core';
tensor([Math.random()]).toString();
it throws this same error in both node.js and bun run
. It doesn't appear intentional that tfjs-core, without one of the backend packages, will "just work"
just checked. they say this on their npm page for this package.
Note: If you are only importing the Core API, you also need to import a backend (e.g., tfjs-backend-cpu, tfjs-backend-webgl, tfjs-backend-wasm).
you likely want to use https://www.npmjs.com/package/@tensorflow/tfjs-node instead
not a bug in bun.
i completely misread, it is a bundler issue.
doesn't happen here so it does feel likely to the todo comment
What version of Bun is running?
1.0.27+c34bbb2e3
What platform is your computer?
Darwin 23.2.0 arm64 arm
What steps can reproduce the bug?
I was trying to make a small lambda with tfjs, so I wanted to bundle it to make the size small.
index.ts
run build command:
run bundled lambda:
Error:
I can reproduce this error message by removing
import '@tensorflow/tfjs-backend-cpu';
fromindex.ts
. It seems like this import line does not get resolved correctly or is somehow omitted from the bundled js.What is the expected behavior?
A random tensor returned from server after running bundled js:
What do you see instead?
Additional information
Build also gives this warning:
Maybe somehow the deoptimization breaks it?