Skip to content

Commit 4c535b2

Browse files
committed
Use pass instead of pattern rewriter
1 parent 454ede4 commit 4c535b2

25 files changed

+430
-448
lines changed

include/tvm/relax/attrs/manipulate.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -156,21 +156,6 @@ struct ScatterElementsAttrs : public tvm::AttrsNode<ScatterElementsAttrs> {
156156
"either \"update\", \"add\", \"mul\", \"mean\", \"min\" or \"max\".");
157157
}
158158
}; // struct ScatterElementsAttrs
159-
160-
/*! \brief Attributes used in sort operator */
161-
struct SortAttrs : public tvm::AttrsNode<SortAttrs> {
162-
Optional<Integer> axis;
163-
Optional<Bool> is_ascend;
164-
165-
TVM_DECLARE_ATTRS(SortAttrs, "relax.attrs.SortAttrs") {
166-
TVM_ATTR_FIELD(axis).describe(
167-
"Axis along which the sort is computed."
168-
"The default (None) is to compute the sort over the flattened array.");
169-
TVM_ATTR_FIELD(is_ascend).describe(
170-
"Whether to sort in ascending or descending order."
171-
"If it is not specified, it defaults to the ascending order.");
172-
}
173-
}; // struct SortAttrs
174159
} // namespace relax
175160
} // namespace tvm
176161

include/tvm/relax/attrs/sort.h

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
20+
/*!
21+
* \file tvm/relax/attrs/sort.h
22+
* \brief Attributes for sorting operators.
23+
*/
24+
#ifndef TVM_RELAX_ATTRS_SORT_H_
25+
#define TVM_RELAX_ATTRS_SORT_H_
26+
27+
#include <tvm/relax/expr.h>
28+
#include <tvm/tir/index_map.h>
29+
30+
namespace tvm {
31+
namespace relax {
32+
33+
/*! \brief Attributes used in sort operator */
34+
struct SortAttrs : public tvm::AttrsNode<SortAttrs> {
35+
Optional<Integer> axis;
36+
Optional<Bool> descending;
37+
38+
TVM_DECLARE_ATTRS(SortAttrs, "relax.attrs.SortAttrs") {
39+
TVM_ATTR_FIELD(axis).describe(
40+
"Axis along which the sort is computed."
41+
"The default (None) is to compute the sort over the flattened array.");
42+
TVM_ATTR_FIELD(descending).describe(
43+
"Whether to sort in descending order."
44+
"If it is not specified, it defaults to the ascending order.");
45+
}
46+
}; // struct SortAttrs
47+
} // namespace relax
48+
} // namespace tvm
49+
50+
#endif // TVM_RELAX_ATTRS_SORT_H_

include/tvm/relax/dataflow_pattern.h

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ class NotPattern;
5656
class ShapePattern;
5757
class TypePattern;
5858
class DataTypePattern;
59-
class TargetPattern;
6059
class AttrPattern;
6160
class SameShapeConstraint;
6261

