pytorch
d35aa2f6 - Inductor cpp wrapper: support Reduction (#88561)

Commit
3 years ago
Inductor cpp wrapper: support Reduction (#88561) For reductions, the code string in the codegen stage and the execution stage are different due to `\`. - The code string gotten from `code.getvalue()` (`code` is an `IndentedBuffer`) in codegen stage: ``` #pragma omp declare reduction(argmax : struct IndexValue_1 :\ omp_out.value = omp_in.value < omp_out.value ? omp_out.value : omp_in.value,\ omp_out.index = omp_in.value < omp_out.value ? omp_out.index : omp_in.index)\ initializer(omp_priv = {0, -std::numeric_limits<float>::infinity()}) ``` - The code string loaded during the execution (`\` will be escaped): ``` #pragma omp declare reduction(argmax : struct IndexValue_1 : omp_out.value = omp_in.value < omp_out.value ? omp_out.value : omp_in.value, omp_out.index = omp_in.value < omp_out.value ? omp_out.index : omp_in.index) initializer(omp_priv = {0, -std::numeric_limits<float>::infinity()}) ``` Thus we can't get the same hash value for these two pieces of code. This PR adds a function to make the transformation escape the backslash in the codegen stage. Pull Request resolved: https://github.com/pytorch/pytorch/pull/88561 Approved by: https://github.com/jgong5, https://github.com/jansel, https://github.com/desertfire
Author
Committer
Parents
Loading