未验证 提交 cd00d9b4 编写于 作者: R Ruibiao Chen 提交者: GitHub

Remove boost::blank (#44028)

上级 c5dbcc8c
...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and ...@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */ limitations under the License. */
#include "paddle/fluid/framework/attribute.h" #include "paddle/fluid/framework/attribute.h"
#include "boost/blank.hpp" #include "paddle/utils/blank.h"
namespace paddle { namespace paddle {
namespace framework { namespace framework {
...@@ -118,7 +118,7 @@ Attribute GetAttrValue(const proto::OpDesc::Attr& attr_desc) { ...@@ -118,7 +118,7 @@ Attribute GetAttrValue(const proto::OpDesc::Attr& attr_desc) {
PADDLE_THROW(platform::errors::Unavailable("Unsupport attribute type %d.", PADDLE_THROW(platform::errors::Unavailable("Unsupport attribute type %d.",
attr_desc.type())); attr_desc.type()));
} }
return boost::blank(); return paddle::blank();
} }
} // namespace framework } // namespace framework
......
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
#include "paddle/fluid/framework/ir/generate_pass.h" #include "paddle/fluid/framework/ir/generate_pass.h"
#include "boost/blank.hpp"
#include "paddle/fluid/framework/ir/graph_pattern_detector.h" #include "paddle/fluid/framework/ir/graph_pattern_detector.h"
#include "paddle/utils/blank.h"
namespace paddle { namespace paddle {
namespace framework { namespace framework {
...@@ -40,7 +40,7 @@ class element_visitor : public boost::static_visitor<Attribute> { ...@@ -40,7 +40,7 @@ class element_visitor : public boost::static_visitor<Attribute> {
if (index >= 0 && static_cast<size_t>(index) < attr.size()) { if (index >= 0 && static_cast<size_t>(index) < attr.size()) {
return static_cast<ET>(attr[index]); return static_cast<ET>(attr[index]);
} }
return boost::blank(); return paddle::blank();
} }
private: private:
...@@ -99,7 +99,7 @@ Attribute GetVarAttrValue(const VarDesc* desc, ...@@ -99,7 +99,7 @@ Attribute GetVarAttrValue(const VarDesc* desc,
return shape; return shape;
} }
} }
return boost::blank(); return paddle::blank();
} }
Attribute GetOpAttrValue(const OpDesc* desc, Attribute GetOpAttrValue(const OpDesc* desc,
......
...@@ -16,7 +16,6 @@ limitations under the License. */ ...@@ -16,7 +16,6 @@ limitations under the License. */
#include <string> #include <string>
#include "boost/blank.hpp"
#include "glog/logging.h" #include "glog/logging.h"
#include "paddle/fluid/framework/block_desc.h" #include "paddle/fluid/framework/block_desc.h"
#include "paddle/fluid/framework/op_call_stack.h" #include "paddle/fluid/framework/op_call_stack.h"
...@@ -24,6 +23,7 @@ limitations under the License. */ ...@@ -24,6 +23,7 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h" #include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/shape_inference.h" #include "paddle/fluid/framework/shape_inference.h"
#include "paddle/fluid/framework/var_type_inference.h" #include "paddle/fluid/framework/var_type_inference.h"
#include "paddle/utils/blank.h"
namespace paddle { namespace paddle {
namespace framework { namespace framework {
...@@ -810,7 +810,7 @@ struct SetAttrDescVisitor : public boost::static_visitor<void> { ...@@ -810,7 +810,7 @@ struct SetAttrDescVisitor : public boost::static_visitor<void> {
VectorToRepeated(v, attr_->mutable_float64s()); VectorToRepeated(v, attr_->mutable_float64s());
} }
void operator()(boost::blank) const { void operator()(paddle::blank) const {
PADDLE_THROW(platform::errors::Unavailable( PADDLE_THROW(platform::errors::Unavailable(
"Unsupported calling method of SetAttrDescVisitor object for " "Unsupported calling method of SetAttrDescVisitor object for "
"`boosst::blank` type.")); "`boosst::blank` type."));
......
...@@ -22,9 +22,9 @@ limitations under the License. */ ...@@ -22,9 +22,9 @@ limitations under the License. */
#include <unordered_set> #include <unordered_set>
#include <vector> #include <vector>
#include "boost/blank.hpp"
#include "paddle/fluid/imperative/type_defs.h" #include "paddle/fluid/imperative/type_defs.h"
#include "paddle/fluid/platform/variant.h" #include "paddle/fluid/platform/variant.h"
#include "paddle/utils/blank.h"
#include "paddle/utils/small_vector.h" #include "paddle/utils/small_vector.h"
#include "paddle/utils/variant.h" #include "paddle/utils/variant.h"
...@@ -42,7 +42,7 @@ class InferNoNeedBufferVarsFN; ...@@ -42,7 +42,7 @@ class InferNoNeedBufferVarsFN;
using VariableNameMap = std::map<std::string, std::vector<std::string>>; using VariableNameMap = std::map<std::string, std::vector<std::string>>;
using VariableValueMap = std::map<std::string, std::vector<Variable*>>; using VariableValueMap = std::map<std::string, std::vector<Variable*>>;
using Attribute = paddle::variant<boost::blank, using Attribute = paddle::variant<paddle::blank,
int, int,
float, float,
std::string, std::string,
...@@ -59,7 +59,7 @@ using Attribute = paddle::variant<boost::blank, ...@@ -59,7 +59,7 @@ using Attribute = paddle::variant<boost::blank,
using AttributeMap = std::unordered_map<std::string, Attribute>; using AttributeMap = std::unordered_map<std::string, Attribute>;
#ifdef PADDLE_WITH_ASCEND_CL #ifdef PADDLE_WITH_ASCEND_CL
using NPUAttribute = paddle::variant<boost::blank, using NPUAttribute = paddle::variant<paddle::blank,
int, int,
float, float,
std::string, std::string,
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
#include <popart/optimizer.hpp> #include <popart/optimizer.hpp>
#include <popart/sgd.hpp> #include <popart/sgd.hpp>
#include "boost/blank.hpp" #include "paddle/utils/blank.h"
#include "paddle/fluid/framework/ir/graph_helper.h" #include "paddle/fluid/framework/ir/graph_helper.h"
#include "paddle/fluid/platform/device/ipu/ipu_names.h" #include "paddle/fluid/platform/device/ipu/ipu_names.h"
...@@ -75,9 +75,9 @@ struct CustomOpAttrVisitor : public boost::static_visitor<void> { ...@@ -75,9 +75,9 @@ struct CustomOpAttrVisitor : public boost::static_visitor<void> {
void operator()(const std::vector<double>& v) const { void operator()(const std::vector<double>& v) const {
attrs_->emplace(attr_name_, v); attrs_->emplace(attr_name_, v);
} }
void operator()(boost::blank) const { void operator()(paddle::blank) const {
PADDLE_THROW(platform::errors::Unavailable( 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.")); "custom operator attributes."));
} }
}; };
...@@ -124,7 +124,7 @@ struct ConstantOpAttrVisitor : public boost::static_visitor<void> { ...@@ -124,7 +124,7 @@ struct ConstantOpAttrVisitor : public boost::static_visitor<void> {
void operator()(BlockDesc* desc) const { RAISE_ERROR; } void operator()(BlockDesc* desc) const { RAISE_ERROR; }
void operator()(const std::vector<BlockDesc*>& v) const { RAISE_ERROR; } void operator()(const std::vector<BlockDesc*>& v) const { RAISE_ERROR; }
void operator()(int64_t 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 #undef RAISE_ERROR
}; };
......
...@@ -213,7 +213,7 @@ struct KernelFuncImpl<Return (*)(Args...), impl_fn> { ...@@ -213,7 +213,7 @@ struct KernelFuncImpl<Return (*)(Args...), impl_fn> {
PD_SPECIALIZE_ComputeCallHelper(const std::vector<std::string>&); PD_SPECIALIZE_ComputeCallHelper(const std::vector<std::string>&);
// TODO(chenweihang): support other attribute type if needed. // TODO(chenweihang): support other attribute type if needed.
// Why not support other attribute type here? // Why not support other attribute type here?
// - boost::blank, std::vector<bool> and std::vector<double> // - paddle::blank, std::vector<bool> and std::vector<double>
// are not used in op // are not used in op
// - BlockDesc* and std::vector<BlockDesc*> are used in framework // - BlockDesc* and std::vector<BlockDesc*> are used in framework
......
...@@ -14,13 +14,12 @@ limitations under the License. */ ...@@ -14,13 +14,12 @@ limitations under the License. */
#include "paddle/phi/core/enforce.h" #include "paddle/phi/core/enforce.h"
#include <boost/variant.hpp>
#include <map> #include <map>
#include <memory> #include <memory>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include "boost/blank.hpp" #include "paddle/utils/blank.h"
#include "paddle/utils/variant.h" #include "paddle/utils/variant.h"
namespace egr { namespace egr {
...@@ -29,7 +28,7 @@ class EagerVariable; ...@@ -29,7 +28,7 @@ class EagerVariable;
namespace paddle { namespace paddle {
namespace framework { namespace framework {
class BlockDesc; class BlockDesc;
using Attribute = paddle::variant<boost::blank, using Attribute = paddle::variant<paddle::blank,
int, int,
float, float,
std::string, std::string,
......
/* Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
// This file copy from boost/blank.hpp, boost version: 1.41.0
// Modified the following points:
// 1. modify namespace from boost to paddle
// 2. remove the depending boost header files
// 3. remove the type traits specializations
// 4. remove streaming support
//-----------------------------------------------------------------------------
// boost blank.hpp header file
// See http://www.boost.org for updates, documentation, and revision history.
//-----------------------------------------------------------------------------
//
// Copyright (c) 2003
// Eric Friedman
//
// Distributed under the Boost Software License, Version 1.0. (See
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#pragma once
namespace paddle {
struct blank {};
inline bool operator==(const blank&, const blank&) { return true; }
inline bool operator<=(const blank&, const blank&) { return true; }
inline bool operator>=(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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册