从最低/最大数据点检索多个阵列阵列

发布于 2025-01-19 03:32:51 字数 1374 浏览 3 评论 0原文

我有一个数组,其中包含一些感人的值。例如:

0 0 1 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 2 2 2 0 0
0 0 0 0 0 0 0 2 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 3 0 0 0 0 0 0 0
0 0 3 0 0 0 0 0 0 0
0 0 3 0 0 0 0 0 0 0

由此,我创建了一组 af::arrays:minX、maxX、minY、maxY。这些定义了包围每个组的框。 所以对于这个例子:

minX would be: [1,5,2] // 1 for label(1), 5 for label(2) and 2 for label(3)
maxX would be: [3,7,2] // 3 for label(1), 7 for label(2) and 2 for label(3)
minY would be: [0,3,7] // 0 for label(1), 3 for label(2) and 7 for label(3)
maxY would be: [1,4,9] // 1 for label(1), 4 for label(2) and 9 for label(3)

如果你从每个数组中取出第 i 个元素,你就可以获得包含相应标签的盒子的左上/右下边界。

我想使用这些值从这个更大的数组中提取子数组。我的目标是将这些包含在框中的值放入一个平面列表中。在 GPU 内存中,我还使用最大/最小 X/Y 值计算了每个框需要多少个条目。因此,在此示例中,平面列表的结果应为:

result=[0 1 0 1 1 1 2 2 2 0 0 2 3 3 3]

其中前 6 个条目来自框中,

 ______
|0 1 0 |
|1 1 1 |
 ------

后 6 个条目来自框

 ______
|2 2 2 |
|0 0 2 |
 ------

最后三个条目来自框中,

 ___
| 3 |
| 3 |
| 3 |
 ---

我无法弄清楚如何使用驻留在 GPU 上的内存中的最小/最大值来索引此 af::array (并且不想将它们传输到 CPU)。我试图看看 gfor/seq 是否适合我,但似乎 af::seq 无法使用数组数据,并且我尝试使用 af::index 的所有内容也无法为我工作。

我能够更改表示最小值/最大值的方式(我可以存储左上/右下的索引),但我的主要目标是在 GPU 上高效地完成此操作,而无需在 GPU 和 CPU 之间来回移动数据。

如何使用 ArrayFire 有效地实现这一目标?

感谢您的帮助

I have an array with sections of touching values in it. For example:

0 0 1 0 0 0 0 0 0 0
0 1 1 1 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 2 2 2 0 0
0 0 0 0 0 0 0 2 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 3 0 0 0 0 0 0 0
0 0 3 0 0 0 0 0 0 0
0 0 3 0 0 0 0 0 0 0

from this, I created a set of af::arrays: minX, maxX, minY, maxY. These define the box that encloses each group.
so for this example:

minX would be: [1,5,2] // 1 for label(1), 5 for label(2) and 2 for label(3)
maxX would be: [3,7,2] // 3 for label(1), 7 for label(2) and 2 for label(3)
minY would be: [0,3,7] // 0 for label(1), 3 for label(2) and 7 for label(3)
maxY would be: [1,4,9] // 1 for label(1), 4 for label(2) and 9 for label(3)

So if you take the i'th element from each of those arrays, you can get the upperleft/lowerright bounds of a box that encloses the corresponding label.

I would like use these values to pull out subarrays from this larger array. My goal is to put these values enclosed in the boxes into a flat list. In GPU memory, I also have calculated how many entries I would need for each box using the max/min X/Y values. So in this example - the result of the flat list should be:

result=[0 1 0 1 1 1 2 2 2 0 0 2 3 3 3]

where the first 6 entries are from the box

 ______
|0 1 0 |
|1 1 1 |
 ------

the second 6 entries are from the box

 ______
|2 2 2 |
|0 0 2 |
 ------

and the final three entries are from the box

 ___
| 3 |
| 3 |
| 3 |
 ---

I cannot figure out how to index into this af::array with min/max values in memory that resides on the GPU (and do not want to transfer them to the CPU). I was trying to see if gfor/seq would work for me, but it appears that af::seq cannot use array data, and everything I have tried with using af::index i could not get to work for me either.

I am able to change how I represent min/max (I could store indices for upper left/lower right) but my main goal is to do this efficiently on the GPU without moving data back and forth between the GPU and CPU.

How can this be achieved efficiently with ArrayFire?

Thank you for your help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

神也荒唐 2025-01-26 03:32:51

到目前为止你是怎么到达那里的?您使用哪种语言?

我猜你可以将结果平铺到第三维来分别处理每个区域,并最终在 GPU 内存中得到最小/最大向量。

How did you get there so far? which language are you using?

I guess you could be tiling the results to 3rd dimensions to handle each regions separately and end up with min/max vectors in GPU memory.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文