pytorch/test/cpp/tensorexpr
Mikhail Zolotukhin b86008ab75 [TensorExpr] Remove buf_ field from class Tensor. (#45390)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/45390

Tensor objects should always refer to their Function's bufs. Currently
we never create a Tensor with a buffer different than of its function,
but having it in two places seems incorrect and dangerous.

Differential Revision: D23952865

Test Plan: Imported from OSS

Reviewed By: nickgg

Pulled By: ZolotukhinM

fbshipit-source-id: e63fc26d7078427514649d9ce973b74ea635a94a
2020-09-29 01:21:57 -07:00
..
__init__.py remediation of S205607 2020-07-17 17:19:47 -07:00
CMakeLists.txt [jit] Pull (most) tests out of libtorch_python (#44795) 2020-09-18 14:04:40 -07:00
gtest_assert_float_eq.h [TensorExpr] Clang-format test/cpp/tensorexpr/*. (#36615) 2020-04-14 19:08:18 -07:00
gtest.cpp [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
test_aten.cpp [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -07: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 [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -07:00
test_cuda.cpp [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -07:00
test_expr.cpp [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -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] Consolidate {buffer,function,tensor}.{h.cpp} in tensor.{h,cpp}. (#45388) 2020-09-29 01:17:10 -07:00
test_llvm.cpp [TensorExpr] Remove buf_ field from class Tensor. (#45390) 2020-09-29 01:21:57 -07:00
test_loopnest.cpp [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -07:00
test_reductions.cpp [TensorExpr] Remove buf_ field from class Tensor. (#45390) 2020-09-29 01:21:57 -07:00
test_registerizer.cpp [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -07:00
test_simplify.cpp [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -07:00
test_te_fuser_pass.cpp [tensorexpr] Add flag to fuse with unknown shapes (#44401) 2020-09-22 18:17:47 -07:00
test_train_impl.cpp [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -07:00
test_train.cpp [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -07:00
test_train.h [TensorExpr] Rename Buffer to Placeholder. (#45389) 2020-09-29 01:21:54 -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 [NNC] fix Half conversion of immediates in Cuda backend (#45213) 2020-09-25 10:53:36 -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*'