pytorch/test/cpp/jit
Nikita Shulga 3036a0309d [skip ci]Revert "Add comments for adding shape function and linting"
This is a technical revert of 6d36bbde7e to reconcile it with e50478c02592597f12b8490ec5496f76c7d8b8cc (which is the same + lint changes applied)

Should be skipped during import
2022-03-30 21:21:28 -07:00
..
upgrader_models [Operator Versioning][Edge] Add old models and unittest (#67726) 2021-12-01 18:46:30 -08:00
__init__.py
CMakeLists.txt [PyTorchEdge] Add getFileFormat() so we can differentiate Zip/Pickle from Flatbuffer (#73707) 2022-03-04 19:35:41 +00:00
README.md
script_module_v4.ptl
script_module_v5.ptl
script_module_v6.ptl
test_add_if_then_else.cpp [JIT][SR] Introduce prim::IfThenElse (#72587) 2022-02-17 18:22:48 +00:00
test_alias_analysis.cpp Codegen: python_torch_functions only include relevant operators (#68693) 2022-01-21 15:37:06 +00:00
test_argument_spec.cpp [jit] Remove graph() call from abstract Function interface. (#65967) 2021-10-27 11:54:26 -07:00
test_autodiff.cpp Clean up profiling mode and profiling executor strategy (#73875) 2022-03-29 18:38:51 +00:00
test_backend_compiler_lib.cpp [Pytorch Edge] Lean Runtime Test 2022-02-24 18:40:47 +00:00
test_backend_compiler_preprocess.cpp [jit] Remove graph() call from abstract Function interface. (#65967) 2021-10-27 11:54:26 -07:00
test_backend_lib.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_backend.cpp Revert D34455360: Multisect successfully blamed D34455360 for test failures 2022-03-08 23:18:54 +00:00
test_class_import.cpp Add SourceView which doesn't own source text as base class of Source (#65309) 2021-10-18 23:17:22 -07:00
test_class_parser.cpp Add SourceView which doesn't own source text as base class of Source (#65309) 2021-10-18 23:17:22 -07:00
test_class_type.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_cleanup_passes.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_code_template.cpp [AutoAccept][Codemod][FBSourceClangFormatLinter] Daily arc lint --take CLANGFORMAT 2022-01-14 06:10:57 -08:00
test_concat_opt.cpp [JIT] Combine concat nodes where possible (#67000) 2021-11-15 12:02:45 -08:00
test_constant_pooling.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_create_autodiff_subgraphs.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_cs_debug_info_serialization.cpp
test_custom_class_registrations.cpp
test_custom_class_registrations.h
test_custom_class.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_custom_operators.cpp [jit] Reduce refcounting of Types (#65345) 2021-10-08 09:03:04 -07:00
test_dce.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_exception.cpp (2/2) Make TorchScript Preserve Fully Qualified Class Name for Python Exceptions: frontend change (#72899) 2022-02-16 03:45:15 +00:00
test_file_format.cpp [PyTorchEdge] Add getFileFormat() so we can differentiate Zip/Pickle from Flatbuffer (#73707) 2022-03-04 19:35:41 +00:00
test_flatbuffer.cpp Back out "Revert D34805092: Extend _save_for_mobile and _load_for_mobile to support flatbuffer format; Default format is pickle + Change buck targets to support only pickle and pickle + flatbuffer for migration" (#74594) 2022-03-24 21:51:05 +00:00
test_fuser.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_gpu_shift.cpp Nvfuser code bump 2_1_2022 (#72127) 2022-02-15 00:43:16 +00:00
test_gpu_validator.h Nvfuser code bump 2_1_2022 (#72127) 2022-02-15 00:43:16 +00:00
test_gpu.cpp Nvfuser code bump 2_1_2022 (#72127) 2022-02-15 00:43:16 +00:00
test_graph_executor.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_graph_iterator.cpp [jit] Rewrote DFS graph iterator to remove unnecessary local state (#61326) (#61980) 2021-07-27 11:50:20 -07:00
test_inliner.cpp [jit] Remove graph() call from abstract Function interface. (#65967) 2021-10-27 11:54:26 -07:00
test_interface.cpp Add SourceView which doesn't own source text as base class of Source (#65309) 2021-10-18 23:17:22 -07:00
test_interpreter_async.pt
test_interpreter.cpp [PyTorch Edge] Backport function for defaults args with out args, flag on (#63651) 2021-09-20 22:50:30 -07:00
test_ir.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_irparser.cpp [jit] Reduce refcounting of Types (#65345) 2021-10-08 09:03:04 -07:00
test_jit_logging_levels.cpp Added jit log stream changing function and some refactor (#65768) 2021-09-30 23:25:11 -07:00
test_jit_type.cpp [jit] Reduce refcounting of Types (#65345) 2021-10-08 09:03:04 -07:00
test_lite_interpreter_direct.cpp [Pytorch Edge] Refactor Compatibility Stuff into own directory (#71432) 2022-01-20 19:38:41 +00:00
test_lite_interpreter.cpp Back out "Revert D34805092: Extend _save_for_mobile and _load_for_mobile to support flatbuffer format; Default format is pickle + Change buck targets to support only pickle and pickle + flatbuffer for migration" (#74594) 2022-03-24 21:51:05 +00:00
test_lite_trainer.cpp [PyTorchEdge] Make _load_parameters() handle flatbuffer inputs (#74580) 2022-03-30 20:39:58 +00:00
test_load_upgraders.cpp Bump version number to 7 and compile old operators with old schema (#68358) 2022-01-05 23:57:22 -08:00
test_memory_dag.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_misc.cpp [skip ci]Revert "Add comments for adding shape function and linting" 2022-03-30 21:21:28 -07:00
test_mobile_type_parser.cpp [jit][edge] Migrate base types to DynamicType on mobile. (#70233) 2022-01-11 13:53:29 -08:00
test_module_api.cpp Fix bug where frozen mod not used for OFI #68903 (#71436) 2022-01-27 23:37:50 +00:00
test_op_replacement.cpp Add graph op replacement pass (#69915) 2021-12-25 13:03:19 -08:00
test_peephole_optimize.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_qualified_name.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_save_load.cpp Create method to map JIT module to (source, constant) and back. (#74119) 2022-03-15 18:30:08 +00:00
test_schema_matching.cpp [jit] Make operation call accept Stack& instead Stack* (#63414) 2021-08-30 11:49:20 -07:00
test_script_profile.cpp
test_shape_analysis.cpp Add support for permutting dynamic fusion group outputs to channels last format (#70656) 2022-01-12 09:11:34 -08:00
test_stack_opt.cpp [JIT] Add variadic stack op (#63578) 2021-08-24 08:20:54 -07:00
test_subgraph_matcher.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_subgraph_rewriter.cpp keep output type after calling SubgraphRewriter (#65453) 2021-09-24 11:07:40 -07:00
test_subgraph_utils.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_union.cpp [jit] Reduce refcounting of Types (#65345) 2021-10-08 09:03:04 -07:00
test_upgrader_utils.cpp Add option to load historic operators in IR when the operator is deprecated (#71148) 2022-01-12 11:07:04 -08:00
test_utils.cpp [jit] Make operation call accept Stack& instead Stack* (#63414) 2021-08-30 11:49:20 -07:00
test_utils.h Revert D34455360: Multisect successfully blamed D34455360 for test failures 2022-03-08 23:18:54 +00:00
tests_setup.py Revert D30279364: [codemod][lint][fbcode/c*] Enable BLACK by default 2021-08-12 11:45:01 -07:00
torch_python_test.cpp Remove WindowsTorchApiMacro.h in favor of Export.h (#69585) 2021-12-09 17:30:09 -08:00

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*'