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

Operator data type mismatch #8341

Closed
DeepLearningMOSA opened this issue Jul 24, 2024 · 4 comments
Closed

Operator data type mismatch #8341

DeepLearningMOSA opened this issue Jul 24, 2024 · 4 comments
Assignees

Comments

@DeepLearningMOSA
Copy link

Operator data type mismatch
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): Windows 10
TensorFlow.js installed from (npm or script link): script link
TensorFlow.js version (use command below): 3.19.0
Browser version: Microsoft Edge 125.0.2535.67(64 bit)、Google Chrome 125.0.6422.112 (64 bit)
Tensorflow.js Converter Version: -
Exception Report
{
"model_inf": "from:0 to:1 operator:identity from:0 to:4 operator:identity from:0 to:8 operator:identity from:0 to:9 operator:identity from:1 to:2 operator:identity from:1 to:7 operator:ReLU from:1 to:9 operator:CBR Block from:2 to:3 operator:ELU from:3 to:4 operator:ELU from:4 to:5 operator:identity from:5 to:6 operator:identity from:5 to:7 operator:PReLU from:6 to:7 operator:identity from:7 to:8 operator:identity from:7 to:9 operator:identity from:8 to:9 operator:identity ",
"error_message": "expected scalar type BFloat16 but found Float"
}

Bug Description
We do not specify any data types for any operator , and the input tensor data type is Float. My expected behavior: through the implicit type conversion declared by TensorFlow.js, the Float type would automatically be converted to the BFloat16 type. However, the conversion does not occur, and an exception was thrown directly. Is it possible that the operator uses a specific default data type when the operator parameter data type is not specified, and thus is incompatible with other data types?

@DeepLearningMOSA DeepLearningMOSA added the type:bug Something isn't working label Jul 24, 2024
@gaikwadrahul8 gaikwadrahul8 self-assigned this Jul 24, 2024
@gaikwadrahul8
Copy link
Contributor

Hi, @DeepLearningMOSA

Thank you for bringing this issue to our attention and TensorFlow.js currently primarily focuses on float32 for computations. While some operators might be internally optimized for bfloat16 (especially in models converted from frameworks that support it) but as far I know TensorFlow.js itself doesn't perform implicit conversions between data types.

Even if you don't specify data types for operators they don't necessarily have built-in default data types that work with various input types. Operators are typically designed to work with specific data types for numerical stability and performance reasons.

The operator in your model (potentially CBR Block or PReLU based on your information) likely expects bfloat16 data as input. Since TensorFlow.js doesn't handle automatic conversion and your input tensor is float32 mismatch leads to the expected scalar type BFloat16 but found Float error.

To help us investigate further, if it's convenient, would you be able to share your GitHub repository or a code snippet containing the model (zipped format)? Additionally, if possible, could you please outline the steps to reproduce the behavior on our end? This information would greatly expedite our troubleshooting process.

Thank you for your cooperation and patience.

Copy link

github-actions bot commented Aug 1, 2024

This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Aug 1, 2024
Copy link

github-actions bot commented Aug 9, 2024

This issue was closed due to lack of activity after being marked stale for past 7 days.

@github-actions github-actions bot closed this as completed Aug 9, 2024
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
Projects
None yet
Development

No branches or pull requests

2 participants