(x:UOp)
| 424 | |
| 425 | # collapse any BUFFERIZE to single input BUFFERIZE |
| 426 | def flatten_bufferize(x:UOp): |
| 427 | if len(x.src) == 2: return None |
| 428 | ret = x.replace(src=(x.src[0], get_single_element(apply_movement_op(Ops.RESHAPE, (prod(x.shape),), x.shape, x.src[1:])))) |
| 429 | rngs = x.src[1:] |
| 430 | ret = ret.reshape(x.shape) |
| 431 | if any(r.op is Ops.RANGE and r.src[0].op is not Ops.CONST for r in rngs): |
| 432 | sym_shape = tuple([r.src[0] if r.op is not Ops.CONST else 1 for r in rngs]) |
| 433 | ret = ret.shrink(tuple([(0,x) for x in sym_shape])) |
| 434 | return ret |
| 435 | pm_flatten_bufferize = PatternMatcher([(UPat(Ops.STAGE, name="x"), flatten_bufferize)]) |
| 436 | |
| 437 | pm_add_buffers = pm_mops+pm_flatten_bufferize+to_bufferview+PatternMatcher([ |
nothing calls this directly
no test coverage detected
searching dependent graphs…