@@ -121,8 +120,6 @@ class DFPattern : public ObjectRef {
121120
TVM_DLL DataTypePattern HasDtype(const std::string& dtype) const;
122121
/*! \brief Syntatic Sugar for creating a ShapePattern */
123122
TVM_DLL ShapePattern HasShape(const Array<PrimExpr>& shape) const;
124-
/*! \brief Syntatic Sugar for creating a TargetPattern with a target */
125-
TVM_DLL TargetPattern HasTarget(const Target& target) const;
126123
/*! \brief Syntatic Sugar for creating a ShapePattern */
127124
TVM_DLL SameShapeConstraint HasSameShapeAs(const DFPattern& other) const;
128125
/*! \brief Syntatic Sugar for duplicating the current pattern */
@@ -846,34 +843,6 @@ class DataTypePattern : public DFPattern {
846843
TVM_DEFINE_OBJECT_REF_METHODS(DataTypePattern, DFPattern, DataTypePatternNode);
847844
};
848845

849-
/*!
850-
* \brief A pattern that asserting a root pattern has a certain target.
851-
* \sa TargetPattern
852-
*/
853-
class TargetPatternNode : public DFPatternNode {
854-
public:
855-
DFPattern pattern; /*!< The root pattern to match */
856-
Target target; /*!< The target to match */
857-
858-
void VisitAttrs(tvm::AttrVisitor* v) {
859-
v->Visit("pattern", &pattern);
860-
v->Visit("target", &target);
861-
}
862-
863-
static constexpr const char* _type_key = "relax.dpl.TargetPattern";
864-
TVM_DECLARE_FINAL_OBJECT_INFO(TargetPatternNode, DFPatternNode);
865-
};
866-
867-
/*!
868-
* \brief Managed reference to TargetPatternNode.
869-
* \sa TargetPatternNode
870-
*/
871-
class TargetPattern : public DFPattern {
872-
public:
873-
TVM_DLL TargetPattern(DFPattern pattern, Target target);
874-
TVM_DEFINE_OBJECT_REF_METHODS(TargetPattern, DFPattern, TargetPatternNode);
875-
};
876-
877846
/*!
878847
* \brief A pattern that asserting a root pattern has certain attributes.
879848
* \sa AttrPattern

include/tvm/relax/dataflow_pattern_functor.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ class DFPatternFunctor<R(const DFPattern& n, Args...)> {
9191
virtual R VisitDFPattern_(const ExprPatternNode* op, Args... args) DFPATTERN_FUNCTOR_DEFAULT;
9292
virtual R VisitDFPattern_(const FunctionPatternNode* op, Args... args) DFPATTERN_FUNCTOR_DEFAULT;
9393
virtual R VisitDFPattern_(const ShapePatternNode* op, Args... args) DFPATTERN_FUNCTOR_DEFAULT;
94-
virtual R VisitDFPattern_(const TargetPatternNode* op, Args... args) DFPATTERN_FUNCTOR_DEFAULT;
9594
virtual R VisitDFPattern_(const TupleGetItemPatternNode* op,
9695
Args... args) DFPATTERN_FUNCTOR_DEFAULT;
9796
virtual R VisitDFPattern_(const TuplePatternNode* op, Args... args) DFPATTERN_FUNCTOR_DEFAULT;
@@ -128,7 +127,6 @@ class DFPatternFunctor<R(const DFPattern& n, Args...)> {
128127
RELAX_DFPATTERN_FUNCTOR_DISPATCH(ExprPatternNode);
129128
RELAX_DFPATTERN_FUNCTOR_DISPATCH(FunctionPatternNode);
130129
RELAX_DFPATTERN_FUNCTOR_DISPATCH(ShapePatternNode);
131-
RELAX_DFPATTERN_FUNCTOR_DISPATCH(TargetPatternNode);
132130
RELAX_DFPATTERN_FUNCTOR_DISPATCH(TupleGetItemPatternNode);
133131
RELAX_DFPATTERN_FUNCTOR_DISPATCH(TuplePatternNode);
134132
RELAX_DFPATTERN_FUNCTOR_DISPATCH(TypePatternNode);
@@ -163,7 +161,6 @@ class DFPatternVisitor : public DFPatternFunctor<void(const DFPattern&)> {
163161
void VisitDFPattern_(const ExprPatternNode* op) override;
164162
void VisitDFPattern_(const FunctionPatternNode* op) override;
165163
void VisitDFPattern_(const ShapePatternNode* op) override;
166-
void VisitDFPattern_(const TargetPatternNode* op) override;
167164
void VisitDFPattern_(const TupleGetItemPatternNode* op) override;
168165
void VisitDFPattern_(const TuplePatternNode* op) override;
169166
void VisitDFPattern_(const TypePatternNode* op) override;

python/tvm/relax/backend/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818

1919
from . import contrib
2020
from .pattern_registry import get_pattern, get_patterns_with_prefix
21-
from .dispatch_ops import DispatchOps
21+
from .dispatch_sort_scan import DispatchSortScan

python/tvm/relax/backend/dispatch_ops.py

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)