Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
5610c171
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2297
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看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
5610c171
编写于
3月 01, 2021
作者:
C
Chen Weihang
提交者:
GitHub
3月 01, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix dtype unmatched (#31305)
上级
f8bdb909
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
10 addition
and
10 deletion
+10
-10
paddle/fluid/extension/include/ext_tensor.h
paddle/fluid/extension/include/ext_tensor.h
+2
-2
paddle/fluid/extension/src/ext_tensor.cc
paddle/fluid/extension/src/ext_tensor.cc
+3
-3
paddle/fluid/framework/custom_tensor_test.cc
paddle/fluid/framework/custom_tensor_test.cc
+5
-5
未找到文件。
paddle/fluid/extension/include/ext_tensor.h
浏览文件 @
5610c171
...
...
@@ -57,7 +57,7 @@ class PD_DLL_DECL Tensor {
/// Reshape must be called before calling
/// mutable_data() or copy_to(const PlaceType& place)
/// \param shape The shape to set.
void
reshape
(
const
std
::
vector
<
int
>&
shape
);
void
reshape
(
const
std
::
vector
<
int
64_t
>&
shape
);
/// \brief Get the memory pointer in CPU or GPU with
/// specific data type.
...
...
@@ -90,7 +90,7 @@ class PD_DLL_DECL Tensor {
Tensor
copy_to
(
const
PlaceType
&
place
)
const
;
/// \brief Return the shape of the Tensor.
std
::
vector
<
int
>
shape
()
const
;
std
::
vector
<
int
64_t
>
shape
()
const
;
/// \brief Return the data type of the tensor.
/// It's usually used to get the output tensor data type.
...
...
paddle/fluid/extension/src/ext_tensor.cc
浏览文件 @
5610c171
...
...
@@ -95,7 +95,7 @@ void GpuCopy(T *src, T *dst, PlaceType src_plc, PlaceType dst_plc,
} \
auto *tensor = static_cast<framework::LoDTensor *>(tensor_.get());
void
Tensor
::
reshape
(
const
std
::
vector
<
int
>
&
shape
)
{
void
Tensor
::
reshape
(
const
std
::
vector
<
int
64_t
>
&
shape
)
{
GET_CASTED_TENSOR
tensor
->
Resize
(
framework
::
make_ddim
(
shape
));
}
...
...
@@ -251,9 +251,9 @@ template PD_DLL_DECL int16_t *Tensor::mutable_data<int16_t>(
const
PlaceType
&
place
);
template
PD_DLL_DECL
bool
*
Tensor
::
mutable_data
<
bool
>(
const
PlaceType
&
place
);
std
::
vector
<
int
>
Tensor
::
shape
()
const
{
std
::
vector
<
int
64_t
>
Tensor
::
shape
()
const
{
GET_CASTED_TENSOR
return
framework
::
vectorize
<
int
>
(
tensor
->
dims
());
return
framework
::
vectorize
<
int
64_t
>
(
tensor
->
dims
());
}
const
PlaceType
&
Tensor
::
place
()
const
{
...
...
paddle/fluid/framework/custom_tensor_test.cc
浏览文件 @
5610c171
...
...
@@ -20,7 +20,7 @@
template
<
typename
T
>
paddle
::
Tensor
InitCPUTensorForTest
()
{
std
::
vector
<
int
>
tensor_shape
{
5
,
5
};
std
::
vector
<
int
64_t
>
tensor_shape
{
5
,
5
};
auto
t1
=
paddle
::
Tensor
(
paddle
::
PlaceType
::
kCPU
);
t1
.
reshape
(
tensor_shape
);
auto
*
p_data_ptr
=
t1
.
mutable_data
<
T
>
(
paddle
::
PlaceType
::
kCPU
);
...
...
@@ -54,7 +54,7 @@ void TestCopyTensor() {
}
void
TestAPIPlace
()
{
std
::
vector
<
int
>
tensor_shape
=
{
5
,
5
};
std
::
vector
<
int
64_t
>
tensor_shape
=
{
5
,
5
};
#ifdef PADDLE_WITH_CUDA
auto
t1
=
paddle
::
Tensor
(
paddle
::
PlaceType
::
kGPU
);
t1
.
reshape
(
tensor_shape
);
...
...
@@ -68,7 +68,7 @@ void TestAPIPlace() {
}
void
TestAPISizeAndShape
()
{
std
::
vector
<
int
>
tensor_shape
=
{
5
,
5
};
std
::
vector
<
int
64_t
>
tensor_shape
=
{
5
,
5
};
auto
t1
=
paddle
::
Tensor
(
paddle
::
PlaceType
::
kCPU
);
t1
.
reshape
(
tensor_shape
);
CHECK_EQ
(
t1
.
size
(),
25
);
...
...
@@ -77,7 +77,7 @@ void TestAPISizeAndShape() {
template
<
typename
T
>
paddle
::
DataType
TestDtype
()
{
std
::
vector
<
int
>
tensor_shape
=
{
5
,
5
};
std
::
vector
<
int
64_t
>
tensor_shape
=
{
5
,
5
};
auto
t1
=
paddle
::
Tensor
(
paddle
::
PlaceType
::
kCPU
);
t1
.
reshape
(
tensor_shape
);
t1
.
template
mutable_data
<
T
>();
...
...
@@ -86,7 +86,7 @@ paddle::DataType TestDtype() {
template
<
typename
T
>
void
TestCast
(
paddle
::
DataType
data_type
)
{
std
::
vector
<
int
>
tensor_shape
=
{
5
,
5
};
std
::
vector
<
int
64_t
>
tensor_shape
=
{
5
,
5
};
auto
t1
=
paddle
::
Tensor
(
paddle
::
PlaceType
::
kCPU
);
t1
.
reshape
(
tensor_shape
);
t1
.
template
mutable_data
<
T
>();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录