From 706d4dd202355f4c431a18fcc3d3865bacca8c8e Mon Sep 17 00:00:00 2001 From: PGZXB Date: Mon, 19 Dec 2022 15:25:51 +0800 Subject: [PATCH] [bug] Add GetElementExpression to offline cache key (#6918) Issue: #4401, #6614 Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- taichi/analysis/gen_offline_cache_key.cpp | 8 ++++++++ taichi/inc/expressions.inc.h | 1 + 2 files changed, 9 insertions(+) diff --git a/taichi/analysis/gen_offline_cache_key.cpp b/taichi/analysis/gen_offline_cache_key.cpp index a121e25fe14d3..f14297399d845 100644 --- a/taichi/analysis/gen_offline_cache_key.cpp +++ b/taichi/analysis/gen_offline_cache_key.cpp @@ -55,6 +55,8 @@ class ASTSerializer : public IRVisitor, public ExpressionVisitor { public: ASTSerializer(Program *prog, std::ostream *os) : ExpressionVisitor(true), prog_(prog), os_(os) { + // TODO(PGZXB): Set allow_undefined_visitor as false. (blocked by + // constant-folding) this->allow_undefined_visitor = true; } @@ -272,6 +274,12 @@ class ASTSerializer : public IRVisitor, public ExpressionVisitor { emit(expr->var); } + void visit(GetElementExpression *expr) override { + emit(ExprOpCode::GetElementExpression); + emit(expr->src); + emit(expr->index); + } + void visit(Block *block) override { emit(StmtOpCode::EnterBlock); emit(static_cast(block->statements.size())); diff --git a/taichi/inc/expressions.inc.h b/taichi/inc/expressions.inc.h index b311e6fb5a441..eaf498ea9598e 100644 --- a/taichi/inc/expressions.inc.h +++ b/taichi/inc/expressions.inc.h @@ -24,3 +24,4 @@ PER_EXPRESSION(MeshIndexConversionExpression) PER_EXPRESSION(ReferenceExpression) PER_EXPRESSION(TextureOpExpression) PER_EXPRESSION(TexturePtrExpression) +PER_EXPRESSION(GetElementExpression)