Skip to content

Commit

Permalink
[Relay][RFC][Fix] Rename RelayPrint to AsText (#2984)
Browse files Browse the repository at this point in the history
  • Loading branch information
jroesch authored and tqchen committed Apr 8, 2019
1 parent cffb4fb commit 552d4aa
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions include/tvm/relay/expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -562,16 +562,16 @@ inline const TTypeNode* ExprNode::type_as() const {
}

/*!
* \brief Print node as text format.
* \param node The node to be printed.
* \brief Render the node as a string in the Relay text format.
* \param node The node to be rendered.
* \param show_meta_data Whether to print meta data section.
* \param annotate An optional callback function for attaching
* additional comment block to an expr.
* \return The text representation.
*/
std::string RelayPrint(const NodeRef& node,
bool show_meta_data = true,
runtime::TypedPackedFunc<std::string(Expr)> annotate = nullptr);
std::string AsText(const NodeRef& node,
bool show_meta_data = true,
runtime::TypedPackedFunc<std::string(Expr)> annotate = nullptr);
} // namespace relay
} // namespace tvm
#endif // TVM_RELAY_EXPR_H_
2 changes: 1 addition & 1 deletion python/tvm/relay/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def astext(self, show_meta_data=True, annotate=None):
text : str
The text format of the expression.
"""
return _expr.RelayPrint(self, show_meta_data, annotate)
return _expr.AsText(self, show_meta_data, annotate)

def set_span(self, span):
_base.set_span(self, span)
Expand Down
6 changes: 3 additions & 3 deletions src/relay/ir/error.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -110,7 +110,7 @@ void ErrorReporter::RenderErrors(const Module& module, bool use_color) {
//
// The annotation callback will annotate the error messages
// contained in the map.
annotated_prog << RelayPrint(func, false, [&err_map](tvm::relay::Expr expr) {
annotated_prog << AsText(func, false, [&err_map](tvm::relay::Expr expr) {
auto it = err_map.find(expr);
if (it != err_map.end()) {
return it->second;
Expand Down
14 changes: 7 additions & 7 deletions src/relay/ir/pretty_printer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -709,9 +709,9 @@ std::string PrettyPrint_(const NodeRef& node,
return doc.str();
}

std::string RelayPrint(const NodeRef& node,
bool show_meta_data,
runtime::TypedPackedFunc<std::string(Expr)> annotate) {
std::string AsText(const NodeRef& node,
bool show_meta_data,
runtime::TypedPackedFunc<std::string(Expr)> annotate) {
return PrettyPrint_(node, show_meta_data, annotate, true);
}

Expand All @@ -722,10 +722,10 @@ std::string PassDebugPrint(const NodeRef& node,
return PrettyPrint_(node, show_meta_data, annotate, gnf);
}

TVM_REGISTER_API("relay._expr.RelayPrint")
TVM_REGISTER_API("relay._expr.AsText")
.set_body_typed<std::string(const NodeRef&,
bool,
runtime::TypedPackedFunc<std::string(Expr)>)>(RelayPrint);
runtime::TypedPackedFunc<std::string(Expr)>)>(AsText);

TVM_REGISTER_API("relay._ir_pass.pass_debug_print")
.set_body_typed<std::string(const NodeRef&,
Expand Down
6 changes: 3 additions & 3 deletions src/relay/pass/fuse_ops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
Expand Down Expand Up @@ -890,7 +890,7 @@ class FuseMutator : private ExprMutator {

// Debug function, dump the group assignment in text.
void DebugDumpGroup(const Expr& body) {
std::string text = RelayPrint(body, false, [this](const Expr& expr) -> std::string {
std::string text = AsText(body, false, [this](const Expr& expr) -> std::string {
auto it = gmap_.find(expr.get());
if (it == gmap_.end()) return "";
std::ostringstream os;
Expand Down

0 comments on commit 552d4aa

Please sign in to comment.