Skip to content

Conversation

@goldsborough
Copy link
Contributor

In our #better-engineering quest of removing all uses of catch in favor of gtest, this PR ports JIT tests to gtest. After #11846 lands, we will be able to delete catch.

I don't claim to use/write these tests much (though I wrote the custom operator tests) so please do scrutinize whether you will want to write tests in the way I propose. Basically:

  1. One function declaration per "test case" in test/cpp/jit/test.h
  2. One definition in test/cpp/jit/test.cpp
  3. If you want to be able to run it in Python, add it to runJitTests() which is called from Python tests
  4. If you want to be able to run it in C++, add a JIT_TEST line in test/cpp/jit/gtest.cpp

Notice also I was able to share support code between C++ frontend and JIT tests, which is healthy.

@ezyang @apaszke @zdevito

This comment was marked as off-topic.

This comment was marked as off-topic.

@ezyang
Copy link
Contributor

ezyang commented Sep 25, 2018

I... don't really understand how this structure works. So if I want to compile PyTorch without linking gtest (which would be weird), what happens to these files?

@goldsborough
Copy link
Contributor Author

@ezyang The tests from tests.cpp and the runJitTests() function get linked into PyTorch, and exposed to Python. The assertions are changed to use AT_ASSERT instead of Gtest asserts. This structure was already how it was, I didn't really change anything here except that "catch-mode" changed to "gtest-mode"

Gtest doesn't get linked into Pytorch (not weird), it gets linked into the test binaries

@goldsborough goldsborough force-pushed the jit-tests branch 5 times, most recently from f856eb0 to 2e3ed19 Compare October 1, 2018 17:18
@goldsborough goldsborough force-pushed the jit-tests branch 3 times, most recently from f23d301 to ee230cf Compare October 4, 2018 21:38
Copy link
Contributor

@ezyang ezyang left a comment

Choose a reason for hiding this comment

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

Sure, why not.

It's pretty weird we need the Python-enabled version, but c'est la vie, I suppose.

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

goldsborough has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@goldsborough
Copy link
Contributor Author

@peterjc123 @yf225 do you know what I have to do here for Windows? I added the TORCH_API macro but it doesn't seem to apply ...

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

goldsborough is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Summary:
In our #better-engineering quest of removing all uses of catch in favor of gtest, this PR ports JIT tests to gtest. After pytorch#11846 lands, we will be able to delete catch.

I don't claim to use/write these tests much (though I wrote the custom operator tests) so please do scrutinize whether you will want to write tests in the way I propose. Basically:

1. One function declaration per "test case" in test/cpp/jit/test.h
2. One definition in test/cpp/jit/test.cpp
3. If you want to be able to run it in Python, add it to `runJitTests()` which is called from Python tests
4. If you want to be able to run it in C++, add a `JIT_TEST` line in test/cpp/jit/gtest.cpp

Notice also I was able to share support code between C++ frontend and JIT tests, which is healthy.

ezyang apaszke zdevito
Pull Request resolved: pytorch#12030

Differential Revision: D10207745

fbshipit-source-id: c1e7d55d05840943bb2f92aa207082e836009416
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

goldsborough is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@goldsborough goldsborough mentioned this pull request Oct 23, 2018
facebook-github-bot pushed a commit that referenced this pull request Oct 25, 2018
Summary:
Removes test_jit.cpp, which was supposed to have been deleted in #12030

I had to move zou3519's dynamic DAG tests into `test/cpp/jit/tests.h` too. No other changes to `test_jit.cpp` seem to have happened in the meantime.

zdevito
Pull Request resolved: #12988

Differential Revision: D10854320

Pulled By: goldsborough

fbshipit-source-id: 7ab533e6e494e34a16ce39bbe62b1150e48fcb58
@ezyang ezyang added the merged label Jun 26, 2019
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