pytorch/test/cpp/jit
Thomas Viehmann 3ab88c3903 Enable TorchBind tests on ROCm (#45426)
Summary:
The torchbind tests didn't work be cause somehow we missed the rename of caffe2_gpu to torch_... (hip for us) in https://github.com/pytorch/pytorch/issues/20774 (merged 2019-06-13, oops) and still tried to link against it.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/45426

Reviewed By: VitalyFedyunin

Differential Revision: D24112439

Pulled By: walterddr

fbshipit-source-id: a66a574e63714728183399c543d2dafbd6c028f7
2020-10-05 09:38:12 -07:00
..
__init__.py
CMakeLists.txt Enable TorchBind tests on ROCm (#45426) 2020-10-05 09:38:12 -07:00
README.md port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_alias_analysis.cpp
test_argument_spec.cpp
test_autodiff.cpp
test_backend.cpp
test_class_import.cpp
test_class_parser.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_class_type.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_cleanup_passes.cpp
test_code_template.cpp
test_constant_pooling.cpp
test_create_autodiff_subgraphs.cpp
test_custom_class.cpp
test_custom_class_registrations.cpp
test_custom_class_registrations.h
test_custom_operators.cpp
test_dce.cpp
test_fuser.cpp
test_gpu.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_graph_executor.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_inliner.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_interface.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_interpreter.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_ir.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_irparser.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_jit_type.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_lite_interpreter.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_lite_trainer.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_memory_dag.cpp
test_misc.cpp Source code level attribution in profiler (#43898) 2020-09-30 00:57:35 -07:00
test_mobile_type_parser.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_module_api.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_peephole_optimize.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_qualified_name.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_save_load.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_schema_matching.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_subgraph_matcher.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_subgraph_rewriter.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_subgraph_utils.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_utils.cpp port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
test_utils.h port all JIT tests to gtest (#45264) 2020-09-25 11:37:43 -07:00
tests_setup.py
torch_python_test.cpp

JIT C++ Tests

Adding a new test

First, create a new test file. Test files should have be placed in this directory, with a name that starts with test_, like test_foo.cpp.

In general a single test suite

Add your test file to the JIT_TEST_SRCS list in test/cpp/jit/CMakeLists.txt.

A test file may look like:

#include <gtest/gtest.h>

using namespace ::torch::jit

TEST(FooTest, BarBaz) {
   // ...
}

// Append '_CUDA' to the test case name will automatically filter it out if CUDA
// is not compiled.
TEST(FooTest, NeedsAGpu_CUDA) {
   // ...
}

// Similarly, if only one GPU is detected, tests with `_MultiCUDA` at the end
// will not be run.
TEST(FooTest, NeedsMultipleGpus_MultiCUDA) {
   // ...
}

Building and running the tests

The following commands assume you are in PyTorch root.

# ... Build PyTorch from source, e.g.
python setup.py develop
# (re)build just the binary
ninja -C build bin/test_jit
# run tests
build/bin/test_jit --gtest_filter='glob_style_filter*'