Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d772166c
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
未验证
提交
d772166c
编写于
2年前
作者:
S
Siming Dai
提交者:
GitHub
2年前
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix UVA Tensor (#46371)
上级
ab97b760
develop
1.8.5
add_kylinv10
bugfix-eval-frame-leakgae
cherry-pick-fix-customOP-random-fail
fix-run-program-grad-node-mem
fix_check
fix_custom_device_copy_sync
fix_dlpack_for
fix_newexe_gc
hack_event
incuabte/new_frl
incubate/new_frl
incubate/new_frl_rc
incubate/stride
layer_norm
matmul_double_grad
operator_opt
pass-compile-eval-frame
prv-md-even-more
prv-reshape-mkldnn-ut2
release-deleted/2.5
release-rc/2.5
release/2.5
release/llm_2.5
revert-46827-deform_comment
revert-47325-remove_cudnn_hardcode
revert-47645-add_npu_storage_dims
revert-48815-set_free_when_no_cache_hit_default_value_true
revert-49499-test_ninja_on_ci
revert-49654-prim_api_gen
revert-49673-modify_get_single_cov
revert-49763-fix_static_composite_gen
revert-50158-fix_found_inf_bug_for_custom_optimizer
revert-50188-refine_optimizer_create_accumulators
revert-50335-fix_optminizer_set_auxiliary_var_bug
revert-51676-flag_delete
revert-51850-fix_softmaxce_dev
revert-52186-deve
revert-52523-test_py38
revert-52912-develop
revert-53248-set_cmake_policy
revert-54029-fix_windows_compile_bug
revert-54068-support_translating_op_attribute
revert-54214-modify_cmake_dependencies
revert-54370-offline_pslib
revert-54391-fix_cmake_md5error
revert-54411-fix_cpp17_compile
revert-54466-offline_pslib
revert-54480-cmake-rocksdb
revert-55568-fix_BF16_bug1
revert-56328-new_ir_support_vector_type_place_transfer
revert-56366-fix_openssl_bug
revert-56545-revert-56366-fix_openssl_bug
revert-56620-fix_new_ir_ocr_bug
revert-56925-check_inputs_grad_semantic
revert-57005-refine_stride_flag
sd_conv_linear_autocast
semi-auto/rule-base
support-0D-sort
test_for_Filtetfiles
zhiqiu-patch-1
v2.5.1
v2.5.0
v2.5.0-rc1
v2.5.0-rc0
无相关合并请求
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
16 addition
and
4 deletion
+16
-4
paddle/fluid/pybind/tensor_py.h
paddle/fluid/pybind/tensor_py.h
+5
-4
python/paddle/fluid/tests/unittests/test_tensor_uva.py
python/paddle/fluid/tests/unittests/test_tensor_uva.py
+11
-0
未找到文件。
paddle/fluid/pybind/tensor_py.h
浏览文件 @
d772166c
...
...
@@ -608,8 +608,9 @@ void SetStringTensorFromPyArray(phi::StringTensor *self,
}
template
<
typename
T
>
void
SetUVATensorFromPyArrayImpl
(
framework
::
LoDTensor
*
self_tensor
,
const
py
::
array_t
<
T
>
&
array
,
void
SetUVATensorFromPyArrayImpl
(
framework
::
LoDTensor
*
self_tensor
,
const
py
::
array_t
<
T
,
py
::
array
::
c_style
|
py
::
array
::
forcecast
>
&
array
,
int
device_id
)
{
#if defined(PADDLE_WITH_CUDA)
VLOG
(
4
)
<<
"Running in SetUVATensorFromPyArrayImpl."
;
...
...
@@ -647,7 +648,7 @@ void SetUVATensorFromPyArrayImpl(framework::LoDTensor *self_tensor,
template
<
typename
T
>
void
SetUVATensorFromPyArray
(
const
std
::
shared_ptr
<
paddle
::
imperative
::
VarBase
>
&
self
,
const
py
::
array_t
<
T
>
&
array
,
const
py
::
array_t
<
T
,
py
::
array
::
c_style
|
py
::
array
::
forcecast
>
&
array
,
int
device_id
)
{
#if defined(PADDLE_WITH_CUDA)
VLOG
(
4
)
<<
"Running in SetUVATensorFromPyArray for VarBase."
;
...
...
This diff is collapsed.
Click to expand it.
python/paddle/fluid/tests/unittests/test_tensor_uva.py
浏览文件 @
d772166c
...
...
@@ -57,6 +57,17 @@ class TestUVATensorFromNumpy(unittest.TestCase):
np
.
testing
.
assert_allclose
(
tensor
.
numpy
(),
data
,
rtol
=
1e-05
)
np
.
testing
.
assert_allclose
(
tensor2
.
numpy
(),
data
,
rtol
=
1e-05
)
def
test_uva_tensor_corectness
(
self
):
if
paddle
.
fluid
.
core
.
is_compiled_with_cuda
():
a
=
np
.
arange
(
0
,
100
,
dtype
=
"int32"
)
a
=
a
.
reshape
([
10
,
10
])
slice_a
=
a
[:,
5
]
tensor1
=
paddle
.
to_tensor
(
slice_a
)
tensor2
=
core
.
eager
.
to_uva_tensor
(
slice_a
)
np
.
testing
.
assert_allclose
(
tensor1
.
numpy
(),
tensor2
.
numpy
(),
rtol
=
1e-05
)
def
test_uva_tensor_creation
(
self
):
with
_test_eager_guard
():
self
.
func_uva_tensor_creation
()
...
...
This diff is collapsed.
Click to expand it.
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录
反馈
建议
客服
返回
顶部