-
Notifications
You must be signed in to change notification settings - Fork 177
fix assign value op bug #1350
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
Conversation
…into fix_assign_value_op_bug
c26572e
to
714585a
Compare
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.
void GetScalars(const std::string &name, std::vector<double> *val){ | ||
auto &op = parser_->GetOpDesc(block_idx_, op_idx_); | ||
parser_->GetOpScalars<double>(op, name, val); | ||
} |
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.
GetAttr 和 GetScalars 感觉都可以用模板简化~
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.
ok,我改一下
paddle2onnx/parser/parser.h
Outdated
@@ -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, |
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.
void GetOpScalars(const paddle2onnx::framework::proto::OpDesc& op, | |
void GetOpScalarsAttr(const paddle2onnx::framework::proto::OpDesc& op, |
感觉加上这个后缀表意能更明确些
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.
ok
int32_t dtype = static_cast<int32_t>(dtype_); | ||
std::string attr_name = HasAttr("values") ? "values" : GetAttrNameByDtype(dtype); |
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.
std::string attr_name = HasAttr("values") ? "values" : GetAttrNameByDtype(dtype); | |
const std::string attr_name = HasAttr("values") ? "values" : GetAttrNameByDtype(dtype); |
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.
ok,我改一下
if (handler != type_handlers.end()) { | ||
handler->second(); | ||
} else { | ||
throw std::invalid_argument("Unsupported dtype value"); |
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.
可以看下2ONNX里面的异常抛出体系有没有统一的规范?
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.
ok
修复 assign_value中无法找到fp32_values属性的问题