TODO: Write this in matcher.hpp as a general matcher for iterating through inputs
| 43 | |
| 44 | // TODO: Write this in matcher.hpp as a general matcher for iterating through inputs |
| 45 | inline auto pointwise_inputs() |
| 46 | { |
| 47 | return [](auto start, auto f) { |
| 48 | std::unordered_set<instruction_ref> visited; |
| 49 | fix([&](auto self, auto ins) { |
| 50 | if(ins->can_eval()) |
| 51 | return; |
| 52 | if(not visited.insert(ins).second) |
| 53 | return; |
| 54 | if(not ins->get_operator().attributes().contains("pointwise") and |
| 55 | ins->get_operator().name() != "reshape") |
| 56 | { |
| 57 | f(ins); |
| 58 | return; |
| 59 | } |
| 60 | for(auto input : ins->inputs()) |
| 61 | self(input); |
| 62 | })(start); |
| 63 | }; |
| 64 | } |
| 65 | |
| 66 | struct find_attention |
| 67 | { |