本文整理汇总了C++中Func::compile_to_module方法的典型用法代码示例。如果您正苦于以下问题:C++ Func::compile_to_module方法的具体用法?C++ Func::compile_to_module怎么用?C++ Func::compile_to_module使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Func
的用法示例。
在下文中一共展示了Func::compile_to_module方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check
void check(const std::string &inner_loop_level,
const std::string &outer_loop_level) {
Buffer<float> result = outer.realize(1, 1, 1);
Module m = outer.compile_to_module({outer.infer_arguments()});
CheckLoopLevels c(inner_loop_level, outer_loop_level);
m.functions().front().body.accept(&c);
}
示例2: main
int main(int argc, char **argv) {
if (argc < 2) return 1;
Func grid; Var cmplx,x,y;
grid(cmplx,x,y) = cast<double>(0.0f);
// No need for a strategy - LLVM should automatically figure out
// that this is a memset.
Target target(get_target_from_environment().os, Target::X86, 64, { Target::SSE41, Target::AVX});
compile_module_to_object(grid.compile_to_module({}, "kern_init", target), argv[1]);
return 0;
}
示例3: rdom_wrapper_test
int rdom_wrapper_test() {
Func source("source"), g("g"), result("result");
Var x("x"), y("y");
source(x, y) = x + y;
ImageParam img(Int(32), 2, "img");
Buffer<int> buf = source.realize(200, 200);
img.set(buf);
g(x, y) = 10;
g(x, y) += 2 * img(x, x);
RDom r(0, 200, 0, 200);
g(r.x, r.y) += 3 * img(r.y, r.y);
// Make a global wrapper on 'g', so that we can schedule initialization
// and the update on the same compute level at the global wrapper
Func wrapper = g.in().compute_root();
g.compute_at(wrapper, x);
Func img_f = img;
img_f.compute_root();
// Check the call graphs.
// Expect 'wrapper' to call 'g', initialization of 'g' to call nothing
// and its update to call 'img_f' and 'g', 'img_f' to call 'img'
Module m = wrapper.compile_to_module({wrapper.infer_arguments()});
CheckCalls c;
m.functions().front().body.accept(&c);
CallGraphs expected = {
{g.name(), {img_f.name(), g.name()}},
{wrapper.name(), {g.name()}},
{img_f.name(), {img.name()}},
};
if (check_call_graphs(c.calls, expected) != 0) {
return -1;
}
Buffer<int> im = wrapper.realize(200, 200);
auto func = [](int x, int y) { return 4*x + 6* y + 10; };
if (check_image(im, func)) {
return -1;
}
return 0;
}
示例4: rdom_wrapper_test
int rdom_wrapper_test() {
Func f("f"), g("g"), result("result");
Var x("x"), y("y");
f(x, y) = x + y;
g(x, y) = 10;
g(x, y) += 2 * f(x, x);
g(x, y) += 3 * f(y, y);
// Make a global wrapper on 'g', so that we can schedule initialization
// and the update on the same compute level at the global wrapper
Func wrapper = g.in().compute_root();
g.compute_at(wrapper, x);
f.compute_root();
// Check the call graphs.
// Expect 'wrapper' to call 'g', initialization of 'g' to call nothing
// and its update to call 'f' and 'g', 'f' to call nothing
Module m = wrapper.compile_to_module({});
CheckCalls c;
m.functions().front().body.accept(&c);
CallGraphs expected = {
{g.name(), {f.name(), g.name()}},
{wrapper.name(), {g.name()}},
{f.name(), {}},
};
if (check_call_graphs(c.calls, expected) != 0) {
return -1;
}
Image<int> im = wrapper.realize(200, 200);
auto func = [](int x, int y) {
return 4*x + 6* y + 10;
};
if (check_image(im, func)) {
return -1;
}
return 0;
}