Skip to content

Commit

Permalink
Add SpanningTreePrinter (csarofeen#1786)
Browse files Browse the repository at this point in the history
  • Loading branch information
zasdfgbnm committed Jul 1, 2022
1 parent 59f3c32 commit 635ebfc
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
18 changes: 18 additions & 0 deletions torch/csrc/jit/codegen/cuda/maxinfo_propagator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,24 @@ std::shared_ptr<MaxInfoSpanningTree::Information> MaxRootDomainInfoSpanningTree:
return from_info;
}

void SpanningTreePrinter::propagateTvPasC(TensorView* from, TensorView* to) {
stream_ << "propagateTvPasC" << std::endl;
stream_ << " from: " << from->toString() << std::endl;
stream_ << " to: " << to->toString() << std::endl;
}

void SpanningTreePrinter::propagateTvCasP(TensorView* from, TensorView* to) {
stream_ << "propagateTvCasP" << std::endl;
stream_ << " from: " << from->toString() << std::endl;
stream_ << " to: " << to->toString() << std::endl;
}

void SpanningTreePrinter::propagateTvSibling(TensorView* from, TensorView* to) {
stream_ << "propagateTvSibling" << std::endl;
stream_ << " from: " << from->toString() << std::endl;
stream_ << " to: " << to->toString() << std::endl;
}

} // namespace cuda
} // namespace fuser
} // namespace jit
Expand Down
11 changes: 11 additions & 0 deletions torch/csrc/jit/codegen/cuda/maxinfo_propagator.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,17 @@ class TORCH_CUDA_CU_API MaxRootDomainInfoSpanningTree
selector) {}
};

class TORCH_CUDA_CU_API SpanningTreePrinter
: public MaxInfoSpanningTree::Propagator {
std::ostream& stream_;

public:
virtual void propagateTvPasC(TensorView* from, TensorView* to) override;
virtual void propagateTvCasP(TensorView* from, TensorView* to) override;
virtual void propagateTvSibling(TensorView* from, TensorView* to) override;
SpanningTreePrinter(std::ostream& stream = std::cout) : stream_(stream) {}
};

} // namespace cuda
} // namespace fuser
} // namespace jit
Expand Down

0 comments on commit 635ebfc

Please sign in to comment.