pytorch/test/cpp/tensorexpr
Mikhail Zolotukhin d66520ba08 [TensorExpr] Fuser: try merging adjacent fusion groups. (#43671)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/43671

Test Plan: Imported from OSS

Reviewed By: eellison

Differential Revision: D23360796

Pulled By: ZolotukhinM

fbshipit-source-id: 60ec318fe77ae9f2c821d9c4d106281845266e0f
2020-09-15 21:31:02 -07:00
..
__init__.py
CMakeLists.txt
gtest.cpp
gtest_assert_float_eq.h
padded_buffer.cpp
padded_buffer.h
README.md
test_aten.cpp [JIT] Remove references to no longer generated _tanh_backward and _sigmoid_backward (#44138) 2020-09-05 01:41:36 -07:00
test_base.h
test_boundsinference.cpp Simplify nested Min and Max patterns. (#44142) 2020-09-14 13:24:46 -07:00
test_cuda.cpp [NNC] Cuda Codegen - mask loops bound to block/thread dimensions (#44325) 2020-09-11 16:48:16 -07:00
test_expr.cpp [NNC] Remove VarBinding and go back to Let stmts (#42634) 2020-08-07 10:50:38 -07:00
test_ir_printer.cpp
test_kernel.cpp [TensorExpr] Check statements in test_kernel.cpp (#43911) 2020-08-31 22:16:25 -07:00
test_llvm.cpp Fix NaN propagation in TE fuser's min/max implementation (#43609) 2020-09-01 02:10:13 -07:00
test_loopnest.cpp [NNC] make inlining immediate (take 3) (#44231) 2020-09-15 11:12:24 -07:00
test_reductions.cpp [NNC] make inlining immediate (take 3) (#44231) 2020-09-15 11:12:24 -07:00
test_registerizer.cpp [NNC] Don't attempt to refactor conditional scalars (#44223) 2020-09-11 04:22:16 -07:00
test_simplify.cpp [NNC] make inlining immediate (take 3) (#44231) 2020-09-15 11:12:24 -07:00
test_te_fuser_pass.cpp [TensorExpr] Fuser: try merging adjacent fusion groups. (#43671) 2020-09-15 21:31:02 -07:00
test_train.cpp [Codemod][GleanFbcode] Remove dead includes in caffe2/test (#43953) 2020-09-01 21:48:28 -07:00
test_train.h [tensorexpr] Autograd for testing (#42548) 2020-08-13 07:58:06 -07:00
test_train_impl.cpp [tensorexpr] Autograd for testing (#42548) 2020-08-13 07:58:06 -07:00
test_type.cpp
test_utils.h
tests.h [TensorExpr] Fuser: try merging adjacent fusion groups. (#43671) 2020-09-15 21:31:02 -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*'