From 40cf6e649c7a11305c7c753898cfcd1c1c9eab1d Mon Sep 17 00:00:00 2001 From: Fisher Date: Wed, 26 Jul 2023 16:18:44 +0800 Subject: [PATCH] [CINN] Fix test_dot_merger segmentation fault (#55667) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_dot_merger和test_dot_merger_pass在CI和本地环境中会随机出现segmentation fault错误,导致单测随机挂,经排查后发现是ginac库相关的问题,现避免使用MathIsZero绕过 --- paddle/cinn/ir/tensor.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/paddle/cinn/ir/tensor.cc b/paddle/cinn/ir/tensor.cc index b324e1fd259..dbd056df695 100644 --- a/paddle/cinn/ir/tensor.cc +++ b/paddle/cinn/ir/tensor.cc @@ -553,14 +553,17 @@ ir::Tensor _Tensor_::Reshape(const std::vector &shape, auto selft = Tensor(const_cast(this)); { - Expr this_num_elements = Expr(1); - for (auto &e : this->shape) this_num_elements = this_num_elements * e; + int32_t this_num_elements = 1; + for (auto &e : this->shape) { + this_num_elements = this_num_elements * e.as_int32(); + } - Expr num_elements = Expr(1); - for (auto &e : shape) num_elements = num_elements * e; + int32_t num_elements = 1; + for (auto &e : shape) { + num_elements = num_elements * e.as_int32(); + } - CHECK(MathIsZero(this_num_elements - num_elements)) - << "number of elements mismatch"; + CHECK_EQ(this_num_elements, num_elements) << "number of elements mismatch."; } n->name = Context::Global().NewName(name + "_reshape"); -- GitLab