Hi All,

I was experimenting to decompose a relay expression (operator or a function) 
into the same kind of operator. Mainly, if I have to do vector addition, I just 
want to replicate the number of additions but each addition operates on part of 
the data. 

For example, to add two vectors of size 30 by 1, let us assume we need one 
vector adder. 

I just want to use two adders, and I want to delegate each adder to operate on 
half (15 =30/2) of the data. 

Here is an example that I write using rewrite. I thought rewrite could do it 
easily, but for some reason, the following program is stuck in an infinite loop 
in callback function. Any ideas? 

```
class ExampleDecomposeByShape(DFPatternCallback):

    def __init__(self):
        self.x = wildcard()
        self.y = wildcard()
        self.patern =  self.x + self.y 

    def callback(self, pre, post, node_map):
        **# This callback is stuck. It  keeps returning to the next line.** 
        x = node_map[self.x][0]
        y = node_map[self.y][0]
        
        dim1, dim2 =  node_map[self.x][0].type_annotations.shape
        
        x1 =  relay.var('x1', shape(dim1//2, dim2))
        y1 =  relay.var('y1', shape(dim1//2, dim2))
        x2 =  relay.var('x2', shape(dim1//2, dim2))
        y2 =  relay.var('y2', shape(dim1//2, dim2))
 
         res =  relay.op.concatenate([x1 + y2, x2+ y1], axis=0)
         return res

# This is how I call
x =  relay.var('x', shape(30, 1))
y =  relay.var('y', shape(30, 1))
f= relay.Function([x, y], x+y)

out = rewrite(ExampleDecomposeByShape(), f)
print(out) 

```





---
[Visit 
Topic](https://discuss.tvm.ai/t/replicating-operator-with-pattern-rewrite-got-stuck-in-an-infinite-loop/7808/1)
 to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click 
here](https://discuss.tvm.ai/email/unsubscribe/208ea47f90a905d390fac56ae8bbe5a8d25960587df18a2cdfaacdaff6ea9ecf).

Reply via email to