Method
replace_by_example
(self, replacement_fn, args, trace_fn=None)
Source from the content-addressed store, hash-verified
| 122 | ) |
| 123 | |
| 124 | def replace_by_example(self, replacement_fn, args, trace_fn=None): |
| 125 | assert self.ctx |
| 126 | if trace_fn is None: |
| 127 | trace_fn = fwd_only |
| 128 | replacement = trace_fn( |
| 129 | replacement_fn, torch.fx.map_arg(args, lambda arg: arg.meta["val"]) |
| 130 | ) |
| 131 | ReplacementPatternEntry.replace_with_graph( |
| 132 | self, |
| 133 | self.ctx.graph, |
| 134 | replacement, |
| 135 | args, |
| 136 | ) |
| 137 | |
| 138 | |
| 139 | class FailedMatch(RuntimeError): |