Skip to content

Commit 2997993

Browse files
committed
While I'm here, use a lambda mutator.
1 parent dacb930 commit 2997993

1 file changed

Lines changed: 8 additions & 21 deletions

File tree

src/Tracing.cpp

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -327,26 +327,6 @@ class InjectTracing : public IRMutator {
327327
Evaluate::make(end_op_call))));
328328
}
329329
};
330-
331-
class RemoveRealizeOverOutput : public IRMutator {
332-
using IRMutator::visit;
333-
const vector<Function> &outputs;
334-
335-
Stmt visit(const Realize *op) override {
336-
for (const Function &f : outputs) {
337-
if (op->name == f.name()) {
338-
return mutate(op->body);
339-
}
340-
}
341-
return IRMutator::visit(op);
342-
}
343-
344-
public:
345-
RemoveRealizeOverOutput(const vector<Function> &o)
346-
: outputs(o) {
347-
}
348-
};
349-
350330
} // namespace
351331

352332
Stmt inject_tracing(Stmt s, const string &pipeline_name, bool trace_pipeline,
@@ -373,7 +353,14 @@ Stmt inject_tracing(Stmt s, const string &pipeline_name, bool trace_pipeline,
373353
s = tracing.mutate(s);
374354

375355
// Strip off the dummy realize blocks
376-
s = RemoveRealizeOverOutput(outputs).mutate(s);
356+
s = mutate_with(s, [&](auto *self, const Realize *op) {
357+
for (const Function &f : outputs) {
358+
if (op->name == f.name()) {
359+
return self->mutate(op->body);
360+
}
361+
}
362+
return self->visit_base(op);
363+
});
377364

378365
if (!s.same_as(original) || trace_pipeline || t.has_feature(Target::TracePipeline)) {
379366
// Add pipeline start and end events

0 commit comments

Comments
 (0)