• H
    Add Support for Tuple in for Loop (#30998) · c1375783
    Huihuang Zheng 提交于
    Dy2stat didn't support tuple as iteration variable in the past. This PR added there main cases:
    
           1). Non-enumerate case: for var1, var2 in var|var.numpy() will be re-written as:
              for FOR_ITER_TUPLE_PREFIX_x in var | var.numpy():
                var1 = FOR_ITER_TUPLE_PREFIX_x[0]
                var2 = FOR_ITER_TUPLE_PREFIX_x[1]
            2). Enumerate out tuple case: for t in enumerate(var|var.numpy) will be rewritten as:
              for FOR_ITER_TUPLE_INDEX_PREFIX_x, FOR_ITER_TUPLE_PREFIX_x in enumerate(var|var.numpy):
                t = (FOR_ITER_TUPLE_INDEX_PREFIX_x, FOR_ITER_TUPLE_PREFIX_x)
            3). Enumerate inner tuple case: for i, (var1, (var2, va3)) in enumerate(var|var.numpy()) will
            be re-written as:
              for i, FOR_ITER_TUPLE_PREFIX_x in var | var.numpy():
                var1 = FOR_ITER_TUPLE_PREFIX_x[0]
                var2 = FOR_ITER_TUPLE_PREFIX_x[1][0]
                var3 = FOR_ITER_TUPLE_PREFIX_x[1][1]
    c1375783
utils.py 49.6 KB