pytorch/test/cpp/tensorexpr
Bert Maher e4d19798f3 [nnc][tests] Convert a bunch of FileCheck to checkIR
Summary:
I added a helper to convert a Stmt to string and FileCheck it, so
started using it in a bunch of places.  I replaced about half the current uses,
got tired, started to write a Perl script to automate it, realized that was
hard, and decided to give up for a bit.  But this cleans up some of the tests a
bit, so seems easy to review and worth landing.

Test Plan: test_tensorexpr --gtest_filter=LoopNest.*

Reviewed By: navahgar

Differential Revision: D27375866

fbshipit-source-id: 15894b9089dec5cf25f340fe17e6e54546a64257
2021-03-26 20:27:50 -07:00
..
CMakeLists.txt [TensorExpr] Add IRVerifier. (#52901) 2021-03-01 20:38:00 -08:00
gtest_assert_float_eq.h [TensorExpr] Clang-format test/cpp/tensorexpr/*. (#36615) 2020-04-14 19:08:18 -07:00
padded_buffer.cpp [TensorExpr] fix warnings (#36167) 2020-04-08 15:42:29 -07:00
padded_buffer.h [pytorch][tensorexpr] Make gtest-style macros in tests match actual gtest signatures (#44861) 2020-09-19 07:25:05 -07:00
README.md [TensorExpr] Add a class for representing data type. (#33217) 2020-02-21 13:10:12 -08:00
test_approx.cpp [nnc] Allow 1 ulp tolerance in log approximation (#52165) 2021-02-16 16:49:36 -08:00
test_aten.cpp [nnc] Expose fast tanh/sigmoid (#50736) 2021-01-22 09:56:02 -08:00
test_base.h [pytorch][tensorexpr] Make gtest-style macros in tests match actual gtest signatures (#44861) 2020-09-19 07:25:05 -07:00
test_boundsinference.cpp [NNC] Implementing LoopFusion (#54461) 2021-03-23 21:20:00 -07:00
test_conv.cpp [codemod][fbcode/caffe2] Apply clang-format update fixes 2021-01-09 14:37:36 -08:00
test_cpp_codegen.cpp changed TE 'Allocate' API to take one argument 'Buf' instead of three arguments 'Var', 'dtype', 'dims'. (#50167) 2021-02-22 15:08:51 -08:00
test_cuda.cpp [TensorExpr] Add an unmasked Load constructor. (#52790) 2021-02-24 22:45:29 -08:00
test_expr.cpp [TensorExpr] Add IRVerifier. (#52901) 2021-03-01 20:38:00 -08:00
test_external_calls.cpp [TensorExpr] Add plumbing for conv2d fusion. (#54439) 2021-03-24 18:49:07 -07:00
test_ir_printer.cpp [tensorexpr] Switch cpp tests to pure gtest (#48160) 2020-11-18 12:23:34 -08:00
test_ir_verifier.cpp [TensorExpr] IRVerifier: add index verifier for Store. (#53137) 2021-03-02 19:56:28 -08:00
test_kernel.cpp [NNC] Implementation for aten::cat without conditionals. (#53128) 2021-03-07 22:57:02 -08:00
test_llvm.cpp Resubmit: Adding parallel support for the LLVM backend. (#54122) 2021-03-18 07:19:37 -07:00
test_loopnest.cpp [nnc][tests] Convert a bunch of FileCheck to checkIR 2021-03-26 20:27:50 -07:00
test_memdependency.cpp [codemod][fbcode/caffe2] Apply clang-format update fixes 2021-01-09 14:37:36 -08:00
test_reductions.cpp [nnc] Add an initialization expression to Reduce() (#53751) 2021-03-10 17:13:14 -08:00
test_registerizer.cpp [TensorExpr] Add an unmasked Load constructor. (#52790) 2021-02-24 22:45:29 -08:00
test_simplify.cpp [nnc] Tests for proposed feature: loop bounds conditional simplification (#54121) 2021-03-17 11:01:10 -07:00
test_te_fuser_pass.cpp [tensorexpr] Switch cpp tests to pure gtest (#48160) 2020-11-18 12:23:34 -08:00
test_train_impl.cpp [codemod][fbcode/caffe2] Apply clang-format update fixes 2021-01-09 14:37:36 -08:00
test_train.cpp [codemod][fbcode/caffe2] Apply clang-format update fixes 2021-01-09 14:37:36 -08:00
test_train.h [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -07:00
test_type.cpp [te] Add BitCast to the IR (#49184) 2020-12-11 16:12:20 -08:00
test_utils.h [TensorExpr] Add a class for representing data type. (#33217) 2020-02-21 13:10:12 -08:00
tutorial.cpp [TensorExpr] Add an unmasked Load constructor. (#52790) 2021-02-24 22:45:29 -08: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*'