Skip to content

Commit 06def23

Browse files
authored
[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
1 parent cc2f079 commit 06def23

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

src/arith/scalable_expression.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,14 @@ bool CanProveVscaleExpressionFromKnownValues(arith::Analyzer* analyzer, const Pr
8686
return can_prove_expr;
8787
}
8888

89-
bool TargetHasSVE(Target current_target) {
90-
bool has_sve{false};
91-
if (current_target.defined()) {
92-
has_sve = current_target->GetFeature<Bool>("has_sve").value_or(Bool(false));
89+
bool TargetHasSVE(Optional<Target> target) {
90+
if (!target.defined()) {
91+
target = Target::Current();
9392
}
94-
return has_sve;
93+
if (target.defined()) {
94+
return Downcast<Target>(target)->GetFeature<Bool>("has_sve").value_or(Bool(false));
95+
}
96+
return false;
9597
}
9698

9799
} // namespace arith

src/arith/scalable_expression.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ bool CanProveVscaleExpressionFromKnownValues(arith::Analyzer* analyzer, const Pr
8383
* \param target The target to check.
8484
* \return Whether SVE is supported
8585
*/
86-
bool TargetHasSVE(Target target);
86+
bool TargetHasSVE(Optional<Target> target = NullOpt);
8787

8888
} // namespace arith
8989
} // namespace tvm

0 commit comments

Comments
 (0)