Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
1f94081d
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
1f94081d
编写于
8月 21, 2023
作者:
L
LiYuRio
提交者:
GitHub
8月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove namespace for dist attr and process mesh (#56449)
上级
95c4bb41
变更
18
显示空白变更内容
内联
并排
Showing
18 changed file
with
39 addition
and
56 deletion
+39
-56
paddle/fluid/distributed/auto_parallel/dist_attr.h
paddle/fluid/distributed/auto_parallel/dist_attr.h
+4
-2
paddle/fluid/distributed/auto_parallel/spmd_rules/dist_tensor_spec.h
...d/distributed/auto_parallel/spmd_rules/dist_tensor_spec.h
+3
-3
paddle/fluid/eager/grad_tensor_holder.cc
paddle/fluid/eager/grad_tensor_holder.cc
+1
-2
paddle/fluid/framework/var_desc.h
paddle/fluid/framework/var_desc.h
+1
-1
paddle/fluid/pybind/auto_parallel_py.cc
paddle/fluid/pybind/auto_parallel_py.cc
+3
-3
paddle/fluid/pybind/eager.cc
paddle/fluid/pybind/eager.cc
+3
-3
paddle/fluid/pybind/eager_utils.cc
paddle/fluid/pybind/eager_utils.cc
+2
-3
paddle/fluid/pybind/eager_utils.h
paddle/fluid/pybind/eager_utils.h
+3
-4
paddle/fluid/pybind/protobuf.cc
paddle/fluid/pybind/protobuf.cc
+1
-1
paddle/phi/api/lib/api_gen_utils.cc
paddle/phi/api/lib/api_gen_utils.cc
+1
-2
paddle/phi/core/distributed/auto_parallel/dist_attr.cc
paddle/phi/core/distributed/auto_parallel/dist_attr.cc
+2
-2
paddle/phi/core/distributed/auto_parallel/dist_attr.h
paddle/phi/core/distributed/auto_parallel/dist_attr.h
+2
-6
paddle/phi/core/distributed/auto_parallel/dist_tensor.h
paddle/phi/core/distributed/auto_parallel/dist_tensor.h
+0
-4
paddle/phi/core/distributed/auto_parallel/process_mesh.cc
paddle/phi/core/distributed/auto_parallel/process_mesh.cc
+6
-3
paddle/phi/core/distributed/auto_parallel/process_mesh.h
paddle/phi/core/distributed/auto_parallel/process_mesh.h
+3
-5
paddle/phi/core/distributed/auto_parallel/reshard_function.h
paddle/phi/core/distributed/auto_parallel/reshard_function.h
+1
-4
paddle/phi/core/distributed/auto_parallel/reshard_utils.h
paddle/phi/core/distributed/auto_parallel/reshard_utils.h
+0
-6
test/cpp/auto_parallel/dist_attr_test.cc
test/cpp/auto_parallel/dist_attr_test.cc
+3
-2
未找到文件。
paddle/fluid/distributed/auto_parallel/dist_attr.h
浏览文件 @
1f94081d
...
...
@@ -40,6 +40,10 @@ class VarDesc;
}
// namespace framework
namespace
distributed
{
using
phi
::
distributed
::
ProcessMesh
;
using
phi
::
distributed
::
TensorDistAttr
;
namespace
auto_parallel
{
using
framework
::
BlockDesc
;
...
...
@@ -48,8 +52,6 @@ using framework::ProgramDesc;
using
framework
::
VarDesc
;
using
phi
::
distributed
::
auto_parallel
::
OperatorDistAttrProto
;
using
phi
::
distributed
::
auto_parallel
::
ProcessMesh
;
using
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
;
constexpr
const
char
*
kDefault
=
"default"
;
...
...
paddle/fluid/distributed/auto_parallel/spmd_rules/dist_tensor_spec.h
浏览文件 @
1f94081d
...
...
@@ -19,10 +19,10 @@ limitations under the License. */
namespace
paddle
{
namespace
distributed
{
namespace
auto_parallel
{
using
phi
::
distributed
::
ProcessMesh
;
using
phi
::
distributed
::
TensorDistAttr
;
using
phi
::
distributed
::
auto_parallel
::
ProcessMesh
;
using
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
;
namespace
auto_parallel
{
/**
* A unified data class for inferring distributed attributes
...
...
paddle/fluid/eager/grad_tensor_holder.cc
浏览文件 @
1f94081d
...
...
@@ -99,8 +99,7 @@ void GradTensorHolder::CopyValueFromTensor(size_t slot_id,
auto
dist_tensor
=
std
::
make_shared
<
phi
::
distributed
::
DistTensor
>
(
dense_temp
,
dense_temp
->
meta
(),
std
::
make_shared
<
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
>
());
std
::
make_shared
<
phi
::
distributed
::
TensorDistAttr
>
());
temp
.
set_impl
(
dist_tensor
);
buffer_
[
slot_id
][
rank
]
=
temp
;
#endif
...
...
paddle/fluid/framework/var_desc.h
浏览文件 @
1f94081d
...
...
@@ -28,7 +28,7 @@ limitations under the License. */
namespace
paddle
{
namespace
framework
{
using
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
;
using
phi
::
distributed
::
TensorDistAttr
;
// convert between std::vector and protobuf repeated.
template
<
typename
T
>
...
...
paddle/fluid/pybind/auto_parallel_py.cc
浏览文件 @
1f94081d
...
...
@@ -40,21 +40,21 @@ namespace paddle {
namespace
pybind
{
using
paddle
::
distributed
::
auto_parallel
::
DistTensorSpec
;
using
paddle
::
distributed
::
auto_parallel
::
kDefault
;
using
paddle
::
distributed
::
auto_parallel
::
OperatorDistAttr
;
using
paddle
::
distributed
::
auto_parallel
::
SPMDRuleBase
;
using
paddle
::
distributed
::
auto_parallel
::
SPMDRuleMap
;
using
paddle
::
framework
::
OpDesc
;
using
paddle
::
framework
::
VarDesc
;
using
phi
::
distributed
::
ProcessMesh
;
using
phi
::
distributed
::
TensorDistAttr
;
using
phi
::
distributed
::
auto_parallel
::
Device
;
using
phi
::
distributed
::
auto_parallel
::
DeviceCapability
;
using
phi
::
distributed
::
auto_parallel
::
DeviceMesh
;
using
phi
::
distributed
::
auto_parallel
::
DistributedMapper
;
using
phi
::
distributed
::
auto_parallel
::
kDefault
;
using
phi
::
distributed
::
auto_parallel
::
Link
;
using
phi
::
distributed
::
auto_parallel
::
LinkCapability
;
using
phi
::
distributed
::
auto_parallel
::
Machine
;
using
phi
::
distributed
::
auto_parallel
::
ProcessMesh
;
using
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
;
PyTypeObject
*
g_tensor_dist_attr_pytype
=
nullptr
;
...
...
paddle/fluid/pybind/eager.cc
浏览文件 @
1f94081d
...
...
@@ -46,7 +46,7 @@ limitations under the License. */
#include "paddle/phi/core/distributed/auto_parallel/dist_attr.h"
#include "paddle/phi/core/distributed/auto_parallel/dist_tensor.h"
using
phi
::
distributed
::
DistTensor
;
using
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
;
using
phi
::
distributed
::
TensorDistAttr
;
#endif
namespace
paddle
{
...
...
@@ -737,7 +737,7 @@ Tensor is the basic data structure in PaddlePaddle. There are some ways to creat
* ** zero_copy: bool,
* ** name: std::string,
* ** stop_gradient: bool,
* ** dist_attr: phi::distributed::
auto_parallel::
TensorDistAttr)
* ** dist_attr: phi::distributed::TensorDistAttr)
* 4.
* def __init__ (
* ** value: ndarray)
...
...
@@ -751,7 +751,7 @@ Tensor is the basic data structure in PaddlePaddle. There are some ways to creat
* ** tensor: Tensor,
* ** place: paddle::platform::Place,
* ** name: std::string,
* ** dist_attr: phi::distributed::
auto_parallel::
TensorDistAttr)
* ** dist_attr: phi::distributed::TensorDistAttr)
* 7. (multi-place) (should have at least one parameter, one parameter similar
* to case 5, zero parameter equals to case 1.)
* def __init__ (
...
...
paddle/fluid/pybind/eager_utils.cc
浏览文件 @
1f94081d
...
...
@@ -546,7 +546,7 @@ platform::Place CastPyArg2Place(PyObject* obj, ssize_t arg_pos) {
}
#ifdef PADDLE_WITH_DISTRIBUTE
using
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
;
using
phi
::
distributed
::
TensorDistAttr
;
std
::
shared_ptr
<
TensorDistAttr
>
CastPyArg2DistAttr
(
PyObject
*
obj
,
ssize_t
arg_pos
)
{
if
(
PyObject_IsInstance
(
...
...
@@ -891,8 +891,7 @@ PyObject* ToPyObject(const phi::distributed::DistTensor* value) {
return
obj
.
ptr
();
}
PyObject
*
ToPyObject
(
const
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
*
value
)
{
PyObject
*
ToPyObject
(
const
phi
::
distributed
::
TensorDistAttr
*
value
)
{
auto
obj
=
::
pybind11
::
cast
(
value
,
py
::
return_value_policy
::
reference
);
obj
.
inc_ref
();
return
obj
.
ptr
();
...
...
paddle/fluid/pybind/eager_utils.h
浏览文件 @
1f94081d
...
...
@@ -121,8 +121,7 @@ PyObject* ToPyObject(const platform::Place& value);
PyObject
*
ToPyObject
(
const
phi
::
DenseTensor
*
value
);
#ifdef PADDLE_WITH_DISTRIBUTE
PyObject
*
ToPyObject
(
const
phi
::
distributed
::
DistTensor
*
value
);
PyObject
*
ToPyObject
(
const
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
*
value
);
PyObject
*
ToPyObject
(
const
phi
::
distributed
::
TensorDistAttr
*
value
);
#endif
PyObject
*
ToPyObject
(
const
phi
::
SelectedRows
*
value
);
PyObject
*
ToPyObject
(
const
paddle
::
framework
::
proto
::
VarType
::
Type
&
dtype
);
...
...
@@ -314,8 +313,8 @@ paddle::DataType CastPyArg2DataTypeDirectly(PyObject* obj,
ssize_t
arg_pos
);
#ifdef PADDLE_WITH_DISTRIBUTE
std
::
shared_ptr
<
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
>
CastPyArg2DistAttr
(
PyObject
*
obj
,
ssize_t
arg_pos
);
std
::
shared_ptr
<
phi
::
distributed
::
TensorDistAttr
>
CastPyArg2DistAttr
(
PyObject
*
obj
,
ssize_t
arg_pos
);
#endif
paddle
::
optional
<
paddle
::
Tensor
>
GetOptionalTensorFromArgs
(
...
...
paddle/fluid/pybind/protobuf.cc
浏览文件 @
1f94081d
...
...
@@ -44,8 +44,8 @@ PyTypeObject *g_blockdesc_pytype = nullptr;
namespace
pd
=
paddle
::
framework
;
namespace
jit
=
paddle
::
jit
;
using
paddle
::
distributed
::
TensorDistAttr
;
using
paddle
::
distributed
::
auto_parallel
::
OperatorDistAttr
;
using
paddle
::
distributed
::
auto_parallel
::
TensorDistAttr
;
template
<
typename
T
>
static
pybind11
::
bytes
SerializeMessage
(
...
...
paddle/phi/api/lib/api_gen_utils.cc
浏览文件 @
1f94081d
...
...
@@ -541,8 +541,7 @@ phi::distributed::DistTensor* SetKernelDistOutput(Tensor* out) {
if
(
out
->
impl
()
==
nullptr
)
{
auto
dense_t
=
std
::
make_shared
<
phi
::
DenseTensor
>
();
// TODO(chenweihang): polish code, dist_attr is null now
auto
dist_attr
=
std
::
make_shared
<
phi
::
distributed
::
auto_parallel
::
TensorDistAttr
>
();
auto
dist_attr
=
std
::
make_shared
<
phi
::
distributed
::
TensorDistAttr
>
();
auto
dist_t
=
std
::
make_shared
<
phi
::
distributed
::
DistTensor
>
(
dense_t
,
phi
::
DenseTensorMeta
(),
dist_attr
);
out
->
set_impl
(
dist_t
);
...
...
paddle/phi/core/distributed/auto_parallel/dist_attr.cc
浏览文件 @
1f94081d
...
...
@@ -22,7 +22,8 @@ limitations under the License. */
namespace
phi
{
namespace
distributed
{
namespace
auto_parallel
{
using
phi
::
distributed
::
auto_parallel
::
str_join
;
using
phi
::
distributed
::
auto_parallel
::
TensorDistAttrProto
;
// partial is not allow annotated by user by now.
std
::
vector
<
std
::
string
>
TensorDistAttr
::
fields_
{
...
...
@@ -343,6 +344,5 @@ std::string TensorDistAttr::partial_status_string() const {
return
partial_status_str
;
}
}
// namespace auto_parallel
}
// namespace distributed
}
// namespace phi
paddle/phi/core/distributed/auto_parallel/dist_attr.h
浏览文件 @
1f94081d
...
...
@@ -30,9 +30,6 @@ limitations under the License. */
namespace
phi
{
namespace
distributed
{
namespace
auto_parallel
{
constexpr
const
char
*
kDefault
=
"default"
;
class
TensorDistAttr
{
public:
...
...
@@ -125,9 +122,9 @@ class TensorDistAttr {
// in partial-support-stage-I partial will always be a runtime attribute,
// there is not need to serialize it. support the partial serialization in
// future partial-support-stage-II.
void
from_proto
(
const
TensorDistAttrProto
&
proto
);
void
from_proto
(
const
auto_parallel
::
TensorDistAttrProto
&
proto
);
TensorDistAttrProto
to_proto
()
const
;
auto_parallel
::
TensorDistAttrProto
to_proto
()
const
;
std
::
string
serialize_to_string
();
...
...
@@ -157,6 +154,5 @@ inline bool operator!=(const TensorDistAttr& lhs, const TensorDistAttr& rhs) {
return
!
operator
==
(
lhs
,
rhs
);
}
}
// namespace auto_parallel
}
// namespace distributed
}
// namespace phi
paddle/phi/core/distributed/auto_parallel/dist_tensor.h
浏览文件 @
1f94081d
...
...
@@ -22,11 +22,7 @@ namespace phi {
class
DenseTensorUtils
;
namespace
distributed
{
namespace
auto_parallel
{
class
TensorDistAttr
;
}
using
auto_parallel
::
TensorDistAttr
;
class
DistTensor
final
:
public
phi
::
TensorBase
,
...
...
paddle/phi/core/distributed/auto_parallel/process_mesh.cc
浏览文件 @
1f94081d
...
...
@@ -12,15 +12,19 @@ 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. */
#include "paddle/phi/core/distributed/auto_parallel/process_mesh.h"
#include <algorithm>
#include <iterator>
#include "paddle/phi/core/distributed/auto_parallel/process_mesh.h"
#include "paddle/phi/core/distributed/auto_parallel/utils.h"
namespace
phi
{
namespace
distributed
{
namespace
auto_parallel
{
using
phi
::
distributed
::
auto_parallel
::
has_duplicates
;
using
phi
::
distributed
::
auto_parallel
::
ProcessMeshProto
;
using
phi
::
distributed
::
auto_parallel
::
str_join
;
ProcessMesh
::
ProcessMesh
(
const
std
::
vector
<
int64_t
>
&
shape
,
const
std
::
vector
<
int64_t
>
&
process_ids
,
...
...
@@ -129,6 +133,5 @@ bool operator==(const ProcessMesh &lhs, const ProcessMesh &rhs) {
return
true
;
}
}
// namespace auto_parallel
}
// namespace distributed
}
// namespace phi
paddle/phi/core/distributed/auto_parallel/process_mesh.h
浏览文件 @
1f94081d
...
...
@@ -27,7 +27,6 @@ limitations under the License. */
namespace
phi
{
namespace
distributed
{
namespace
auto_parallel
{
class
ProcessMesh
{
public:
...
...
@@ -48,7 +47,7 @@ class ProcessMesh {
int64_t
ndim
()
const
{
return
shape_
.
size
();
}
int64_t
dim_size
(
int64_t
dim
)
const
{
int64_t
cdim
=
canonical_dim
(
dim
,
shape_
.
size
());
int64_t
cdim
=
auto_parallel
::
canonical_dim
(
dim
,
shape_
.
size
());
return
shape_
[
cdim
];
}
...
...
@@ -68,8 +67,8 @@ class ProcessMesh {
// ProcessMesh from_string(const std::string& mesh_str);
std
::
string
to_string
()
const
;
static
ProcessMesh
from_proto
(
const
ProcessMeshProto
&
proto
);
ProcessMeshProto
to_proto
()
const
;
static
ProcessMesh
from_proto
(
const
auto_parallel
::
ProcessMeshProto
&
proto
);
auto_parallel
::
ProcessMeshProto
to_proto
()
const
;
private:
std
::
vector
<
int64_t
>
shape_
;
...
...
@@ -88,6 +87,5 @@ inline bool operator!=(const ProcessMesh& lhs, const ProcessMesh& rhs) {
return
!
operator
==
(
lhs
,
rhs
);
}
}
// namespace auto_parallel
}
// namespace distributed
}
// namespace phi
paddle/phi/core/distributed/auto_parallel/reshard_function.h
浏览文件 @
1f94081d
...
...
@@ -19,12 +19,9 @@ namespace phi {
class
DeviceContext
;
namespace
distributed
{
namespace
auto_parallel
{
class
TensorDistAttr
;
}
// namespace auto_parallel
class
DistTensor
;
using
auto_parallel
::
TensorDistAttr
;
class
TensorDistAttr
;
class
ReshardFunction
{
public:
...
...
paddle/phi/core/distributed/auto_parallel/reshard_utils.h
浏览文件 @
1f94081d
...
...
@@ -27,13 +27,7 @@ class DeviceContext;
namespace
distributed
{
class
CommContext
;
namespace
auto_parallel
{
class
ProcessMesh
;
}
// namespace auto_parallel
using
auto_parallel
::
ProcessMesh
;
bool
IsDimsMappingShard
(
const
std
::
vector
<
int64_t
>&
dims_mapping
);
...
...
test/cpp/auto_parallel/dist_attr_test.cc
浏览文件 @
1f94081d
...
...
@@ -17,11 +17,11 @@ limitations under the License. */
#include "glog/logging.h"
#include "gtest/gtest.h"
#include "paddle/fluid/distributed/auto_parallel/dist_attr.h"
#include "paddle/fluid/framework/block_desc.h"
#include "paddle/fluid/framework/op_desc.h"
#include "paddle/fluid/framework/program_desc.h"
#include "paddle/fluid/framework/var_desc.h"
#include "paddle/phi/core/distributed/auto_parallel/dist_attr.h"
namespace
phi
{
namespace
distributed
{
...
...
@@ -127,7 +127,8 @@ TEST(DistAttr, ctor) {
EXPECT_EQ
(
out_dist_attr
.
verify
(
get_tensor_shape
(
out
)),
true
);
OperatorDistAttr
mul_dist_attr
(
*
op
);
EXPECT_EQ
(
mul_dist_attr
.
impl_type
(),
kDefault
);
EXPECT_EQ
(
mul_dist_attr
.
impl_type
(),
paddle
::
distributed
::
auto_parallel
::
kDefault
);
EXPECT_EQ
(
mul_dist_attr
.
impl_idx
(),
0
);
EXPECT_EQ
(
mul_dist_attr
.
is_recompute
(),
false
);
EXPECT_EQ
(
mul_dist_attr
.
is_annotated
(
"process_mesh"
),
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录