pytorch/test/cpp/tensorexpr
Mikhail Zolotukhin bd8e38cd88 [TensorExpr] Fuser: check node inputs' device before merging the node into a fusion group. (#44241)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/44241

Test Plan: Imported from OSS

Reviewed By: gmagogsfm

Differential Revision: D23554192

Pulled By: ZolotukhinM

fbshipit-source-id: fb03262520303152b83671603e08e7aecc24f5f2
2020-09-08 19:32:23 -07:00
..
__init__.py remediation of S205607 2020-07-17 17:19:47 -07:00
CMakeLists.txt
gtest.cpp [TensorExpr] Clang-format test/cpp/tensorexpr/*. (#36615) 2020-04-14 19:08:18 -07:00
gtest_assert_float_eq.h [TensorExpr] Clang-format test/cpp/tensorexpr/*. (#36615) 2020-04-14 19:08:18 -07:00
padded_buffer.cpp
padded_buffer.h Add trivial reduce for Cuda (#36293) 2020-04-15 13:03:58 -07:00
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 [Codemod][GleanFbcode] Remove dead includes in caffe2/test (#43953) 2020-09-01 21:48:28 -07:00
test_cuda.cpp [NNC] fix support for FP16 in CudaCodgen (#44209) 2020-09-08 18:00:39 -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 [TensorExpr] Fix IRPrinter for function calls with uniqued names (#39753) 2020-06-11 12:13:28 -07:00
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 Revert D23503636: [pytorch][PR] [NNC] make inlining immediate (take 2) and fix bugs 2020-09-04 10:58:23 -07:00
test_reductions.cpp Revert D23503636: [pytorch][PR] [NNC] make inlining immediate (take 2) and fix bugs 2020-09-04 10:58:23 -07:00
test_registerizer.cpp [NNC] Hook up registerizer to Cuda codegen [2/x] (#42878) 2020-08-31 10:39:46 -07:00
test_simplify.cpp Revert D23503636: [pytorch][PR] [NNC] make inlining immediate (take 2) and fix bugs 2020-09-04 10:58:23 -07:00
test_te_fuser_pass.cpp [TensorExpr] Fuser: check node inputs' device before merging the node into a fusion group. (#44241) 2020-09-08 19:32:23 -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 [TensorExpr] remove Let and LetStmt in favour of binding in Block (#37606) 2020-05-09 16:23:37 -07:00
test_utils.h
tests.h [TensorExpr] Fuser: check node inputs' device before merging the node into a fusion group. (#44241) 2020-09-08 19:32:23 -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*'