Skip to content

Commit b966b58

Browse files
committed
debug
1 parent d6c010b commit b966b58

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Intermediate Representation
2+
3+
In this section, we begin by introducing basic IR concepts and the types
4+
of IR employed in classical compilers. Next, we address the new
5+
requirements and challenges that arise in the IR design for machine
6+
learning frameworks. To conclude this section, we examine the types of
7+
IRs utilized by well-known machine learning frameworks and delve into
8+
their implementation.
9+
10+
## Definition of Intermediate Representations
11+
12+
An IR is a data structure or a form of code that a compiler utilizes to
13+
represent source code. Almost all compilers need IRs to model the
14+
program code that requires analysis, transformation, and optimization.
15+
The representational capability of an IR is crucial during the
16+
compilation process. It must accurately depict source code without
17+
information loss, ensure the completeness of the source-to-target code
18+
compilation, and guarantee the effectiveness and performance of code
19+
optimization.
20+
21+
As illustrated in Figure :numref:`ch04/ch04-IR`, IRs facilitate the representation of
22+
multiple source program languages from the frontend and enable the
23+
backend to connect to various target machines. Located between the
24+
frontend and backend is an optimizer, which allows for the addition of
25+
new optimization processes directly into the frontend and backend. These
26+
processes use existing IRs as input and generate new IRs as output. By
27+
analyzing and optimizing IRs, the optimizer enhances the extensibility
28+
of the compilation process and minimizes the impact that might be
29+
introduced during an optimization process on the frontend and backend.
30+
31+
![Compiler's optimizationprocess](../img/ch04/IR-IR_structure.png)
32+
:label:`ch04/ch04-IR`
33+
34+
With the ongoing evolution of compiler techniques, the development of
35+
IRs has progressed through three stages. In the initial stage, IRs were
36+
confined within a compiler and exclusively used by compiler developers.
37+
During the middle stage, when specific compilers became open source, IRs
38+
started being made publicly available, primarily for use by the users of
39+
compilers and related compilation tools. In the current stage, IRs are
40+
advancing toward facilitating an ecosystem of ecosystems (through a
41+
unified IR approach), encouraging increasing stakeholders (for example,
42+
hardware accelerator designers, machine learning framework users, and
43+
more) to participate in advertising AI computing.
44+
45+
## Types of Intermediate Representations
46+
47+
We will discuss various types of IR structures used by classical
48+
compilers. Understanding these IR structures is essential for analyzing
49+
source programs and generating optimized compiled code. Table
50+
:numref:`ch06/ch06-categorize` offers an overview of the
51+
different IR types. It is important to design IR structures carefully,
52+
considering the specific requirements of the compiler's design.
53+

0 commit comments

Comments
 (0)