Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
4f56e7c2
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看板
未验证
提交
4f56e7c2
编写于
6月 02, 2023
作者:
Y
YuanRisheng
提交者:
GitHub
6月 02, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[BugFix]Fix TypeInfo errors in MacOS (#54279)
* fix mac typeinfo bugs * add file * move code to cc * fix compile bugs
上级
85d5f26d
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
105 addition
and
119 deletion
+105
-119
paddle/fluid/framework/type_info.cc
paddle/fluid/framework/type_info.cc
+21
-31
paddle/phi/backends/cpu/cpu_context.cc
paddle/phi/backends/cpu/cpu_context.cc
+0
-4
paddle/phi/backends/custom/custom_context.cc
paddle/phi/backends/custom/custom_context.cc
+0
-5
paddle/phi/backends/gpu/gpu_context.cc
paddle/phi/backends/gpu/gpu_context.cc
+0
-9
paddle/phi/backends/xpu/xpu_context.cc
paddle/phi/backends/xpu/xpu_context.cc
+0
-3
paddle/phi/core/CMakeLists.txt
paddle/phi/core/CMakeLists.txt
+1
-1
paddle/phi/core/dense_tensor.cc
paddle/phi/core/dense_tensor.cc
+0
-5
paddle/phi/core/selected_rows.cc
paddle/phi/core/selected_rows.cc
+0
-5
paddle/phi/core/sparse_coo_tensor.cc
paddle/phi/core/sparse_coo_tensor.cc
+0
-5
paddle/phi/core/sparse_csr_tensor.cc
paddle/phi/core/sparse_csr_tensor.cc
+0
-5
paddle/phi/core/storage_properties.cc
paddle/phi/core/storage_properties.cc
+0
-32
paddle/phi/core/string_tensor.cc
paddle/phi/core/string_tensor.cc
+0
-5
paddle/phi/core/tensor_array.cc
paddle/phi/core/tensor_array.cc
+0
-5
paddle/phi/core/utils/type_info.cc
paddle/phi/core/utils/type_info.cc
+71
-0
paddle/phi/core/utils/type_info.h
paddle/phi/core/utils/type_info.h
+2
-4
test/cpp/phi/core/test_type_info.cc
test/cpp/phi/core/test_type_info.cc
+10
-0
未找到文件。
paddle/fluid/framework/type_info.cc
浏览文件 @
4f56e7c2
...
@@ -19,36 +19,26 @@ limitations under the License. */
...
@@ -19,36 +19,26 @@ limitations under the License. */
#include "paddle/fluid/prim/utils/static/desc_tensor.h"
#include "paddle/fluid/prim/utils/static/desc_tensor.h"
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
phi
::
TensorBase
>
template
<
typename
BaseT
,
typename
DerivedT
>
TypeInfoTraits
<
phi
::
TensorBase
,
paddle
::
framework
::
RawTensor
>::
kType
=
TypeInfoTraits
<
BaseT
,
DerivedT
>::
TypeInfoTraits
()
{
RegisterStaticType
<
phi
::
TensorBase
>
(
static_cast
<
BaseT
*>
(
static_cast
<
DerivedT
*>
(
this
))
->
type_info_
=
kType
;
paddle
::
framework
::
RawTensor
::
name
());
}
template
<
>
template
<
typename
BaseT
,
typename
DerivedT
>
const
TypeInfo
<
phi
::
TensorBase
>
const
TypeInfo
<
BaseT
>
TypeInfoTraits
<
BaseT
,
DerivedT
>::
kType
=
TypeInfoTraits
<
phi
::
TensorBase
,
paddle
::
framework
::
Vocab
>::
kType
=
RegisterStaticType
<
BaseT
>
(
DerivedT
::
name
());
RegisterStaticType
<
phi
::
TensorBase
>
(
paddle
::
framework
::
Vocab
::
name
());
template
<
typename
BaseT
,
typename
DerivedT
>
template
<
>
bool
TypeInfoTraits
<
BaseT
,
DerivedT
>::
classof
(
const
BaseT
*
obj
)
{
const
TypeInfo
<
phi
::
TensorBase
>
return
obj
->
type_info
()
==
kType
;
TypeInfoTraits
<
phi
::
TensorBase
,
paddle
::
framework
::
Strings
>::
kType
=
}
RegisterStaticType
<
phi
::
TensorBase
>
(
paddle
::
framework
::
Strings
::
name
());
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
paddle
::
framework
::
RawTensor
>;
template
<
>
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
paddle
::
framework
::
Vocab
>;
const
TypeInfo
<
phi
::
TensorBase
>
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
paddle
::
framework
::
Strings
>;
TypeInfoTraits
<
phi
::
TensorBase
,
paddle
::
framework
::
FeedList
>::
kType
=
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
paddle
::
framework
::
FeedList
>;
RegisterStaticType
<
phi
::
TensorBase
>
(
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
egr
::
VariableCompatTensor
>;
paddle
::
framework
::
FeedList
::
name
());
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
paddle
::
prim
::
DescTensor
>;
template
<
>
const
TypeInfo
<
phi
::
TensorBase
>
TypeInfoTraits
<
phi
::
TensorBase
,
egr
::
VariableCompatTensor
>::
kType
=
RegisterStaticType
<
phi
::
TensorBase
>
(
egr
::
VariableCompatTensor
::
name
());
template
<
>
const
TypeInfo
<
phi
::
TensorBase
>
TypeInfoTraits
<
phi
::
TensorBase
,
paddle
::
prim
::
DescTensor
>::
kType
=
RegisterStaticType
<
phi
::
TensorBase
>
(
paddle
::
prim
::
DescTensor
::
name
());
}
// namespace phi
}
// namespace phi
paddle/phi/backends/cpu/cpu_context.cc
浏览文件 @
4f56e7c2
...
@@ -24,10 +24,6 @@
...
@@ -24,10 +24,6 @@
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
DeviceContext
>
TypeInfoTraits
<
DeviceContext
,
CPUContext
>::
kType
=
RegisterStaticType
<
DeviceContext
>
(
CPUContext
::
name
());
struct
CPUContext
::
Impl
{
struct
CPUContext
::
Impl
{
Impl
()
:
place_
(
CPUPlace
())
{}
Impl
()
:
place_
(
CPUPlace
())
{}
...
...
paddle/phi/backends/custom/custom_context.cc
浏览文件 @
4f56e7c2
...
@@ -19,11 +19,6 @@ limitations under the License. */
...
@@ -19,11 +19,6 @@ limitations under the License. */
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
DeviceContext
>
TypeInfoTraits
<
DeviceContext
,
CustomContext
>::
kType
=
RegisterStaticType
<
DeviceContext
>
(
CustomContext
::
name
());
struct
CustomContext
::
Impl
{
struct
CustomContext
::
Impl
{
explicit
Impl
(
const
CustomPlace
&
place
)
:
place_
(
place
)
{}
explicit
Impl
(
const
CustomPlace
&
place
)
:
place_
(
place
)
{}
...
...
paddle/phi/backends/gpu/gpu_context.cc
浏览文件 @
4f56e7c2
...
@@ -59,15 +59,6 @@ limitations under the License. */
...
@@ -59,15 +59,6 @@ limitations under the License. */
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
DeviceContext
>
TypeInfoTraits
<
DeviceContext
,
GPUContext
>::
kType
=
RegisterStaticType
<
DeviceContext
>
(
GPUContext
::
name
());
template
<
>
const
TypeInfo
<
DeviceContext
>
TypeInfoTraits
<
DeviceContext
,
GPUPinnedContext
>::
kType
=
RegisterStaticType
<
DeviceContext
>
(
GPUPinnedContext
::
name
());
namespace
internal
{
namespace
internal
{
class
EigenGpuStreamDevice
:
public
Eigen
::
StreamInterface
{
class
EigenGpuStreamDevice
:
public
Eigen
::
StreamInterface
{
...
...
paddle/phi/backends/xpu/xpu_context.cc
浏览文件 @
4f56e7c2
...
@@ -30,9 +30,6 @@ namespace xpu = baidu::xpu::api;
...
@@ -30,9 +30,6 @@ namespace xpu = baidu::xpu::api;
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
DeviceContext
>
TypeInfoTraits
<
DeviceContext
,
XPUContext
>::
kType
=
RegisterStaticType
<
DeviceContext
>
(
XPUContext
::
name
());
struct
XPUContext
::
Impl
{
struct
XPUContext
::
Impl
{
void
SetL3Cache
(
int
l3_size
=
14155776
)
{
void
SetL3Cache
(
int
l3_size
=
14155776
)
{
const
int
MAX_XPU_NUM
=
16
;
const
int
MAX_XPU_NUM
=
16
;
...
...
paddle/phi/core/CMakeLists.txt
浏览文件 @
4f56e7c2
...
@@ -37,4 +37,4 @@ collect_srcs(
...
@@ -37,4 +37,4 @@ collect_srcs(
generator.cc
generator.cc
kernel_factory.cc
kernel_factory.cc
tensor_utils.cc
tensor_utils.cc
storage_properties
.cc
)
utils/type_info
.cc
)
paddle/phi/core/dense_tensor.cc
浏览文件 @
4f56e7c2
...
@@ -42,11 +42,6 @@ limitations under the License. */
...
@@ -42,11 +42,6 @@ limitations under the License. */
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
phi
::
TensorBase
>
TypeInfoTraits
<
phi
::
TensorBase
,
DenseTensor
>::
kType
=
RegisterStaticType
<
phi
::
TensorBase
>
(
DenseTensor
::
name
());
DenseTensor
::
DenseTensor
(
Allocator
*
a
,
const
DenseTensorMeta
&
meta
)
DenseTensor
::
DenseTensor
(
Allocator
*
a
,
const
DenseTensorMeta
&
meta
)
:
meta_
(
meta
),
holder_
(
a
->
Allocate
(
SizeOf
(
dtype
())
*
numel
()))
{}
:
meta_
(
meta
),
holder_
(
a
->
Allocate
(
SizeOf
(
dtype
())
*
numel
()))
{}
...
...
paddle/phi/core/selected_rows.cc
浏览文件 @
4f56e7c2
...
@@ -16,11 +16,6 @@ limitations under the License. */
...
@@ -16,11 +16,6 @@ limitations under the License. */
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
phi
::
TensorBase
>
TypeInfoTraits
<
phi
::
TensorBase
,
SelectedRows
>::
kType
=
RegisterStaticType
<
phi
::
TensorBase
>
(
SelectedRows
::
name
());
SelectedRows
::
SelectedRows
(
const
std
::
vector
<
int64_t
>&
rows
,
SelectedRows
::
SelectedRows
(
const
std
::
vector
<
int64_t
>&
rows
,
const
int64_t
&
height
)
const
int64_t
&
height
)
:
impl_
(
std
::
make_shared
<
phi
::
SelectedRowsImpl
>
(
rows
,
height
))
{}
:
impl_
(
std
::
make_shared
<
phi
::
SelectedRowsImpl
>
(
rows
,
height
))
{}
...
...
paddle/phi/core/sparse_coo_tensor.cc
浏览文件 @
4f56e7c2
...
@@ -16,11 +16,6 @@ limitations under the License. */
...
@@ -16,11 +16,6 @@ limitations under the License. */
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
phi
::
TensorBase
>
TypeInfoTraits
<
phi
::
TensorBase
,
SparseCooTensor
>::
kType
=
RegisterStaticType
<
phi
::
TensorBase
>
(
SparseCooTensor
::
name
());
SparseCooTensor
::
SparseCooTensor
()
{
SparseCooTensor
::
SparseCooTensor
()
{
DenseTensor
non_zero_indices
,
non_zero_elements
;
DenseTensor
non_zero_indices
,
non_zero_elements
;
this
->
SetMember
(
non_zero_indices
,
non_zero_elements
,
{
1
},
true
);
this
->
SetMember
(
non_zero_indices
,
non_zero_elements
,
{
1
},
true
);
...
...
paddle/phi/core/sparse_csr_tensor.cc
浏览文件 @
4f56e7c2
...
@@ -16,11 +16,6 @@ limitations under the License. */
...
@@ -16,11 +16,6 @@ limitations under the License. */
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
phi
::
TensorBase
>
TypeInfoTraits
<
phi
::
TensorBase
,
SparseCsrTensor
>::
kType
=
RegisterStaticType
<
phi
::
TensorBase
>
(
SparseCsrTensor
::
name
());
SparseCsrTensor
::
SparseCsrTensor
()
{
SparseCsrTensor
::
SparseCsrTensor
()
{
DenseTensor
crows
,
cols
,
values
;
DenseTensor
crows
,
cols
,
values
;
this
->
non_zero_crows_
=
crows
;
this
->
non_zero_crows_
=
crows
;
...
...
paddle/phi/core/storage_properties.cc
已删除
100644 → 0
浏览文件 @
85d5f26d
/* 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/storage_properties.h"
namespace
phi
{
#ifdef PADDLE_WITH_MKLDNN
template
<
>
const
TypeInfo
<
StorageProperties
>
TypeInfoTraits
<
StorageProperties
,
OneDNNStorageProperties
>::
kType
=
RegisterStaticType
<
StorageProperties
>
(
OneDNNStorageProperties
::
name
());
#endif
template
<
>
const
TypeInfo
<
StorageProperties
>
TypeInfoTraits
<
StorageProperties
,
NPUStorageProperties
>::
kType
=
RegisterStaticType
<
StorageProperties
>
(
NPUStorageProperties
::
name
());
}
// namespace phi
paddle/phi/core/string_tensor.cc
浏览文件 @
4f56e7c2
...
@@ -21,11 +21,6 @@ limitations under the License. */
...
@@ -21,11 +21,6 @@ limitations under the License. */
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
phi
::
TensorBase
>
TypeInfoTraits
<
phi
::
TensorBase
,
StringTensor
>::
kType
=
RegisterStaticType
<
phi
::
TensorBase
>
(
StringTensor
::
name
());
StringTensor
::
StringTensor
()
{
meta_
.
offset
=
0
;
}
StringTensor
::
StringTensor
()
{
meta_
.
offset
=
0
;
}
StringTensor
::
StringTensor
(
Allocator
*
a
,
const
StringTensorMeta
&
meta
)
StringTensor
::
StringTensor
(
Allocator
*
a
,
const
StringTensorMeta
&
meta
)
...
...
paddle/phi/core/tensor_array.cc
浏览文件 @
4f56e7c2
...
@@ -16,11 +16,6 @@ limitations under the License. */
...
@@ -16,11 +16,6 @@ limitations under the License. */
namespace
phi
{
namespace
phi
{
template
<
>
const
TypeInfo
<
phi
::
TensorBase
>
TypeInfoTraits
<
phi
::
TensorBase
,
TensorArray
>::
kType
=
RegisterStaticType
<
phi
::
TensorBase
>
(
TensorArray
::
name
());
TensorArray
::
TensorArray
(
const
std
::
vector
<
DenseTensor
>&
vec
)
{
TensorArray
::
TensorArray
(
const
std
::
vector
<
DenseTensor
>&
vec
)
{
tensors_
=
vec
;
tensors_
=
vec
;
}
}
...
...
paddle/phi/core/utils/type_info.cc
0 → 100644
浏览文件 @
4f56e7c2
/* Copyright (c) 2021 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/phi/backends/cpu/cpu_context.h"
#include "paddle/phi/backends/custom/custom_context.h"
#include "paddle/phi/backends/gpu/gpu_context.h"
#include "paddle/phi/backends/xpu/xpu_context.h"
#include "paddle/phi/core/selected_rows.h"
#include "paddle/phi/core/sparse_coo_tensor.h"
#include "paddle/phi/core/sparse_csr_tensor.h"
#include "paddle/phi/core/storage_properties.h"
#include "paddle/phi/core/string_tensor.h"
#include "paddle/phi/core/tensor_array.h"
#include "paddle/phi/core/utils/type_info.h"
namespace
phi
{
template
<
typename
BaseT
,
typename
DerivedT
>
TypeInfoTraits
<
BaseT
,
DerivedT
>::
TypeInfoTraits
()
{
static_cast
<
BaseT
*>
(
static_cast
<
DerivedT
*>
(
this
))
->
type_info_
=
kType
;
}
template
<
typename
BaseT
,
typename
DerivedT
>
bool
TypeInfoTraits
<
BaseT
,
DerivedT
>::
classof
(
const
BaseT
*
obj
)
{
return
obj
->
type_info
()
==
kType
;
}
template
<
typename
BaseT
,
typename
DerivedT
>
const
TypeInfo
<
BaseT
>
TypeInfoTraits
<
BaseT
,
DerivedT
>::
kType
=
RegisterStaticType
<
BaseT
>
(
DerivedT
::
name
());
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
DenseTensor
>;
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
SelectedRows
>;
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
SparseCooTensor
>;
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
SparseCsrTensor
>;
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
StringTensor
>;
template
class
TypeInfoTraits
<
phi
::
TensorBase
,
TensorArray
>;
template
class
TypeInfoTraits
<
phi
::
DeviceContext
,
CPUContext
>;
template
class
TypeInfoTraits
<
phi
::
DeviceContext
,
CustomContext
>;
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) || \
defined(PADDLE_WITH_XPU_KP)
template
class
TypeInfoTraits
<
phi
::
DeviceContext
,
GPUContext
>;
template
class
TypeInfoTraits
<
phi
::
DeviceContext
,
GPUPinnedContext
>;
#endif
#ifdef PADDLE_WITH_XPU
template
class
TypeInfoTraits
<
phi
::
DeviceContext
,
XPUContext
>;
#endif
#ifdef PADDLE_WITH_MKLDNN
template
class
TypeInfoTraits
<
phi
::
StorageProperties
,
OneDNNStorageProperties
>;
#endif
template
class
TypeInfoTraits
<
phi
::
StorageProperties
,
NPUStorageProperties
>;
}
// namespace phi
paddle/phi/core/utils/type_info.h
浏览文件 @
4f56e7c2
...
@@ -43,10 +43,8 @@ template <typename BaseT, typename DerivedT>
...
@@ -43,10 +43,8 @@ template <typename BaseT, typename DerivedT>
class
TypeInfoTraits
{
class
TypeInfoTraits
{
public:
public:
static
const
TypeInfo
<
BaseT
>
kType
;
static
const
TypeInfo
<
BaseT
>
kType
;
TypeInfoTraits
()
{
TypeInfoTraits
();
static_cast
<
BaseT
*>
(
static_cast
<
DerivedT
*>
(
this
))
->
type_info_
=
kType
;
static
bool
classof
(
const
BaseT
*
obj
);
}
static
bool
classof
(
const
BaseT
*
obj
)
{
return
obj
->
type_info
()
==
kType
;
}
};
};
template
<
typename
BaseT
>
template
<
typename
BaseT
>
...
...
test/cpp/phi/core/test_type_info.cc
浏览文件 @
4f56e7c2
...
@@ -22,6 +22,16 @@ template <typename BaseT, typename DerivedT>
...
@@ -22,6 +22,16 @@ template <typename BaseT, typename DerivedT>
const
TypeInfo
<
BaseT
>
TypeInfoTraits
<
BaseT
,
DerivedT
>::
kType
=
const
TypeInfo
<
BaseT
>
TypeInfoTraits
<
BaseT
,
DerivedT
>::
kType
=
RegisterStaticType
<
BaseT
>
(
DerivedT
::
name
());
RegisterStaticType
<
BaseT
>
(
DerivedT
::
name
());
template
<
typename
BaseT
,
typename
DerivedT
>
bool
TypeInfoTraits
<
BaseT
,
DerivedT
>::
classof
(
const
BaseT
*
obj
)
{
return
obj
->
type_info
()
==
kType
;
}
template
<
typename
BaseT
,
typename
DerivedT
>
TypeInfoTraits
<
BaseT
,
DerivedT
>::
TypeInfoTraits
()
{
static_cast
<
BaseT
*>
(
static_cast
<
DerivedT
*>
(
this
))
->
type_info_
=
kType
;
}
namespace
tests
{
namespace
tests
{
template
<
typename
T
>
template
<
typename
T
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录