pytorch
320c3568 - [TensorExpr] (trivial) unique Kernel input names (#38678)

Commit
4 years ago
[TensorExpr] (trivial) unique Kernel input names (#38678) Summary: We have a bug where Function names are not uniqued which produces bad printed output, e.g: ``` { for (int i0 = 0; i0 < 1024; i0++) { input[i0] = t0[0 + i0 * 1]; } for (int i0_1 = 0; i0_1 < 1024; i0_1++) { input_1[i0_1] = t1[0 + i0_1 * 1]; } for (int v = 0; v < 1024; v++) { aten_add[v] = (input(v)) + float(1) * (input(v)); } for (int v_1 = 0; v_1 < 1024; v_1++) { aten_sub[v_1] = (aten_add(v_1)) - float(1) * (input(v_1)); } } ``` Notice the names of the vars in the `aten_add` line which make it appear as though input_1 isn't used. This is because the Buf names are uniqued by the unique_name_manager but the FunctionCall names are not. Not fixing this right now, but working around it by reducing the number of Tensors that are created with the same name ("input") in kernel.cpp. That example now looks like: ``` { for (int i0 = 0; i0 < 1024; i0++) { input1[i0] = t0[0 + i0 * 1]; } for (int i0_1 = 0; i0_1 < 1024; i0_1++) { input2[i0_1] = t1[0 + i0_1 * 1]; } for (int v = 0; v < 1024; v++) { aten_add[v] = (input1(v)) + float(1) * (input2(v)); } for (int v_1 = 0; v_1 < 1024; v_1++) { aten_sub[v_1] = (aten_add(v_1)) - float(1) * (input1(v_1)); } } ``` To be clear, the bug still exists but it's not blocking what I'm trying to do right now 😄 Pull Request resolved: https://github.com/pytorch/pytorch/pull/38678 Differential Revision: D21630276 Pulled By: nickgg fbshipit-source-id: 39dec2178cf492302bc5a61e1e688ae81513858a
Author
Parents
Loading