fix sidx<0 in atomic tuner

This commit is contained in:
Dun Liang 2020-09-08 21:17:16 +08:00
parent 727dbc70b8
commit fc5ee8573e
2 changed files with 3 additions and 1 deletions

View File

@ -69,6 +69,8 @@ class TestAtomicTunerClass(unittest.TestCase):
'atomictuner: move atomicAdd to loop -1',
'atomictuner: move atomicAdd to loop -1',
])
self.check(lambda x: x.reindex_reduce("add", x.shape, ["i2","i3","i0","i1"]), [])
if __name__ == "__main__":
unittest.main()

View File

@ -218,7 +218,7 @@ static void tune_atomic(Pass* pass, KernelIR* ir, bool is_cuda, int tdim, vector
auto def=p->father->find_define(didx);
ASSERT(def != nullptr);
if (def->father == loops[sidx])
if (sidx>=0 && def->father == loops[sidx])
return true;
auto& loop_i = loops.at(sidx+1);
code = OpCompiler::precompile(defs, t) + ";";