This is an automated email from the ASF dual-hosted git repository.

cbalint13 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 06def23ad1 [Refactor] Improve TargetHasSVE function with optional 
target handling (#17666)
06def23ad1 is described below

commit 06def23ad1af82926bd7d166b9a882df5238e390
Author: Lei Wang <[email protected]>
AuthorDate: Thu Feb 20 04:20:30 2025 +0800

    [Refactor] Improve TargetHasSVE function with optional target handling 
(#17666)
    
    * Improve TargetHasSVE function with optional target handling
    
    - Update TargetHasSVE to accept an optional Target parameter
    - Add default behavior to use current target if no target is specified
    - Simplify target checking logic in the function
---
 src/arith/scalable_expression.cc | 12 +++++++-----
 src/arith/scalable_expression.h  |  2 +-
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/arith/scalable_expression.cc b/src/arith/scalable_expression.cc
index 5e3a65438d..beb75c1f3e 100644
--- a/src/arith/scalable_expression.cc
+++ b/src/arith/scalable_expression.cc
@@ -86,12 +86,14 @@ bool 
CanProveVscaleExpressionFromKnownValues(arith::Analyzer* analyzer, const Pr
   return can_prove_expr;
 }
 
-bool TargetHasSVE(Target current_target) {
-  bool has_sve{false};
-  if (current_target.defined()) {
-    has_sve = 
current_target->GetFeature<Bool>("has_sve").value_or(Bool(false));
+bool TargetHasSVE(Optional<Target> target) {
+  if (!target.defined()) {
+    target = Target::Current();
   }
-  return has_sve;
+  if (target.defined()) {
+    return 
Downcast<Target>(target)->GetFeature<Bool>("has_sve").value_or(Bool(false));
+  }
+  return false;
 }
 
 }  // namespace arith
diff --git a/src/arith/scalable_expression.h b/src/arith/scalable_expression.h
index 06ff8104e9..d31e81fffc 100644
--- a/src/arith/scalable_expression.h
+++ b/src/arith/scalable_expression.h
@@ -83,7 +83,7 @@ bool CanProveVscaleExpressionFromKnownValues(arith::Analyzer* 
analyzer, const Pr
  * \param target The target to check.
  * \return Whether SVE is supported
  */
-bool TargetHasSVE(Target target);
+bool TargetHasSVE(Optional<Target> target = NullOpt);
 
 }  // namespace arith
 }  // namespace tvm

Reply via email to