Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
f30ead13
P
Paddle
项目概览
PaddlePaddle
/
Paddle
接近 2 年 前同步成功
通知
2323
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
f30ead13
编写于
9月 22, 2022
作者:
Y
YuanRisheng
提交者:
GitHub
9月 22, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[BUG FIX]Fix MetaTensor's bug when run infermeta (#46265)
* fix sum bug * fix ci bugs * fix ci bugs * update code according comment
上级
b1771368
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
12 addition
and
9 deletion
+12
-9
paddle/phi/core/meta_tensor.cc
paddle/phi/core/meta_tensor.cc
+11
-5
paddle/phi/core/selected_rows.h
paddle/phi/core/selected_rows.h
+1
-4
未找到文件。
paddle/phi/core/meta_tensor.cc
浏览文件 @
f30ead13
...
@@ -39,7 +39,11 @@ int64_t MetaTensor::numel() const {
...
@@ -39,7 +39,11 @@ int64_t MetaTensor::numel() const {
DDim
MetaTensor
::
dims
()
const
{
DDim
MetaTensor
::
dims
()
const
{
ValidCheck
(
*
this
);
ValidCheck
(
*
this
);
return
tensor_
->
dims
();
if
(
phi
::
SelectedRows
::
classof
(
tensor_
))
{
return
static_cast
<
SelectedRows
*>
(
tensor_
)
->
GetCompleteDims
();
}
else
{
return
tensor_
->
dims
();
}
}
}
DataType
MetaTensor
::
dtype
()
const
{
DataType
MetaTensor
::
dtype
()
const
{
...
@@ -61,9 +65,7 @@ void MetaTensor::set_dims(const DDim& dims) {
...
@@ -61,9 +65,7 @@ void MetaTensor::set_dims(const DDim& dims) {
StringTensorUtils
::
GetMutableMeta
(
static_cast
<
StringTensor
*>
(
tensor_
))
StringTensorUtils
::
GetMutableMeta
(
static_cast
<
StringTensor
*>
(
tensor_
))
->
dims
=
dims
;
->
dims
=
dims
;
}
else
if
(
phi
::
SelectedRows
::
classof
(
tensor_
))
{
}
else
if
(
phi
::
SelectedRows
::
classof
(
tensor_
))
{
DenseTensorUtils
::
GetMutableMeta
(
static_cast
<
SelectedRows
*>
(
tensor_
)
->
set_height
(
dims
[
0
]);
static_cast
<
SelectedRows
*>
(
tensor_
)
->
mutable_value
())
->
dims
=
dims
;
}
else
if
(
phi
::
SparseCooTensor
::
classof
(
tensor_
))
{
}
else
if
(
phi
::
SparseCooTensor
::
classof
(
tensor_
))
{
DenseTensorUtils
::
GetMutableMeta
(
static_cast
<
SparseCooTensor
*>
(
tensor_
))
DenseTensorUtils
::
GetMutableMeta
(
static_cast
<
SparseCooTensor
*>
(
tensor_
))
->
dims
=
dims
;
->
dims
=
dims
;
...
@@ -179,7 +181,6 @@ void MetaTensor::share_dims(const MetaTensor& meta_tensor) {
...
@@ -179,7 +181,6 @@ void MetaTensor::share_dims(const MetaTensor& meta_tensor) {
bool
is_sparse_coo
=
phi
::
SparseCooTensor
::
classof
(
tensor_
);
bool
is_sparse_coo
=
phi
::
SparseCooTensor
::
classof
(
tensor_
);
bool
is_sparse_csr
=
phi
::
SparseCsrTensor
::
classof
(
tensor_
);
bool
is_sparse_csr
=
phi
::
SparseCsrTensor
::
classof
(
tensor_
);
if
(
is_dense_tensor
||
is_selected_rows
||
is_sparse_coo
||
is_sparse_csr
)
{
if
(
is_dense_tensor
||
is_selected_rows
||
is_sparse_coo
||
is_sparse_csr
)
{
set_dims
(
meta_tensor
.
dims
());
if
(
is_selected_rows
)
{
if
(
is_selected_rows
)
{
const
auto
in_tensor_base
=
meta_tensor
.
tensor
();
const
auto
in_tensor_base
=
meta_tensor
.
tensor
();
PADDLE_ENFORCE_EQ
(
PADDLE_ENFORCE_EQ
(
...
@@ -191,6 +192,11 @@ void MetaTensor::share_dims(const MetaTensor& meta_tensor) {
...
@@ -191,6 +192,11 @@ void MetaTensor::share_dims(const MetaTensor& meta_tensor) {
auto
*
selected_rows_in
=
static_cast
<
SelectedRows
*>
(
in_tensor_base
);
auto
*
selected_rows_in
=
static_cast
<
SelectedRows
*>
(
in_tensor_base
);
selected_rows_out
->
set_rows
(
selected_rows_in
->
rows
());
selected_rows_out
->
set_rows
(
selected_rows_in
->
rows
());
selected_rows_out
->
set_height
(
selected_rows_in
->
height
());
selected_rows_out
->
set_height
(
selected_rows_in
->
height
());
DenseTensorUtils
::
GetMutableMeta
(
static_cast
<
SelectedRows
*>
(
tensor_
)
->
mutable_value
())
->
dims
=
selected_rows_in
->
mutable_value
()
->
dims
();
}
else
{
set_dims
(
meta_tensor
.
dims
());
}
}
}
else
{
}
else
{
PADDLE_THROW
(
phi
::
errors
::
Unimplemented
(
PADDLE_THROW
(
phi
::
errors
::
Unimplemented
(
...
...
paddle/phi/core/selected_rows.h
浏览文件 @
f30ead13
...
@@ -132,10 +132,7 @@ class SelectedRows : public TensorBase,
...
@@ -132,10 +132,7 @@ class SelectedRows : public TensorBase,
/// \brief Returns the dims of the tensor.
/// \brief Returns the dims of the tensor.
/// \return The dims of the tensor.
/// \return The dims of the tensor.
const
DDim
&
dims
()
const
noexcept
override
{
const
DDim
&
dims
()
const
noexcept
override
{
return
impl_
->
dims
();
}
return
impl_
->
dims
();
// return phi::make_ddim(dims);
}
/// \brief Returns the data type of the tensor.
/// \brief Returns the data type of the tensor.
/// \return The data type of the tensor.
/// \return The data type of the tensor.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录