【发布时间】:2021-07-17 12:38:09
【问题描述】:
我目前正在使用带有生成器和提前编译的 Halide。
在管道的某个地方,我有一个 3D 缓冲区,其中一个维度的范围有限(通常为 3-6 个值)。 我想对该维度中的值进行排序。 当我跳过管道开头的处理时, 它看起来有点像这样:
Input < Buffer<uint16_t>> input { "input" , 2}; // Dimensions: (y, x)
Input < uint8_t> > sizeZ { "sizeZ" }; // Size in Z-dimension
Output< Buffer<uint16_t>> output { "output", 3}; // Dimensions: (z, y, x)
Var x,y,z;
Func input3D(z,y,x) = input(y,z+x*sizeZ);
output = 'sort input3D on Z dimension'.
如果 Halide 中已经提供了一些排序功能(是这样吗?),我会得到最大的帮助。 另一种方法是调用外部 C 实现对该维度中的所有值进行排序并将它们分配给输出缓冲区。 那将是这样的:
output(:, y, x) = external_sort(input(:, y, x))
其中我使用 Python 表示法来表示 Z 维度中的所有元素。 在 Halide 中是否有可能发生这样的事情?
【问题讨论】:
标签: halide