halide - Halide:无法在生成器中打印 - “!function_takes_user_context(op->name)”
问题描述
当我尝试在生成器中 print() 表达式时,我无法构建:
Internal Error at /home/halidenightly/build_bot/worker/linux-64-gcc53-800/halide/src/CodeGen_OpenCL_Dev.cpp:229 triggered by user code at :
Condition failed: !function_takes_user_context(op->name):
Aborted (core dumped)
我不明白这个错误信息,它是什么?
编辑 1:我现在在下面包含了更完整的代码。
#include "Halide.h"
using namespace Halide;
class SimpleGenerator : public Generator<SimpleGenerator>{
public:
Input<Buffer<uint8_t >> source{"src", 2};
Input<Buffer<uint8_t >> reference{"ref", 2};
Output<Buffer<uint8_t >> output{"out", 2};
void generate(){
intermediate(x, y) = print(source(x, y), "source at (", x,", ", y, ")") + print(reference(x, y));
output(x, y) = intermediate(x, y);
}
void schedule(){
Var xo("xo"), yo("yo"), xi("xi"), yi("yi");
if (get_target().has_gpu_feature()) {
std::cout << "Using GPU schedule\n";
output.gpu_tile(x, y, xo, yo, xi, yi, 16, 16, TailStrategy::GuardWithIf);
} else {
std::cout << "Using CPU schedule\n";
}
}
private:
Func intermediate{"intermediate"};
Var x{"x"}, y{"y"};
};
HALIDE_REGISTER_GENERATOR(SimpleGenerator, simple_generator)
编辑2:我缩小了问题范围;尝试使用 OpenCL 以 GPU 为目标时会出现此问题。我记得在某处读到,在 GPU 上打印 Halide Exprs 是有问题的。有谁知道如何解决这个问题?
解决方案
你的语法似乎很好,就像教程中的一样 - 第4 课
Func f;
f(x, y) = sin(x) + print(cos(y), "<- this is cos(", y, ") when x =", x);
您能否分享更多“最终”功能以获取更多上下文?也许它可能是在那之前的东西
推荐阅读
- mpdf - 使用 mPDF 生成 PDF 时出现错误“HTML 包含无效的 UTF-8 字符”
- python - Python - 列表 - 字符串值更改
- html - 有没有办法在不附加的情况下在段落中使单个世界加粗?
- mobile-phones - 从用户呼出呼叫中收集 DTMF 输入
- python - 无法加载音乐
- flutter - 如何正确检查来自 JSON 的输入数据是否为双倍?
- python - OrdinalEncoder 显示带有 -1 的列
- python - 如何允许执行 T 个测试用例,即输入的数量取决于输入的 T
- elixir - Access.get/3 中没有匹配的函数子句
- flutter - Getx 不刷新值