Files
pytorch/test/cpp/jit/torch_python_test.cpp
davidriazati 3c07eb33bb Better error for torch::jit::loading a eager file (#31709)
Summary:
This adds a check to catch the case where someone `torch.save`s something then `torch::jit::load`s it in C++.

Relevant for #31620
](https://our.intern.facebook.com/intern/diff/19252172/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/31709

Pulled By: driazati

Differential Revision: D19252172

fbshipit-source-id: f2a9b4442647285418b2778306629b4ff77c15e5
2020-01-07 16:20:42 -08:00

30 lines
775 B
C++

#include <test/cpp/jit/tests.h>
#include <c10/util/Exception.h>
namespace torch {
namespace jit {
#if defined(_WIN32)
void runJITCPPTests(bool runCuda) {
TORCH_INTERNAL_ASSERT(false, "JIT tests not yet supported on Windows");
}
#else
#define JIT_TEST(name) test##name();
TORCH_API void runJITCPPTests(bool runCuda) {
TH_FORALL_TESTS(JIT_TEST)
if (runCuda) {
TH_FORALL_TESTS_CUDA(JIT_TEST)
}
// This test is special since it requires prior setup in python.
// So it is not part of the general test list (which is shared between the gtest
// and python test runners), but is instead invoked manually by the
// torch_python_test.cpp
testEvalModeForLoadedModule();
testTorchSaveError();
}
#undef JIT_TEST
#endif
} // namespace jit
} // namespace torch