[LT] Move MakeNode into ir_builder.h

Summary: Move MakeNode into ir_builder.h to avoid circular header
reference later when introducing a trie cache for IR node lookup.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/76482

Approved by: https://github.com/wconstab
This commit is contained in:
Bin Bao 2022-05-03 00:54:20 +00:00 committed by PyTorch MergeBot
parent 138c944a6b
commit f8a4780eb2
8 changed files with 13 additions and 6 deletions

View file

@ -4,6 +4,7 @@
#include <c10/util/Exception.h>
#include <torch/csrc/lazy/core/config.h>
#include <torch/csrc/lazy/core/ir.h>
#include <torch/csrc/lazy/core/ir_builder.h>
#include <torch/csrc/lazy/core/debug_util.h>
#include <torch/csrc/lazy/core/ir_metadata.h>
#include <torch/csrc/lazy/ts_backend/ts_node.h>

View file

@ -3,6 +3,7 @@
#include <c10/util/Exception.h>
#include <torch/csrc/lazy/core/config.h>
#include <torch/csrc/lazy/core/ir.h>
#include <torch/csrc/lazy/core/ir_builder.h>
#include <torch/csrc/lazy/core/ir_metadata.h>
#include <torch/csrc/lazy/core/ir_util.h>

View file

@ -5,6 +5,7 @@
#include <c10/core/Device.h>
#include <test/cpp/lazy/test_lazy_ops_util.h>
#include <torch/csrc/lazy/core/helpers.h>
#include <torch/csrc/lazy/core/ir_builder.h>
#include <torch/csrc/lazy/core/metrics.h>
#include <torch/csrc/lazy/core/debug_util.h>
#include <torch/csrc/lazy/core/lazy_graph_executor.h>

View file

@ -4,6 +4,7 @@
#include <test/cpp/lazy/test_lazy_ops_util.h>
#include <torch/csrc/lazy/core/debug_util.h>
#include <torch/csrc/lazy/core/helpers.h>
#include <torch/csrc/lazy/core/ir_builder.h>
#include <torch/csrc/lazy/core/lazy_graph_executor.h>
#include <torch/csrc/lazy/core/metrics.h>
#include <torch/csrc/lazy/core/permutation_util.h>

View file

@ -175,12 +175,6 @@ inline std::ostream& operator<<(std::ostream& stream, const Node& node) {
return stream;
}
// TODO(alanwaketan): Support r-value reference argument type.
template <typename T, typename... Args>
NodePtr MakeNode(Args&&... args) {
return std::make_shared<T>(std::forward<Args>(args)...);
}
template <typename T>
const T* NodeCast(const Node* node, OpKind op) {
if (op != node->op()) {

View file

@ -12,6 +12,12 @@
namespace torch {
namespace lazy {
// TODO(alanwaketan): Support r-value reference argument type.
template <typename T, typename... Args>
NodePtr MakeNode(Args&&... args) {
return std::make_shared<T>(std::forward<Args>(args)...);
}
struct IrBuilder {
virtual NodePtr MakeDeviceData(const std::shared_ptr<BackendData>& data) const = 0;
virtual NodePtr MakeScalar(const at::Scalar& value, const at::ScalarType& type) const = 0;

View file

@ -2,6 +2,8 @@
#include <torch/csrc/lazy/ts_backend/ts_node.h>
#include <torch/csrc/lazy/core/ir_builder.h>
namespace torch {
namespace lazy {

View file

@ -451,6 +451,7 @@ def run_gen_lazy_tensor(
"ATen/MetaFunctions.h",
"ATen/Operators.h",
"ATen/native/CPUFallback.h",
"torch/csrc/lazy/core/ir_builder.h",
"torch/csrc/lazy/core/lazy_graph_executor.h",
"torch/csrc/lazy/core/metrics.h",
"torch/csrc/lazy/core/shape.h",