File: pattern_encapsulation.h

package info (click to toggle)
pytorch 1.13.1%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 139,252 kB
  • sloc: cpp: 1,100,274; python: 706,454; ansic: 83,052; asm: 7,618; java: 3,273; sh: 2,841; javascript: 612; makefile: 323; xml: 269; ruby: 185; yacc: 144; objc: 68; lex: 44
file content (34 lines) | stat: -rw-r--r-- 1,387 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once

#include <torch/csrc/jit/ir/ir.h>

namespace torch {
namespace jit {

// Introduction
//
// The encapsulation part will find the nodes of patterns, like how other
// pre-onnx passes are written. But instead of converting the nodes, it will
// encapsulate them into a sub-block of a new placeholder node. This part is
// called before onnx pass, so it runs before calling symbolic functions.
//
// Note: Why separate the function into two parts
//
// The purpose is to support conversions that depend on shape and type
// information. Shape and type information is only available after
// _jit_pass_onnx, which converts aten nodes to onnx nodes. So there is a
// interdependent issue. _jit_pass_onnx depends on preprocess passes to convert
// aten nodes into convertable condition, and preprocess passes depend on
// _jit_pass_onnx to convert upstream nodes and apply onnx shape inference.
// Separating the pass into two parts breaks the interdependency.
//
// Note: Edit Pattern Encapsulation
//
// Encapsulation step identifies the pattern, and copies the nodes into
// the subblock of a new placeholder node. The outputs of the new placeholder
// node are used in place of the original nodes instead. The category of the
// pattern is stored as attr::name.
TORCH_API c10::optional<Node*> EncapsulatePatternIntoSubblock(Node* n);

} // namespace jit
} // namespace torch