pytorch/test/cpp/tensorexpr
Hui Guo afe6b4c8ee [NNC] Add logical Operators '&&' and '||' (#56947)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/56947

Test Plan: Imported from OSS

Reviewed By: ZolotukhinM

Differential Revision: D28007342

Pulled By: huiguoo

fbshipit-source-id: a2ad8d2e99d7c8d8c8bdcd8f65fa3f340bdd2bbc
2021-05-01 18:44:27 -07:00
..
CMakeLists.txt [TensorExpr] Add IRVerifier. (#52901) 2021-03-01 20:38:00 -08:00
gtest_assert_float_eq.h
padded_buffer.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
padded_buffer.h [TensorExpr] Add CodeGen::call_raw method. (#55113) 2021-04-30 15:24:37 -07:00
README.md
test_approx.cpp [nnc] Allow 1 ulp tolerance in log approximation (#52165) 2021-02-16 16:49:36 -08:00
test_aten.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_base.h
test_boundsinference.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_conv.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_cpp_codegen.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_cuda.cpp [TensorExpr] Rename Tensor::call to Tensor::load to be consistent with Buf and Placeholder. (#55826) 2021-04-13 12:08:53 -07:00
test_expr.cpp [NNC] Add logical Operators '&&' and '||' (#56947) 2021-05-01 18:44:27 -07:00
test_external_calls.cpp [pytorch][nnc] update external functions for mobile build (#56850) 2021-04-30 19:07:19 -07:00
test_ir_printer.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_ir_verifier.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_kernel.cpp Revert D28110359: [TensorExpr] Add TensorExprKernel::runFast method. 2021-05-01 16:16:37 -07:00
test_llvm.cpp [TensorExpr] Add CodeGen::call_raw method. (#55113) 2021-04-30 15:24:37 -07:00
test_loopnest.cpp [NNC] Make flatten transform in-place (#56629) 2021-04-30 09:51:45 -07:00
test_memdependency.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_reductions.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_registerizer.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_simplify.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_te_fuser_pass.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_train.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_train.h
test_train_impl.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_type.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -07:00
test_utils.h
tutorial.cpp Make PyTorch code-base clang-tidy compliant (#56892) 2021-04-28 14:10:25 -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*'