You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "guan404ming (via GitHub)" <gi...@apache.org> on 2026/02/12 02:15:19 UTC

[PR] [TIR] Move SymbolicMatcher to tir/analysis [tvm]

guan404ming opened a new pull request, #18762:
URL: https://github.com/apache/tvm/pull/18762

   ## Why
   
   The SymbolicMatcher class was defined inline in fuse_tir.cc. To move it under the TIR folder for better reusability.
   
   ## How
   
   - Extract `SymbolicMatcher` into a standalone header at `src/tir/analysis/symbolic_matcher.h`
   - Replace inline definition in fuse_tir.cc with an include of the new header


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [TIR] Move SymbolicMatcher to tir/analysis [tvm]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #18762:
URL: https://github.com/apache/tvm/pull/18762#issuecomment-3888318444

   Sure, that makes sense. Just updated!


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [TIR] Move SymbolicMatcher to tir/analysis [tvm]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #18762:
URL: https://github.com/apache/tvm/pull/18762#issuecomment-3888283797

   ## Summary of Changes
   
   Hello @guan404ming, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
   
   This pull request refactors the `SymbolicMatcher` class by extracting its definition from an existing source file into a new, standalone header. This change improves code organization and promotes better reusability of the symbolic matching logic across the codebase, aligning with best practices for modular design.
   
   ### Highlights
   
   * **Code Reorganization**: The `SymbolicMatcher` class has been extracted from an inline definition within `src/relax/transform/fuse_tir.cc` and moved to its own dedicated header file at `src/tir/analysis/symbolic_matcher.h`.
   * **Improved Reusability**: This refactoring enhances the reusability of the `SymbolicMatcher` class by placing it in a more appropriate and accessible location within the TIR analysis module, allowing other components to easily utilize its functionality.
   
   🧠 **New Feature in Public Preview:** You can now enable **Memory** to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.**
   
   <details>
   <summary><b>Changelog</b></summary>
   
   * **src/relax/transform/fuse_tir.cc**
       * Removed the inline definition of the `SymbolicMatcher` class.
       * Added an include statement for the newly created `symbolic_matcher.h` header.
   * **src/tir/analysis/symbolic_matcher.h**
       * Added a new header file containing the complete definition of the `SymbolicMatcher` class, previously defined inline.
   </details>
   
   <details>
   <summary><b>Activity</b></summary>
   
   * The pull request author `guan404ming` initiated this change to improve the reusability and organization of the `SymbolicMatcher` class.
   * The core activity involves moving a class definition from one C++ file to a new header file and updating the original file to reference the new header.
   </details>
   
   <details>
   <summary><b>Using Gemini Code Assist</b></summary>
   <br>
   
   The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
   
   <b>Invoking Gemini</b>
   
   You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
   
   Feature | Command | Description
   --- | --- | ---
   Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
   Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
   Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
   Help | `/gemini help` | Displays a list of available commands.
   
   <b>Customization</b>
   
   To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
   
   <b>Limitations & Feedback</b>
   
   Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
   
   <b>You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the [Gemini Code Assist IDE Extension](https://cloud.google.com/products/gemini/code-assist).</b>
   </details>
   
   
   [^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [TIR] Move SymbolicMatcher to tir/analysis [tvm]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on PR #18762:
URL: https://github.com/apache/tvm/pull/18762#issuecomment-3888319031

   https://github.com/apache/tvm/pull/18650


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [TIR] Move SymbolicMatcher to tir/analysis [tvm]

Posted by "tqchen (via GitHub)" <gi...@apache.org>.
tqchen commented on PR #18762:
URL: https://github.com/apache/tvm/pull/18762#issuecomment-3888294476

   sorry we seems to have previous comment on this that this file is better kept under relax given it is only used in one place and relax specific. Maybe we should update the comment instead so we don't have to pick it up again


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [Relax] Remove TODO comment for moving code in fuse_tir.cc [tvm]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming merged PR #18762:
URL: https://github.com/apache/tvm/pull/18762


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [TIR] Move SymbolicMatcher to tir/analysis [tvm]

Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #18762:
URL: https://github.com/apache/tvm/pull/18762#discussion_r2796444951


##########
src/tir/analysis/symbolic_matcher.h:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tir/analysis/symbolic_matcher.h
+ * \brief Match symbolic vars according to given PrimExpr patterns and update a var remap.
+ */
+#ifndef SRC_TIR_ANALYSIS_SYMBOLIC_MATCHER_H_
+#define SRC_TIR_ANALYSIS_SYMBOLIC_MATCHER_H_
+
+#include <tvm/arith/analyzer.h>
+#include <tvm/tir/expr_functor.h>
+#include <tvm/tir/op.h>
+#include <tvm/tir/stmt_functor.h>
+
+namespace tvm {
+namespace tir {
+
+/*!
+ * \brief Match symbolic vars according to the given PrimExpr, and update the var_remap.
+ * Will throw errors if there is a mismatch.
+ */
+class SymbolicMatcher : ExprFunctor<void(const PrimExpr& n, const PrimExpr& other)> {
+ public:
+  explicit SymbolicMatcher(arith::Analyzer* analyzer, ffi::Map<tir::Var, PrimExpr>* var_remap)
+      : analyzer_(analyzer), var_remap_(var_remap) {}
+
+  void Match(const ffi::Array<PrimExpr>& params, const ffi::Array<PrimExpr>& args) {
+    CHECK_EQ(params.size(), args.size());
+    for (size_t i = 0; i < params.size(); ++i) {
+      Match(params[i], args[i]);
+    }
+  }
+  void Match(const PrimExpr& param, const PrimExpr& arg) {
+    VisitExpr(param, arg);
+    must_prove_ = analyzer_->Simplify(Substitute(must_prove_, *var_remap_));
+    CHECK(!is_zero(must_prove_));
+  }
+
+ private:
+  void VisitExpr(const PrimExpr& node, const PrimExpr& other) {
+    if (node.same_as(other)) {
+      return;
+    } else if (node.dtype().code() != other.dtype().code()) {
+      LOG(FATAL) << "Parameter expression " << node << " with dtype " << node.dtype()
+                 << " cannot match to argument " << other << " with dtype " << other.dtype();
+    } else {
+      ExprFunctor::VisitExpr(node, other);
+    }
+  }
+
+#define TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(OpName)                       \
+  void VisitExpr_(const OpName* op, const PrimExpr& other) {             \
+    const auto* rhs = other.as<OpName>();                                \
+    if (rhs) {                                                           \
+      VisitExpr(op->a, rhs->a);                                          \
+      VisitExpr(op->b, rhs->b);                                          \
+    } else {                                                             \
+      must_prove_ = must_prove_ && (ffi::GetRef<PrimExpr>(op) == other); \
+    }                                                                    \
+  }
+
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(AddNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(SubNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(MulNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(DivNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(ModNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(EQNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(NENode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(LTNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(LENode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(GTNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(GENode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(AndNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(OrNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(MinNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(MaxNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(FloorDivNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(FloorModNode);
+
+  void VisitExpr_(const IntImmNode* op, const PrimExpr& other) {
+    const auto* rhs = other.as<IntImmNode>();
+    if (!rhs || (op->value != rhs->value)) {
+      LOG(FATAL) << "Parameter expression " << ffi::GetRef<PrimExpr>(op)
+                 << " expected an integer argument with value " << op->value << ", "
+                 << "but was provided with the argument " << other;
+    }
+  }
+
+  void VisitExpr_(const FloatImmNode* op, const PrimExpr& other) {
+    const auto* rhs = other.as<FloatImmNode>();
+    if (!rhs || (op->value != rhs->value)) {
+      LOG(FATAL) << "Parameter expression " << ffi::GetRef<PrimExpr>(op)
+                 << " expected an float argument with value " << op->value << ", "
+                 << "but was provided with the argument " << other;
+    }
+  }
+
+  void VisitExpr_(const CastNode* op, const PrimExpr& other) {
+    const auto* rhs = other.as<CastNode>();
+    if (!rhs) {
+      LOG(FATAL) << "Parameter expression " << ffi::GetRef<PrimExpr>(op) << " expected an cast to "
+                 << op->dtype << " as the argument, "
+                 << "but was provided with the argument " << other;
+    }
+    VisitExpr(op->value, rhs->value);
+  }
+
+  void VisitExpr_(const VarNode* op, const PrimExpr& rhs) {
+    auto lhs = ffi::GetRef<Var>(op);
+
+    if (lhs.same_as(rhs)) {
+      // Reference identity, no further checks needed.
+    } else if (op->dtype.code() != rhs->dtype.code()) {

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   Similar to the check in `VisitExpr`, the dtype check here is too weak. It only compares the type code and ignores bits and lanes. Please change it to `op->dtype != rhs.dtype()` for a full comparison.
   
   ```suggestion
       } else if (op->dtype != rhs.dtype()) {
   ```



##########
src/tir/analysis/symbolic_matcher.h:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tir/analysis/symbolic_matcher.h
+ * \brief Match symbolic vars according to given PrimExpr patterns and update a var remap.
+ */
+#ifndef SRC_TIR_ANALYSIS_SYMBOLIC_MATCHER_H_
+#define SRC_TIR_ANALYSIS_SYMBOLIC_MATCHER_H_
+
+#include <tvm/arith/analyzer.h>
+#include <tvm/tir/expr_functor.h>
+#include <tvm/tir/op.h>
+#include <tvm/tir/stmt_functor.h>
+
+namespace tvm {
+namespace tir {
+
+/*!
+ * \brief Match symbolic vars according to the given PrimExpr, and update the var_remap.
+ * Will throw errors if there is a mismatch.
+ */
+class SymbolicMatcher : ExprFunctor<void(const PrimExpr& n, const PrimExpr& other)> {
+ public:
+  explicit SymbolicMatcher(arith::Analyzer* analyzer, ffi::Map<tir::Var, PrimExpr>* var_remap)
+      : analyzer_(analyzer), var_remap_(var_remap) {}
+
+  void Match(const ffi::Array<PrimExpr>& params, const ffi::Array<PrimExpr>& args) {
+    CHECK_EQ(params.size(), args.size());
+    for (size_t i = 0; i < params.size(); ++i) {
+      Match(params[i], args[i]);
+    }
+  }
+  void Match(const PrimExpr& param, const PrimExpr& arg) {
+    VisitExpr(param, arg);
+    must_prove_ = analyzer_->Simplify(Substitute(must_prove_, *var_remap_));
+    CHECK(!is_zero(must_prove_));
+  }
+
+ private:
+  void VisitExpr(const PrimExpr& node, const PrimExpr& other) {
+    if (node.same_as(other)) {
+      return;
+    } else if (node.dtype().code() != other.dtype().code()) {

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   The dtype check `node.dtype().code() != other.dtype().code()` is not sufficient as it only compares the type code (e.g., `kDLInt`, `kDLFloat`) but not the number of bits or lanes. This can lead to incorrect matches between types like `int32` and `int64`, or vectors of different widths. You should use `node.dtype() != other.dtype()` for a complete type comparison.
   
   ```suggestion
       } else if (node.dtype() != other.dtype()) {
   ```



##########
src/tir/analysis/symbolic_matcher.h:
##########
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/*!
+ * \file tir/analysis/symbolic_matcher.h
+ * \brief Match symbolic vars according to given PrimExpr patterns and update a var remap.
+ */
+#ifndef SRC_TIR_ANALYSIS_SYMBOLIC_MATCHER_H_
+#define SRC_TIR_ANALYSIS_SYMBOLIC_MATCHER_H_
+
+#include <tvm/arith/analyzer.h>
+#include <tvm/tir/expr_functor.h>
+#include <tvm/tir/op.h>
+#include <tvm/tir/stmt_functor.h>
+
+namespace tvm {
+namespace tir {
+
+/*!
+ * \brief Match symbolic vars according to the given PrimExpr, and update the var_remap.
+ * Will throw errors if there is a mismatch.
+ */
+class SymbolicMatcher : ExprFunctor<void(const PrimExpr& n, const PrimExpr& other)> {
+ public:
+  explicit SymbolicMatcher(arith::Analyzer* analyzer, ffi::Map<tir::Var, PrimExpr>* var_remap)
+      : analyzer_(analyzer), var_remap_(var_remap) {}
+
+  void Match(const ffi::Array<PrimExpr>& params, const ffi::Array<PrimExpr>& args) {
+    CHECK_EQ(params.size(), args.size());
+    for (size_t i = 0; i < params.size(); ++i) {
+      Match(params[i], args[i]);
+    }
+  }
+  void Match(const PrimExpr& param, const PrimExpr& arg) {
+    VisitExpr(param, arg);
+    must_prove_ = analyzer_->Simplify(Substitute(must_prove_, *var_remap_));
+    CHECK(!is_zero(must_prove_));
+  }
+
+ private:
+  void VisitExpr(const PrimExpr& node, const PrimExpr& other) {
+    if (node.same_as(other)) {
+      return;
+    } else if (node.dtype().code() != other.dtype().code()) {
+      LOG(FATAL) << "Parameter expression " << node << " with dtype " << node.dtype()
+                 << " cannot match to argument " << other << " with dtype " << other.dtype();
+    } else {
+      ExprFunctor::VisitExpr(node, other);
+    }
+  }
+
+#define TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(OpName)                       \
+  void VisitExpr_(const OpName* op, const PrimExpr& other) {             \
+    const auto* rhs = other.as<OpName>();                                \
+    if (rhs) {                                                           \
+      VisitExpr(op->a, rhs->a);                                          \
+      VisitExpr(op->b, rhs->b);                                          \
+    } else {                                                             \
+      must_prove_ = must_prove_ && (ffi::GetRef<PrimExpr>(op) == other); \
+    }                                                                    \
+  }
+
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(AddNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(SubNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(MulNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(DivNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(ModNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(EQNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(NENode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(LTNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(LENode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(GTNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(GENode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(AndNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(OrNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(MinNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(MaxNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(FloorDivNode);
+  TVM_DECLARE_SYMBOLIC_MATCHER_BINOP(FloorModNode);
+
+  void VisitExpr_(const IntImmNode* op, const PrimExpr& other) {
+    const auto* rhs = other.as<IntImmNode>();
+    if (!rhs || (op->value != rhs->value)) {
+      LOG(FATAL) << "Parameter expression " << ffi::GetRef<PrimExpr>(op)
+                 << " expected an integer argument with value " << op->value << ", "
+                 << "but was provided with the argument " << other;
+    }
+  }
+
+  void VisitExpr_(const FloatImmNode* op, const PrimExpr& other) {
+    const auto* rhs = other.as<FloatImmNode>();
+    if (!rhs || (op->value != rhs->value)) {
+      LOG(FATAL) << "Parameter expression " << ffi::GetRef<PrimExpr>(op)
+                 << " expected an float argument with value " << op->value << ", "
+                 << "but was provided with the argument " << other;
+    }
+  }
+
+  void VisitExpr_(const CastNode* op, const PrimExpr& other) {
+    const auto* rhs = other.as<CastNode>();
+    if (!rhs) {
+      LOG(FATAL) << "Parameter expression " << ffi::GetRef<PrimExpr>(op) << " expected an cast to "
+                 << op->dtype << " as the argument, "
+                 << "but was provided with the argument " << other;
+    }
+    VisitExpr(op->value, rhs->value);
+  }
+
+  void VisitExpr_(const VarNode* op, const PrimExpr& rhs) {
+    auto lhs = ffi::GetRef<Var>(op);
+
+    if (lhs.same_as(rhs)) {
+      // Reference identity, no further checks needed.
+    } else if (op->dtype.code() != rhs->dtype.code()) {
+      LOG(FATAL) << "Parameter expression " << ffi::GetRef<PrimExpr>(op) << " with dtype "
+                 << op->dtype << " cannot match to argument " << rhs << " with dtype "
+                 << rhs.dtype();
+    } else if (auto it = var_remap_->find(lhs); it != var_remap_->end()) {
+      VisitExpr((*it).second, rhs);
+    } else {
+      var_remap_->Set(lhs, rhs);
+    }
+  }
+
+  void VisitExpr_(const SelectNode* op, const PrimExpr& other) {
+    const auto* rhs = other.as<SelectNode>();
+    if (rhs) {
+      VisitExpr(op->true_value, rhs->true_value);
+      VisitExpr(op->false_value, rhs->false_value);

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   The `condition` field of the `SelectNode` is not being visited. This can lead to missed symbolic variable mappings if they appear in the condition. You should add a recursive call to `VisitExpr` for the condition.
   
   ```suggestion
         VisitExpr(op->condition, rhs->condition);
         VisitExpr(op->true_value, rhs->true_value);
         VisitExpr(op->false_value, rhs->false_value);
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org


Re: [PR] [Relax] Remove TODO comment for moving code in fuse_tir.cc [tvm]

Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #18762:
URL: https://github.com/apache/tvm/pull/18762#issuecomment-3888324940

   Oops, I forget that. We should remove that stale todo at that time.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org