diff --git a/paddle/pybind/protobuf.cc b/paddle/pybind/protobuf.cc index 23c322ac3651fa3668a55bd1e2f6010ec24e2da6..3b2ac68714a4d8311cfac27514d3d34985fb6bb7 100644 --- a/paddle/pybind/protobuf.cc +++ b/paddle/pybind/protobuf.cc @@ -128,10 +128,24 @@ public: struct SetAttrDescVisitor : public boost::static_visitor { explicit SetAttrDescVisitor(OpDesc::Attr *attr) : attr_(attr) {} - OpDesc::Attr *attr_; - void operator()(int v) { attr_->set_i(v); } - void operator()(float v) { attr_->set_f(v); } - void operator()(const std::string &v) { attr_->set_s(v); } + mutable OpDesc::Attr *attr_; + void operator()(int v) const { attr_->set_i(v); } + void operator()(float v) const { attr_->set_f(v); } + void operator()(const std::string &v) const { attr_->set_s(v); } + void operator()(bool b) const { attr_->set_b(b); } + + void operator()(const std::vector &v) const { + VectorToRepeated(v, attr_->mutable_ints()); + } + void operator()(const std::vector &v) const { + VectorToRepeated(v, attr_->mutable_floats()); + } + void operator()(const std::vector &v) const { + VectorToRepeated(v, attr_->mutable_strings()); + } + void operator()(const std::vector &v) const { + VectorToRepeated(v, attr_->mutable_bools()); + } }; void Sync() {