Skip to content

Commit

Permalink
A skeleton implmentation for the expression, IR and visitor dispatche…
Browse files Browse the repository at this point in the history
…rs. (pytorch#33)

To run the test: cmake . && make cpptest && ./expr_test

Refactor the RefHandle class. (pytorch#34)

Add convenience operator for Expr.

clang-format change (pytorch#35)

Adding Var, Let and eval_context support. (pytorch#36)

Add LLVM JIT class for online codegen

Refactor llvm codegen

fix caps of LlvmJit

Generate code for integer arithmetic

Test all arithmetic ops with LLVM

Fix rtti

Compat with llvm 7 and 8

Add support for tensor expressions. (pytorch#38)

Add Casting support so mixed dtypes are supported.
Add basic dtype and logging support. This should be merged with PyTorch during integration.

clang-format fix (pytorch#39)

Extend dtypes to support vector types (pytorch#40)

Support LLVM 9 too

Disambigate dependent type name with template keyword

Remove empty scalar.h

Add basic support for statements. (pytorch#41)

Add support for For, Ramp, Block, Load, Store and Broadcast.
Add support for Buffer.

Adding Stmt evaluation support. (pytorch#42)

Use third_party/googletest from pytorch

Remove nnc/tests/googletest submodule

Move nnc tld to torch/csrc/jit/compiler

Add a README (probably temporary) for jit/compiler

Move from namespace nnc to torch::jit::compiler

Refactor JIT class to isolate no-rtti pieces

Adding comparison operator to Var. (pytorch#43)

Fix typo in README.md

Use absolute imports and pragma once

Use absolute includes in new llvm_jit.h

Build non-LLVM compiler stuff with libtorch

Minimal asmjit codegen from the tensor IR

fix pessimizing moves

IR printer

fix printer bug

Add printer to build system.

Add data structure for schedule support and Split.

clang-format using the new template

Add IRMutator and basic support to substitude Var in Expr and Stmts.

Change the default count of RefCounted as zero.
Merge Expr(node) and Expr::make(node).

Add basic lowering to the tensor expression trees.

fix the schedule_test

fixed lowering

LLVM code generation for simple loops

bugfixes

refcount fixing self-assignment

Make LOG(FATAL) nonreturn
Enable Werror

Adding statement conversion for SplitWithTail

Add a reference tests for Split

clang-format

A functinoal reference chck for schedule tests.

clang-format

Add support for Float immediates.

Get absolute path for ASMJIT_DIR (pytorch#24)

Silence deprecation warnings from LLVM

Include legacy PassManager for debug printing

Set code model to medium to avoid indirect jumps in generated asm

Fix argument type of input float buffers

Add support for Casts in LLVM codegen.

Add a complete tensor+lower+llvm test

Enable the failing test

Enable export of compile_commands.json.

Floating point arithmetic

Test fp32 mul using compute expr

Broadcast add test using compute expr

Update to LLVM 9

Implementation of Broadcast for LLVM.

Add Buffer operator() overload, and some other minor features

Cleanup use of ConstantInt API.

fix accidental experimental changes

Change the Compute interface to bring the dim sizes and names together

clang-format

refactor Buffer into its own files

Add support for vector casts in LLVM CodeGen

Implement masked loads and stores.

Implement vector masked loads and stores.

Add a PaddedBuffer test util

Improve the user interface for SimpleIREvaluator

Add a test for Block codegen.

Fix gtest include path

clang-format

Add expressions and support for Max and Min. (pytorch#5)

Rename compiler to tensorexpr and move files around to be more similar to other pytorch parts. (pytorch#6)

Summary:

1. Move compiler to tensorexpr folder
2. Move files from src and include to the same folder (and remove src and include folders)
3. Rename .cc to .cpp

Add missing include <math.h> (pytorch#7)

Change isnan to std::isnan. It breaks my clang builds. (pytorch#8)

Change the SimpleIREvaluator frontend (pytorch#9)

Add RefHandle for subclass

Make LLVM dependency optional. (pytorch#10)

[wip] Basic fuser pass to select texpr subgraphs

Revert "[wip] Basic fuser pass to select texpr subgraphs"

This reverts commit a9d9919.

Revert changes to the main pytorch CMakeLists.txt (for now).

Add a test for aten::_cast_Float lowering. (pytorch#12)

Hook tensorexp up to the main build, and switch to c10 logging

More ATen op tests. (pytorch#16)

Fix some missing returns

Include tests back to the 'all' target. (pytorch#14)

Even more ATen op tests. (pytorch#18)

Test for relu ATen op. (pytorch#19)

Add intrinsics function support. (pytorch#20)

Remove fmax/fmin, as they are already covered by the Max/Min operators (pytorch#21)

refactor CallNode and BaseCallNode, so we can have a common concrete base class for visitors. (pytorch#22)

This is the first step to add other call types.

Add FunctionCall to use existing tensors (pytorch#23)

Add the ability to use an existing tensor expression in other compute functions. (pytorch#24)

fixing broken compilation on mac/clang

adding IRnode for Compare-Select Ops and their LLVM Codegen

Fix Werror. (pytorch#26)

Add tests for some transcendental ops. (pytorch#27)

Add Allocate and Free support. (pytorch#29)

Add Eval and test basic alloc support.
Add Lowering support for buffer allocation for intermediate tensors.

Tensor expr fuser pass for extremely simple expressions

Make fusion work for arbitrary buffer/tensor combinations of inputs (pytorch#30)

fix Let02 test

Access inputs and intermediates uniformly through Tensors (pytorch#31)

fix Let02 test (pytorch#32)

adding LLVM Codegen for Let

modifying CMakeLists.txt to enable ninja test && minor update for LLVM Codegen for Let (handling XQ's comment)

Adding ComputeInline support. (pytorch#35)

Fix broken tests (pytorch#36)

Make tx fuser work with arbitrary ranks

[fuser] Broadcast args

Improve naming of arg broadcasting function

Test cases for tensorexpr fusion (pytorch#37)

CompareSelct Op: Addressing XQ and Owen's comments

modifying CMakeLists.txt to enable ninja test && minor update for LLVM Codegen for Let (handling XQ's comment)

CompareSelct Op: Addressing XQ and Owen's comments

Sketch sufficient support for constants to get constant alpha working. (pytorch#40)

* Refactor to use a switch statement over Node kinds.

* Sketch sufficient support for constants to get constant alpha working.

Fix indices when inlining non-leaf calls (pytorch#39)

Fixing the inline ordering issue (pytorch#43)

Solve more problems with the inliner

Avoid creating redundant and/or improperly ordered Constant's in fused subgraphs. (pytorch#42)

Move fuser-styled tests to schedule_test (pytorch#44)

Add aten::sub to the new fuser. (pytorch#46)

Refactor CodeGen from SimpleIREval (pytorch#47)

Inline all the things (pytorch#45)

clang-format for atent_test.cpp

Eliminate a ton of warnings for my own sanity. (pytorch#48)

Add support for type promotion/demotion. (pytorch#50)

Flesh out new fuser coverage to several more ops. (pytorch#51)

Adding the first basic CudaCodeGen. (pytorch#52)

aten tests for eq, ge, gt, le, lt

support for aten ops: eq

support for more  aten ops: ge, gt, le, lt, ne

Minimal CMake change to link LLVM to libtorch

Fix issues causing assertion failures in llvm debug builds

Fatal on unimplement llvm codegen ops (Allocate, etc.)

Optionally compile tx fuser kernels with llvm

Test for 2D broadcasted with large dims to show vectorization

Updated isSupported for increased op coverage. (pytorch#54)

Refactor LLVMCodeGen to compile kernel in constructor

Cmake integration to PT codebase (pytorch#28)

With this change our code blends with the usual PyTorch code and is built the usual way. I added a cmake option to specify where to look for LLVM, if it's not specified, LLVM is not used.

An example of invocation (from the root of pytorch repo):

```
USE_LLVM=/path/to/llvm9/install  python setup.py develop
```

This command will build libtorch.{a,so} and other libraries, and tensorexpr code will be a part of it.

The tests will be built in build/bin/test_tensorexpr (I've ported only one test so far). So, invocation of the tests will be:

```
build/bin/test_tensorexpr
```

Remove old padded_buffer.{cpp,h}. (pytorch#56)

Add support for code generation of Log10 intrinsics with LLVM. (pytorch#57)

Remove tests/test_utils.h: inline what's still used and nuke what's unused. (pytorch#58)

Move Fuser tests (tests/tests.py) to test/test_tensorexpr.py. (pytorch#59)

Remove old CMakeLists and README.txt

Add support for vectorized and unmasked loads and stores with LLVM. (pytorch#62)

Enable CodeGen-level optimizations in LLVM. (pytorch#63)

Add Bind/GPUBlock/GPUThread support. (pytorch#64)

Bind/run interface to CodeGen (pytorch#60)

* Bind/run interface to CodeGen

* Make LLVMCodeGen implement CodeGen interface

* Allow bind/run to be unimplemented for the moment (CUDA)

* Cache compilation result

* Two nasty bugs: forgot virtual dtor, forgot to clear bindings after run()

Fix ambiguity in CreateExtractElementCall (0ull can be a Value*, I guess?) (pytorch#65)

Allow constants as lhs/rhs args (not just alpha) (pytorch#66)

Use correct tensor type for fuser output (pytorch#67)

clang-format

Rename 'compiler' namespace to 'tensorexpr'.

Include all built llvm targets (pytorch#68)

Switch back to linking only the native LLVM target. (pytorch#69)

Virtual dtors for IRVisitor/IRMutator (pytorch#70)

Add semicolon to make nvcc compile (pytorch#71)

Enable NVRTC for the GPU backend. (pytorch#74)

Fix non-CUDA testing. (pytorch#75)

Getting fused (a)Sin(h), (a)Cos(h),(a) Tan(h), abs working with the interpreter (pytorch#73)

* Getting fused (a)Sin(h), (a)Cos(h),(a) Tan(h), abs working with the interpreter

* take the interpreter path only when ENABLE_LLVM is not set

remove the leak tests, as we will get rid of refcounting (pytorch#76)

Implement aten::min, max, and clamp (pytorch#72)

* Implement aten::min, max, and clamp

* Propagate NaNs like std::max/min

* Change NaN propagation in interpreter too

clang-format tensorexpr/tests.h (pytorch#77)

Refactor UniqueNameManager into its own files. (pytorch#79)

refactor cuda_codegen (pytorch#80)

simplify nvrtc major, minor versions (pytorch#81)

Allow CodeGen to take Var args (interpreter support only) (pytorch#78)

* Test demonstrating dynamic shape

* Allow binding of Vars to args in interpreter

* Pass BufferArgs to LLVMCodeGen

* clang-format-diff

[LLVMCodeGen] Refactor kernel constructor to be less sprawling (pytorch#82)

* Member TM to TM_ in LLVMCodeGen

* [LLVMCodeGen] Add helper for getContext

* [LLVMCodeGen] Refactor type support

* [LLVMCodeGen] Refactor kernel emission
  • Loading branch information
zheng-xq authored and lly-zero-one committed Feb 8, 2020
1 parent 61a2b34 commit 6e2e7d4
Show file tree
Hide file tree
Showing 56 changed files with 11,599 additions and 1 deletion.
42 changes: 41 additions & 1 deletion caffe2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
${TORCH_SRC_DIR}/csrc/jit/passes/requires_grad_analysis.cpp
${TORCH_SRC_DIR}/csrc/jit/passes/specialize_autogradzero.cpp
${TORCH_SRC_DIR}/csrc/jit/passes/subgraph_rewrite.cpp
${TORCH_SRC_DIR}/csrc/jit/passes/tensorexpr_fuser.cpp
${TORCH_SRC_DIR}/csrc/jit/passes/python_print.cpp
${TORCH_SRC_DIR}/csrc/jit/passes/utils/subgraph_utils.cpp
${TORCH_SRC_DIR}/csrc/jit/passes/utils/check_alias_annotation.cpp
Expand Down Expand Up @@ -461,8 +462,38 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)
${TORCH_SRC_DIR}/csrc/jit/fuser/fallback.cpp
${TORCH_SRC_DIR}/csrc/jit/function.cpp
${TORCH_SRC_DIR}/csrc/jit/vararg_functions.cpp

${TORCH_SRC_DIR}/csrc/jit/tensorexpr/expr.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/function.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/ir.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/ir_visitor.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/asmjit_codegen.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/llvm_codegen.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/llvm_jit.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/types.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/ir_printer.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/ir_mutator.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/schedule.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/tensor.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/unique_name_manager.cpp
)

if (USE_LLVM)
message(STATUS "Looking for LLVM in ${USE_LLVM}")
find_package(LLVM QUIET PATHS ${USE_LLVM} NO_DEFAULT_PATH)

if (LLVM_FOUND)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")

include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(-DENABLE_LLVM ${LLVM_DEFINITIONS})
endif (LLVM_FOUND)
endif (USE_LLVM)

set_source_files_properties(${TORCH_SRC_DIR}/csrc/jit/tensorexpr/llvm_jit.cpp PROPERTIES COMPILE_FLAGS -fno-rtti)


if (NOT INTERN_BUILD_MOBILE)
set (MOBILE_SRCS
${TORCH_SRC_DIR}/csrc/jit/mobile/function.cpp
Expand Down Expand Up @@ -525,10 +556,11 @@ if (NOT INTERN_BUILD_MOBILE OR NOT BUILD_CAFFE2_MOBILE)

if (USE_CUDA)
list(APPEND Caffe2_GPU_SRCS
${TORCH_SRC_DIR}/csrc/jit/fuser/cuda/fused_kernel.cpp
${TORCH_SRC_DIR}/csrc/autograd/profiler_cuda.cpp
${TORCH_SRC_DIR}/csrc/autograd/functions/comm.cpp
${TORCH_SRC_DIR}/csrc/cuda/comm.cpp
${TORCH_SRC_DIR}/csrc/jit/fuser/cuda/fused_kernel.cpp
${TORCH_SRC_DIR}/csrc/jit/tensorexpr/cuda_codegen.cpp
)
add_library(caffe2_nvrtc SHARED ${ATen_NVRTC_STUB_SRCS})
target_link_libraries(caffe2_nvrtc ${CUDA_NVRTC} ${CUDA_CUDA_LIB} ${CUDA_NVRTC_LIB})
Expand Down Expand Up @@ -626,6 +658,13 @@ endif()
add_library(torch_cpu ${Caffe2_CPU_SRCS})
torch_compile_options(torch_cpu) # see cmake/public/utils.cmake

if (LLVM_FOUND)
llvm_map_components_to_libnames(LLVM_LINK_LIBS
support core analysis executionengine instcombine
scalaropts transformutils native orcjit)
target_link_libraries(torch_cpu PRIVATE ${LLVM_LINK_LIBS})
endif (LLVM_FOUND)

# This is required for older versions of CMake, which don't allow
# specifying add_library() without a list of source files
set(DUMMY_EMPTY_FILE ${CMAKE_BINARY_DIR}/empty.cpp)
Expand Down Expand Up @@ -759,6 +798,7 @@ ENDIF()

if (BUILD_TEST AND NOT MSVC AND NOT USE_ROCM)
add_subdirectory(${TORCH_ROOT}/test/cpp/jit ${CMAKE_BINARY_DIR}/test_jit)
add_subdirectory(${TORCH_ROOT}/test/cpp/tensorexpr ${CMAKE_BINARY_DIR}/test_tensorexpr)
if (USE_DISTRIBUTED)
add_subdirectory(${TORCH_ROOT}/test/cpp/rpc ${CMAKE_BINARY_DIR}/test_cpp_rpc)
endif()
Expand Down
40 changes: 40 additions & 0 deletions test/cpp/tensorexpr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
set(TENSOREXPR_TEST_ROOT ${TORCH_ROOT}/test/cpp/tensorexpr)

file(GLOB TENSOREXPR_TEST_SRCS ${TENSOREXPR_TEST_ROOT}/test_*.cpp)
set(TENSOREXPR_TEST_SRCS ${TENSOREXPR_TEST_SRCS} PARENT_SCOPE)

add_executable(test_tensorexpr
${TORCH_ROOT}/test/cpp/common/main.cpp
${TENSOREXPR_TEST_ROOT}/gtest.cpp
${TENSOREXPR_TEST_ROOT}/padded_buffer.cpp
${TENSOREXPR_TEST_SRCS})

target_link_libraries(test_tensorexpr PRIVATE torch gtest asmjit)
target_include_directories(test_tensorexpr PRIVATE ${ATen_CPU_INCLUDE})

if (USE_CUDA)
target_link_libraries(test_tensorexpr PRIVATE
${CUDA_LIBRARIES}
${CUDA_NVRTC_LIB}
${CUDA_CUDA_LIB}
${TORCH_CUDA_LIBRARIES})

target_compile_definitions(test_tensorexpr PRIVATE USE_CUDA)
elseif (USE_ROCM)
target_link_libraries(test_tensorexpr PRIVATE
${ROCM_HIPRTC_LIB}
${PYTORCH_HIP_HCC_LIBRARIES}
${TORCH_CUDA_LIBRARIES})

target_link_libraries(test_tensorexpr PRIVATE caffe2_gpu)

target_compile_definitions(test_tensorexpr PRIVATE USE_ROCM)
endif()

if (INSTALL_TEST)
install(TARGETS test_tensorexpr DESTINATION bin)
# Install PDB files for MSVC builds
if (MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:test_tensorexpr> DESTINATION bin OPTIONAL)
endif()
endif()
69 changes: 69 additions & 0 deletions test/cpp/tensorexpr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# JIT 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.
```cpp
#include <test/cpp/jit/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`:
```cpp
// 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
```

## Why do we have two different test runners?
We have two different ways of running our cpp tests:
1. With `gtest`, from a standalone binary.
2. With Python, from `TestJit.test_cpp` and `TestJit.test_cpp_cuda` (in
`test/test_jit.py`)

We want both because we need to test things from a pure-C++ environment and
with all our various Python patch-points enabled.

## How do I run the tests?
The following commands assume you are in PyTorch root.

1. With `gtest`:
```bash
# (re)build the test binary
ninja build/bin/test_jit
# run
build/bin/test_jit --gtest_filter='glob_style_filter*'
```
2. With Python:
```
python test/test_jit.py TestJit.test_cpp TestJit.test_cpp_cuda
```
Empty file added test/cpp/tensorexpr/__init__.py
Empty file.
23 changes: 23 additions & 0 deletions test/cpp/tensorexpr/gtest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <test/cpp/tensorexpr/tests.h>

#include <gtest/gtest.h>

namespace torch {
namespace jit {

#define TENSOREXPR_GTEST(name) \
TEST(TensorExprTest, name) { \
test##name(); \
}
TH_FORALL_TESTS(TENSOREXPR_GTEST)
#undef TENSOREXPR_GTEST

#define TENSOREXPR_GTEST_CUDA(name) \
TEST(TensorExprTest, name##_CUDA) { \
test##name(); \
}
TH_FORALL_TESTS_CUDA(TENSOREXPR_GTEST_CUDA)
#undef TENSOREXPR_GTEST_CUDA

} // namespace jit
} // namespace torch
110 changes: 110 additions & 0 deletions test/cpp/tensorexpr/padded_buffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#include "test/cpp/tensorexpr/padded_buffer.h"

#include <sstream>

#include <gtest/gtest.h>

#include <c10/util/Logging.h>

namespace torch {
namespace jit {
namespace tensorexpr {

int PaddedBufferBase::Index(const std::vector<int>& indices) const {
DCHECK_EQ(dims_.size(), indices.size());
int total_index = 0;
for (int i = 0; i < dims_.size(); i++) {
total_index += indices[i] * strides_[i];
}
return total_index;
}

PaddedBufferBase::PaddedBufferBase(
const std::vector<int>& dims,
const std::string& name)
: dims_(dims), name_(name), strides_(dims.size()) {
for (int i = dims.size() - 1; i >= 0; --i) {
if (i == dims.size() - 1) {
strides_[i] = 1;
} else {
strides_[i] = strides_[i + 1] * dims[i + 1];
}
}
total_size_ = strides_[0] * dims[0];
}

template <typename T>
std::string CompareErrorMsg(
const PaddedBuffer<T>& v1,
const PaddedBuffer<T>& v2,
int index) {
std::ostringstream oss;
oss << "index: " << index << ", names: " << v1.name() << ", " << v2.name();
return oss.str();
}

template <typename T>
void PaddedBuffer<T>::ValidateWatermark() const {
for (int i = 0; i < kPaddingSize; i++) {
EXPECT_EQ(data_[i], kPaddingValue)
<< "left-side watermark broken: "
<< "index: " << i << ", name: " << name();
EXPECT_EQ(data_[i + total_size_ + kPaddingSize], kPaddingValue)
<< "right-side watermark broken: "
<< "index: " << i << ", name: " << name();
}
}

template <typename T>
void PaddedBuffer<T>::CheckBackup() const {
ValidateWatermark();
DCHECK(backup_data_.size() == data_.size())
<< "Please make sure you have call Backup() before calling CheckBackup()";
for (int i = 0; i < total_size_; i++) {
EXPECT_EQ(data_[i + kPaddingSize], backup_data_[i + kPaddingSize])
<< "mismatch against backup, "
<< "index: " << i << ", name: " << name();
}
}

template <typename T>
void ExpectAllEqual(const PaddedBuffer<T>& f1, const PaddedBuffer<T>& f2) {
const std::vector<T>& v1 = f1.data_;
const std::vector<T>& v2 = f2.data_;
const int kPaddingSize = f1.kPaddingSize;
const int total_size = f1.total_size_;
ASSERT_EQ(v1.size(), v2.size());
f1.ValidateWatermark();
f2.ValidateWatermark();
for (int i = 0; i < total_size; i++) {
EXPECT_EQ(v1[kPaddingSize + i], v2[kPaddingSize + i])
<< CompareErrorMsg(f1, f2, i);
}
}

void ExpectAllNear(
const PaddedBuffer<float>& f1,
const PaddedBuffer<float>& f2,
float abs_error) {
const std::vector<float>& v1 = f1.data_;
const std::vector<float>& v2 = f2.data_;
const int kPaddingSize = f1.kPaddingSize;
const int total_size = f1.total_size_;
ASSERT_EQ(v1.size(), v2.size());
f1.ValidateWatermark();
f2.ValidateWatermark();
for (int i = 0; i < total_size; i++) {
EXPECT_NEAR(v1[kPaddingSize + i], v2[kPaddingSize + i], abs_error)
<< CompareErrorMsg(f1, f2, i);
}
}

template class PaddedBuffer<int>;
template class PaddedBuffer<float>;
template void ExpectAllEqual(
const PaddedBuffer<int>& f1,
const PaddedBuffer<int>& f2);

} // namespace tensorexpr
} // namespace jit
} // namespace torch
Loading

0 comments on commit 6e2e7d4

Please sign in to comment.