Caffe2 - C++ API
A deep learning, cross platform ML framework
subgraph_utils.h
1 #pragma once
2 
3 #include <torch/csrc/jit/ir.h>
4 
5 namespace torch {
6 namespace jit {
7 
8 // Utilities for dealing with nodes that contain subgraphs.
9 //
10 // They handle the complexity of editing inputs/outputs as you merge nodes in
11 // and out of subgraphs.
12 namespace SubgraphUtils {
13 
14 // Create a new subgraph node that contains only `n`. The new subgraph will have
15 // `subgraphKind` as its type.
16 //
17 // `n` is destroyed.
18 //
19 // Returns the new subgraph node.
20 Node* createSingletonSubgraph(Node* n, Symbol subgraphKind);
21 
22 // Merge a node into a subgraph node. If `toMerge` is also a subgraph, the
23 // subgraphs are merged.
24 // `toMerge` is destroyed.
25 void mergeNodeIntoSubgraph(Node* toMerge, Node* subgraphNode);
26 
27 // Move nodes from a subgraph node to the outer graph.
28 // `subgraphNode` is destroyed.
29 void unmergeSubgraph(Node* subgraphNode);
30 
31 // Convenience function
32 std::shared_ptr<Graph> getSubgraph(Node* n);
33 
34 std::vector<Value*> inlineGraph(
35  const std::shared_ptr<Graph>& subgraph,
36  at::ArrayRef<Value*> outerInputs,
37  Node* insertBefore);
38 
39 } // namespace SubgraphUtils
40 } // namespace jit
41 } // namespace torch
Definition: jit_type.h:17
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: ArrayRef.h:41