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] Support ti.zero(x) and ti.one(x) for making zero/one value for the same type with x #1857

Merged
merged 2 commits into from Sep 11, 2020

Conversation

archibate
Copy link
Collaborator

@archibate archibate commented Sep 8, 2020

Related issue = http://www.jlhub.com/julia/manual/en/function/zero

[Click here for the format server]


Yeah it's still using x * 0 since we seems can't get the data type of an expr from python-scope.. maybe iapr, let's set up the API here imutating the Julia zero/one.

@archibate archibate requested review from xumingkuan, k-ye and yuanming-hu and removed request for xumingkuan, k-ye and yuanming-hu September 8, 2020 16:09
@codecov
Copy link

codecov bot commented Sep 8, 2020

Codecov Report

Merging #1857 into master will increase coverage by 0.15%.
The diff coverage is 76.92%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1857      +/-   ##
==========================================
+ Coverage   44.06%   44.21%   +0.15%     
==========================================
  Files          44       44              
  Lines        6089     6111      +22     
  Branches     1089     1092       +3     
==========================================
+ Hits         2683     2702      +19     
- Misses       3237     3240       +3     
  Partials      169      169              
Impacted Files Coverage Δ
python/taichi/lang/impl.py 66.66% <50.00%> (-0.19%) ⬇️
python/taichi/lang/transformer.py 82.02% <81.81%> (+0.04%) ⬆️
python/taichi/lang/util.py 32.93% <0.00%> (+1.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb8268e...bb0b3e0. Read the comment docs.

Copy link
Member

@k-ye k-ye left a comment

Choose a reason for hiding this comment

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

LGTM + nits!

@@ -131,3 +132,29 @@ def test():
print(i)

test()


@ti.test(require=ti.extension.data64)
Copy link
Member

Choose a reason for hiding this comment

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

IIUC, this applies to all the test cases, so platforms like Metal cannot be covered, even for 32-bit types? If so, could you split this into two cases, one for 64-bit and the other for non-64?

if ti.core.is_integral(dt):
x = int(x)
assert func(x) == 0 # intentionally not using ti.approx here

Copy link
Member

Choose a reason for hiding this comment

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

nit: Test for ti.Matrix as well?

@archibate archibate requested a review from k-ye September 9, 2020 15:47
@k-ye k-ye added the LGTM label Sep 10, 2020
@archibate archibate merged commit ef072d3 into taichi-dev:master Sep 11, 2020
@yuanming-hu yuanming-hu mentioned this pull request Sep 12, 2020
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.

None yet

2 participants