Skip to content

Parameterize test_link_params #9276

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

Merged
merged 1 commit into from
Feb 18, 2022

Conversation

areusch
Copy link
Contributor

@areusch areusch commented Oct 13, 2021

Cleaning up test_link_params to support the new parameterized testing.

cc @Lunderberg

Copy link
Member

@Mousius Mousius left a comment

Choose a reason for hiding this comment

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

This is pretty cool, didn't realise we had this!

Comment on lines +42 to +46
linkable_dtype = tvm.testing.parameter(
*(
[f"uint{b}" for b in (8, 16, 32, 64)]
+ [f"int{b}" for b in (8, 16, 32, 64)]
+ ["float32", "float64"]
)
Copy link
Member

Choose a reason for hiding this comment

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

I think you can do this a tiny bit neater?

Suggested change
linkable_dtype = tvm.testing.parameter(
*(
[f"uint{b}" for b in (8, 16, 32, 64)]
+ [f"int{b}" for b in (8, 16, 32, 64)]
+ ["float32", "float64"]
)
linkable_dtype = tvm.testing.parameter(
*[f"uint{b}" for b in (8, 16, 32, 64)],
*[f"int{b}" for b in (8, 16, 32, 64)],
"float32", "float64"

Copy link
Contributor

@Lunderberg Lunderberg 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 to me, just had a couple small questions on it.


# NOTE: Need to export_library() and load_library() to link all the Module(llvm, ...)
# against one another.
temp_dir = tempfile.mkdtemp()
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't related to the current PR, but do you know why tempfile.mkdtemp is used instead of tempfile.TemporaryDirectory? The mkdtemp requires manual cleanup which doesn't seem to be done here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed this one

else:
np.testing.assert_allclose(unlinked_output.numpy(), linked_output.numpy())
def test_llvm_link_params(linkable_dtype):
ir_mod, param_init = _make_mod_and_params(linkable_dtype)
Copy link
Contributor

Choose a reason for hiding this comment

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

Now that linkable_dtype is a parameter, we can change _make_mod_and_params from a function to a fixture. This would let pytest make a distinction between setup errors in the module setup due to tvm.parser, and test errors in the linking.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'd like to address this one, but i'm a little short on time right now. hopefully we can merge this in the spirit of incremental progress and address later

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, and agreed.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 2, 2022

It has been a while since this PR was updated, @Lunderberg @Mousius @Lunderberg please leave a review or address the outstanding comments

@areusch areusch force-pushed the parameterize-link-params-tests branch from 8128067 to f5a85c2 Compare February 17, 2022 06:16
@areusch areusch requested a review from icemelon as a code owner February 17, 2022 06:16
@areusch
Copy link
Contributor Author

areusch commented Feb 17, 2022

@Lunderberg I sync'd this one up, PTAL when you get a chance.

@areusch areusch force-pushed the parameterize-link-params-tests branch from f5a85c2 to f6d3494 Compare February 17, 2022 17:52
Copy link
Contributor

@Lunderberg Lunderberg left a comment

Choose a reason for hiding this comment

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

LGTM!

else:
np.testing.assert_allclose(unlinked_output.numpy(), linked_output.numpy())
def test_llvm_link_params(linkable_dtype):
ir_mod, param_init = _make_mod_and_params(linkable_dtype)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, and agreed.

@areusch areusch merged commit 6591cba into apache:main Feb 18, 2022
pfk-beta pushed a commit to pfk-beta/tvm that referenced this pull request Apr 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants