mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
Summary: * Add a pass at end of runCleanupPasses to annotate `aten::warn` so that each has its unique id * Enhanced interpreter so that it tracks which `aten::warn` has been executed before and skip them * Improved insertInstruction so that it correctly checks for overflow Fixes https://github.com/pytorch/pytorch/issues/45108 Pull Request resolved: https://github.com/pytorch/pytorch/pull/45382 Reviewed By: mrshenli Differential Revision: D24060677 Pulled By: gmagogsfm fbshipit-source-id: 9221bc55b9ce36b374bdf614da3fe47496b481c1
30 lines
524 B
C++
30 lines
524 B
C++
#include <torch/csrc/jit/passes/annotate_warns.h>
|
|
|
|
#include <atomic>
|
|
|
|
namespace torch {
|
|
namespace jit {
|
|
|
|
void AnnotateWarns(Block* b) {
|
|
static std::atomic<int64_t> idx(0);
|
|
for (Node* n : b->nodes()) {
|
|
for (Block* child_b : n->blocks()) {
|
|
AnnotateWarns(child_b);
|
|
}
|
|
|
|
if (n->kind() != aten::warn) {
|
|
continue;
|
|
}
|
|
|
|
n->i_(attr::warn_id, idx);
|
|
idx++;
|
|
}
|
|
}
|
|
|
|
void AnnotateWarns(const std::shared_ptr<Graph>& graph) {
|
|
AnnotateWarns(graph->block());
|
|
}
|
|
|
|
} // namespace jit
|
|
} // namespace torch
|