Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
01fedf4f
P
Paddle
项目概览
Crayon鑫
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
01fedf4f
编写于
7月 04, 2022
作者:
R
Ruibiao Chen
提交者:
GitHub
7月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove boost::static_visitor (#44024)
上级
cd00d9b4
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
37 addition
and
55 deletion
+37
-55
paddle/fluid/framework/dlpack_tensor.cc
paddle/fluid/framework/dlpack_tensor.cc
+2
-1
paddle/fluid/framework/ir/generate_pass.cc
paddle/fluid/framework/ir/generate_pass.cc
+2
-2
paddle/fluid/framework/op_desc.cc
paddle/fluid/framework/op_desc.cc
+1
-1
paddle/fluid/framework/tensor_util.cc
paddle/fluid/framework/tensor_util.cc
+4
-4
paddle/fluid/imperative/gradient_accumulator.cc
paddle/fluid/imperative/gradient_accumulator.cc
+2
-1
paddle/fluid/memory/allocation/naive_best_fit_allocator.cc
paddle/fluid/memory/allocation/naive_best_fit_allocator.cc
+4
-4
paddle/fluid/operators/array_to_lod_tensor_op.cc
paddle/fluid/operators/array_to_lod_tensor_op.cc
+1
-1
paddle/fluid/operators/controlflow/feed_op.cc
paddle/fluid/operators/controlflow/feed_op.cc
+1
-1
paddle/fluid/operators/controlflow/op_variant.cc
paddle/fluid/operators/controlflow/op_variant.cc
+4
-7
paddle/fluid/operators/lod_tensor_to_array_op.cc
paddle/fluid/operators/lod_tensor_to_array_op.cc
+2
-1
paddle/fluid/operators/math/matrix_bit_code.cc
paddle/fluid/operators/math/matrix_bit_code.cc
+8
-9
paddle/fluid/platform/device/ipu/ipu_compiler.cc
paddle/fluid/platform/device/ipu/ipu_compiler.cc
+2
-2
paddle/fluid/platform/variant.h
paddle/fluid/platform/variant.h
+0
-1
paddle/fluid/pybind/global_value_getter_setter.cc
paddle/fluid/pybind/global_value_getter_setter.cc
+1
-1
paddle/fluid/pybind/pybind_boost_headers.h
paddle/fluid/pybind/pybind_boost_headers.h
+1
-18
paddle/phi/kernels/funcs/math_function.cc
paddle/phi/kernels/funcs/math_function.cc
+2
-1
未找到文件。
paddle/fluid/framework/dlpack_tensor.cc
浏览文件 @
01fedf4f
...
...
@@ -69,7 +69,8 @@ static DLDataType GetDLDataTypeFromTypeIndex(proto::VarType::Type type) {
#undef REG_DL_DATA_TYPE
}
struct
DLDeviceVisitor
:
public
boost
::
static_visitor
<::
DLDevice
>
{
struct
DLDeviceVisitor
:
public
std
::
unary_function
<
const
platform
::
Place
&
,
::
DLDevice
>
{
inline
::
DLDevice
operator
()(
const
platform
::
CPUPlace
&
place
)
const
{
::
DLDevice
device
;
device
.
device_type
=
kDLCPU
;
...
...
paddle/fluid/framework/ir/generate_pass.cc
浏览文件 @
01fedf4f
...
...
@@ -21,7 +21,7 @@ namespace paddle {
namespace
framework
{
namespace
ir
{
class
element_visitor
:
public
boost
::
static_visitor
<
Attribute
>
{
class
element_visitor
{
public:
explicit
element_visitor
(
int
index
)
:
index_
(
index
)
{}
...
...
@@ -47,7 +47,7 @@ class element_visitor : public boost::static_visitor<Attribute> {
int
index_
;
};
class
operation_visitor
:
public
boost
::
static_visitor
<
Attribute
>
{
class
operation_visitor
{
public:
explicit
operation_visitor
(
const
proto
::
PassDesc
::
OperationType
&
type
)
:
type_
(
type
)
{}
...
...
paddle/fluid/framework/op_desc.cc
浏览文件 @
01fedf4f
...
...
@@ -764,7 +764,7 @@ void OpDesc::RenameInput(const std::string &old_name,
need_update_
=
true
;
}
struct
SetAttrDescVisitor
:
public
boost
::
static_visitor
<
void
>
{
struct
SetAttrDescVisitor
{
explicit
SetAttrDescVisitor
(
proto
::
OpDesc
::
Attr
*
attr
)
:
attr_
(
attr
)
{}
mutable
proto
::
OpDesc
::
Attr
*
attr_
;
void
operator
()(
int
v
)
const
{
attr_
->
set_i
(
v
);
}
...
...
paddle/fluid/framework/tensor_util.cc
浏览文件 @
01fedf4f
...
...
@@ -689,7 +689,7 @@ inline void AnyImpl(Predicate predicate,
}
template
<
typename
Predicate
>
class
AnyVisitor
:
public
boost
::
static_visitor
<
bool
>
{
class
AnyVisitor
:
public
std
::
unary_function
<
const
Place
&
,
bool
>
{
private:
const
framework
::
Tensor
&
tensor_
;
Predicate
predicate_
;
...
...
@@ -774,7 +774,7 @@ class AnyVisitor : public boost::static_visitor<bool> {
};
template
<
typename
Predicate
>
class
AnyOutVisitor
:
public
boost
::
static_visitor
<
>
{
class
AnyOutVisitor
:
public
std
::
unary_function
<
const
Place
&
,
void
>
{
private:
const
framework
::
Tensor
&
tensor_
;
mutable
framework
::
Tensor
*
out_
;
...
...
@@ -843,7 +843,7 @@ inline void AllImpl(Predicate predicate,
}
template
<
typename
Predicate
>
class
AllOutVisitor
:
public
boost
::
static_visitor
<
>
{
class
AllOutVisitor
:
public
std
::
unary_function
<
const
Place
&
,
void
>
{
private:
const
framework
::
Tensor
&
tensor_
;
mutable
framework
::
Tensor
*
out_
;
...
...
@@ -942,7 +942,7 @@ static inline void __global__ BothFalse(const T* cmp, T* out, int element_num) {
}
#endif
struct
BothFalseVisitor
:
public
boost
::
static_visitor
<
>
{
struct
BothFalseVisitor
:
public
std
::
unary_function
<
const
Place
&
,
void
>
{
const
framework
::
Tensor
&
in_
;
mutable
framework
::
Tensor
*
out_
;
BothFalseVisitor
(
const
framework
::
Tensor
&
in
,
framework
::
Tensor
*
out
)
...
...
paddle/fluid/imperative/gradient_accumulator.cc
浏览文件 @
01fedf4f
...
...
@@ -79,7 +79,8 @@ static void MoveOrCopyVar(framework::Variable* dst,
}
template
<
typename
T
>
class
TensorAddFunctor
:
public
boost
::
static_visitor
<>
{
class
TensorAddFunctor
:
public
std
::
unary_function
<
const
platform
::
Place
&
,
void
>
{
public:
TensorAddFunctor
(
int64_t
numel
,
const
T
*
x
,
T
*
y
)
:
numel_
(
numel
),
x_
(
x
),
y_
(
y
)
{}
...
...
paddle/fluid/memory/allocation/naive_best_fit_allocator.cc
浏览文件 @
01fedf4f
...
...
@@ -59,7 +59,7 @@ uint64_t Release(const Place &place);
template
<
typename
Place
>
size_t
Used
(
const
Place
&
place
);
struct
Usage
:
public
boost
::
static_visitor
<
size_t
>
{
struct
Usage
{
size_t
operator
()(
const
platform
::
CPUPlace
&
cpu
)
const
;
size_t
operator
()(
const
platform
::
CUDAPlace
&
gpu
)
const
;
size_t
operator
()(
const
platform
::
CUDAPinnedPlace
&
cuda_pinned
)
const
;
...
...
@@ -894,7 +894,7 @@ size_t Used<platform::CustomPlace>(const platform::CustomPlace &place) {
#endif
}
struct
AllocVisitor
:
public
boost
::
static_visitor
<
void
*>
{
struct
AllocVisitor
:
std
::
unary_function
<
const
Place
,
void
*>
{
inline
explicit
AllocVisitor
(
size_t
size
)
:
size_
(
size
)
{}
template
<
typename
Place
>
...
...
@@ -906,7 +906,7 @@ struct AllocVisitor : public boost::static_visitor<void *> {
size_t
size_
;
};
struct
FreeVisitor
:
public
boost
::
static_visitor
<
void
>
{
struct
FreeVisitor
:
public
std
::
unary_function
<
const
Place
,
void
>
{
inline
explicit
FreeVisitor
(
void
*
ptr
,
size_t
size
)
:
ptr_
(
ptr
),
size_
(
size
)
{}
...
...
@@ -920,7 +920,7 @@ struct FreeVisitor : public boost::static_visitor<void> {
size_t
size_
;
};
struct
ReleaseVisitor
:
public
boost
::
static_visitor
<
uint64_t
>
{
struct
ReleaseVisitor
:
std
::
unary_function
<
const
Place
,
uint64_t
>
{
template
<
typename
Place
>
inline
uint64_t
operator
()(
const
Place
&
place
)
const
{
return
Release
<
Place
>
(
place
);
...
...
paddle/fluid/operators/array_to_lod_tensor_op.cc
浏览文件 @
01fedf4f
...
...
@@ -43,7 +43,7 @@ struct ArrayToLoDFunctorImpl {
void
apply
();
};
struct
ArrayToLoDFunctor
:
public
boost
::
static_visitor
<
void
>
{
struct
ArrayToLoDFunctor
:
public
std
::
unary_function
<
platform
::
Place
,
void
>
{
std
::
vector
<
framework
::
Tensor
>
in
;
mutable
framework
::
Tensor
*
out
;
...
...
paddle/fluid/operators/controlflow/feed_op.cc
浏览文件 @
01fedf4f
...
...
@@ -29,7 +29,7 @@ namespace operators {
// FeedVariableVisitor is to feed the variable data
// according to data type (LoDTensor or Strings).
class
FeedVariableVisitor
:
public
boost
::
static_visitor
<
void
>
{
class
FeedVariableVisitor
{
public:
explicit
FeedVariableVisitor
(
framework
::
Variable
*
out_var
,
const
platform
::
Place
&
place
)
...
...
paddle/fluid/operators/controlflow/op_variant.cc
浏览文件 @
01fedf4f
...
...
@@ -17,24 +17,21 @@
namespace
paddle
{
namespace
operators
{
struct
InputsVisitor
:
public
boost
::
static_visitor
<
const
framework
::
VariableNameMap
*>
{
struct
InputsVisitor
{
template
<
typename
OpType
>
const
framework
::
VariableNameMap
*
operator
()(
const
OpType
*
op
)
const
{
return
&
(
op
->
Inputs
());
}
};
struct
OutputsVisitor
:
public
boost
::
static_visitor
<
const
framework
::
VariableNameMap
*>
{
struct
OutputsVisitor
{
template
<
typename
OpType
>
const
framework
::
VariableNameMap
*
operator
()(
const
OpType
*
op
)
const
{
return
&
(
op
->
Outputs
());
}
};
struct
AttributeMapVisitor
:
public
boost
::
static_visitor
<
const
framework
::
AttributeMap
*>
{
struct
AttributeMapVisitor
{
const
framework
::
AttributeMap
*
operator
()(
const
framework
::
OpDesc
*
op
)
const
{
return
&
(
op
->
GetAttrMap
());
}
...
...
@@ -45,7 +42,7 @@ struct AttributeMapVisitor
}
};
struct
RawPointerVisitor
:
public
boost
::
static_visitor
<
const
void
*>
{
struct
RawPointerVisitor
{
template
<
typename
OpType
>
const
void
*
operator
()(
const
OpType
*
op
)
const
{
return
op
;
...
...
paddle/fluid/operators/lod_tensor_to_array_op.cc
浏览文件 @
01fedf4f
...
...
@@ -44,7 +44,8 @@ struct LoDTensorToArrayFunctorImpl {
void
apply
();
};
struct
LoDTensorToArrayFunctor
:
public
boost
::
static_visitor
<
void
>
{
struct
LoDTensorToArrayFunctor
:
public
std
::
unary_function
<
platform
::
Place
,
void
>
{
std
::
vector
<
const
framework
::
Tensor
*>
ref_inputs_
;
mutable
std
::
vector
<
framework
::
Tensor
*>
outputs_
;
const
framework
::
Tensor
&
input_
;
...
...
paddle/fluid/operators/math/matrix_bit_code.cc
浏览文件 @
01fedf4f
...
...
@@ -19,7 +19,7 @@ namespace operators {
namespace
math
{
template
<
typename
T
>
struct
MatrixBitCodeFunctorAdd
:
public
boost
::
static_visitor
<
void
>
{
struct
MatrixBitCodeFunctorAdd
{
const
framework
::
Tensor
&
vec_
;
framework
::
Tensor
*
tmat_
;
...
...
@@ -51,7 +51,7 @@ void MatrixBitCodeFunctor<T>::Add(const framework::Tensor &vec,
}
template
<
typename
T
>
struct
MatrixBitCodeFunctorAddGrad
:
public
boost
::
static_visitor
<
void
>
{
struct
MatrixBitCodeFunctorAddGrad
{
const
framework
::
Tensor
&
tmat_
;
framework
::
Tensor
*
vec_
;
MatrixBitCodeFunctorAddGrad
(
const
framework
::
Tensor
&
tmat
,
...
...
@@ -83,7 +83,7 @@ void MatrixBitCodeFunctor<T>::AddGrad(const framework::Tensor &tmat,
}
template
<
typename
T
>
struct
MatrixBitCodeFunctorSum
:
public
boost
::
static_visitor
<
void
>
{
struct
MatrixBitCodeFunctorSum
{
const
framework
::
Tensor
&
tmat_
;
framework
::
Tensor
*
sum_
;
T
scale_sum_
;
...
...
@@ -125,7 +125,7 @@ void MatrixBitCodeFunctor<T>::Sum(const framework::Tensor &tmat,
}
template
<
typename
T
>
struct
MatrixBitCodeFunctorMul
:
public
boost
::
static_visitor
<
void
>
{
struct
MatrixBitCodeFunctorMul
{
framework
::
Tensor
*
tmat_
;
const
framework
::
Tensor
&
weight_
;
const
framework
::
Tensor
&
input_
;
...
...
@@ -174,7 +174,7 @@ class ReservedVector : public std::vector<T> {
};
template
<
typename
T
>
struct
MatrixBitCodeFunctorMulGradWeight
:
public
boost
::
static_visitor
<
void
>
{
struct
MatrixBitCodeFunctorMulGradWeight
{
const
framework
::
Tensor
&
tmat_
;
framework
::
Tensor
*
weight_
;
const
framework
::
Tensor
&
input_
;
...
...
@@ -224,8 +224,7 @@ void MatrixBitCodeFunctor<T>::MulGradWeight(const framework::Tensor &tmat,
}
template
<
typename
T
>
struct
MatrixBitCodeFunctorMulGradWeightSR
:
public
boost
::
static_visitor
<
void
>
{
struct
MatrixBitCodeFunctorMulGradWeightSR
{
const
framework
::
Tensor
&
tmat_
;
phi
::
SelectedRows
*
weight_
;
const
framework
::
Tensor
&
input_
;
...
...
@@ -280,7 +279,7 @@ void MatrixBitCodeFunctor<T>::MulGradWeight(const framework::Tensor &tmat,
}
template
<
typename
T
>
struct
MatrixBitCodeFunctorMulGradError
:
public
boost
::
static_visitor
<
void
>
{
struct
MatrixBitCodeFunctorMulGradError
{
const
framework
::
Tensor
&
tmat_
;
const
framework
::
Tensor
&
weight_
;
framework
::
Tensor
*
input_
;
...
...
@@ -324,7 +323,7 @@ void MatrixBitCodeFunctor<T>::MulGradError(const framework::Tensor &tmat,
}
template
<
typename
T
>
struct
MatrixBitCodeFunctorSub
:
public
boost
::
static_visitor
<
void
>
{
struct
MatrixBitCodeFunctorSub
{
framework
::
Tensor
*
tmat_
;
explicit
MatrixBitCodeFunctorSub
(
framework
::
Tensor
*
tmat
)
:
tmat_
(
tmat
)
{}
...
...
paddle/fluid/platform/device/ipu/ipu_compiler.cc
浏览文件 @
01fedf4f
...
...
@@ -32,7 +32,7 @@ namespace ipu {
namespace
{
struct
CustomOpAttrVisitor
:
public
boost
::
static_visitor
<
void
>
{
struct
CustomOpAttrVisitor
{
CustomOpAttrVisitor
(
std
::
map
<
std
::
string
,
popart
::
any
>*
attr
,
const
std
::
string
&
attr_name
)
:
attrs_
(
attr
),
attr_name_
(
attr_name
)
{}
...
...
@@ -82,7 +82,7 @@ struct CustomOpAttrVisitor : public boost::static_visitor<void> {
}
};
struct
ConstantOpAttrVisitor
:
public
boost
::
static_visitor
<
void
>
{
struct
ConstantOpAttrVisitor
{
ConstantOpAttrVisitor
(
framework
::
LoDTensor
*
tensor
,
VarType
::
Type
dtype
)
:
tensor_
(
tensor
),
dtype_
(
dtype
)
{}
...
...
paddle/fluid/platform/variant.h
浏览文件 @
01fedf4f
...
...
@@ -40,7 +40,6 @@ limitations under the License. */
#include <boost/mpl/comparison.hpp>
#include <boost/mpl/less_equal.hpp>
#include <boost/variant.hpp>
#include "paddle/utils/any.h"
#include "paddle/utils/optional.h"
...
...
paddle/fluid/pybind/global_value_getter_setter.cc
浏览文件 @
01fedf4f
...
...
@@ -217,7 +217,7 @@ void BindGlobalValueGetterSetter(pybind11::module *module) {
GlobalVarGetterSetterRegistry::CreateSetter(&var)); \
} while (0)
struct
RegisterGetterSetterVisitor
:
public
boost
::
static_visitor
<
void
>
{
struct
RegisterGetterSetterVisitor
{
RegisterGetterSetterVisitor
(
const
std
::
string
&
name
,
bool
is_writable
,
void
*
value_ptr
)
...
...
paddle/fluid/pybind/pybind_boost_headers.h
浏览文件 @
01fedf4f
...
...
@@ -18,14 +18,12 @@ limitations under the License. */
#include <vector>
#include "glog/logging.h"
#include "paddle/fluid/platform/variant.h"
#include "paddle/utils/variant.h"
#include "pybind11/numpy.h"
#include "pybind11/pybind11.h"
#include "pybind11/stl.h"
// Cast paddle::variant for PyBind.
// Copy from
// https://github.com/pybind/pybind11/issues/576#issuecomment-269563199
namespace
pybind11
{
namespace
detail
{
...
...
@@ -78,10 +76,7 @@ struct paddle_variant_caster<V<Ts...>> {
using
Type
=
V
<
Ts
...
>
;
template
<
typename
T
>
typename
std
::
enable_if
<
!
std
::
is_same
<
T
,
boost
::
detail
::
variant
::
void_
>::
value
,
bool
>::
type
try_load
(
handle
src
,
bool
convert
)
{
bool
try_load
(
handle
src
,
bool
convert
)
{
auto
caster
=
make_caster
<
T
>
();
if
(
!
load_success_
&&
caster
.
load
(
src
,
convert
))
{
load_success_
=
true
;
...
...
@@ -112,13 +107,6 @@ struct paddle_variant_caster<V<Ts...>> {
return
false
;
}
template
<
typename
T
>
typename
std
::
enable_if
<
std
::
is_same
<
T
,
boost
::
detail
::
variant
::
void_
>::
value
,
bool
>::
type
try_load
(
handle
src
,
bool
convert
)
{
return
false
;
}
bool
load
(
handle
src
,
bool
convert
)
{
auto
unused
=
{
false
,
try_load
<
Ts
>
(
src
,
convert
)...};
(
void
)(
unused
);
...
...
@@ -128,11 +116,6 @@ struct paddle_variant_caster<V<Ts...>> {
static
handle
cast
(
Type
const
&
src
,
return_value_policy
policy
,
handle
parent
)
{
/*
auto paddle_variant_caster_visitor = [&](Type const& src)->handle {
return make_caster<Type>::cast(src, policy, parent);
}
*/
paddle_variant_caster_visitor
visitor
(
policy
,
parent
);
return
paddle
::
visit
(
visitor
,
src
);
}
...
...
paddle/phi/kernels/funcs/math_function.cc
浏览文件 @
01fedf4f
...
...
@@ -214,7 +214,8 @@ void set_constant_with_place<paddle::platform::CUDAPinnedPlace>(
phi
::
VisitDataType
(
tensor
->
dtype
(),
TensorSetConstantCPU
(
tensor
,
value
));
}
struct
TensorSetConstantWithPlace
:
public
boost
::
static_visitor
<
void
>
{
struct
TensorSetConstantWithPlace
:
public
std
::
unary_function
<
paddle
::
platform
::
Place
,
void
>
{
TensorSetConstantWithPlace
(
const
paddle
::
platform
::
DeviceContext
&
context
,
paddle
::
framework
::
Tensor
*
tensor
,
float
value
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录