Acessing a value on an ArrayFire array

旧巷老猫 提交于 2019-12-11 04:29:40

问题


I had a af::array and need to acess the value in a row, like z(8), e.g. But, when i try to do this, in a loop with a incremental i, the compiler returns

    cannot convert from 'af::array::array_proxy' to 'double'

Someone knows how can I acess the value inside the array? Thanks.


回答1:


Take a look at scalar in the arrayfire documentation here.

For your use case, you can access the element like this :

float val = z(8).scalar<float>();

Could you talk about why you need to do this? In many cases, transferring values to the host from the GPU is unnecessary and avoidable.



来源:https://stackoverflow.com/questions/44684155/acessing-a-value-on-an-arrayfire-array

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!