MCPcopy Create free account
hub / github.com/pytorch/pytorch / replace_by_example

Method replace_by_example

torch/_inductor/pattern_matcher.py:124–136  ·  view source on GitHub ↗
(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
139class FailedMatch(RuntimeError):

Callers 6

addmmFunction · 0.80
replace_randomFunction · 0.80
replace_randintFunction · 0.80
addmm_replacementMethod · 0.80

Calls 3

trace_fnFunction · 0.85
map_argMethod · 0.80
replace_with_graphMethod · 0.45

Tested by 1

addmm_replacementMethod · 0.64