gemini-code-assist[bot] commented on code in PR #20013:
URL: https://github.com/apache/tvm/pull/20013#discussion_r3592692886
##########
src/relax/transform/lift_transform_params.cc:
##########
@@ -46,6 +46,18 @@ constexpr const char* kLiftTransformConsumeParams =
"relax.lift_transform_params
TVM_REGISTER_PASS_CONFIG_OPTION(kLiftTransformConsumeParams, bool);
namespace {
+std::optional<size_t> GetNumInput(const FunctionNode* func) {
+ if (auto opt = func->attrs.GetAttr<int64_t>(attr::kNumInput)) {
Review Comment:

Directly accessing `func->attrs` without checking if it is defined can lead
to a segmentation fault if the function has no attributes (which is common for
local/nested functions visited by `LocalLiftableBindingCollector`). In TVM,
`func->attrs` is a nullable `DictAttrs` object.
Using `func->GetAttr<int64_t>(attr::kNumInput)` is safer and cleaner because
`BaseFuncNode::GetAttr` internally checks if `attrs` is defined before
attempting to retrieve the attribute.
```suggestion
if (auto opt = func->GetAttr<int64_t>(attr::kNumInput)) {
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]