pytorch/test/cpp/tensorexpr
Richard Barnes ee44d73e59 Modernize override (#61744)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/61744

Test Plan: Sandcastle

Reviewed By: malfet

Differential Revision: D29717320

fbshipit-source-id: 6eea4295ee2e5572ab337620be412376fcc2f3cc
2021-07-23 23:04:46 -07:00
..
CMakeLists.txt [pytorch][nnc] external function call to xnnpack ops (#59525) 2021-06-22 21:29:31 -07:00
gtest_assert_float_eq.h
padded_buffer.cpp
padded_buffer.h Reland: [TensorExpr] Add CodeGen::call_raw method. (#57551) 2021-05-05 09:10:25 -07:00
README.md
test_approx.cpp [nnc] Modified vectorize API to return bool (#59422) 2021-06-11 12:02:19 -07:00
test_aten.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_base.h
test_boundsinference.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_conv.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_cpp_codegen.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_cuda.cpp [nnc] Removed setGPUBlockIndex and setGPUThreadIndex methods from LoopNest (#59495) 2021-06-15 10:37:46 -07:00
test_expr.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_external_calls.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_graph_opt.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_ir_printer.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_ir_verifier.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_kernel.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_llvm.cpp [nnc] Get rid of fuser trigger counters (#57334) 2021-06-29 22:22:15 -07:00
test_loopnest.cpp Modernize override (#61744) 2021-07-23 23:04:46 -07:00
test_memdependency.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_ops.cpp Reland D29190420: [nnc][tests] Tests and benchmarks for computeSum (#60550) 2021-06-23 10:50:03 -07:00
test_reductions.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_registerizer.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_simplify.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_te_fuser_pass.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_train.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_train.h
test_train_impl.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_type.cpp Disable avoid-non-const-global-variables lint check (#62008) 2021-07-22 18:04:40 -07:00
test_utils.h [nnc] Refactored test macros and updated compress buffer tests to use them (#61716) 2021-07-15 21:17:14 -07:00
tutorial.cpp [NNC] Make splitWithTail transform in-place (#58268) 2021-05-25 11:31:14 -07:00

TensorExpr C++ Tests

How to add 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.

Here is an example test file you can copy-paste.

#include <test/cpp/tensorexpr/test_base.h>

// Tests go in torch::jit
namespace torch {
namespace jit {

// 1. Test cases are void() functions.
// 2. They start with the prefix `test`
void testCaseOne() {
    // ...
}

void testCaseTwo() {
    // ...
}
}
}

Then, register your test in tests.h:

// Add to TH_FORALL_TESTS_CUDA instead for CUDA-requiring tests
#define TH_FORALL_TESTS(_)             \
  _(ADFormulas)                        \
  _(Attributes)                        \
  ...
  _(CaseOne)  // note that the `test` prefix is omitted.
  _(CaseTwo)

We glob all the test files together in CMakeLists.txt so that you don't have to edit it every time you add a test. Unfortunately, this means that in order to get the build to pick up your new test file, you need to re-run cmake:

python setup.py build --cmake

How do I run the tests?

The following commands assume you are in PyTorch root.

# (re)build the test binary
ninja build/bin/test_tensorexpr
# run
build/bin/test_tensorexpr --gtest_filter='glob_style_filter*'