From cd00d9b40aa09612c0c623408c1d269d3555f618 Mon Sep 17 00:00:00 2001 From: Ruibiao Chen Date: Mon, 4 Jul 2022 11:07:46 +0800 Subject: [PATCH] Remove boost::blank (#44028) --- paddle/fluid/framework/attribute.cc | 4 +- paddle/fluid/framework/ir/generate_pass.cc | 6 +-- paddle/fluid/framework/op_desc.cc | 4 +- paddle/fluid/framework/type_defs.h | 6 +-- .../fluid/platform/device/ipu/ipu_compiler.cc | 8 +-- paddle/phi/api/ext/op_meta_info.h | 2 +- paddle/phi/core/enforce.cc | 5 +- paddle/utils/blank.h | 52 +++++++++++++++++++ 8 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 paddle/utils/blank.h diff --git a/paddle/fluid/framework/attribute.cc b/paddle/fluid/framework/attribute.cc index ed50d5f6bfc..a2d0f2db282 100644 --- a/paddle/fluid/framework/attribute.cc +++ b/paddle/fluid/framework/attribute.cc @@ -13,7 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "paddle/fluid/framework/attribute.h" -#include "boost/blank.hpp" +#include "paddle/utils/blank.h" namespace paddle { namespace framework { @@ -118,7 +118,7 @@ Attribute GetAttrValue(const proto::OpDesc::Attr& attr_desc) { PADDLE_THROW(platform::errors::Unavailable("Unsupport attribute type %d.", attr_desc.type())); } - return boost::blank(); + return paddle::blank(); } } // namespace framework diff --git a/paddle/fluid/framework/ir/generate_pass.cc b/paddle/fluid/framework/ir/generate_pass.cc index 83c3ab9933d..160304784a9 100644 --- a/paddle/fluid/framework/ir/generate_pass.cc +++ b/paddle/fluid/framework/ir/generate_pass.cc @@ -14,8 +14,8 @@ #include "paddle/fluid/framework/ir/generate_pass.h" -#include "boost/blank.hpp" #include "paddle/fluid/framework/ir/graph_pattern_detector.h" +#include "paddle/utils/blank.h" namespace paddle { namespace framework { @@ -40,7 +40,7 @@ class element_visitor : public boost::static_visitor { if (index >= 0 && static_cast(index) < attr.size()) { return static_cast(attr[index]); } - return boost::blank(); + return paddle::blank(); } private: @@ -99,7 +99,7 @@ Attribute GetVarAttrValue(const VarDesc* desc, return shape; } } - return boost::blank(); + return paddle::blank(); } Attribute GetOpAttrValue(const OpDesc* desc, diff --git a/paddle/fluid/framework/op_desc.cc b/paddle/fluid/framework/op_desc.cc index c8a9950ae5e..169722b971b 100644 --- a/paddle/fluid/framework/op_desc.cc +++ b/paddle/fluid/framework/op_desc.cc @@ -16,7 +16,6 @@ limitations under the License. */ #include -#include "boost/blank.hpp" #include "glog/logging.h" #include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/op_call_stack.h" @@ -24,6 +23,7 @@ limitations under the License. */ #include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/shape_inference.h" #include "paddle/fluid/framework/var_type_inference.h" +#include "paddle/utils/blank.h" namespace paddle { namespace framework { @@ -810,7 +810,7 @@ struct SetAttrDescVisitor : public boost::static_visitor { VectorToRepeated(v, attr_->mutable_float64s()); } - void operator()(boost::blank) const { + void operator()(paddle::blank) const { PADDLE_THROW(platform::errors::Unavailable( "Unsupported calling method of SetAttrDescVisitor object for " "`boosst::blank` type.")); diff --git a/paddle/fluid/framework/type_defs.h b/paddle/fluid/framework/type_defs.h index ca9d6ec44a8..5c768b10a3d 100644 --- a/paddle/fluid/framework/type_defs.h +++ b/paddle/fluid/framework/type_defs.h @@ -22,9 +22,9 @@ limitations under the License. */ #include #include -#include "boost/blank.hpp" #include "paddle/fluid/imperative/type_defs.h" #include "paddle/fluid/platform/variant.h" +#include "paddle/utils/blank.h" #include "paddle/utils/small_vector.h" #include "paddle/utils/variant.h" @@ -42,7 +42,7 @@ class InferNoNeedBufferVarsFN; using VariableNameMap = std::map>; using VariableValueMap = std::map>; -using Attribute = paddle::variant; #ifdef PADDLE_WITH_ASCEND_CL -using NPUAttribute = paddle::variant #include -#include "boost/blank.hpp" +#include "paddle/utils/blank.h" #include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/platform/device/ipu/ipu_names.h" @@ -75,9 +75,9 @@ struct CustomOpAttrVisitor : public boost::static_visitor { void operator()(const std::vector& v) const { attrs_->emplace(attr_name_, v); } - void operator()(boost::blank) const { + void operator()(paddle::blank) const { PADDLE_THROW(platform::errors::Unavailable( - "Unsupported calling method for `boost::blank` type when extracting " + "Unsupported calling method for `paddle::blank` type when extracting " "custom operator attributes.")); } }; @@ -124,7 +124,7 @@ struct ConstantOpAttrVisitor : public boost::static_visitor { void operator()(BlockDesc* desc) const { RAISE_ERROR; } void operator()(const std::vector& v) const { RAISE_ERROR; } void operator()(int64_t v) const { RAISE_ERROR; } - void operator()(boost::blank) const { RAISE_ERROR; } + void operator()(paddle::blank) const { RAISE_ERROR; } #undef RAISE_ERROR }; diff --git a/paddle/phi/api/ext/op_meta_info.h b/paddle/phi/api/ext/op_meta_info.h index fa19714dde7..546b0accf8b 100644 --- a/paddle/phi/api/ext/op_meta_info.h +++ b/paddle/phi/api/ext/op_meta_info.h @@ -213,7 +213,7 @@ struct KernelFuncImpl { PD_SPECIALIZE_ComputeCallHelper(const std::vector&); // TODO(chenweihang): support other attribute type if needed. // Why not support other attribute type here? - // - boost::blank, std::vector and std::vector + // - paddle::blank, std::vector and std::vector // are not used in op // - BlockDesc* and std::vector are used in framework diff --git a/paddle/phi/core/enforce.cc b/paddle/phi/core/enforce.cc index 0dd415d1313..8074fbeb491 100644 --- a/paddle/phi/core/enforce.cc +++ b/paddle/phi/core/enforce.cc @@ -14,13 +14,12 @@ limitations under the License. */ #include "paddle/phi/core/enforce.h" -#include #include #include #include #include -#include "boost/blank.hpp" +#include "paddle/utils/blank.h" #include "paddle/utils/variant.h" namespace egr { @@ -29,7 +28,7 @@ class EagerVariable; namespace paddle { namespace framework { class BlockDesc; -using Attribute = paddle::variant=(const blank&, const blank&) { return true; } + +inline bool operator!=(const blank&, const blank&) { return false; } + +inline bool operator<(const blank&, const blank&) { return false; } + +inline bool operator>(const blank&, const blank&) { return false; } + +} // namespace paddle -- GitLab