@@ -199,18 +199,15 @@ class PVar : public Pattern<PVar<T>> {
199199 // Store PVars by reference in the expression.
200200 using Nested = const PVar<T>&;
201201
202- void InitMatch_ () const {
203- value_ = nullptr ;
204- filled_ = false ;
205- }
202+ void InitMatch_ () const { filled_ = false ; }
206203
207204 bool Match_ (const T& value) const {
208205 if (!filled_) {
209206 value_ = value;
210207 filled_ = true ;
211208 return true ;
212209 } else {
213- return PEqualChecker<T>()(value_. value () , value);
210+ return PEqualChecker<T>()(value_, value);
214211 }
215212 }
216213
@@ -226,14 +223,14 @@ class PVar : public Pattern<PVar<T>> {
226223
227224 T Eval () const {
228225 TVM_FFI_ICHECK (filled_);
229- return value_. value () ;
226+ return value_;
230227 }
231228
232- T EvalOr (const T& default_value) const { return filled_ ? value_. value () : default_value; }
229+ T EvalOr (const T& default_value) const { return filled_ ? value_ : default_value; }
233230
234231 protected:
235232 /* ! \brief The matched value */
236- mutable ffi::Optional<T> value_;
233+ mutable T value_;
237234 /* ! \brief whether the variable has been filled */
238235 mutable bool filled_{false };
239236};
@@ -285,7 +282,7 @@ class PVarWithDataType : public PVarWithCheck<PVarWithDataType<T, DType>, T> {
285282 public:
286283 explicit PVarWithDataType (const DType& dtype) : dtype_(dtype) {}
287284
288- bool Match_ (const T& value) const { return dtype_.Match_ (value.ty ()); }
285+ bool Match_ (const T& value) const { return dtype_.Match_ (value.ty ()-> dtype ); }
289286
290287 protected:
291288 typename DType::Nested dtype_;
@@ -294,15 +291,15 @@ class PVarWithDataType : public PVarWithCheck<PVarWithDataType<T, DType>, T> {
294291/* !
295292 * \brief Pattern variable container for data type with lanes.
296293 */
297- class PVecDataType : public PVarWithCheck <PVecDataType, PrimType > {
294+ class PVecDataType : public PVarWithCheck <PVecDataType, DLDataType > {
298295 public:
299296 /* ! \brief construct vector dtype placeholder with element type check */
300- explicit PVecDataType (PrimType elem_dtype) : elem_dtype_(elem_dtype) {}
297+ explicit PVecDataType (DLDataType elem_dtype) : elem_dtype_(elem_dtype) {}
301298
302- bool Match_ (PrimType dtype) const { return dtype.code () == elem_dtype_.code () ; }
299+ bool Match_ (DLDataType dtype) const { return dtype.code == elem_dtype_.code ; }
303300
304301 protected:
305- PrimType elem_dtype_;
302+ DLDataType elem_dtype_;
306303};
307304
308305/* !
@@ -543,15 +540,15 @@ class PCastExpr : public Pattern<PCastExpr<DType, TA>> {
543540
544541 bool Match_ (const ffi::ObjectRef& node) const {
545542 if (const tirx::CastNode* ptr = node.as <tirx::CastNode>()) {
546- if (!dtype_.Match_ (ptr->ty ())) return false ;
543+ if (!dtype_.Match_ (ptr->ty ()-> dtype )) return false ;
547544 if (!value_.Match_ (ptr->value )) return false ;
548545 return true ;
549546 } else {
550547 return false ;
551548 }
552549 }
553550
554- PrimExpr Eval () const { return tirx::Cast (dtype_.Eval (), value_.Eval ()); }
551+ PrimExpr Eval () const { return tirx::Cast (PrimType ( dtype_.Eval () ), value_.Eval ()); }
555552
556553 private:
557554 typename DType::Nested dtype_;
@@ -561,7 +558,7 @@ class PCastExpr : public Pattern<PCastExpr<DType, TA>> {
561558/* !
562559 * \brief Construct a cast pattern.
563560 *
564- * \param dtype The target data type, can be PVar<PrimType > or PConst<PrimType >.
561+ * \param dtype The target data type, can be PVar<DLDataType > or PConst<DLDataType >.
565562 * \param value The input type.
566563 *
567564 * \return The result pattern.
0 commit comments