AI EncyclopediaAIMore concepts 1
Compilation
컴파일
The process of converting human-written code or a model into a form a machine can run, ahead of time.
Overview
Compilation is the process of turning the computing structure of a human-readable program or model into an executable file that a machine can run directly. Because the conversion is done once before running, it runs faster and more efficiently than a method that interprets the program every time it runs.
As software grows more complex and AI models get larger, it has become important to adapt the same computation as well as possible to each device. On devices with limited resources, such as smartphones or robots, the compilation method greatly affects speed and power use.
How it works
A compiler analyzes the computing structure of a program or model and converts it into machine code or an executable file. In the process it cuts unneeded computation and sets the order of execution to fit the target device's memory and compute units.
For AI models, it is common to fix the computation flow in advance like a graph and compile it. If the input size is fixed, optimization is easier, but if the input length varies, you have to prepare a different executable file for each length.
Where it is used
When you run an AI model on a limited device such as a smartphone, a car or a robot, compilation is used to raise speed and power efficiency. If you make an executable file tuned to an NPU or a dedicated accelerator, the same model can run with fewer resources.
When you apply it, you should decide in advance the type of target hardware, the range of input lengths and the precision settings. An executable file built once is verified only for that device and those settings, so moving it to another device means compiling and testing again.
Limits and misconceptions
It is easy to think that compiling always makes a model faster. In reality the effect varies greatly with the target and the input conditions, and if an operation is not supported, it can fall onto a slow path.
You have to check that the compiled result behaves the same as the original code. The optimization process can change the calculation precision or cause errors on rare inputs, so a verification step is needed before real service.
An everyday example
It is like a translator who turns a foreign-language book into your own language in advance, so readers can read it right away without looking up a dictionary each time. Compilation is also work done ahead of time, before running.
Why it matters
Depending on how it is compiled, the same AI model can run faster or slower, and on more or less power, on a device. Knowing this helps you understand news about edge devices, such as the question of how many executable files have to be built.