Skip to content

Commit 6fb1aa9

Browse files
committed
[TVMScript] Continue migrating to TVMScript format
This PR includes more TIR types to default to TVMScript format
1 parent 7e3dc45 commit 6fb1aa9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+340
-374
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,6 @@ tvm_file_glob(GLOB_RECURSE COMPILER_SRCS
288288
src/topi/*.cc
289289
src/driver/*.cc
290290
src/parser/*.cc
291-
src/printer/*.cc
292291
src/support/*.cc
293292
src/script/*.cc
294293
)
@@ -317,6 +316,7 @@ tvm_file_glob(GLOB RELAY_BACKEND_SRCS
317316
)
318317
tvm_file_glob(GLOB_RECURSE RELAY_IR_SRCS
319318
src/relay/ir/*.cc
319+
src/relay/printer/*.cc
320320
)
321321
tvm_file_glob(GLOB_RECURSE RELAY_QNN_SRCS
322322
src/relay/qnn/*.cc

include/tvm/ir/module.h

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -446,34 +446,6 @@ class IRModule : public ObjectRef {
446446
TVM_DEFINE_OBJECT_REF_COW_METHOD(IRModuleNode);
447447
};
448448

449-
/*!
450-
* \brief Pretty print a node for debug purposes.
451-
*
452-
* \param node The node to be printed.
453-
* \return The text reperesentation.
454-
* \note This function does not show version or meta-data.
455-
* Use AsText if you want to store the text.
456-
* \sa AsText.
457-
*/
458-
TVM_DLL String PrettyPrint(const ObjectRef& node);
459-
460-
/*!
461-
* \brief Render the node as a string in the text format.
462-
*
463-
* \param node The node to be rendered.
464-
* \param show_meta_data Whether to print meta data section.
465-
* \param annotate An optional callback function for attaching
466-
* additional comment block to an expr.
467-
*
468-
* \note We support a limited set of IR nodes that are part of
469-
* relay IR and
470-
*
471-
* \sa PrettyPrint.
472-
* \return The text representation.
473-
*/
474-
TVM_DLL String AsText(const ObjectRef& node, bool show_meta_data = true,
475-
runtime::TypedPackedFunc<String(ObjectRef)> annotate = nullptr);
476-
477449
namespace attr {
478450

479451
// Following are attributes for IRModule only.

include/tvm/ir/transform.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
#define TVM_IR_TRANSFORM_H_
5858

5959
#include <tvm/ir/diagnostic.h>
60-
#include <tvm/ir/error.h>
6160
#include <tvm/ir/instrument.h>
6261
#include <tvm/ir/module.h>
6362
#include <tvm/runtime/container/array.h>

include/tvm/relay/base.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,34 @@ class Id : public ObjectRef {
120120
TVM_DEFINE_OBJECT_REF_METHODS(Id, ObjectRef, IdNode);
121121
};
122122

123+
/*!
124+
* \brief Pretty print a node for debug purposes.
125+
*
126+
* \param node The node to be printed.
127+
* \return The text reperesentation.
128+
* \note This function does not show version or meta-data.
129+
* Use AsText if you want to store the text.
130+
* \sa AsText.
131+
*/
132+
TVM_DLL String PrettyPrint(const ObjectRef& node);
133+
134+
/*!
135+
* \brief Render the node as a string in the text format.
136+
*
137+
* \param node The node to be rendered.
138+
* \param show_meta_data Whether to print meta data section.
139+
* \param annotate An optional callback function for attaching
140+
* additional comment block to an expr.
141+
*
142+
* \note We support a limited set of IR nodes that are part of
143+
* relay IR and
144+
*
145+
* \sa PrettyPrint.
146+
* \return The text representation.
147+
*/
148+
TVM_DLL String AsText(const ObjectRef& node, bool show_meta_data = true,
149+
runtime::TypedPackedFunc<String(ObjectRef)> annotate = nullptr);
150+
123151
} // namespace relay
124152
} // namespace tvm
125153

include/tvm/ir/error.h renamed to include/tvm/relay/error.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,8 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
20-
/*!
21-
* \file tvm/ir/error.h
22-
* \brief Utilities for error tracking and reporting.
23-
*/
24-
#ifndef TVM_IR_ERROR_H_
25-
#define TVM_IR_ERROR_H_
19+
#ifndef TVM_RELAY_ERROR_H_
20+
#define TVM_RELAY_ERROR_H_
2621

2722
#include <tvm/ir/module.h>
2823
#include <tvm/ir/span.h>
@@ -33,6 +28,7 @@
3328
#include <vector>
3429

3530
namespace tvm {
31+
namespace relay {
3632
/*!
3733
* \brief A wrapper around std::stringstream to build error.
3834
*
@@ -181,5 +177,6 @@ class ErrorReporter {
181177
std::unordered_map<ObjectRef, GlobalVar, ObjectPtrHash, ObjectPtrEqual> node_to_gv_;
182178
};
183179

180+
} // namespace relay
184181
} // namespace tvm
185-
#endif // TVM_IR_ERROR_H_
182+
#endif // TVM_RELAY_ERROR_H_

include/tvm/relay/expr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ using BaseFunc = tvm::BaseFunc;
5757
using BaseFuncNode = tvm::BaseFuncNode;
5858
using GlobalVar = tvm::GlobalVar;
5959
using GlobalVarNode = tvm::GlobalVarNode;
60-
using tvm::PrettyPrint;
6160

6261
/*!
6362
* \brief Constant tensor, backed by an NDArray on the cpu(0) device.

include/tvm/relay/expr_functor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@
2525
#ifndef TVM_RELAY_EXPR_FUNCTOR_H_
2626
#define TVM_RELAY_EXPR_FUNCTOR_H_
2727

28-
#include <tvm/ir/error.h>
2928
#include <tvm/node/functor.h>
3029
#include <tvm/relay/adt.h>
30+
#include <tvm/relay/error.h>
3131
#include <tvm/relay/expr.h>
3232
#include <tvm/relay/function.h>
3333
#include <tvm/relay/op.h>

include/tvm/relay/pattern_functor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
#ifndef TVM_RELAY_PATTERN_FUNCTOR_H_
2626
#define TVM_RELAY_PATTERN_FUNCTOR_H_
2727

28-
#include <tvm/ir/error.h>
2928
#include <tvm/node/functor.h>
29+
#include <tvm/relay/error.h>
3030

3131
#include <string>
3232
#include <unordered_map>

python/tvm/ir/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
Span,
2828
assert_structural_equal,
2929
load_json,
30-
pretty_print,
3130
save_json,
3231
structural_equal,
3332
structural_hash,

python/tvm/ir/affine_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __ne__(self, other):
3232
return not self.__eq__(other)
3333

3434
def __str__(self):
35-
from tvm.ir import pretty_print # pylint: disable=import-outside-toplevel
35+
from tvm.relay import pretty_print # pylint: disable=import-outside-toplevel
3636

3737
return pretty_print(self)
3838

0 commit comments

Comments
 (0)