Skip to content
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

fix assign value op bug #1350

Merged
merged 6 commits into from
Aug 15, 2024

Conversation

risemeup1
Copy link
Collaborator

@risemeup1 risemeup1 commented Aug 15, 2024

修复 assign_value中无法找到fp32_values属性的问题

Copy link
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMeow 🐾

整体上感觉没啥问题

void GetScalars(const std::string &name, std::vector<double> *val){
auto &op = parser_->GetOpDesc(block_idx_, op_idx_);
parser_->GetOpScalars<double>(op, name, val);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GetAttr 和 GetScalars 感觉都可以用模板简化~

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,我改一下

@@ -187,6 +189,11 @@ class PaddleParser {
const std::string& tensor_name,
std::vector<T>* data) const;

template <typename T>
void GetOpScalars(const paddle2onnx::framework::proto::OpDesc& op,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void GetOpScalars(const paddle2onnx::framework::proto::OpDesc& op,
void GetOpScalarsAttr(const paddle2onnx::framework::proto::OpDesc& op,

感觉加上这个后缀表意能更明确些

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

int32_t dtype = static_cast<int32_t>(dtype_);
std::string attr_name = HasAttr("values") ? "values" : GetAttrNameByDtype(dtype);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
std::string attr_name = HasAttr("values") ? "values" : GetAttrNameByDtype(dtype);
const std::string attr_name = HasAttr("values") ? "values" : GetAttrNameByDtype(dtype);

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok,我改一下

if (handler != type_handlers.end()) {
handler->second();
} else {
throw std::invalid_argument("Unsupported dtype value");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可以看下2ONNX里面的异常抛出体系有没有统一的规范?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@Jiang-Jia-Jun Jiang-Jia-Jun merged commit c6dcef7 into PaddlePaddle:develop Aug 15, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants