ir_simplify_test.cc 823 Bytes
Newer Older
Haichen Shen committed
1 2
#include <dmlc/logging.h>
#include <gtest/gtest.h>
3
#include <tvm/ir_pass.h>
Haichen Shen committed
4
#include <tvm/tvm.h>
5
#include <arithmetic/Simplify.h>
Haichen Shen committed
6 7

TEST(IRSIMPLIFY, Basic) {
8
  using namespace HalideIR::Internal;
Haichen Shen committed
9 10 11
  simplify_test();
}

12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
TEST(IRSIMPLIFY, MinMax) {
  auto x = tvm::var("x");
  auto e1 = (tvm::max(x, 1) - tvm::max(x, 1)) ;
  auto e1s = tvm::ir::CanonicalSimplify(e1);
  CHECK(is_zero(e1s));

  auto e2 = (x * tvm::min(x, 1)) - (x * tvm::min(x, 1));
  auto e2s = tvm::ir::CanonicalSimplify(e2);
  CHECK(is_zero(e2s));
}

TEST(IRSIMPLIFY, Mul) {
  auto x = tvm::var("x");
  auto e = (x * x) - (x * x) ;
  auto es = tvm::ir::CanonicalSimplify(e);
  CHECK(is_zero(es));
}

Haichen Shen committed
30 31 32 33 34
int main(int argc, char ** argv) {
  testing::InitGoogleTest(&argc, argv);
  testing::FLAGS_gtest_death_test_style = "threadsafe";
  return RUN_ALL_TESTS();
}