Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
e337d280
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
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看板
未验证
提交
e337d280
编写于
11月 30, 2022
作者:
Z
zyfncg
提交者:
GitHub
11月 30, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix the name map of operator from Phi to fluid (#48496)
* rename some kernel name * fix compile problem
上级
35902ec6
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
79 addition
and
39 deletion
+79
-39
cmake/phi.cmake
cmake/phi.cmake
+21
-8
paddle/fluid/operators/size_op.cc
paddle/fluid/operators/size_op.cc
+1
-1
paddle/phi/api/yaml/legacy_ops.yaml
paddle/phi/api/yaml/legacy_ops.yaml
+2
-2
paddle/phi/core/compat/op_utils.h
paddle/phi/core/compat/op_utils.h
+15
-14
paddle/phi/infermeta/unary.cc
paddle/phi/infermeta/unary.cc
+1
-1
paddle/phi/infermeta/unary.h
paddle/phi/infermeta/unary.h
+1
-1
paddle/phi/kernels/cpu/numel_kernel.cc
paddle/phi/kernels/cpu/numel_kernel.cc
+4
-4
paddle/phi/kernels/gpu/numel_kernel.cu
paddle/phi/kernels/gpu/numel_kernel.cu
+4
-4
paddle/phi/kernels/impl/numel_kernel_impl.h
paddle/phi/kernels/impl/numel_kernel_impl.h
+3
-3
paddle/phi/kernels/numel_kernel.h
paddle/phi/kernels/numel_kernel.h
+3
-1
paddle/phi/ops/compat/einsum_sig.cc
paddle/phi/ops/compat/einsum_sig.cc
+2
-0
paddle/phi/ops/compat/embedding_sig.cc
paddle/phi/ops/compat/embedding_sig.cc
+5
-0
paddle/phi/ops/compat/size_sig.cc
paddle/phi/ops/compat/size_sig.cc
+17
-0
未找到文件。
cmake/phi.cmake
浏览文件 @
e337d280
...
@@ -111,19 +111,31 @@ function(kernel_declare TARGET_LIST)
...
@@ -111,19 +111,31 @@ function(kernel_declare TARGET_LIST)
endfunction
()
endfunction
()
function
(
append_op_util_declare TARGET
)
function
(
append_op_util_declare TARGET
)
file
(
READ
${
TARGET
}
target_content
)
string
(
REGEX MATCH
"(PD_REGISTER_ARG_MAPPING_FN)
\\
([
\t\r\n
]*[a-z0-9_]*"
util_registrar
"
${
target_content
}
"
)
if
(
NOT
${
util_registrar
}
EQUAL
""
)
string
(
REPLACE
"PD_REGISTER_ARG_MAPPING_FN"
"PD_DECLARE_ARG_MAPPING_FN"
util_declare
"
${
util_registrar
}
"
)
string
(
APPEND util_declare
");
\n
"
)
file
(
APPEND
${
op_utils_header
}
"
${
util_declare
}
"
)
endif
()
endfunction
()
function
(
append_op_kernel_map_declare TARGET
)
file
(
READ
${
TARGET
}
target_content
)
file
(
READ
${
TARGET
}
target_content
)
string
(
string
(
REGEX
REGEX
MATCH
MATCH
"(PD_REGISTER_BASE_KERNEL_NAME
|PD_REGISTER_ARG_MAPPING_FN)
\\
([
\t\r\n
]*[a-z0-9_]*"
"(PD_REGISTER_BASE_KERNEL_NAME
)
\\
([
\t\r\n
]*[a-z0-9_]*,[
\\
\t\r\n
]*[a-z0-9_]*"
util
_registrar
kernel_mapping
_registrar
"
${
target_content
}
"
)
"
${
target_content
}
"
)
string
(
REPLACE
"PD_REGISTER_ARG_MAPPING_FN"
"PD_DECLARE_ARG_MAPPING_FN"
if
(
NOT
${
kernel_mapping_registrar
}
EQUAL
""
)
util_declare
"
${
util_registrar
}
"
)
string
(
REPLACE
"PD_REGISTER_BASE_KERNEL_NAME"
"PD_DECLARE_BASE_KERNEL_NAME"
string
(
REPLACE
"PD_REGISTER_BASE_KERNEL_NAME"
"PD_DECLARE_BASE_KERNEL_NAME"
kernel_mapping_declare
"
${
kernel_mapping_registrar
}
"
)
util_declare
"
${
util_declare
}
"
)
string
(
APPEND kernel_mapping_declare
");
\n
"
)
string
(
APPEND util_declare
");
\n
"
)
file
(
APPEND
${
op_utils_header
}
"
${
kernel_mapping_declare
}
"
)
file
(
APPEND
${
op_utils_header
}
"
${
util_declare
}
"
)
endif
(
)
endfunction
()
endfunction
()
function
(
register_op_utils TARGET_NAME
)
function
(
register_op_utils TARGET_NAME
)
...
@@ -137,6 +149,7 @@ function(register_op_utils TARGET_NAME)
...
@@ -137,6 +149,7 @@ function(register_op_utils TARGET_NAME)
file
(
GLOB SIGNATURES
"
${
PADDLE_SOURCE_DIR
}
/paddle/phi/ops/compat/*_sig.cc"
)
file
(
GLOB SIGNATURES
"
${
PADDLE_SOURCE_DIR
}
/paddle/phi/ops/compat/*_sig.cc"
)
foreach
(
target
${
SIGNATURES
}
)
foreach
(
target
${
SIGNATURES
}
)
append_op_util_declare
(
${
target
}
)
append_op_util_declare
(
${
target
}
)
append_op_kernel_map_declare
(
${
target
}
)
list
(
APPEND utils_srcs
${
target
}
)
list
(
APPEND utils_srcs
${
target
}
)
endforeach
()
endforeach
()
...
...
paddle/fluid/operators/size_op.cc
浏览文件 @
e337d280
...
@@ -62,7 +62,7 @@ DECLARE_NO_NEED_BUFFER_VARS_INFERER(SizeOpNoNeedBufferVarInferer, "Input");
...
@@ -62,7 +62,7 @@ DECLARE_NO_NEED_BUFFER_VARS_INFERER(SizeOpNoNeedBufferVarInferer, "Input");
namespace
ops
=
paddle
::
operators
;
namespace
ops
=
paddle
::
operators
;
DECLARE_INFER_SHAPE_FUNCTOR
(
size
,
DECLARE_INFER_SHAPE_FUNCTOR
(
size
,
SizeInferShapeFunctor
,
SizeInferShapeFunctor
,
PD_INFER_META
(
phi
::
Size
InferMeta
));
PD_INFER_META
(
phi
::
Numel
InferMeta
));
REGISTER_OPERATOR
(
REGISTER_OPERATOR
(
size
,
size
,
ops
::
SizeOp
,
ops
::
SizeOp
,
...
...
paddle/phi/api/yaml/legacy_ops.yaml
浏览文件 @
e337d280
...
@@ -1465,9 +1465,9 @@
...
@@ -1465,9 +1465,9 @@
args
:
(Tensor x)
args
:
(Tensor x)
output
:
Tensor(size)
output
:
Tensor(size)
infer_meta
:
infer_meta
:
func
:
Size
InferMeta
func
:
Numel
InferMeta
kernel
:
kernel
:
func
:
size
func
:
numel
data_transform
:
data_transform
:
skip_transform
:
x
skip_transform
:
x
...
...
paddle/phi/core/compat/op_utils.h
浏览文件 @
e337d280
...
@@ -223,21 +223,22 @@ struct ArgumentMappingFnRegistrar {
...
@@ -223,21 +223,22 @@ struct ArgumentMappingFnRegistrar {
}
}
};
};
#define PD_REGISTER_BASE_KERNEL_NAME(op_type, base_kernel_name) \
#define PD_REGISTER_BASE_KERNEL_NAME(op_type, base_kernel_name) \
PD_STATIC_ASSERT_GLOBAL_NAMESPACE( \
PD_REGISTER_base_kernel_name_ns_check_##base_kernel_name, \
"PD_REGISTER_BASE_KERNEL_NAME must be called in global namespace."); \
static const ::phi::BaseKernelNameRegistrar \
__registrar_base_kernel_name_for_##base_kernel_name(#op_type, \
#base_kernel_name); \
int TouchBaseKernelNameSymbol_##base_kernel_name() { return 0; }
#define PD_DECLARE_BASE_KERNEL_NAME(op_type, base_kernel_name) \
PD_STATIC_ASSERT_GLOBAL_NAMESPACE( \
PD_STATIC_ASSERT_GLOBAL_NAMESPACE( \
PD_REGISTER_base_kernel_name_ns_check_##op_type, \
PD_DECLARE_ai_name_ns_check_##base_kernel_name, \
"PD_REGISTER_BASE_KERNEL_NAME must be called in global namespace."); \
"PD_DECLARE_BASE_KERNEL_NAME must be called in global namespace."); \
static const ::phi::BaseKernelNameRegistrar \
extern int TouchBaseKernelNameSymbol_##base_kernel_name(); \
__registrar_base_kernel_name_for_##op_type(#op_type, #base_kernel_name); \
UNUSED static int __declare_base_kernel_name_symbol_for_##base_kernel_name = \
int TouchBaseKernelNameSymbol_##op_type() { return 0; }
TouchBaseKernelNameSymbol_##base_kernel_name()
#define PD_DECLARE_BASE_KERNEL_NAME(op_type) \
PD_STATIC_ASSERT_GLOBAL_NAMESPACE( \
PD_DECLARE_ai_name_ns_check_##op_type, \
"PD_DECLARE_BASE_KERNEL_NAME must be called in global namespace."); \
extern int TouchBaseKernelNameSymbol_##op_type(); \
UNUSED static int __declare_base_kernel_name_symbol_for_##op_type = \
TouchBaseKernelNameSymbol_##op_type()
#define PD_REGISTER_ARG_MAPPING_FN(op_type, arg_mapping_fn) \
#define PD_REGISTER_ARG_MAPPING_FN(op_type, arg_mapping_fn) \
PD_STATIC_ASSERT_GLOBAL_NAMESPACE( \
PD_STATIC_ASSERT_GLOBAL_NAMESPACE( \
...
...
paddle/phi/infermeta/unary.cc
浏览文件 @
e337d280
...
@@ -3243,7 +3243,7 @@ void ShardIndexInferMeta(const MetaTensor& in,
...
@@ -3243,7 +3243,7 @@ void ShardIndexInferMeta(const MetaTensor& in,
out
->
set_dtype
(
in
.
dtype
());
out
->
set_dtype
(
in
.
dtype
());
}
}
void
Size
InferMeta
(
const
MetaTensor
&
input
,
MetaTensor
*
out
)
{
void
Numel
InferMeta
(
const
MetaTensor
&
input
,
MetaTensor
*
out
)
{
out
->
set_dtype
(
DataType
::
INT64
);
out
->
set_dtype
(
DataType
::
INT64
);
if
(
input
.
dims
().
size
()
==
0
)
{
if
(
input
.
dims
().
size
()
==
0
)
{
out
->
set_dims
(
phi
::
make_ddim
({}));
out
->
set_dims
(
phi
::
make_ddim
({}));
...
...
paddle/phi/infermeta/unary.h
浏览文件 @
e337d280
...
@@ -478,7 +478,7 @@ void ShardIndexInferMeta(const MetaTensor& in,
...
@@ -478,7 +478,7 @@ void ShardIndexInferMeta(const MetaTensor& in,
MetaTensor
*
out
,
MetaTensor
*
out
,
MetaConfig
config
=
MetaConfig
());
MetaConfig
config
=
MetaConfig
());
void
Size
InferMeta
(
const
MetaTensor
&
input
,
MetaTensor
*
out
);
void
Numel
InferMeta
(
const
MetaTensor
&
input
,
MetaTensor
*
out
);
void
SliceRawInferMeta
(
const
MetaTensor
&
input
,
void
SliceRawInferMeta
(
const
MetaTensor
&
input
,
const
std
::
vector
<
int64_t
>&
axes
,
const
std
::
vector
<
int64_t
>&
axes
,
...
...
paddle/phi/kernels/cpu/
size
_kernel.cc
→
paddle/phi/kernels/cpu/
numel
_kernel.cc
浏览文件 @
e337d280
...
@@ -12,16 +12,16 @@
...
@@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#include "paddle/phi/kernels/
size
_kernel.h"
#include "paddle/phi/kernels/
numel
_kernel.h"
#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/
size
_kernel_impl.h"
#include "paddle/phi/kernels/impl/
numel
_kernel_impl.h"
PD_REGISTER_KERNEL
(
size
,
PD_REGISTER_KERNEL
(
numel
,
CPU
,
CPU
,
ALL_LAYOUT
,
ALL_LAYOUT
,
phi
::
Size
Kernel
,
phi
::
Numel
Kernel
,
uint8_t
,
uint8_t
,
int16_t
,
int16_t
,
int
,
int
,
...
...
paddle/phi/kernels/gpu/
size
_kernel.cu
→
paddle/phi/kernels/gpu/
numel
_kernel.cu
浏览文件 @
e337d280
...
@@ -12,16 +12,16 @@
...
@@ -12,16 +12,16 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.
#include "paddle/phi/kernels/
size
_kernel.h"
#include "paddle/phi/kernels/
numel
_kernel.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/core/kernel_registry.h"
#include "paddle/phi/kernels/impl/
size
_kernel_impl.h"
#include "paddle/phi/kernels/impl/
numel
_kernel_impl.h"
PD_REGISTER_KERNEL
(
size
,
PD_REGISTER_KERNEL
(
numel
,
GPU
,
GPU
,
ALL_LAYOUT
,
ALL_LAYOUT
,
phi
::
Size
Kernel
,
phi
::
Numel
Kernel
,
int16_t
,
int16_t
,
int
,
int
,
int64_t
,
int64_t
,
...
...
paddle/phi/kernels/impl/
size
_kernel_impl.h
→
paddle/phi/kernels/impl/
numel
_kernel_impl.h
浏览文件 @
e337d280
...
@@ -19,9 +19,9 @@
...
@@ -19,9 +19,9 @@
namespace
phi
{
namespace
phi
{
template
<
typename
T
,
typename
Context
>
template
<
typename
T
,
typename
Context
>
void
Size
Kernel
(
const
Context
&
ctx
,
void
Numel
Kernel
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
const
DenseTensor
&
input
,
DenseTensor
*
out
)
{
DenseTensor
*
out
)
{
auto
place
=
ctx
.
GetPlace
();
auto
place
=
ctx
.
GetPlace
();
auto
out_data
=
ctx
.
template
Alloc
<
int64_t
>(
out
);
auto
out_data
=
ctx
.
template
Alloc
<
int64_t
>(
out
);
...
...
paddle/phi/kernels/
size
_kernel.h
→
paddle/phi/kernels/
numel
_kernel.h
浏览文件 @
e337d280
...
@@ -19,6 +19,8 @@
...
@@ -19,6 +19,8 @@
namespace
phi
{
namespace
phi
{
template
<
typename
T
,
typename
Context
>
template
<
typename
T
,
typename
Context
>
void
SizeKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
DenseTensor
*
out
);
void
NumelKernel
(
const
Context
&
ctx
,
const
DenseTensor
&
input
,
DenseTensor
*
out
);
}
// namespace phi
}
// namespace phi
paddle/phi/ops/compat/einsum_sig.cc
浏览文件 @
e337d280
...
@@ -31,5 +31,7 @@ KernelSignature EinsumGradOpArgumentMapping(const ArgumentMappingContext& ctx) {
...
@@ -31,5 +31,7 @@ KernelSignature EinsumGradOpArgumentMapping(const ArgumentMappingContext& ctx) {
}
}
}
// namespace phi
}
// namespace phi
PD_REGISTER_BASE_KERNEL_NAME
(
einsum
,
einsum_raw
);
PD_REGISTER_ARG_MAPPING_FN
(
einsum
,
phi
::
EinsumOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
einsum
,
phi
::
EinsumOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
einsum_grad
,
phi
::
EinsumGradOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
einsum_grad
,
phi
::
EinsumGradOpArgumentMapping
);
paddle/phi/ops/compat/embedding_sig.cc
浏览文件 @
e337d280
...
@@ -58,6 +58,11 @@ KernelSignature EmbeddingGradOpArgumentMapping(
...
@@ -58,6 +58,11 @@ KernelSignature EmbeddingGradOpArgumentMapping(
PD_REGISTER_BASE_KERNEL_NAME
(
lookup_table_v2
,
embedding
);
PD_REGISTER_BASE_KERNEL_NAME
(
lookup_table_v2
,
embedding
);
PD_REGISTER_BASE_KERNEL_NAME
(
lookup_table_v2_grad
,
embedding_grad
);
PD_REGISTER_BASE_KERNEL_NAME
(
lookup_table_v2_grad
,
embedding_grad
);
PD_REGISTER_BASE_KERNEL_NAME
(
lookup_table_v2_grad
,
embedding_sparse_grad
);
PD_REGISTER_BASE_KERNEL_NAME
(
lookup_table_v2_grad
,
sparse_weight_embedding_grad
);
PD_REGISTER_BASE_KERNEL_NAME
(
lookup_table_v2_grad
,
sparse_weight_embedding_sparse_grad
);
PD_REGISTER_ARG_MAPPING_FN
(
lookup_table_v2
,
phi
::
EmbeddingOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
lookup_table_v2
,
phi
::
EmbeddingOpArgumentMapping
);
PD_REGISTER_ARG_MAPPING_FN
(
lookup_table_v2_grad
,
PD_REGISTER_ARG_MAPPING_FN
(
lookup_table_v2_grad
,
...
...
paddle/phi/ops/compat/size_sig.cc
0 → 100644
浏览文件 @
e337d280
// Copyright (c) 2022 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 "paddle/phi/core/compat/op_utils.h"
PD_REGISTER_BASE_KERNEL_NAME
(
size
,
numel
);
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录