Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
e5c61b15
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2305
Star
20932
Fork
5423
代码
文件
提交
分支
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看板
未验证
提交
e5c61b15
编写于
4月 19, 2022
作者:
C
Chen Weihang
提交者:
GitHub
4月 19, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
polish tensor api details (#41971)
上级
8113c913
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
13 addition
and
13 deletion
+13
-13
paddle/phi/api/include/tensor.h
paddle/phi/api/include/tensor.h
+3
-3
paddle/phi/api/lib/tensor.cc
paddle/phi/api/lib/tensor.cc
+2
-2
paddle/phi/api/lib/tensor_method.cc
paddle/phi/api/lib/tensor_method.cc
+2
-2
python/paddle/utils/code_gen/api_base.py
python/paddle/utils/code_gen/api_base.py
+5
-5
python/paddle/utils/code_gen/strings_api_gen.py
python/paddle/utils/code_gen/strings_api_gen.py
+1
-1
未找到文件。
paddle/phi/api/include/tensor.h
浏览文件 @
e5c61b15
...
...
@@ -166,7 +166,7 @@ class PADDLE_API Tensor final {
*
* @return phi::DDim
*/
phi
::
DDim
dims
()
const
;
const
phi
::
DDim
&
dims
()
const
;
/**
* @brief Return the shape (dimensions) of Tensor.
...
...
@@ -260,7 +260,7 @@ class PADDLE_API Tensor final {
*
* @return Place
*/
Place
place
()
const
;
const
Place
&
place
()
const
;
/**
* @brief Determine whether the tensor device is CPU
...
...
@@ -421,7 +421,7 @@ class PADDLE_API Tensor final {
* @param blocking, Should we copy this in sync way.
* @return Tensor
*/
Tensor
copy_to
(
Place
place
,
bool
blocking
)
const
;
Tensor
copy_to
(
const
Place
&
place
,
bool
blocking
)
const
;
/**
* @brief Transfer the source Tensor to current Tensor.
...
...
paddle/phi/api/lib/tensor.cc
浏览文件 @
e5c61b15
...
...
@@ -110,7 +110,7 @@ int64_t Tensor::numel() const { return impl_->numel(); }
int64_t
Tensor
::
size
()
const
{
return
impl_
->
numel
();
}
phi
::
DDim
Tensor
::
dims
()
const
{
return
impl_
->
dims
();
}
const
phi
::
DDim
&
Tensor
::
dims
()
const
{
return
impl_
->
dims
();
}
std
::
vector
<
int64_t
>
Tensor
::
shape
()
const
{
auto
dims
=
impl_
->
dims
();
...
...
@@ -158,7 +158,7 @@ bool Tensor::is_string_tensor() const {
}
/* Part 3: Device and Backend methods */
Place
Tensor
::
place
()
const
{
const
Place
&
Tensor
::
place
()
const
{
PADDLE_ENFORCE_NOT_NULL
(
impl_
,
phi
::
errors
::
PermissionDenied
(
...
...
paddle/phi/api/lib/tensor_method.cc
浏览文件 @
e5c61b15
...
...
@@ -27,13 +27,13 @@ namespace paddle {
namespace
experimental
{
// declare cast api
Tensor
cast
(
const
Tensor
&
x
,
DataType
out_dtype
);
Tensor
copy_to
(
const
Tensor
&
x
,
Place
place
,
bool
blocking
);
Tensor
copy_to
(
const
Tensor
&
x
,
const
Place
&
place
,
bool
blocking
);
Tensor
Tensor
::
cast
(
DataType
target_type
)
const
{
return
experimental
::
cast
(
*
this
,
target_type
);
}
Tensor
Tensor
::
copy_to
(
Place
place
,
bool
blocking
)
const
{
Tensor
Tensor
::
copy_to
(
const
Place
&
place
,
bool
blocking
)
const
{
return
experimental
::
copy_to
(
*
this
,
place
,
blocking
);
}
...
...
python/paddle/utils/code_gen/api_base.py
浏览文件 @
e5c61b15
...
...
@@ -105,7 +105,7 @@ class BaseAPI(object):
'double'
:
'double'
,
'bool'
:
'bool'
,
'str'
:
'const std::string&'
,
'Place'
:
'
Place
'
,
'Place'
:
'
const Place&
'
,
'DataLayout'
:
'DataLayout'
,
'DataType'
:
'DataType'
,
'int64_t[]'
:
'const std::vector<int64_t>&'
,
...
...
@@ -120,7 +120,7 @@ class BaseAPI(object):
'float'
:
'paddle::optional<float>'
,
'double'
:
'paddle::optional<double>'
,
'bool'
:
'paddle::optional<bool>'
,
'Place'
:
'paddle::optional<
Place
>'
,
'Place'
:
'paddle::optional<
const Place&
>'
,
'DataLayout'
:
'paddle::optional<DataLayout>'
,
'DataType'
:
'paddle::optional<DataType>'
}
...
...
@@ -328,7 +328,7 @@ PADDLE_API {self.gene_return_type_code()} {self.get_api_func_name() + '_'}({self
assert
len
(
vars_list
)
==
2
,
f
"
{
self
.
api
}
api: The number of params to set backend with '>' only allows 2, but received
{
len
(
vars_list
)
}
."
assert
(
vars_list
[
0
].
strip
()
in
self
.
attrs
[
'names'
])
and
(
self
.
attrs
[
'attr_info'
][
vars_list
[
0
].
strip
()][
0
]
==
'
Place
'
),
\
assert
(
vars_list
[
0
].
strip
()
in
self
.
attrs
[
'names'
])
and
(
self
.
attrs
[
'attr_info'
][
vars_list
[
0
].
strip
()][
0
]
==
'
const Place&
'
),
\
f
"
{
self
.
api
}
api: When use '>' to set kernel backend, the first param should be a attribute with Place type."
backend_select_code
=
f
"""
kernel_backend = ParseBackendWithInputOrder(
{
vars_list
[
0
].
strip
()
}
,
{
vars_list
[
1
].
strip
()
}
);
...
...
@@ -360,7 +360,7 @@ PADDLE_API {self.gene_return_type_code()} {self.get_api_func_name() + '_'}({self
attr_layout_count
=
0
attr_data_type_count
=
0
for
attr_name
in
attrs
[
'names'
]:
if
attrs
[
'attr_info'
][
attr_name
][
0
]
==
'
Place
'
:
if
attrs
[
'attr_info'
][
attr_name
][
0
]
==
'
const Place&
'
:
assert
kernel
[
'backend'
]
is
not
None
,
\
f
"
{
api
}
api: When there is a parameter with 'Place' type in attributes, you must set backend of kernel manually."
attr_backend_count
=
attr_backend_count
+
1
...
...
@@ -420,7 +420,7 @@ PADDLE_API {self.gene_return_type_code()} {self.get_api_func_name() + '_'}({self
if
len
(
input_names
)
==
0
:
assert
attr_backend_count
>
0
and
attr_data_type_count
>
0
,
\
f
"
{
api
}
api: When there is no input tensor, the args must have '
Backend
' and 'DataType'."
f
"
{
api
}
api: When there is no input tensor, the args must have '
Place
' and 'DataType'."
kernel_select_args
=
""
for
input_name
in
input_names
:
...
...
python/paddle/utils/code_gen/strings_api_gen.py
浏览文件 @
e5c61b15
...
...
@@ -225,7 +225,7 @@ PADDLE_API {self.outputs['return_type']} {self.get_api_func_name()}({self.args_s
assert
len
(
vars_list
)
==
2
,
f
"
{
api
}
api: The number of params to set backend with '>' only allows 2, but received
{
len
(
vars_list
)
}
."
assert
(
vars_list
[
0
].
strip
()
in
attrs
[
'names'
])
and
(
attrs
[
'attr_info'
][
vars_list
[
0
].
strip
()][
0
]
==
'
Place
'
),
\
assert
(
vars_list
[
0
].
strip
()
in
attrs
[
'names'
])
and
(
attrs
[
'attr_info'
][
vars_list
[
0
].
strip
()][
0
]
==
'
const Place&
'
),
\
f
"
{
api
}
api: When use '>' to set kernel backend, the first param should be a attribute with Place type."
kernel_select_code
=
kernel_select_code
+
f
"""
kernel_backend = ParseBackendWithInputOrder(
{
vars_list
[
0
].
strip
()
}
,
{
vars_list
[
1
].
strip
()
}
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录