Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f5342918
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看板
未验证
提交
f5342918
编写于
6月 02, 2023
作者:
W
Wang Xin
提交者:
GitHub
6月 02, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
static graph autogen code for shape op (#54221)
* static graph autogen code for shape op * fix onednn * fix onednn
上级
c642aa17
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
20 addition
and
95 deletion
+20
-95
paddle/fluid/operators/shape_op.cc
paddle/fluid/operators/shape_op.cc
+0
-82
paddle/phi/api/yaml/legacy_ops.yaml
paddle/phi/api/yaml/legacy_ops.yaml
+0
-11
paddle/phi/api/yaml/op_compat.yaml
paddle/phi/api/yaml/op_compat.yaml
+6
-0
paddle/phi/api/yaml/ops.yaml
paddle/phi/api/yaml/ops.yaml
+11
-0
paddle/phi/kernels/onednn/shape_kernel.cc
paddle/phi/kernels/onednn/shape_kernel.cc
+3
-1
test/cpp/fluid/mkldnn/CMakeLists.txt
test/cpp/fluid/mkldnn/CMakeLists.txt
+0
-1
未找到文件。
paddle/fluid/operators/shape_op.cc
已删除
100644 → 0
浏览文件 @
c642aa17
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
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 <string>
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/phi/core/infermeta_utils.h"
#include "paddle/phi/infermeta/unary.h"
namespace
paddle
{
namespace
operators
{
class
ShapeOp
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
phi
::
KernelKey
GetExpectedKernelType
(
const
framework
::
ExecutionContext
&
ctx
)
const
override
{
auto
input_data_type
=
framework
::
OperatorWithKernel
::
IndicateVarDataType
(
ctx
,
"Input"
);
return
phi
::
KernelKey
(
input_data_type
,
ctx
.
GetPlace
());
}
protected:
phi
::
KernelKey
GetKernelTypeForVar
(
const
std
::
string
&
var_name
,
const
phi
::
DenseTensor
&
tensor
,
const
phi
::
KernelKey
&
expected_kernel_type
)
const
override
{
return
phi
::
KernelKey
(
phi
::
Backend
::
ALL_BACKEND
,
tensor
.
layout
(),
expected_kernel_type
.
dtype
());
}
};
class
ShapeOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
public:
void
Make
()
override
{
AddInput
(
"Input"
,
"(phi::DenseTensor), The input tensor."
);
AddOutput
(
"Out"
,
"(phi::DenseTensor), The shape of input tensor, the data type of "
"the shape"
" is int32_t, will be on the same device with the input Tensor."
);
AddComment
(
R"DOC(
Shape Operator.
Return the shape of the input.
)DOC"
);
}
};
DECLARE_NO_NEED_BUFFER_VARS_INFERER
(
ShapeNoNeedBufferVarsInferer
,
"Input"
);
}
// namespace operators
}
// namespace paddle
namespace
ops
=
paddle
::
operators
;
namespace
plat
=
paddle
::
platform
;
DECLARE_INFER_SHAPE_FUNCTOR
(
shape
,
ShapeInferShapeFunctor
,
PD_INFER_META
(
phi
::
ShapeInferMeta
));
REGISTER_OPERATOR
(
shape
,
ops
::
ShapeOp
,
ops
::
ShapeOpMaker
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
framework
::
OpDesc
>
,
paddle
::
framework
::
EmptyGradOpMaker
<
paddle
::
imperative
::
OpBase
>
,
ops
::
ShapeNoNeedBufferVarsInferer
,
ShapeInferShapeFunctor
);
paddle/phi/api/yaml/legacy_ops.yaml
浏览文件 @
f5342918
...
@@ -903,17 +903,6 @@
...
@@ -903,17 +903,6 @@
intermediate
:
noise
intermediate
:
noise
backward
:
rrelu_grad
backward
:
rrelu_grad
-
op
:
shape
args
:
(Tensor input)
output
:
Tensor(out)
infer_meta
:
func
:
ShapeInferMeta
kernel
:
func
:
shape {dense -> dense},
shape_sr {selected_rows -> selected_rows}
data_transform
:
skip_transform
:
input
-
op
:
slice
-
op
:
slice
args
:
(Tensor input, int64_t[] axes, IntArray starts, IntArray ends, int64_t[] infer_flags, int64_t[] decrease_axis)
args
:
(Tensor input, int64_t[] axes, IntArray starts, IntArray ends, int64_t[] infer_flags, int64_t[] decrease_axis)
output
:
Tensor
output
:
Tensor
...
...
paddle/phi/api/yaml/op_compat.yaml
浏览文件 @
f5342918
...
@@ -2135,6 +2135,12 @@
...
@@ -2135,6 +2135,12 @@
extra
:
extra
:
attrs
:
[
bool use_mkldnn=false
]
attrs
:
[
bool use_mkldnn=false
]
-
op
:
shape
inputs
:
input
:
Input
outputs
:
out
:
Out
-
op
:
shape
-
op
:
shape
extra
:
extra
:
attrs
:
[
bool use_mkldnn = false
,
str mkldnn_data_type = "float32"
]
attrs
:
[
bool use_mkldnn = false
,
str mkldnn_data_type = "float32"
]
...
...
paddle/phi/api/yaml/ops.yaml
浏览文件 @
f5342918
...
@@ -1959,6 +1959,17 @@
...
@@ -1959,6 +1959,17 @@
optional
:
master_param, master_param_out
optional
:
master_param, master_param_out
inplace
:
(param -> param_out), (master_param -> master_param_out)
inplace
:
(param -> param_out), (master_param -> master_param_out)
-
op
:
shape
args
:
(Tensor input)
output
:
Tensor(out)
infer_meta
:
func
:
ShapeInferMeta
kernel
:
func
:
shape {dense -> dense},
shape_sr {selected_rows -> selected_rows}
data_transform
:
skip_transform
:
input
-
op
:
shard_index
-
op
:
shard_index
args
:
(Tensor input, int index_num, int nshards, int shard_id, int ignore_value=-1)
args
:
(Tensor input, int index_num, int nshards, int shard_id, int ignore_value=-1)
output
:
Tensor(out)
output
:
Tensor(out)
...
...
paddle/phi/kernels/onednn/shape_kernel.cc
浏览文件 @
f5342918
...
@@ -56,4 +56,6 @@ PD_REGISTER_KERNEL(shape,
...
@@ -56,4 +56,6 @@ PD_REGISTER_KERNEL(shape,
float
,
float
,
phi
::
dtype
::
bfloat16
,
phi
::
dtype
::
bfloat16
,
int8_t
,
int8_t
,
uint8_t
)
{}
uint8_t
)
{
kernel
->
InputAt
(
0
).
SetBackend
(
phi
::
Backend
::
ALL_BACKEND
);
}
test/cpp/fluid/mkldnn/CMakeLists.txt
浏览文件 @
f5342918
...
@@ -42,7 +42,6 @@ cc_test_old(
...
@@ -42,7 +42,6 @@ cc_test_old(
recurrent_op
recurrent_op
op_registry
op_registry
pool_op
pool_op
shape_op
crop_op
crop_op
activation_op
activation_op
generated_op
generated_op
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录