Description
Please make sure that this is a bug. As per our
GitHub Policy,
we only address code/doc bugs, performance issues, feature requests and
build/installation issues on GitHub. tag:bug_template
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow.js):
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 20.04, Macos 13.3 (22E252)
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
- TensorFlow.js installed from (npm or script link): script link
- TensorFlow.js version (use command below): 4.2.0
- Browser version: Chrome Version 128.0.6613.86 (Official Build) (arm64)
- Tensorflow.js Converter Version:
Describe the current behavior
Given the "t1": [[-1767738612.8308272,1342651338.1728053]], "t2": [[-1069397745.6943247,-1040119386.9828408],[630839119.41397,-1766313500.9227078]]
, tf.dot(t1,t2) return [ [ 2737412593109958700, -532884082837684200 ] ] on the CPU backend. However, tf.dot(t1,t2) return [[2737412867987865600, -532884048477945860]] on the WebGL backend and return [[2737412867987865600, -532884082837684200]] on Wasm, and tensorflow backends.
Describe the expected behavior
The output should be consistent across all backends.
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.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>bug00</title>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@4.2.0/dist/tf.js"> </script>
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-wasm@4.2.0/dist/tf-backend-wasm.js"></script>
</head>
<body>
<script>
async function dot(backend){
await tf.setBackend(backend);
await tf.ready()
t1 = [[-1767738612.8308272,1342651338.1728053]]
t2 = [[-1069397745.6943247,-1040119386.9828408],[630839119.41397,-1766313500.9227078]]
const result = await tf.dot(t1,t2);
await console.log("the result of ", tf.getBackend(), "is:\n" );
await result.print();
}
async function test() {
await dot("cpu");
await dot("webgl");
await dot("wasm");
}
test();
</script>
</body>
</html>
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.