[TVM Discuss] [Questions] Same shape pattern

2020-06-19 Thread Thomas V via TVM Discuss
Yeah, it all wants to be static static to operate on. But so what I'm after is the next step, eliminate all ops not needed in a static setting. This seems important for anything where the graph is created automatic - with the frontend converters as well as differentiation. Best regards Thomas

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Matthew Brookhart via TVM Discuss
@t-vi Sorry for my delay, I had a lot of meetings today. I've finally read through this enough to grok the problem. I'm not sure the Pattern Language is the right tool for this pass. As you said here: [quote="t-vi, post:3, topic:7012"] I’m always wondering whether I’m missing ready-made pass

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Thomas V via TVM Discuss
[quote="mbrookhart, post:13, topic:7012"] I don’t particular want to force users to type their problems before using the pattern language in all cases. [/quote] I can see why. But so it seems that the shape processing gets really tedious here - with the inability to pass .shape back to relay b

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Matthew Brookhart via TVM Discuss
Ah, yeah, this makes sense now. The first LikeZapp pass will return this in certain cases: ``` tvm.relay.broadcast_to(data, list(res._checked_type_.shape)) ``` Which doesn't have a type when it is constructed, but ZeroZapp later can find that node and assume it does have a type. Thus, the prob

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Cody H. Yu via TVM Discuss
I agree with @matt-arm. The `checked_type_` would be empty when a node is created until `InterType` is run or a new function is added to the module. It means the later processing node may not get the type of its parents if the parents were replaced with new nodes without properly propogating

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Matt Barrett via TVM Discuss
The sort of case I'm thinking of is when a mutation takes place, the mutated part of the graph won't have types associated with it (at least, not until type_infer is called on the expression again). It's not immediately obvious to me whether that's happening in this example. But now I've thoug

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Thomas V via TVM Discuss
The above ZeroZapper code snippet also has the problem. --- [Visit Topic](https://discuss.tvm.ai/t/same-shape-pattern/7012/10) 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/

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Matthew Brookhart via TVM Discuss
@matt-arm Can you give me an example? Is this just the partition issue we talked about before, or something else? --- [Visit Topic](https://discuss.tvm.ai/t/same-shape-pattern/7012/9) to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these email

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Thomas V via TVM Discuss
Oh, that is very likely the case for me here. --- [Visit Topic](https://discuss.tvm.ai/t/same-shape-pattern/7012/8) 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/3e50fe8fbc5

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Matt Barrett via TVM Discuss
There is another way types can go awry in the dataflow matcher. When things get mutated they lose their type info until the rewrite is completed. We might want to start treating that behaviour as a bug because it's caught me out before. Maybe @mbrookhart can comment? --- [Visit Topic](htt

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Thomas V via TVM Discuss
Thank you Matt! Oh no. :man_facepalming: (But `checked_type` isn't the solution, unfortunately.) I must admit the ffi is too clever for me. Without the tab completion I'm lost. I even have a 2-line patch to fix that for classes, but I don't know where to put the unittest... --- [Visit

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Matt Barrett via TVM Discuss
Have you tried using checked_type rather than _checked_type_? --- [Visit Topic](https://discuss.tvm.ai/t/same-shape-pattern/7012/5) to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from these emails, [click here](https://discuss.tvm.ai/email/unsubsc

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Thomas V via TVM Discuss
So with the following rewrites and passes ```python class ZeroZapp(tvm.relay.dataflow_pattern.DFPatternCallback): def __init__(self): self.zeros = tvm.relay.dataflow_pattern.is_op("zeros")(tvm.relay.dataflow_pattern.wildcard()) self.other_tensor = tvm.relay.dataflow_pattern.

[TVM Discuss] [Questions] Same shape pattern

2020-06-18 Thread Thomas V via TVM Discuss
Thank you, yes. So I have this graph produced by gradient (and graph normal form and removing the forward outputs) of a dense + bias_add. Obviously, the gradients would be `ones_like(output).collapse_like(bias)` and a couple of `dense( )` with `grad_out` or its transpose replacing weight and i

[TVM Discuss] [Questions] Same shape pattern

2020-06-17 Thread Cody H. Yu via TVM Discuss
Could you provide example graphs before and after the pattern matching and rewriting to better illustrate your requirements? --- [Visit Topic](https://discuss.tvm.ai/t/same-shape-pattern/7012/2) to respond. You are receiving this because you enabled mailing list mode. To unsubscribe from

[TVM Discuss] [Questions] Same shape pattern

2020-06-17 Thread Thomas V via TVM Discuss
Now I'm trying to produce a pattern that matches nodes if they have the same shape. Is such a pattern available? I only saw has_shape which seems to compare to a fixed shape (which I don't know). I'm trying to use rewrite and so it seems checking after the matching (an returning an unchanged e