Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
TonyTonyFun
Paddle
提交
0cd577cf
P
Paddle
项目概览
TonyTonyFun
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
0cd577cf
编写于
4月 08, 2022
作者:
R
ronnywang
提交者:
GitHub
4月 08, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
pybind support CustomPlace (#41136)
上级
bc88fbb5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
43 addition
and
0 deletion
+43
-0
paddle/fluid/pybind/imperative.cc
paddle/fluid/pybind/imperative.cc
+6
-0
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+37
-0
未找到文件。
paddle/fluid/pybind/imperative.cc
浏览文件 @
0cd577cf
...
...
@@ -2182,6 +2182,7 @@ void BindImperative(py::module *m_ptr) {
m
.
def
(
"varbase_copy"
,
&
VarBaseCopy
<
platform
::
XPUPlace
>
);
m
.
def
(
"varbase_copy"
,
&
VarBaseCopy
<
platform
::
CUDAPinnedPlace
>
);
m
.
def
(
"varbase_copy"
,
&
VarBaseCopy
<
platform
::
NPUPlace
>
);
m
.
def
(
"varbase_copy"
,
&
VarBaseCopy
<
platform
::
CustomPlace
>
);
m
.
def
(
"varbase_copy"
,
&
VarBaseCopy
<
platform
::
MLUPlace
>
);
m
.
def
(
...
...
@@ -2341,6 +2342,11 @@ void BindImperative(py::module *m_ptr) {
const
py
::
args
args
,
const
py
::
kwargs
kwargs
)
{
return
imperative
::
PyLayerApply
(
place
,
cls
,
args
,
kwargs
);
});
m
.
def
(
"pylayer_apply"
,
[](
const
platform
::
CustomPlace
&
place
,
const
py
::
object
&
cls
,
const
py
::
args
args
,
const
py
::
kwargs
kwargs
)
{
return
imperative
::
PyLayerApply
(
place
,
cls
,
args
,
kwargs
);
});
#if defined(PADDLE_WITH_CUDA)
m
.
def
(
"to_uva_tensor"
,
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
0cd577cf
...
...
@@ -845,6 +845,10 @@ PYBIND11_MODULE(core_noavx, m) {
[](
framework
::
Tensor
&
self
,
const
std
::
string
&
layout
)
{
self
.
set_layout
(
StringToDataLayout
(
layout
));
})
.
def
(
"_alloc_float"
,
[](
framework
::
Tensor
&
self
,
paddle
::
platform
::
CustomPlace
&
place
)
{
self
.
mutable_data
<
float
>
(
place
);
})
.
def
(
"_alloc_float"
,
[](
framework
::
Tensor
&
self
,
paddle
::
platform
::
CUDAPlace
&
place
)
{
self
.
mutable_data
<
float
>
(
place
);
...
...
@@ -873,6 +877,10 @@ PYBIND11_MODULE(core_noavx, m) {
[](
framework
::
Tensor
&
self
,
paddle
::
platform
::
CPUPlace
&
place
)
{
self
.
mutable_data
<
int
>
(
place
);
})
.
def
(
"_alloc_int"
,
[](
framework
::
Tensor
&
self
,
paddle
::
platform
::
CustomPlace
&
place
)
{
self
.
mutable_data
<
int
>
(
place
);
})
.
def
(
"_alloc_int"
,
[](
framework
::
Tensor
&
self
,
paddle
::
platform
::
XPUPlace
&
place
)
{
self
.
mutable_data
<
int
>
(
place
);
...
...
@@ -901,6 +909,12 @@ PYBIND11_MODULE(core_noavx, m) {
return
reinterpret_cast
<
uintptr_t
>
(
self
.
mutable_data
(
place
,
framework
::
TransToPhiDataType
(
type
)));
})
.
def
(
"_mutable_data"
,
[](
framework
::
Tensor
&
self
,
paddle
::
platform
::
CustomPlace
&
place
,
paddle
::
framework
::
proto
::
VarType
::
Type
type
)
{
return
reinterpret_cast
<
uintptr_t
>
(
self
.
mutable_data
(
place
,
framework
::
TransToPhiDataType
(
type
)));
})
.
def
(
"_mutable_data"
,
[](
framework
::
Tensor
&
self
,
paddle
::
platform
::
XPUPlace
&
place
,
paddle
::
framework
::
proto
::
VarType
::
Type
type
)
{
...
...
@@ -934,6 +948,8 @@ PYBIND11_MODULE(core_noavx, m) {
})
.
def
(
"_copy_from"
,
&
TensorCopyFrom
<
paddle
::
platform
::
CPUPlace
>
,
py
::
arg
(
"tensor"
),
py
::
arg
(
"place"
),
py
::
arg
(
"batch_size"
)
=
-
1
)
.
def
(
"_copy_from"
,
&
TensorCopyFrom
<
paddle
::
platform
::
CustomPlace
>
,
py
::
arg
(
"tensor"
),
py
::
arg
(
"place"
),
py
::
arg
(
"batch_size"
)
=
-
1
)
.
def
(
"_copy_from"
,
&
TensorCopyFrom
<
paddle
::
platform
::
XPUPlace
>
,
py
::
arg
(
"tensor"
),
py
::
arg
(
"place"
),
py
::
arg
(
"batch_size"
)
=
-
1
)
.
def
(
"_copy_from"
,
&
TensorCopyFrom
<
paddle
::
platform
::
CUDAPlace
>
,
...
...
@@ -948,6 +964,8 @@ PYBIND11_MODULE(core_noavx, m) {
py
::
arg
(
"tensor"
),
py
::
arg
(
"place"
),
py
::
arg
(
"batch_size"
)
=
-
1
)
.
def
(
"set"
,
SetTensorFromPyArray
<
paddle
::
platform
::
CPUPlace
>
,
py
::
arg
(
"array"
),
py
::
arg
(
"place"
),
py
::
arg
(
"zero_copy"
)
=
false
)
.
def
(
"set"
,
SetTensorFromPyArray
<
paddle
::
platform
::
CustomPlace
>
,
py
::
arg
(
"array"
),
py
::
arg
(
"place"
),
py
::
arg
(
"zero_copy"
)
=
false
)
.
def
(
"set"
,
SetTensorFromPyArray
<
paddle
::
platform
::
XPUPlace
>
,
py
::
arg
(
"array"
),
py
::
arg
(
"place"
),
py
::
arg
(
"zero_copy"
)
=
false
)
.
def
(
"set"
,
SetTensorFromPyArray
<
paddle
::
platform
::
CUDAPlace
>
,
...
...
@@ -1985,6 +2003,19 @@ All parameter, weight, gradient are variables in Paddle.
"Please recompile or reinstall Paddle with NPU support."
));
#else
return
new
paddle
::
platform
::
NPUDeviceContext
(
place
);
#endif
})
.
def_static
(
"create"
,
[](
paddle
::
platform
::
CustomPlace
&
place
)
->
paddle
::
platform
::
DeviceContext
*
{
#ifndef PADDLE_WITH_CUSTOM_DEVICE
PADDLE_THROW
(
platform
::
errors
::
PermissionDenied
(
"Cannot use CustomPlace in CPU/GPU/XPU version, "
"Please recompile or reinstall Paddle with "
"CustomDevice support."
));
#else
return
new
paddle
::
platform
::
CustomDeviceContext
(
place
);
#endif
})
.
def_static
(
"create"
,
...
...
@@ -2722,6 +2753,12 @@ All parameter, weight, gradient are variables in Paddle.
pybind11
::
gil_scoped_release
release
;
self
.
Run
(
scope
,
place
);
})
.
def
(
"run"
,
[](
OperatorBase
&
self
,
const
Scope
&
scope
,
const
platform
::
CustomPlace
&
place
)
{
pybind11
::
gil_scoped_release
release
;
self
.
Run
(
scope
,
place
);
})
.
def
(
"type"
,
[](
const
OperatorBase
&
op
)
->
std
::
string
{
return
op
.
Type
();
})
.
def
(
"outputs"
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录