@@ -62,10 +62,13 @@ Type translateScalarType(int tcType) {
6262 }
6363}
6464
65+ // Translate the TC def input params to corresponding Halide components.
66+ // params, inputs will be populated here.
6567void translateParam (
6668 const lang::Param& p,
6769 map<string, Parameter>* params,
6870 vector<ImageParam>* inputs) {
71+ // Check if the param has already been converted to halide components.
6972 if (params->find (p.ident ().name ()) != params->end ()) {
7073 return ;
7174 } else {
@@ -488,6 +491,9 @@ Expr reductionUpdate(Expr e) {
488491 return Call::make (e.type (), kReductionUpdate , {e}, Call::Intrinsic);
489492}
490493
494+ // Translate a single TC comprehension/statement to Halide components: funcs,
495+ // bounds, reductions.
496+ //
491497// Note that the function definitions created by translateComprehension may
492498// contain kReductionUpdate intrinsics. These may have to be removed
493499// in order to be able to apply internal Halide analysis passes on them.
@@ -736,6 +742,7 @@ void translateComprehension(
736742 stage.reorder (loop_nest);
737743}
738744
745+ // Translate a semantically checked TC def to HalideComponents struct.
739746HalideComponents translateDef (const lang::Def& def, bool throwWarnings) {
740747 map<string, Function> funcs;
741748 HalideComponents components;
@@ -895,6 +902,8 @@ translate(isl::ctx ctx, const lang::TreeRef& treeRef, bool throwWarnings) {
895902 lang::Def (lang::Sema ().checkFunction (treeRef)), throwWarnings);
896903}
897904
905+ // NOTE: there is no guarantee here that the tc string has only one def. It
906+ // could have many defs. Only first def will be converted in that case.
898907HalideComponents
899908translate (isl::ctx ctx, const std::string& tc, bool throwWarnings) {
900909 LOG_IF (INFO, tc::FLAGS_debug_halide) << tc;
0 commit comments