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

[lang] Annotate constants with dtype without casting. #4224

Merged
merged 1 commit into from
Feb 8, 2022

Conversation

ailzhang
Copy link
Contributor

@ailzhang ailzhang commented Feb 7, 2022

Fixes #4210

This PR also simplifies the clamping logic by:

  1. Make sure constant is valid in range of specified dtype.
  2. Always use the widest int64/float64 to communicate between python and C++ and
    converts it to the specified dtype in C++. This is just to avoid
    handling each dtype on both python and C++ side.

We might consider further improve it by moving this logic from python to C++ in the future and this PR made it a step closer.

Related issue = #

@netlify
Copy link

netlify bot commented Feb 7, 2022

✔️ Deploy Preview for docsite-preview ready!

🔨 Explore the source changes: a6d5c09

🔍 Inspect the deploy log: https://app.netlify.com/sites/docsite-preview/deploys/6202408662b5340007217fb8

😎 Browse the preview: https://deploy-preview-4224--docsite-preview.netlify.app

taichi/python/export_lang.cpp Outdated Show resolved Hide resolved
python/taichi/lang/expr.py Outdated Show resolved Hide resolved
python/taichi/lang/impl.py Outdated Show resolved Hide resolved
Fixes taichi-dev#4210

This PR also simplifies the clamping logic by:
1. Make sure constant is valid in range of specified dtype.
2. Always use int64/float64 to communicate between python and C++ and
converts it to the specified dtype in C++. This is just to avoid
handling each dtype on both python and C++ side.

We might consider further improve it by moving this logic from python to C++ in the future and this PR made it a step closer.
Copy link
Contributor

@lin-hitonami lin-hitonami left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ailzhang ailzhang merged commit 8bdb4ab into taichi-dev:master Feb 8, 2022
Lang Features & Python automation moved this from To do to Done Feb 8, 2022
@ailzhang ailzhang deleted the const_with_dt branch February 8, 2022 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

False warnings on unsigned integer overflow
2 participants