-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Unity][IR][UX] Privacy annotation in Relax #15140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
1600441
4cd11a2
dabcb1e
ebd1b80
e2ecadc
f2c999d
e012683
24769c0
aaee0cd
801000b
d1f7c01
5b6c814
954dfd3
249ec0e
886a63e
4b4b52f
8064cfe
25e4712
8c7bab1
b815449
68142e1
4e272ae
5314469
a0df076
d2a4902
5ac02e8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,17 +52,45 @@ TVM_STATIC_IR_FUNCTOR(IRDocsifier, vtable) | |
| (*f)->func_vars = nullptr; | ||
| // Step 4. Print attributes | ||
| if (n->attrs.defined() && !n->attrs->dict.empty()) { | ||
| (*f)->stmts.push_back( | ||
| ExprStmtDoc(Relax(d, "func_attr") // | ||
| ->Call({d->AsDoc<ExprDoc>(n->attrs, n_p->Attr("attrs"))}))); | ||
| // if the function is a global function and has a global symbol, | ||
| // then don't print the global symbol (it will be implicit from not being private) | ||
| if (d->frames.size() == 3 && n->attrs->dict.count("global_symbol")) { | ||
|
||
| Map<String, ObjectRef> new_attrs; | ||
| for (auto kv : n->attrs->dict) { | ||
| if (kv.first != "global_symbol") { | ||
| new_attrs.Set(kv.first, kv.second); | ||
| } | ||
| } | ||
| if (!new_attrs.empty()) { | ||
| (*f)->stmts.push_back(ExprStmtDoc( | ||
| Relax(d, "func_attr") // | ||
| ->Call({d->AsDoc<ExprDoc>(DictAttrs(new_attrs), n_p->Attr("attrs"))}))); | ||
| } | ||
| } else { | ||
| (*f)->stmts.push_back( | ||
| ExprStmtDoc(Relax(d, "func_attr") // | ||
| ->Call({d->AsDoc<ExprDoc>(n->attrs, n_p->Attr("attrs"))}))); | ||
| } | ||
| } | ||
| // Step 5. Prepare the decorator (include purity if it's impure) | ||
| ExprDoc decorator = Relax(d, "function"); | ||
| Array<ExprDoc, void> pos_args = {}; | ||
| Array<String, void> dec_keys; | ||
| Array<ExprDoc, void> dec_values; | ||
| if (!n->is_pure) { | ||
| Array<ExprDoc> pos_args = {}; | ||
| decorator = std::move(decorator->Call( | ||
| pos_args, {"pure"}, {LiteralDoc::Boolean(false, Optional<ObjectPath>())})); | ||
| dec_keys.push_back("pure"); | ||
| dec_values.push_back(LiteralDoc::Boolean(false, Optional<ObjectPath>())); | ||
| } | ||
| // if the function is global and does not have a global symbol, indicate that it's private | ||
| if (d->frames.size() == 3 && | ||
| (!n->attrs.defined() || !n->attrs->dict.count("global_symbol"))) { | ||
| dec_keys.push_back("private"); | ||
| dec_values.push_back(LiteralDoc::Boolean(true, Optional<ObjectPath>())); | ||
| } | ||
| if (dec_keys.size()) { | ||
| decorator = std::move(decorator->Call(pos_args, dec_keys, dec_values)); | ||
| } | ||
|
|
||
| // Step 6. Print body | ||
| Array<StmtDoc> body = | ||
| PrintSeqExpr(Downcast<relax::SeqExpr>(n->body), n_p->Attr("body"), d, /*use_ret=*/true); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am assuming we want them to be public.