Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
5a6a2d27
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看板
未验证
提交
5a6a2d27
编写于
12月 31, 2021
作者:
Z
Zhanlue Yang
提交者:
GitHub
12月 31, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Removed friend class EigenTensor/EigenMatrix/EigenVector from Tensor (#38607)
上级
02c17c0b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
6 addition
and
16 deletion
+6
-16
paddle/fluid/framework/eigen.h
paddle/fluid/framework/eigen.h
+6
-6
paddle/fluid/framework/tensor.h
paddle/fluid/framework/tensor.h
+0
-10
未找到文件。
paddle/fluid/framework/eigen.h
浏览文件 @
5a6a2d27
...
@@ -57,7 +57,7 @@ struct EigenTensor {
...
@@ -57,7 +57,7 @@ struct EigenTensor {
}
}
static
Type
From
(
Tensor
&
tensor
)
{
// NOLINT
static
Type
From
(
Tensor
&
tensor
)
{
// NOLINT
return
From
(
tensor
,
tensor
.
dims
_
);
return
From
(
tensor
,
tensor
.
dims
()
);
}
// NOLINT
}
// NOLINT
static
ConstType
From
(
const
Tensor
&
tensor
,
DDim
dims
)
{
static
ConstType
From
(
const
Tensor
&
tensor
,
DDim
dims
)
{
...
@@ -65,7 +65,7 @@ struct EigenTensor {
...
@@ -65,7 +65,7 @@ struct EigenTensor {
}
}
static
ConstType
From
(
const
Tensor
&
tensor
)
{
static
ConstType
From
(
const
Tensor
&
tensor
)
{
return
From
(
tensor
,
tensor
.
dims
_
);
return
From
(
tensor
,
tensor
.
dims
()
);
}
}
};
};
...
@@ -74,7 +74,7 @@ template <typename T, int MajorType = Eigen::RowMajor,
...
@@ -74,7 +74,7 @@ template <typename T, int MajorType = Eigen::RowMajor,
struct
EigenMatrix
:
public
EigenTensor
<
T
,
2
,
MajorType
,
IndexType
>
{
struct
EigenMatrix
:
public
EigenTensor
<
T
,
2
,
MajorType
,
IndexType
>
{
static
typename
EigenMatrix
::
Type
Reshape
(
Tensor
&
tensor
,
// NOLINT
static
typename
EigenMatrix
::
Type
Reshape
(
Tensor
&
tensor
,
// NOLINT
int
num_col_dims
)
{
int
num_col_dims
)
{
int
rank
=
tensor
.
dims
_
.
size
();
int
rank
=
tensor
.
dims
()
.
size
();
PADDLE_ENFORCE_EQ
((
num_col_dims
>
0
&&
num_col_dims
<
rank
),
true
,
PADDLE_ENFORCE_EQ
((
num_col_dims
>
0
&&
num_col_dims
<
rank
),
true
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input dimension number(num_col_dims) must be "
"Input dimension number(num_col_dims) must be "
...
@@ -86,7 +86,7 @@ struct EigenMatrix : public EigenTensor<T, 2, MajorType, IndexType> {
...
@@ -86,7 +86,7 @@ struct EigenMatrix : public EigenTensor<T, 2, MajorType, IndexType> {
static
typename
EigenMatrix
::
ConstType
Reshape
(
const
Tensor
&
tensor
,
static
typename
EigenMatrix
::
ConstType
Reshape
(
const
Tensor
&
tensor
,
int
num_col_dims
)
{
int
num_col_dims
)
{
int
rank
=
tensor
.
dims
_
.
size
();
int
rank
=
tensor
.
dims
()
.
size
();
PADDLE_ENFORCE_EQ
((
num_col_dims
>
0
&&
num_col_dims
<
rank
),
true
,
PADDLE_ENFORCE_EQ
((
num_col_dims
>
0
&&
num_col_dims
<
rank
),
true
,
platform
::
errors
::
InvalidArgument
(
platform
::
errors
::
InvalidArgument
(
"Input dimension number(num_col_dims) must be "
"Input dimension number(num_col_dims) must be "
...
@@ -102,12 +102,12 @@ template <typename T, int MajorType = Eigen::RowMajor,
...
@@ -102,12 +102,12 @@ template <typename T, int MajorType = Eigen::RowMajor,
struct
EigenVector
:
public
EigenTensor
<
T
,
1
,
MajorType
,
IndexType
>
{
struct
EigenVector
:
public
EigenTensor
<
T
,
1
,
MajorType
,
IndexType
>
{
// Flatten reshapes a Tensor into an EigenVector.
// Flatten reshapes a Tensor into an EigenVector.
static
typename
EigenVector
::
Type
Flatten
(
Tensor
&
tensor
)
{
// NOLINT
static
typename
EigenVector
::
Type
Flatten
(
Tensor
&
tensor
)
{
// NOLINT
return
EigenVector
::
From
(
tensor
,
{
product
(
tensor
.
dims
_
)});
return
EigenVector
::
From
(
tensor
,
{
product
(
tensor
.
dims
()
)});
}
}
static
typename
EigenVector
::
ConstType
Flatten
(
static
typename
EigenVector
::
ConstType
Flatten
(
const
Tensor
&
tensor
)
{
// NOLINT
const
Tensor
&
tensor
)
{
// NOLINT
return
EigenVector
::
From
(
tensor
,
{
product
(
tensor
.
dims
_
)});
return
EigenVector
::
From
(
tensor
,
{
product
(
tensor
.
dims
()
)});
}
}
};
};
...
...
paddle/fluid/framework/tensor.h
浏览文件 @
5a6a2d27
...
@@ -111,16 +111,6 @@ class Tensor {
...
@@ -111,16 +111,6 @@ class Tensor {
dnnl
::
memory
::
format_tag
format_
=
dnnl
::
memory
::
format_tag
::
undef
;
dnnl
::
memory
::
format_tag
format_
=
dnnl
::
memory
::
format_tag
::
undef
;
#endif
#endif
public:
template
<
typename
T
,
size_t
D
,
int
MajorType
,
typename
IndexType
>
friend
struct
EigenTensor
;
template
<
typename
T
,
int
MajorType
,
typename
IndexType
>
friend
struct
EigenMatrix
;
template
<
typename
T
,
int
MajorType
,
typename
IndexType
>
friend
struct
EigenVector
;
public:
public:
Tensor
()
Tensor
()
:
type_
(
proto
::
VarType
::
FP32
),
:
type_
(
proto
::
VarType
::
FP32
),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录