mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Follows #131997 Co-authored-by: Aaron Gokaslan <aaronGokaslan@gmail.com> Pull Request resolved: https://github.com/pytorch/pytorch/pull/132010 Approved by: https://github.com/Skylion007
28 lines
506 B
C++
28 lines
506 B
C++
#include <torch/csrc/jit/passes/annotate_warns.h>
|
|
|
|
#include <atomic>
|
|
|
|
namespace torch::jit {
|
|
|
|
static 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 torch::jit
|