开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 3

xiongying/Halide

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
main
分支 (1093)
标签 (17)
main
xtensa-codegen
vksnk/dma-limit-channels
rootjalex/trs-codegen-cross
abadams/fix_7374
abadams/remove_hack_from_gpu_only_aottest
srj/gpu-cache
srj/generator_aot_gpu_multi_context_threaded
srj/xtensa-merge
abadams/vector_scan
abadams/fix_7365
darya-ver/ir-viz
vulkan-phase2-runtime
srj/param-map-deprecation
srj/rt-return-types
srj/main-vs2022
release/15.x
srj/param-map
abadams/ir_builder_unique_ptr
vksnk/restrict
v14.0.0
v13.0.4
v13.0.3
v13.0.2
v13.0.1
v13.0.0
v12.0.1
v12.0.0
v11.0.1
v11.0.0
v10.0.1
v10.0.0
release_2019_08_27
release_8.0.0
v8.0.0
release_2018_02_15
release_2013_11_11
main
分支 (1093)
标签 (17)
main
xtensa-codegen
vksnk/dma-limit-channels
rootjalex/trs-codegen-cross
abadams/fix_7374
abadams/remove_hack_from_gpu_only_aottest
srj/gpu-cache
srj/generator_aot_gpu_multi_context_threaded
srj/xtensa-merge
abadams/vector_scan
abadams/fix_7365
darya-ver/ir-viz
vulkan-phase2-runtime
srj/param-map-deprecation
srj/rt-return-types
srj/main-vs2022
release/15.x
srj/param-map
abadams/ir_builder_unique_ptr
vksnk/restrict
v14.0.0
v13.0.4
v13.0.3
v13.0.2
v13.0.1
v13.0.0
v12.0.1
v12.0.0
v11.0.1
v11.0.0
v10.0.1
v10.0.0
release_2019_08_27
release_8.0.0
v8.0.0
release_2018_02_15
release_2013_11_11
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
main
分支 (1093)
标签 (17)
main
xtensa-codegen
vksnk/dma-limit-channels
rootjalex/trs-codegen-cross
abadams/fix_7374
abadams/remove_hack_from_gpu_only_aottest
srj/gpu-cache
srj/generator_aot_gpu_multi_context_threaded
srj/xtensa-merge
abadams/vector_scan
abadams/fix_7365
darya-ver/ir-viz
vulkan-phase2-runtime
srj/param-map-deprecation
srj/rt-return-types
srj/main-vs2022
release/15.x
srj/param-map
abadams/ir_builder_unique_ptr
vksnk/restrict
v14.0.0
v13.0.4
v13.0.3
v13.0.2
v13.0.1
v13.0.0
v12.0.1
v12.0.0
v11.0.1
v11.0.0
v10.0.1
v10.0.0
release_2019_08_27
release_8.0.0
v8.0.0
release_2018_02_15
release_2013_11_11
Halide
/
src
/
Lower.cpp
Halide
/
src
/
Lower.cpp
Lower.cpp 21.77 KB
一键复制 编辑 原始数据 按行查看 历史
Andrew Adams 提交于 2022年12月17日 01:56 +08:00 . Explicitly stage strided loads (#7230)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
#include <algorithm>
#include <chrono>
#include <iostream>
#include <set>
#include <sstream>
#include "Lower.h"
#include "AddAtomicMutex.h"
#include "AddImageChecks.h"
#include "AddParameterChecks.h"
#include "AllocationBoundsInference.h"
#include "AsyncProducers.h"
#include "BoundSmallAllocations.h"
#include "Bounds.h"
#include "BoundsInference.h"
#include "CSE.h"
#include "CanonicalizeGPUVars.h"
#include "ClampUnsafeAccesses.h"
#include "CompilerLogger.h"
#include "Debug.h"
#include "DebugArguments.h"
#include "DebugToFile.h"
#include "Deinterleave.h"
#include "EarlyFree.h"
#include "ExtractTileOperations.h"
#include "FindCalls.h"
#include "FindIntrinsics.h"
#include "FlattenNestedRamps.h"
#include "Func.h"
#include "Function.h"
#include "FuseGPUThreadLoops.h"
#include "FuzzFloatStores.h"
#include "HexagonOffload.h"
#include "IRMutator.h"
#include "IROperator.h"
#include "IRPrinter.h"
#include "InferArguments.h"
#include "InjectHostDevBufferCopies.h"
#include "Inline.h"
#include "LICM.h"
#include "LoopCarry.h"
#include "LowerParallelTasks.h"
#include "LowerWarpShuffles.h"
#include "Memoization.h"
#include "OffloadGPULoops.h"
#include "PartitionLoops.h"
#include "Prefetch.h"
#include "Profiling.h"
#include "PurifyIndexMath.h"
#include "Qualify.h"
#include "RealizationOrder.h"
#include "RebaseLoopsToZero.h"
#include "RemoveDeadAllocations.h"
#include "RemoveExternLoops.h"
#include "RemoveUndef.h"
#include "ScheduleFunctions.h"
#include "SelectGPUAPI.h"
#include "Simplify.h"
#include "SimplifyCorrelatedDifferences.h"
#include "SimplifySpecializations.h"
#include "SkipStages.h"
#include "SlidingWindow.h"
#include "SplitTuples.h"
#include "StageStridedLoads.h"
#include "StorageFlattening.h"
#include "StorageFolding.h"
#include "StrictifyFloat.h"
#include "Substitute.h"
#include "Tracing.h"
#include "TrimNoOps.h"
#include "UnifyDuplicateLets.h"
#include "UniquifyVariableNames.h"
#include "UnpackBuffers.h"
#include "UnrollLoops.h"
#include "UnsafePromises.h"
#include "VectorizeLoops.h"
#include "WrapCalls.h"
namespace Halide {
namespace Internal {
using std::ostringstream;
using std::string;
using std::vector;
namespace {
class LoweringLogger {
Stmt last_written;
public:
void operator()(const string &message, const Stmt &s) {
if (!s.same_as(last_written)) {
debug(2) << message << "\n"
<< s << "\n";
last_written = s;
} else {
debug(2) << message << " (unchanged)\n\n";
}
}
};
void lower_impl(const vector<Function> &output_funcs,
const string &pipeline_name,
const Target &t,
const vector<Argument> &args,
const LinkageType linkage_type,
const vector<Stmt> &requirements,
bool trace_pipeline,
const vector<IRMutator *> &custom_passes,
Module &result_module) {
auto time_start = std::chrono::high_resolution_clock::now();
size_t initial_lowered_function_count = result_module.functions().size();
// Create a deep-copy of the entire graph of Funcs.
auto [outputs, env] = deep_copy(output_funcs, build_environment(output_funcs));
bool any_strict_float = strictify_float(env, t);
result_module.set_any_strict_float(any_strict_float);
// Output functions should all be computed and stored at root.
for (const Function &f : outputs) {
Func(f).compute_root().store_root();
}
// Finalize all the LoopLevels
for (auto &iter : env) {
iter.second.lock_loop_levels();
}
// Substitute in wrapper Funcs
env = wrap_func_calls(env);
// Compute a realization order and determine group of functions which loops
// are to be fused together
auto [order, fused_groups] = realization_order(outputs, env);
// Try to simplify the RHS/LHS of a function definition by propagating its
// specializations' conditions
simplify_specializations(env);
LoweringLogger log;
debug(1) << "Creating initial loop nests...\n";
bool any_memoized = false;
Stmt s = schedule_functions(outputs, fused_groups, env, t, any_memoized);
log("Lowering after creating initial loop nests:", s);
if (any_memoized) {
debug(1) << "Injecting memoization...\n";
s = inject_memoization(s, env, pipeline_name, outputs);
log("Lowering after injecting memoization:", s);
} else {
debug(1) << "Skipping injecting memoization...\n";
}
debug(1) << "Injecting tracing...\n";
s = inject_tracing(s, pipeline_name, trace_pipeline, env, outputs, t);
log("Lowering after injecting tracing:", s);
debug(1) << "Adding checks for parameters\n";
s = add_parameter_checks(requirements, s, t);
log("Lowering after injecting parameter checks:", s);
// Compute the maximum and minimum possible value of each
// function. Used in later bounds inference passes.
debug(1) << "Computing bounds of each function's value\n";
FuncValueBounds func_bounds = compute_function_value_bounds(order, env);
// Clamp unsafe instances where a Func f accesses a Func g using
// an index which depends on a third Func h.
debug(1) << "Clamping unsafe data-dependent accesses\n";
s = clamp_unsafe_accesses(s, env, func_bounds);
log("Lowering after clamping unsafe data-dependent accesses", s);
// This pass injects nested definitions of variable names, so we
// can't simplify statements from here until we fix them up. (We
// can still simplify Exprs).
debug(1) << "Performing computation bounds inference...\n";
s = bounds_inference(s, outputs, order, fused_groups, env, func_bounds, t);
log("Lowering after computation bounds inference:", s);
debug(1) << "Removing extern loops...\n";
s = remove_extern_loops(s);
log("Lowering after removing extern loops:", s);
debug(1) << "Performing sliding window optimization...\n";
s = sliding_window(s, env);
log("Lowering after sliding window:", s);
// This uniquifies the variable names, so we're good to simplify
// after this point. This lets later passes assume syntactic
// equivalence means semantic equivalence.
debug(1) << "Uniquifying variable names...\n";
s = uniquify_variable_names(s);
log("Lowering after uniquifying variable names:", s);
debug(1) << "Simplifying...\n";
s = simplify(s, false); // Storage folding and allocation bounds inference needs .loop_max symbols
log("Lowering after first simplification:", s);
debug(1) << "Simplifying correlated differences...\n";
s = simplify_correlated_differences(s);
log("Lowering after simplifying correlated differences:", s);
debug(1) << "Performing allocation bounds inference...\n";
s = allocation_bounds_inference(s, env, func_bounds);
log("Lowering after allocation bounds inference:", s);
bool will_inject_host_copies =
(t.has_gpu_feature() ||
t.has_feature(Target::OpenGLCompute) ||
t.has_feature(Target::HexagonDma) ||
(t.arch != Target::Hexagon && (t.has_feature(Target::HVX))));
debug(1) << "Adding checks for images\n";
s = add_image_checks(s, outputs, t, order, env, func_bounds, will_inject_host_copies);
log("Lowering after injecting image checks:", s);
debug(1) << "Removing code that depends on undef values...\n";
s = remove_undef(s);
log("Lowering after removing code that depends on undef values:", s);
debug(1) << "Performing storage folding optimization...\n";
s = storage_folding(s, env);
log("Lowering after storage folding:", s);
debug(1) << "Injecting debug_to_file calls...\n";
s = debug_to_file(s, outputs, env);
log("Lowering after injecting debug_to_file calls:", s);
debug(1) << "Injecting prefetches...\n";
s = inject_prefetch(s, env);
log("Lowering after injecting prefetches:", s);
debug(1) << "Discarding safe promises...\n";
s = lower_safe_promises(s);
log("Lowering after discarding safe promises:", s);
debug(1) << "Dynamically skipping stages...\n";
s = skip_stages(s, order);
log("Lowering after dynamically skipping stages:", s);
debug(1) << "Forking asynchronous producers...\n";
s = fork_async_producers(s, env);
log("Lowering after forking asynchronous producers:", s);
debug(1) << "Destructuring tuple-valued realizations...\n";
s = split_tuples(s, env);
log("Lowering after destructuring tuple-valued realizations:", s);
// OpenGL relies on GPU var canonicalization occurring before
// storage flattening.
if (t.has_gpu_feature() ||
t.has_feature(Target::OpenGLCompute)) {
debug(1) << "Canonicalizing GPU var names...\n";
s = canonicalize_gpu_vars(s);
log("Lowering after canonicalizing GPU var names:", s);
}
debug(1) << "Bounding small realizations...\n";
s = simplify_correlated_differences(s);
s = bound_small_allocations(s);
log("Lowering after bounding small realizations:", s);
debug(1) << "Performing storage flattening...\n";
s = storage_flattening(s, outputs, env, t);
log("Lowering after storage flattening:", s);
debug(1) << "Adding atomic mutex allocation...\n";
s = add_atomic_mutex(s, env);
log("Lowering after adding atomic mutex allocation:", s);
debug(1) << "Unpacking buffer arguments...\n";
s = unpack_buffers(s);
log("Lowering after unpacking buffer arguments:", s);
if (any_memoized) {
debug(1) << "Rewriting memoized allocations...\n";
s = rewrite_memoized_allocations(s, env);
log("Lowering after rewriting memoized allocations:", s);
} else {
debug(1) << "Skipping rewriting memoized allocations...\n";
}
if (will_inject_host_copies) {
debug(1) << "Selecting a GPU API for GPU loops...\n";
s = select_gpu_api(s, t);
log("Lowering after selecting a GPU API:", s);
debug(1) << "Injecting host <-> dev buffer copies...\n";
s = inject_host_dev_buffer_copies(s, t);
log("Lowering after injecting host <-> dev buffer copies:", s);
debug(1) << "Selecting a GPU API for extern stages...\n";
s = select_gpu_api(s, t);
log("Lowering after selecting a GPU API for extern stages:", s);
}
debug(1) << "Simplifying...\n";
s = simplify(s);
s = unify_duplicate_lets(s);
log("Lowering after second simplifcation:", s);
debug(1) << "Reduce prefetch dimension...\n";
s = reduce_prefetch_dimension(s, t);
log("Lowering after reduce prefetch dimension:", s);
debug(1) << "Simplifying correlated differences...\n";
s = simplify_correlated_differences(s);
log("Lowering after simplifying correlated differences:", s);
debug(1) << "Unrolling...\n";
s = unroll_loops(s);
log("Lowering after unrolling:", s);
debug(1) << "Vectorizing...\n";
s = vectorize_loops(s, env);
s = simplify(s);
log("Lowering after vectorizing:", s);
if (t.has_gpu_feature() ||
t.has_feature(Target::OpenGLCompute)) {
debug(1) << "Injecting per-block gpu synchronization...\n";
s = fuse_gpu_thread_loops(s);
log("Lowering after injecting per-block gpu synchronization:", s);
}
debug(1) << "Detecting vector interleavings...\n";
s = rewrite_interleavings(s);
s = simplify(s);
log("Lowering after rewriting vector interleavings:", s);
debug(1) << "Partitioning loops to simplify boundary conditions...\n";
s = partition_loops(s);
s = simplify(s);
log("Lowering after partitioning loops:", s);
debug(1) << "Staging strided loads...\n";
s = stage_strided_loads(s);
log("Lowering after staging strided loads:", s);
debug(1) << "Trimming loops to the region over which they do something...\n";
s = trim_no_ops(s);
log("Lowering after loop trimming:", s);
debug(1) << "Rebasing loops to zero...\n";
s = rebase_loops_to_zero(s);
debug(2) << "Lowering after rebasing loops to zero:\n"
<< s << "\n\n";
debug(1) << "Hoisting loop invariant if statements...\n";
s = hoist_loop_invariant_if_statements(s);
log("Lowering after hoisting loop invariant if statements:", s);
debug(1) << "Injecting early frees...\n";
s = inject_early_frees(s);
log("Lowering after injecting early frees:", s);
if (t.has_feature(Target::FuzzFloatStores)) {
debug(1) << "Fuzzing floating point stores...\n";
s = fuzz_float_stores(s);
log("Lowering after fuzzing floating point stores:", s);
}
debug(1) << "Simplifying correlated differences...\n";
s = simplify_correlated_differences(s);
log("Lowering after simplifying correlated differences:", s);
debug(1) << "Bounding small allocations...\n";
s = bound_small_allocations(s);
log("Lowering after bounding small allocations:", s);
if (t.has_feature(Target::Profile) || t.has_feature(Target::ProfileByTimer)) {
debug(1) << "Injecting profiling...\n";
s = inject_profiling(s, pipeline_name);
log("Lowering after injecting profiling:", s);
}
if (t.has_feature(Target::CUDA)) {
debug(1) << "Injecting warp shuffles...\n";
s = lower_warp_shuffles(s, t);
log("Lowering after injecting warp shuffles:", s);
}
debug(1) << "Simplifying...\n";
s = common_subexpression_elimination(s);
debug(1) << "Lowering unsafe promises...\n";
s = lower_unsafe_promises(s, t);
log("Lowering after lowering unsafe promises:", s);
if (t.has_feature(Target::AVX512_SapphireRapids)) {
debug(1) << "Extracting tile operations...\n";
s = extract_tile_operations(s);
log("Lowering after extracting tile operations:", s);
}
debug(1) << "Flattening nested ramps...\n";
s = flatten_nested_ramps(s);
log("Lowering after flattening nested ramps:", s);
debug(1) << "Removing dead allocations and moving loop invariant code...\n";
s = remove_dead_allocations(s);
s = simplify(s);
s = hoist_loop_invariant_values(s);
s = hoist_loop_invariant_if_statements(s);
log("Lowering after removing dead allocations and hoisting loop invariants:", s);
debug(1) << "Finding intrinsics...\n";
// Must be run after the last simplification, because it turns
// divisions into shifts, which the simplifier reverses.
s = find_intrinsics(s);
log("Lowering after finding intrinsics:", s);
debug(1) << "Hoisting prefetches...\n";
s = hoist_prefetches(s);
log("Lowering after hoisting prefetches:", s);
debug(1) << "Lowering after final simplification:\n"
<< s << "\n\n";
if (!custom_passes.empty()) {
for (size_t i = 0; i < custom_passes.size(); i++) {
debug(1) << "Running custom lowering pass " << i << "...\n";
s = custom_passes[i]->mutate(s);
debug(1) << "Lowering after custom pass " << i << ":\n"
<< s << "\n\n";
}
}
if (t.arch != Target::Hexagon && t.has_feature(Target::HVX)) {
debug(1) << "Splitting off Hexagon offload...\n";
s = inject_hexagon_rpc(s, t, result_module);
debug(2) << "Lowering after splitting off Hexagon offload:\n"
<< s << "\n";
} else {
debug(1) << "Skipping Hexagon offload...\n";
}
if (t.has_gpu_feature()) {
debug(1) << "Offloading GPU loops...\n";
s = inject_gpu_offload(s, t);
debug(2) << "Lowering after splitting off GPU loops:\n"
<< s << "\n\n";
} else {
debug(1) << "Skipping GPU offload...\n";
}
// TODO: This needs to happen before lowering parallel tasks, because global
// images used inside parallel loops are rewritten from loads from images to
// loads from closure parameters. Closure parameters are missing the Buffer<>
// object, which needs to be found by infer_arguments here. Running
// infer_arguments prior to lower_parallel_tasks is a hacky solution to this
// problem. It would be better if closures could directly reference globals
// so they don't add overhead to the closure.
vector<InferredArgument> inferred_args = infer_arguments(s, outputs);
std::vector<LoweredFunc> closure_implementations;
debug(1) << "Lowering Parallel Tasks...\n";
s = lower_parallel_tasks(s, closure_implementations, pipeline_name, t);
// Process any LoweredFunctions added by other passes. In practice, this
// will likely not work well enough due to ordering issues with
// closure generating passes and instead all such passes will need to
// be done at once.
for (size_t i = initial_lowered_function_count; i < result_module.functions().size(); i++) {
// Note that lower_parallel_tasks() appends to the end of closure_implementations
result_module.functions()[i].body =
lower_parallel_tasks(result_module.functions()[i].body, closure_implementations,
result_module.functions()[i].name, t);
}
for (auto &lowered_func : closure_implementations) {
result_module.append(lowered_func);
}
debug(2) << "Lowering after generating parallel tasks and closures:\n"
<< s << "\n\n";
vector<Argument> public_args = args;
for (const auto &out : outputs) {
for (const Parameter &buf : out.output_buffers()) {
public_args.emplace_back(buf.name(),
Argument::OutputBuffer,
buf.type(), buf.dimensions(), buf.get_argument_estimates());
}
}
for (const InferredArgument &arg : inferred_args) {
if (arg.param.defined() && arg.param.name() == "__user_context") {
// The user context is always in the inferred args, but is
// not required to be in the args list.
continue;
}
internal_assert(arg.arg.is_input()) << "Expected only input Arguments here";
bool found = false;
for (const Argument &a : args) {
found |= (a.name == arg.arg.name);
}
if (arg.buffer.defined() && !found) {
// It's a raw Buffer used that isn't in the args
// list. Embed it in the output instead.
debug(1) << "Embedding image " << arg.buffer.name() << "\n";
result_module.append(arg.buffer);
} else if (!found) {
std::ostringstream err;
err << "Generated code refers to ";
if (arg.arg.is_buffer()) {
err << "image ";
}
err << "parameter " << arg.arg.name
<< ", which was not found in the argument list.\n";
err << "\nArgument list specified: ";
for (const auto &arg : args) {
err << arg.name << " ";
}
err << "\n\nParameters referenced in generated code: ";
for (const InferredArgument &ia : inferred_args) {
if (ia.arg.name != "__user_context") {
err << ia.arg.name << " ";
}
}
err << "\n\n";
user_error << err.str();
}
}
// We're about to drop the environment and outputs vector, which
// contain the only strong refs to Functions that may still be
// pointed to by the IR. So make those refs strong.
class StrengthenRefs : public IRMutator {
using IRMutator::visit;
Expr visit(const Call *c) override {
Expr expr = IRMutator::visit(c);
c = expr.as<Call>();
internal_assert(c);
if (c->func.defined()) {
FunctionPtr ptr = c->func;
ptr.strengthen();
expr = Call::make(c->type, c->name, c->args, c->call_type,
ptr, c->value_index,
c->image, c->param);
}
return expr;
}
};
s = StrengthenRefs().mutate(s);
LoweredFunc main_func(pipeline_name, public_args, s, linkage_type);
// If we're in debug mode, add code that prints the args.
if (t.has_feature(Target::Debug)) {
debug_arguments(&main_func, t);
}
result_module.append(main_func);
auto *logger = get_compiler_logger();
if (logger) {
auto time_end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = time_end - time_start;
logger->record_compilation_time(CompilerLogger::Phase::HalideLowering, diff.count());
}
}
} // namespace
Module lower(const vector<Function> &output_funcs,
const string &pipeline_name,
const Target &t,
const vector<Argument> &args,
const LinkageType linkage_type,
const vector<Stmt> &requirements,
bool trace_pipeline,
const vector<IRMutator *> &custom_passes) {
Module result_module{strip_namespaces(pipeline_name), t};
run_with_large_stack([&]() {
lower_impl(output_funcs, pipeline_name, t, args, linkage_type, requirements, trace_pipeline, custom_passes, result_module);
});
return result_module;
}
Stmt lower_main_stmt(const std::vector<Function> &output_funcs,
const std::string &pipeline_name,
const Target &t,
const std::vector<Stmt> &requirements,
bool trace_pipeline,
const std::vector<IRMutator *> &custom_passes) {
// We really ought to start applying for appellation d'origine contrôlée
// status on types representing arguments in the Halide compiler.
vector<InferredArgument> inferred_args = infer_arguments(Stmt(), output_funcs);
vector<Argument> args;
for (const auto &ia : inferred_args) {
if (!ia.arg.name.empty() && ia.arg.is_input()) {
args.push_back(ia.arg);
}
}
Module module = lower(output_funcs, pipeline_name, t, args, LinkageType::External, requirements, trace_pipeline, custom_passes);
return module.functions().front().body;
}
} // namespace Internal
} // namespace Halide
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

MIT计算机科学和人工智能实验室的研究人员创造出一种专门设计简化图像处理的程序语言Halide,源代码托管在GitHub上,目前二进制程序只支持Mac OS X和Ubuntu 12
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/VisionDeveloper/Halide.git
git@gitee.com:VisionDeveloper/Halide.git
VisionDeveloper
Halide
Halide
main
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /