-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
support vector<float64> as type of op attribute and op set_value suppport float64 numpy.array #30126
support vector<float64> as type of op attribute and op set_value suppport float64 numpy.array #30126
Conversation
Thanks for your contribution! |
✅ This PR's description meets the template requirements! |
eb908ce
to
f78a3e9
Compare
f78a3e9
to
b114d7a
Compare
…port float64 numpy.array
b114d7a
to
52b40d4
Compare
std::vector<double>* operator()(Attribute& attr) const { | ||
if (attr.type() == typeid(std::vector<int>)) { // NOLINT | ||
std::vector<int> val = BOOST_GET_CONST(std::vector<int>, attr); | ||
std::vector<double> vec(val.begin(), val.end()); |
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.
This code is inefficient because line 176 will construct vec
by iterating the vector and then attr = vec
will do an iterating copy.
Can you convert val
to attr
inplace so that it just iterates once?
Same as line 179 - line 181
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.
Thanks.
explicit ExtractAttribute(const std::string& attr_name) | ||
: attr_name_(attr_name) {} | ||
|
||
std::vector<double>* operator()(Attribute& attr) const { |
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.
Just knowledge, not your fault. Our C++ style requires the change-able input parameter attr
as a pointer, but I read the old code doesn't follow the style...
So you don have to change anything. It is just a kindly remind comment :-)
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.
Thanks a lot.
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.
LGTM
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.
LGTM for framework.py
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.
LGTM for boost::get
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.
LGTM
…et_value suppport vector<double> as value (PaddlePaddle#30126)
PR types
New features
PR changes
OPs
Describe
vector<float64>
as type of op attribute.set_value
suppportsfloat64
numpy.array