Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
0dccdee0
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
0dccdee0
编写于
2月 04, 2022
作者:
C
Chen Weihang
提交者:
GitHub
2月 04, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove unchanged infermeta new (#39343)
上级
633c71c2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
12 addition
and
76 deletion
+12
-76
paddle/fluid/operators/conj_op.cc
paddle/fluid/operators/conj_op.cc
+8
-11
paddle/fluid/operators/sign_op.cc
paddle/fluid/operators/sign_op.cc
+2
-1
paddle/fluid/operators/sign_op.h
paddle/fluid/operators/sign_op.h
+0
-47
paddle/pten/infermeta/unary.cc
paddle/pten/infermeta/unary.cc
+1
-11
paddle/pten/infermeta/unary.h
paddle/pten/infermeta/unary.h
+0
-5
paddle/pten/tests/core/test_meta_fn_utils.cc
paddle/pten/tests/core/test_meta_fn_utils.cc
+1
-1
未找到文件。
paddle/fluid/operators/conj_op.cc
浏览文件 @
0dccdee0
...
...
@@ -22,22 +22,16 @@
#include "paddle/fluid/platform/mkldnn_helper.h"
#endif
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/pten/core/infermeta_utils.h"
#include "paddle/pten/infermeta/unary.h"
namespace
paddle
{
namespace
operators
{
class
ConjOp
:
public
framework
::
OperatorWithKernel
{
public:
using
framework
::
OperatorWithKernel
::
OperatorWithKernel
;
void
InferShape
(
framework
::
InferShapeContext
*
ctx
)
const
override
{
OP_INOUT_CHECK
(
ctx
->
HasInput
(
"X"
),
"Input"
,
"X"
,
"conj"
);
OP_INOUT_CHECK
(
ctx
->
HasOutput
(
"Out"
),
"Output"
,
"Out"
,
"conj"
);
auto
in_dims
=
ctx
->
GetInputDim
(
"X"
);
ctx
->
SetOutputDim
(
"Out"
,
in_dims
);
ctx
->
ShareLoD
(
"X"
,
/*->*/
"Out"
);
}
};
class
ConjOpMaker
:
public
framework
::
OpProtoAndCheckerMaker
{
...
...
@@ -72,9 +66,12 @@ class ConjGradMaker : public framework::SingleGradOpMaker<T> {
namespace
ops
=
paddle
::
operators
;
DELCARE_INFER_SHAPE_FUNCTOR
(
conj
,
ConjInferShapeFunctor
,
PT_INFER_META
(
pten
::
UnchangedInferMeta
));
REGISTER_OPERATOR
(
conj
,
ops
::
ConjOp
,
ops
::
ConjOpMaker
,
ops
::
ConjGradMaker
<
paddle
::
framework
::
OpDesc
>
,
ops
::
ConjGradMaker
<
paddle
::
imperative
::
OpBase
>
);
ops
::
ConjGradMaker
<
paddle
::
imperative
::
OpBase
>
,
ConjInferShapeFunctor
);
REGISTER_OP_CPU_KERNEL
(
conj
,
ops
::
ConjKernel
<
paddle
::
platform
::
CPUDeviceContext
,
...
...
paddle/fluid/operators/sign_op.cc
浏览文件 @
0dccdee0
...
...
@@ -13,6 +13,7 @@ See the License for the specific language governing permissions and
limitations under the License. */
#include <memory>
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/platform/float16.h"
...
...
@@ -60,7 +61,7 @@ class SignGradMaker : public framework::SingleGradOpMaker<T> {
namespace
ops
=
paddle
::
operators
;
DELCARE_INFER_SHAPE_FUNCTOR
(
sign
,
SignInferShapeFunctor
,
PT_INFER_META
(
pten
::
UnchangedInferMeta
New
));
PT_INFER_META
(
pten
::
UnchangedInferMeta
));
REGISTER_OPERATOR
(
sign
,
ops
::
SignOp
,
ops
::
SignOpMaker
<
float
>
,
ops
::
SignGradMaker
<
paddle
::
framework
::
OpDesc
>
,
ops
::
SignGradMaker
<
paddle
::
imperative
::
OpBase
>
,
...
...
paddle/fluid/operators/sign_op.h
已删除
100644 → 0
浏览文件 @
633c71c2
/* Copyright (c) 2016 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. */
#pragma once
#include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/pten_utils.h"
#include "paddle/fluid/operators/eigen/eigen_function.h"
#include "paddle/pten/kernels/sign_kernel.h"
namespace
paddle
{
namespace
operators
{
// See Note [ Why still keep the original kernel implementation? ]
template
<
typename
DeviceContext
,
typename
T
>
class
SignKernel
:
public
framework
::
OpKernel
<
T
>
{
public:
virtual
void
Compute
(
const
framework
::
ExecutionContext
&
context
)
const
{
auto
*
x
=
context
.
Input
<
framework
::
Tensor
>
(
"X"
);
auto
*
out
=
context
.
Output
<
framework
::
Tensor
>
(
"Out"
);
auto
&
dev_ctx
=
context
.
device_context
<
DeviceContext
>
();
out
->
mutable_data
<
T
>
(
x
->
place
());
// call new kernel
pten
::
SignKernel
<
T
,
typename
paddle
::
framework
::
ConvertToPtenContext
<
DeviceContext
>::
TYPE
>
(
static_cast
<
const
typename
paddle
::
framework
::
ConvertToPtenContext
<
DeviceContext
>::
TYPE
&>
(
dev_ctx
),
*
x
,
out
);
}
};
}
// namespace operators
}
// namespace paddle
paddle/pten/infermeta/unary.cc
浏览文件 @
0dccdee0
...
...
@@ -21,16 +21,6 @@ limitations under the License. */
namespace
pten
{
void
UnchangedInferMetaNew
(
MetaConfig
config
,
const
MetaTensor
&
x
,
MetaTensor
*
out
)
{
out
->
share_meta
(
x
);
}
DenseTensorMeta
UnchangedInferMeta
(
const
DenseTensorMeta
&
x_meta
)
{
return
x_meta
;
}
void
UnchangedInferMeta
(
const
MetaTensor
&
x
,
MetaTensor
*
out
)
{
out
->
share_meta
(
x
);
}
...
...
@@ -319,4 +309,4 @@ void ReduceInferMeta(const MetaTensor& x,
}
// namespace pten
PT_REGISTER_INFER_META_FN
(
sign
,
pten
::
UnchangedInferMeta
New
);
PT_REGISTER_INFER_META_FN
(
sign
,
pten
::
UnchangedInferMeta
);
paddle/pten/infermeta/unary.h
浏览文件 @
0dccdee0
...
...
@@ -31,11 +31,6 @@ class MetaConfig;
// Because functions in this file not only can infer shape, but also need
// infer lod or other useful data.
// TODO(chenweihang): to avoid conflit, remove this function in next PR
void
UnchangedInferMetaNew
(
MetaConfig
config
,
const
MetaTensor
&
x
,
MetaTensor
*
out
);
void
UnchangedInferMeta
(
const
MetaTensor
&
x
,
MetaTensor
*
out
);
void
FlattenInferMeta
(
const
MetaTensor
&
x
,
...
...
paddle/pten/tests/core/test_meta_fn_utils.cc
浏览文件 @
0dccdee0
...
...
@@ -29,7 +29,7 @@ TEST(MetaFunctionMap, InferMetaFnExists) {
pten
::
MetaTensor
meta_x
(
&
dense_x
);
pten
::
DenseTensor
dense_out1
;
pten
::
MetaTensor
meta_out
(
&
dense_out1
);
pten
::
UnchangedInferMeta
New
(
/*is_runtime=*/
true
,
meta_x
,
&
meta_out
);
pten
::
UnchangedInferMeta
(
meta_x
,
&
meta_out
);
auto
shared_meat_x
=
std
::
make_shared
<
pten
::
MetaTensor
>
(
&
dense_x
);
pten
::
DenseTensor
dense_out2
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录