Skip to content

Conversation

@zhuzilin
Copy link
Contributor

This PR adds support for generating data of any shape in threefry_generate.

Thank you for your time on reviewing this pr.

cc @tkonolige

Copy link
Contributor

@tkonolige tkonolige left a comment

Choose a reason for hiding this comment

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

Thanks for the PR! I've left a couple of comments. Also, could you add a test that makes sure the last 3 random number of a size 4*x+3 shape change between calls with different keys?

Comment on lines 312 to 319
with irb.if_scope(out_len % 4 != 0):
out_gen[7] = tmp[7] + tir.Cast(gen.dtype, out_len % 4)
with irb.else_scope():
out_gen[7] = tmp[7] + tir.Cast(gen.dtype, out_len) # increment counter
Copy link
Contributor

Choose a reason for hiding this comment

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

This is incorrect. It should just be out_gen[7] = tmp[7] + tir.Cast(gen.dtype, out_len) because we used out_len values from the counter.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@tkonolige I changed the increment to out_len % 4 here because I already update the tmp[7] above with:

tmp[7] = tmp[7] + tir.Cast(gen.dtype, out_len // 4 * 4)

The reason for the separate update is that I think we need to update the key before the second threefry.

However, I update the second update from tir.Cast(gen.dtype, out_len % 4) to tir.Cast(gen.dtype, 4), because 4 random numbers are actually generated (though partially discarded).

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh yeah, you are correct. Could you leave a comment that it was updated earlier.


# Compute random values
_threefry(irb, tmp, 0, tmp, 4, out_array, 0, out_len // 4)
with irb.if_scope(out_len % 4 != 0):
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be if out_len.value % 4 != 0:

@zhuzilin
Copy link
Contributor Author

@tkonolige Thank you for your review~ I've updated the code based on them. Could you take a second look? As for the incorrect part of the update, I have some different opinion, see the comment above.

@zhuzilin
Copy link
Contributor Author

zhuzilin commented May 24, 2021

@tkonolige I've added the comment and rebased the code to main branch to fix the shape limit in uniform. Could you take another look? Thank you~

Copy link
Contributor

@tkonolige tkonolige left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you!

@zhuzilin
Copy link
Contributor Author

@tqchen Could you give a help to this PR? Thank you~ 😄

@tqchen tqchen merged commit 6f82e98 into apache:main May 25, 2021
trevor-m pushed a commit to trevor-m/tvm that referenced this pull request Jun 17, 2021
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Jun 17, 2021
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.

3 participants