import random from test.unit.test_shapetracker import CheckingShapeTracker def do_permute(st): perm = list(range(0, len(st.shape))) random.shuffle(perm) perm = tuple(perm) print("st.permute(", perm, ")") st.permute(perm) def do_pad(st): c = random.randint(0, len(st.shape)-1) pad = tuple((random.randint(0,2), random.randint(0,2)) if i==c else (0,0) for i in range(len(st.shape))) print("st.pad(", pad, ")") st.pad(pad) def do_reshape_split_one(st): c = random.randint(0, len(st.shape)-1) poss = [n for n in [1,2,3,4,5] if st.shape[c]%n == 0] spl = random.choice(poss) shp = st.shape[0:c] + (st.shape[c]//spl, spl) + st.shape[c+1:] print("st.reshape(", shp, ")") st.reshape(shp) def do_reshape_combine_two(st): if len(st.shape) < 2: return c = random.randint(0, len(st.shape)-2) shp = st.shape[:c] + (st.shape[c] * st.shape[c+1], ) + st.shape[c+2:] print("st.reshape(", shp, ")") st.reshape(shp) def do_shrink(st): c = random.randint(0, len(st.shape)-1) while 1: shrink = tuple((random.randint(0,s), random.randint(0,s)) if i == c else (0,s) for i,s in enumerate(st.shape)) if all(x