@@ -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 is already converted to halide components
6972 if (params->find (p.ident ().name ()) != params->end ()) {
7073 return ;
7174 } else {
@@ -492,6 +495,8 @@ Expr reductionUpdate(Expr e) {
492495 return Call::make (e.type (), kReductionUpdate , {e}, Call::Intrinsic);
493496}
494497
498+ // translate a single TC comprehension/statement to Halide component.
499+ // funcs, bounds, reductions will be populated
495500void translateComprehension (
496501 const lang::Comprehension& c,
497502 const map<string, Parameter>& params,
@@ -737,6 +742,7 @@ void translateComprehension(
737742 stage.reorder (loop_nest);
738743}
739744
745+ // translate a semantically checked TC def to Halide components struct
740746HalideComponents translateDef (const lang::Def& def, bool throwWarnings) {
741747 map<string, Function> funcs;
742748 HalideComponents components;
@@ -956,6 +962,8 @@ translate(isl::ctx ctx, const lang::TreeRef& treeRef, bool throwWarnings) {
956962 lang::Def (lang::Sema ().checkFunction (treeRef)), throwWarnings);
957963}
958964
965+ // NOTE: there is no guarantee here that the tc string has only one def. It
966+ // could have many defs. Only first def will be converted in that case.
959967HalideComponents
960968translate (isl::ctx ctx, const std::string& tc, bool throwWarnings) {
961969 LOG_IF (INFO, tc::FLAGS_debug_halide) << tc;
0 commit comments