Paddle uint8类型的tensor无法切片

b1zrtrql  于 2022-11-19  发布在  其他
关注(0)|答案(3)|浏览(160)

报错信息

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
/tmp/ipykernel_168/1390243965.py in <module>
----> 1 u8_data_cpu[0]

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/varbase_patch_methods.py in __getitem__(self, item)
    738         else:
    739             # 2. Call c++ func getitem_index_not_tensor to speedup.
--> 740             return self._getitem_index_not_tensor(item)
    741 
    742     def __setitem__(self, item, value):

RuntimeError: (NotFound) Operator slice does not have kernel for {data_type[uint8_t]; data_layout[Undefined(AnyLayout)]; place[Place(cpu)]; library_type[PLAIN]}.
  [Hint: Expected kernel_iter != kernels.end(), but received kernel_iter == kernels.end().] (at /paddle/paddle/fluid/imperative/prepared_operator.cc:403)
  [operator < slice > error]

复现代码

import paddle
from paddle.fluid import core

u8_data = paddle.empty(shape=[2, 3, 4, 4], dtype=paddle.uint8)

u8_data_gpu = paddle.to_tensor(u8_data, place=core.CUDAPlace(0))
u8_data_cpu = paddle.to_tensor(u8_data, place=core.CPUPlace())

u8_data_cpu[0]
u8_data_gpu[0]
oknrviil

oknrviil1#

您好,我们已经收到了您的问题,会安排技术人员尽快解答您的问题,请耐心等待。请您再次检查是否提供了清晰的问题描述、复现代码、环境&版本、报错信息等。同时,您也可以通过查看 官网API文档常见问题历史IssueAI社区 来寻求解答。祝您生活愉快~

Hi! We've received your issue and please be patient to get responded. We will arrange technicians to answer your questions as soon as possible. Please make sure that you have posted enough message to demo your request. You may also check out the APIFAQGithub Issue and AI community to get the answer.Have a nice day!

相关问题