tqchen commented on a change in pull request #9533:
URL: https://github.com/apache/tvm/pull/9533#discussion_r752626980
##########
File path: src/relay/ir/expr.cc
##########
@@ -71,6 +71,29 @@ Tuple::Tuple(tvm::Array<relay::Expr> fields, Span span) {
data_ = std::move(n);
}
+Tuple Tuple::WithFields(Optional<Array<Expr>> opt_fields, Optional<Span>
opt_span) {
+ Array<Expr> fields = opt_fields.value_or(get()->fields);
Review comment:
I see, it might be worth thinking a bit about the tradeoff since the
original semantics on the python and c++ side is WithAttr do not mutate the
original value that is passed in(unless it is moved in and ensures that there
is no followup).
Since a common usage pattern may ends up look like this:
```python
x = PrimFunc(args, body)
# y is a new copy that comes with a new attr
# x remains as the original case
y = x.with_attr("new_attr", value)
record([x, y])
```
If it is a mution semantics, then we might want to rename it as SetXYZ, like
Array.Set
--
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]