electriclilies commented on a change in pull request #9533:
URL: https://github.com/apache/tvm/pull/9533#discussion_r752750605
##########
File path: src/relay/ir/expr.cc
##########
@@ -76,6 +76,26 @@ TVM_REGISTER_NODE_TYPE(TupleNode);
TVM_REGISTER_GLOBAL("relay.ir.Tuple").set_body_typed([](tvm::Array<relay::Expr>
fields, Span span) {
return Tuple(fields, span);
});
+Tuple WithFields(Tuple tuple, Optional<Array<Expr>> opt_fields, Optional<Span>
opt_span) {
+ Array<Expr> fields = opt_fields.value_or(tuple->fields);
+ Span span = opt_span.value_or(tuple->span);
+
+ bool all_fields_unchanged = true;
+ if (fields.size() == tuple->fields.size()) {
+ for (uint i = 0; i < fields.size(); i++) {
+ all_fields_unchanged &= fields[i] == (tuple->fields[i]);
+ }
+ } else {
+ all_fields_unchanged = false;
+ }
+
+ all_fields_unchanged = all_fields_unchanged && span == tuple->span;
+ if (all_fields_unchanged) {
+ return std::move(tuple);
+ } else {
+ return Tuple(std::move(fields), std::move(span));
Review comment:
I see, Mark and I were confused about what you were saying before.
Changed it back to use COW
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]