Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
16abb325
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
16abb325
编写于
3月 14, 2023
作者:
C
cxxly
提交者:
Xiaoxu Chen
3月 21, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move split/reshape prim api to auto generated file
上级
cdc5896f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
12 addition
and
69 deletion
+12
-69
cmake/cblas.cmake
cmake/cblas.cmake
+1
-0
paddle/fluid/prim/api/api.yaml
paddle/fluid/prim/api/api.yaml
+2
-0
paddle/fluid/prim/api/auto_code_generated/eager_gen.py
paddle/fluid/prim/api/auto_code_generated/eager_gen.py
+8
-2
paddle/fluid/prim/api/auto_code_generated/template/utils.cc.j2
...e/fluid/prim/api/auto_code_generated/template/utils.cc.j2
+1
-1
paddle/fluid/prim/api/manual_prim/eager_prim_api.cc
paddle/fluid/prim/api/manual_prim/eager_prim_api.cc
+0
-14
paddle/fluid/prim/api/manual_prim/prim_manual_api.h
paddle/fluid/prim/api/manual_prim/prim_manual_api.h
+0
-8
paddle/fluid/prim/api/manual_prim/static_prim_api.cc
paddle/fluid/prim/api/manual_prim/static_prim_api.cc
+0
-44
未找到文件。
cmake/cblas.cmake
浏览文件 @
16abb325
...
...
@@ -96,6 +96,7 @@ if(NOT DEFINED CBLAS_PROVIDER)
STATUS
"Found OpenBLAS (include:
${
OPENBLAS_INC_DIR
}
, library:
${
CBLAS_LIBRARIES
}
)"
)
message
(
STATUS
"Found lapack in OpenBLAS (include:
${
OPENBLAS_LAPACKE_INC_DIR
}
)"
)
...
...
paddle/fluid/prim/api/api.yaml
浏览文件 @
16abb325
...
...
@@ -43,3 +43,5 @@
-
sin
-
cos
-
where
-
reshape
-
split
paddle/fluid/prim/api/auto_code_generated/eager_gen.py
浏览文件 @
16abb325
...
...
@@ -225,14 +225,20 @@ class BaseAPI:
return
inputs
,
attrs
def
parse_output
(
self
,
outputs_list
):
output_types_map
=
{
'Tensor[]'
:
'std::vector<Tensor>'
,
}
out_type_list
=
[]
out_name_list
=
[]
out_size_expr_list
=
[]
for
output_dict
in
outputs_list
:
if
output_dict
[
'intermediate'
]:
continue
out_type_list
.
append
(
output_dict
[
'typename'
])
out_type_list
.
append
(
output_types_map
.
get
(
output_dict
[
'typename'
],
output_dict
[
'typename'
]
)
)
out_name_list
.
append
(
output_dict
[
'name'
])
if
'size'
in
output_dict
.
keys
():
out_size_expr_list
.
append
(
output_dict
[
'size'
])
...
...
paddle/fluid/prim/api/auto_code_generated/template/utils.cc.j2
浏览文件 @
16abb325
...
...
@@ -115,7 +115,7 @@ op->SetInput("{{input.fluid_name | to_pascal}}", {std::static_pointer_cast<prim:
{%- if output.typename is tensor_sequence -%} {#- render the output of type std::Vector<Tensor> -#}
std::vector<Tensor> {{output.name}};
std::vector<std::string> {{output.name}}_names;
for (
auto
i=0; i<{{output.size}}; i++) {
for (
size_t
i=0; i<{{output.size}}; i++) {
auto tmp = empty<DescTensor>({}, phi::DataType::FLOAT32, paddle::Place());
{{output.name}}.push_back(tmp);
{{output.name}}_names.push_back(std::static_pointer_cast<prim::DescTensor>(tmp.impl())->Name());
...
...
paddle/fluid/prim/api/manual_prim/eager_prim_api.cc
浏览文件 @
16abb325
...
...
@@ -19,12 +19,6 @@
namespace
paddle
{
namespace
prim
{
template
<
>
Tensor
reshape
<
Tensor
>
(
const
Tensor
&
x
,
const
IntArray
&
shape
)
{
VLOG
(
4
)
<<
"Eager Prim API reshape_ad_func call"
;
return
::
reshape_ad_func
(
x
,
shape
);
}
template
<
>
Tensor
full
<
Tensor
>
(
const
IntArray
&
shape
,
const
Scalar
&
value
,
...
...
@@ -34,14 +28,6 @@ Tensor full<Tensor>(const IntArray& shape,
return
::
full_ad_func
(
shape
,
value
,
dtype
,
place
);
}
template
<
>
std
::
vector
<
Tensor
>
split
<
Tensor
>
(
const
Tensor
&
x
,
const
IntArray
&
sections
,
const
Scalar
&
axis
)
{
VLOG
(
4
)
<<
"Eager Prim API split_ad_func call"
;
return
::
split_ad_func
(
x
,
sections
,
axis
);
}
template
<
>
Tensor
cast
<
Tensor
>
(
const
Tensor
&
x
,
DataType
dtype
)
{
return
::
cast_ad_func
(
x
,
dtype
);
...
...
paddle/fluid/prim/api/manual_prim/prim_manual_api.h
浏览文件 @
16abb325
...
...
@@ -29,20 +29,12 @@ using Scalar = paddle::experimental::Scalar;
using
IntArray
=
paddle
::
experimental
::
IntArray
;
using
DataType
=
phi
::
DataType
;
template
<
typename
T
>
Tensor
reshape
(
const
Tensor
&
x
,
const
IntArray
&
shape
);
template
<
typename
T
>
Tensor
full
(
const
IntArray
&
shape
,
const
Scalar
&
value
,
DataType
dtype
=
DataType
::
FLOAT32
,
const
Place
&
place
=
CPUPlace
());
template
<
typename
T
>
std
::
vector
<
Tensor
>
split
(
const
Tensor
&
x
,
const
IntArray
&
sections
,
const
Scalar
&
axis
);
template
<
typename
T
>
Tensor
cast
(
const
Tensor
&
x
,
DataType
dtype
);
...
...
paddle/fluid/prim/api/manual_prim/static_prim_api.cc
浏览文件 @
16abb325
...
...
@@ -37,24 +37,6 @@
namespace
paddle
{
namespace
prim
{
template
<
>
Tensor
reshape
<
DescTensor
>
(
const
Tensor
&
x
,
const
IntArray
&
shape
)
{
framework
::
BlockDesc
*
block
=
StaticCompositeContext
::
Instance
().
GetBlock
();
framework
::
OpDesc
*
op
=
block
->
AppendOp
();
// TODO(cxxly): move to auto generate dir.
op
->
SetType
(
"reshape2"
);
op
->
SetInput
(
"X"
,
{
std
::
static_pointer_cast
<
prim
::
DescTensor
>
(
x
.
impl
())
->
Name
()});
auto
out
=
empty
<
DescTensor
>
({},
x
.
dtype
(),
paddle
::
Place
());
op
->
SetOutput
(
"Out"
,
{
std
::
static_pointer_cast
<
prim
::
DescTensor
>
(
out
.
impl
())
->
Name
()});
op
->
SetAttr
(
"shape"
,
unsafe_vector_cast
<
int64_t
,
int
>
(
shape
.
GetData
()));
op
->
CheckAttrs
();
op
->
InferVarType
(
block
);
op
->
InferShape
(
*
block
);
return
out
;
}
template
<
>
Tensor
full
<
DescTensor
>
(
const
IntArray
&
shape
,
const
Scalar
&
value
,
...
...
@@ -127,32 +109,6 @@ Tensor full<DescTensor>(const IntArray& shape,
return
out
;
}
template
<
>
std
::
vector
<
Tensor
>
split
<
DescTensor
>
(
const
Tensor
&
x
,
const
IntArray
&
sections
,
const
Scalar
&
axis
)
{
int
elem_num
=
sections
.
size
();
std
::
vector
<
std
::
string
>
outs_name
;
std
::
vector
<
Tensor
>
outs
;
for
(
int
i
=
0
;
i
<
elem_num
;
++
i
)
{
Tensor
out
=
empty
<
DescTensor
>
({},
x
.
dtype
(),
paddle
::
Place
());
std
::
string
out_name
=
std
::
static_pointer_cast
<
prim
::
DescTensor
>
(
out
.
impl
())
->
Name
();
outs_name
.
push_back
(
std
::
move
(
out_name
));
outs
.
push_back
(
out
);
}
framework
::
BlockDesc
*
block
=
StaticCompositeContext
::
Instance
().
GetBlock
();
framework
::
OpDesc
*
op
=
block
->
AppendOp
();
op
->
SetType
(
"split"
);
op
->
SetAttr
(
"sections"
,
sections
.
GetData
());
op
->
SetAttr
(
"axis"
,
axis
.
to
<
int
>
());
op
->
SetOutput
(
"Out"
,
outs_name
);
op
->
CheckAttrs
();
op
->
InferVarType
(
block
);
op
->
InferShape
(
*
block
);
return
outs
;
}
template
<
>
Tensor
cast
<
DescTensor
>
(
const
Tensor
&
x
,
DataType
dtype
)
{
Tensor
out
=
empty
<
DescTensor
>
({},
DataType
::
FLOAT32
,
paddle
::
Place
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录