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

[BugFix]Ensure that bf16 arrays are created as expected #16436

Merged
merged 1 commit into from
Jan 20, 2024

Conversation

sisleyli
Copy link
Contributor

If we use the bfloat16 type of ml_dtypes to create an array of tvm.ndarray, the result of the created tvm.ndarray will be wrong.

x = np.random.uniform(low=0.3, high=13.3, size=shape).astype(ml_dtypes.bfloat16)
# The values of x_ndarray and x are inconsistent!
x_ndarray = tvm.nd.array(x)

I understand that the reason for this error is that we have not considered that the input passed in is ml_dtypes.bfloat16. The np_float2np_bf16 function that has been used in the past (this function will convert the fp32 type numpy array into a uint16 numpy array)

@sisleyli
Copy link
Contributor Author

Hi @masahi @Hzfengsy , could you please help me review this PR? Thank you!

@sisleyli
Copy link
Contributor Author

@tvm-bot rerun

@masahi masahi merged commit ccca00a into apache:main Jan 20, 2024
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants