pytorch/test/cpp/tensorexpr
Raghavan Raman 4b859cbca1 [NNC] Do not optimize conditionals when the corresponding loop is not normalized (#57675)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/57675

Test Plan: Imported from OSS

Reviewed By: bertmaher

Differential Revision: D28231375

Pulled By: navahgar

fbshipit-source-id: bcbcebca25577744c7190a0aa9fa376f76dea77d
2021-05-18 14:25:53 -07:00
..
CMakeLists.txt
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 Reland: [TensorExpr] Add CodeGen::call_raw method. (#57551) 2021-05-05 09:10:25 -07:00
README.md
test_approx.cpp
test_aten.cpp [clang-tidy] Exclude cppcoreguidelines-avoid-magic-numbers (#57841) 2021-05-07 20:02:33 -07:00
test_base.h
test_boundsinference.cpp [AutoAccept][Codemod][FBSourceClangFormatLinter] Daily arc lint --take CLANGFORMAT 2021-05-10 03:39:31 -07:00
test_conv.cpp [clang-tidy] Exclude cppcoreguidelines-avoid-magic-numbers (#57841) 2021-05-07 20:02:33 -07:00
test_cpp_codegen.cpp [AutoAccept][Codemod][FBSourceClangFormatLinter] Daily arc lint --take CLANGFORMAT 2021-05-10 03:39:31 -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 [clang-tidy] Exclude cppcoreguidelines-avoid-magic-numbers (#57841) 2021-05-07 20:02:33 -07:00
test_external_calls.cpp [AutoAccept][Codemod][FBSourceClangFormatLinter] Daily arc lint --take CLANGFORMAT 2021-05-10 03:39:31 -07:00
test_ir_printer.cpp [clang-tidy] Exclude cppcoreguidelines-avoid-magic-numbers (#57841) 2021-05-07 20:02:33 -07:00
test_ir_verifier.cpp [clang-tidy] Exclude cppcoreguidelines-avoid-magic-numbers (#57841) 2021-05-07 20:02:33 -07:00
test_kernel.cpp [NNC] Optimize conditionals that correspond to the form generated for aten::cat op. (#57673) 2021-05-18 14:23:48 -07:00
test_llvm.cpp [TensorExpr] Implement 'call_raw' in IREval. (#57882) 2021-05-12 14:08:18 -07:00
test_loopnest.cpp [NNC] Do not optimize conditionals when the corresponding loop is not normalized (#57675) 2021-05-18 14:25:53 -07:00
test_memdependency.cpp [AutoAccept][Codemod][FBSourceClangFormatLinter] Daily arc lint --take CLANGFORMAT 2021-05-10 03:39:31 -07:00
test_reductions.cpp [clang-tidy] Exclude cppcoreguidelines-avoid-magic-numbers (#57841) 2021-05-07 20:02:33 -07:00
test_registerizer.cpp [AutoAccept][Codemod][FBSourceClangFormatLinter] Daily arc lint --take CLANGFORMAT 2021-05-10 03:39:31 -07:00
test_simplify.cpp [NNC] Fixing a bug in simplifier (#58291) 2021-05-18 01:28:33 -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 [clang-tidy] Exclude cppcoreguidelines-avoid-magic-numbers (#57841) 2021-05-07 20:02:33 -07:00
test_train.h
test_train_impl.cpp [clang-tidy] Exclude cppcoreguidelines-avoid-magic-numbers (#57841) 2021-05-07 20:02:33 -07:00
test_type.cpp [clang-tidy] Exclude cppcoreguidelines-avoid-magic-numbers (#57841) 2021-05-07 20:02:33 -07:00
test_utils.h
tutorial.cpp [AutoAccept][Codemod][FBSourceClangFormatLinter] Daily arc lint --take CLANGFORMAT 2021-05-10 03:39:31 -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*'