ExecuTorch Compiler ์์ธ
๊ฐ์
ExecuTorch ์ปดํ์ผ๋ฌ๋ PyTorch ๋ชจ๋ธ์ ์ฃ์ง ๋๋ฐ์ด์ค์์ ํจ์จ์ ์ผ๋ก ์คํํ ์ ์๋ .pte ํ์ผ๋ก ๋ณํํ๋ ์ ์ (AOT) ์ปดํ์ผ ์์คํ
์ด๋ค. ๊ธฐ์กด Backend ๋ฌธ์๊ฐ ๋ฐฑ์๋ ์์คํ
๊ณผ ๋๋ฆฌ๊ฒ์ดํธ ๋ฉ์ปค๋์ฆ์ ์ด์ ์ ๋ง์ถ ๋ฐ๋ฉด, ๋ณธ ๋ฌธ์๋ ์ปดํ์ผ๋ฌ ํ์ดํ๋ผ์ธ์ ๋ด๋ถ ๋์์ ์ง์คํ๋ค.
ExecuTorch ์ปดํ์ผ๋ฌ์ ํต์ฌ์ EXIR(ExecuTorch Intermediate Representation)์ด๋ผ๋ ์ค๊ฐ ํํ ์ฒด๊ณ์ด๋ค. ATen ๋ค์ด์ด๋ ํฐ๋ธ โ Edge ๋ค์ด์ด๋ ํฐ๋ธ โ Backend ๋ค์ด์ด๋ ํฐ๋ธ๋ก ์ด์ด์ง๋ 3๋จ๊ณ ๋ค์ด์ด๋ ํฐ๋ธ ๋ณํ์ ํตํด, ์ฌ์ฉ์ ๋ชจ๋ธ์ ํ๋์จ์ด์ ์ต์ ํ๋ ์คํ ๊ฐ๋ฅํ ํํ๋ก ๋ฎ์ถ(lowering)๋ ๊ฒ์ด ๋ชฉํ์ด๋ค. ์ด ๊ณผ์ ์์ ์ปค์คํ ์ปดํ์ผ๋ฌ ํจ์ค, ์ฐ์ฐ ์ตํฉ, ๋ฉ๋ชจ๋ฆฌ ํ๋๋, ์ฝ๋ ์์ฑ ๋ฑ ๋ค์ํ ์ต์ ํ๊ฐ ์ํ๋๋ค.
ํต์ฌ ๊ฐ๋
EXIR ๋ค์ด์ด๋ ํฐ๋ธ ์ฒด๊ณ
ExecuTorch๋ ๋ชจ๋ธ์ ๋จ๊ณ์ ์ผ๋ก ๋ฎ์ถ๊ธฐ ์ํด ์ธ ๊ฐ์ง ๋ค์ด์ด๋ ํฐ๋ธ๋ฅผ ์ฌ์ฉํ๋ค:
| ๋ค์ด์ด๋ ํฐ๋ธ | ๋จ๊ณ | ํน์ง | ์ฐ์ฐ์ ์ธํธ |
|---|---|---|---|
| ATen | 1๋จ๊ณ | PyTorch eager ๋ชจ๋ธ์ ๊ฐ์ฅ ์ถฉ์คํ ์บก์ฒ | torch.ops.aten ๋ค์์คํ์ด์ค |
| Edge | 2๋จ๊ณ | ์ฃ์ง ๋๋ฐ์ด์ค์ ์ ์ฉํ ํนํ (ํ๋์จ์ด ๋ ๋ฆฝ์ ) | dtype ํนํ๋ Edge ์ฐ์ฐ์ |
| Backend | 3๋จ๊ณ | ํ๋์จ์ด๋ณ ํ๊ฒ ์ฐ์ฐ์, ๋๋ฆฌ๊ฒ์ดํธ ํตํฉ | ๋ฐฑ์๋ ์ ์ฉ ์ฐ์ฐ์ |
ATen ๋ค์ด์ด๋ ํฐ๋ธ
ATen ๋ค์ด์ด๋ ํฐ๋ธ๋ torch.export()์ ์ง์ ์ ์ธ ์ถ๋ ฅ์ผ๋ก, eager ๋ชจ๋ PyTorch ํ๋ก๊ทธ๋จ์ด Exported IR ๊ทธ๋ํ๊ฐ ๋๋ ์ฒซ ๋ฒ์งธ ๋จ๊ณ์ด๋ค:
import torch
# ๋ชจ๋ธ ์ ์
model = MyModel().eval()
example_inputs = (torch.randn(1, 3, 224, 224),)
# Export โ ATen ๋ค์ด์ด๋ ํฐ๋ธ
aten_program = torch.export.export(model, example_inputs)
ATen ๋ค์ด์ด๋ ํฐ๋ธ ์์ฑ:
- ๊ธฐ๋ฅํ(functionalization)๊ฐ ์ํ๋์ด ํ
์ ๋ณ์นญ(alias)๊ณผ ๋ณ์ด(mutation)๊ฐ ์ ๊ฑฐ๋จ
- ๋ชจ๋ ์ฐ์ฐ์๋ torch.ops.aten ๋ค์์คํ์ด์ค์ ATen ์ฐ์ฐ์์ด๊ฑฐ๋ ๋ฑ๋ก๋ ์ปค์คํ
์ฐ์ฐ์
- ๋ชจ๋ ์ฐ์ฐ์์ meta kernel์ด ์์ด์ผ ํจ (์
๋ ฅ shape์ผ๋ก ์ถ๋ ฅ shape ์ถ๋ก )
- ๋ชจ๋ ํ
์๋ torch.contiguous_format ๋ฉ๋ชจ๋ฆฌ ํฌ๋งท ์ฌ์ฉ
- ๋์ dtype, ์๋ฌต์ dtype ํ๋ก๋ชจ์
, ์๋ฌต์ ๋ธ๋ก๋์บ์คํ
์ง์
Edge ๋ค์ด์ด๋ ํฐ๋ธ
Edge ๋ค์ด์ด๋ ํฐ๋ธ๋ ์ฃ์ง ๋๋ฐ์ด์ค์ ์ ์ฉํ์ง๋ง ํ๋์จ์ด์ ์์ง ํนํ๋์ง ์์ ์ค๊ฐ ๋จ๊ณ์ด๋ค:
from executorch import exir
# ATen โ Edge ๋ณํ
edge_program: exir.EdgeProgramManager = exir.to_edge(aten_program)
Edge ๋ค์ด์ด๋ ํฐ๋ธ ์์ฑ:
- ๋ชจ๋ ์ฐ์ฐ์๋ dtype ํนํ๋ Edge ์ฐ์ฐ์ (ํ๋์จ์ด ๋
๋ฆฝ์ )
- ๋ชจ๋ Scalar ํ์
์ Tensor๋ก ๋ณํ
- edge.yaml์ dtype ์ ์ฝ ์กฐ๊ฑด ์ ์
- ์ปค์คํ
๊ทธ๋ํ ๋ณํ(Pass) ์ ์ฉ ๊ฐ๋ฅ
dtype ์ ์ฝ ์กฐ๊ฑด ์์:
- func: sigmoid
namespace: edge
inherits: aten::sigmoid
type_alias:
T0: [Bool, Byte, Char, Int, Long, Short]
T1: [Double, Float]
T2: [Float]
type_constraint:
- self: T0
__ret_0: T2
- self: T1
__ret_0: T1
Backend ๋ค์ด์ด๋ ํฐ๋ธ
Backend ๋ค์ด์ด๋ ํฐ๋ธ๋ ์ ํ์ ๋จ๊ณ๋ก, ๋ฐฑ์๋๊ฐ ๊ทธ๋ํ๋ฅผ ํ๋์จ์ด๋ณ ์ฐ์ฐ์, ๋ฉํ๋ฐ์ดํฐ, ๋๋ฆฌ๊ฒ์ดํธ๋ ๋ก์ด ๋ชจ๋๋ก ์ฌ์์ฑํ ๋ ์ฌ์ฉ๋๋ค:
# Edge โ Backend ๋ณํ (๋ฐฑ์๋๋ณ ํํฐ์
๋ ์ฌ์ฉ)
program = to_edge_transform_and_lower(
aten_program,
partitioner=[XnnpackPartitioner()]
).to_executorch()
Backend ๋ค์ด์ด๋ ํฐ๋ธ ํน์ง:
- Edge ๋ค์ด์ด๋ ํฐ๋ธ ์ดํ์๋ง ์คํ
- ํ๋์จ์ด๋ณ ์ตํฉ, ๋ก์ด๋ง ํจํด, ๋๋ฆฌ๊ฒ์ดํธ ํตํฉ์ ์ฌ์ฉ
- ์ปค์คํ
์ฐ์ฐ์์ ๋ฌ๋ฆฌ ๋ฐฑ์๋ ์ ์ฉ ์ฐ์ฐ์๋ ์ด ๋จ๊ณ์์๋ง ๋์
์ปค์คํ ์ปดํ์ผ๋ฌ ํจ์ค
ExecuTorch๋ ๊ทธ๋ํ ์ต์ ํ๋ฅผ ์ํ ๋ค์ํ ์ปค์คํ ํจ์ค๋ฅผ ์ ๊ณตํ๋ค:
ํจ์ค ๋ถ๋ฅ ์ฒด๊ณ:
| ์ถ | ๊ตฌ๋ถ | ์์ |
|---|---|---|
| ๋งคํ ์ ํ | 1-to-X (๋ถํด) | ์ฐ์ฐ์ ๋ถํด |
| Many-to-1 (์ตํฉ) | ์ฐ์ฐ์ ์ตํฉ | |
| ๋ฐ๋ณต ๋ฐฉํฅ | ์๋ฐฉํฅ (shape ์ ํ) | shape ์ถ๋ก |
| ์ญ๋ฐฉํฅ (์ฝ๋ ์ ๊ฑฐ) | ์ฃฝ์ ์ฝ๋ ์ ๊ฑฐ | |
| ์ ๋ณด ์์กด์ฑ | ๋ก์ปฌ ๋ ธ๋ ์ ๋ณด | out-variant ๋ณํ |
| ๊ธ๋ก๋ฒ ๊ทธ๋ํ ์ ๋ณด | ๋ฉ๋ชจ๋ฆฌ ํ๋๋ |
ExportPass (Level 1 ํจ์ค):
from executorch.exir.pass_base import ExportPass
class ReplaceInPlaceReluWithOutOfPlaceReluPass(ExportPass):
"""in-place relu_๋ฅผ out-of-place relu๋ก ๊ต์ฒด"""
def call_operator(self, op, args, kwargs, meta):
if op != torch.ops.aten.relu_.default:
return super().call_operator(op, args, kwargs, meta)
return super().call_operator(
Op(torch.ops.aten.relu.default), args, kwargs, meta
)
# ํจ์ค ์คํ
replace_pass = ReplaceInPlaceReluWithOutOfPlaceReluPass()
new_graph_module = replace_pass(graph_module).graph_module
Subgraph Rewriter (Level 2 ํจ์ค):
from torch.fx import subgraph_rewriter
def replace_patterns(graph_module):
def pattern(x, y):
x = torch.ops.aten.add.Tensor(x, y)
x = torch.ops.aten.mul.Tensor(x, y)
return x
def replacement(x, y):
return torch.ops.aten.sub.Tensor(x, y)
return subgraph_rewriter.replace_pattern_with_filters(
graph_module, pattern, replacement
)
ํํฐ์ ๋
ํํฐ์ ๋๋ ๋ชจ๋ธ ๊ทธ๋ํ๋ฅผ ํ๋์จ์ด ์ง์ ์๋ธ๊ทธ๋ํ์ CPU ํด๋ฐฑ์ผ๋ก ๋ถํ ํ๋ค:
| ํํฐ์ ๋ ์ ํ | ์ค๋ช | ์ฌ์ฉ ์ฌ๋ก |
|---|---|---|
| Subgraph Matcher | ํจํด ๊ธฐ๋ฐ ์๋ธ๊ทธ๋ํ ํ์ | ํน์ ์ฐ์ฐ์ ์กฐํฉ ํ์ง |
| Capability-Based | ์ง์๋๋ ์ฐ์ฐ์ ๊ธฐ๋ฐ ๋ถํ | ํ๋์จ์ด ์ง์ ๋ฒ์ ๊ธฐ๋ฐ ๋ถํ |
| Source Partitioner | ์์ค ์์ค ๋ชจ๋ ๋ถํ | torch.nn.Linear ๋ฑ ๊ณ ์์ค ๋ชจ๋ ํ์ง |
from torch.fx.passes.infra.partitioner import CapabilityBasedPartitioner
from torch.fx.passes.operator_support import OperatorSupportBase
class AddMulOperatorSupport(OperatorSupportBase):
def is_node_supported(self, submodules, node: torch.fx.Node) -> bool:
return node.op == "call_function" and node.target in [
torch.ops.aten.add.Tensor,
torch.ops.aten.mul.Tensor,
]
partitioner = CapabilityBasedPartitioner(graph_module, AddMulOperatorSupport())
partitions = partitioner.propose_partitions()
๋์ ์๋ฆฌ
์ ์ฒด ์ปดํ์ผ๋ฌ ํ์ดํ๋ผ์ธ
ExecuTorch ์ปดํ์ผ๋ฌ์ ์ ์ฒด ํ์ดํ๋ผ์ธ์ ๋ค์ ๋จ๊ณ๋ก ๊ตฌ์ฑ๋๋ค:
1๋จ๊ณ: ๋ชจ๋ธ ์บก์ฒ (torch.export)
import torch
from executorch.exir import to_edge_transform_and_lower
# eager ๋ชจ๋ ๋ชจ๋ธ ์ ์
model = MyModel().eval()
example_inputs = (torch.randn(1, 3, 224, 224),)
# Export โ ATen ๋ค์ด์ด๋ ํฐ๋ธ
aten_program = torch.export.export(model, example_inputs)
2๋จ๊ณ: ์ฃ์ง ๋ณํ (to_edge)
# ATen โ Edge ๋ค์ด์ด๋ ํฐ๋ธ
# dtype ํนํ, Scalar โ Tensor ๋ณํ ์ํ
edge_program = exir.to_edge(aten_program)
3๋จ๊ณ: ๊ทธ๋ํ ์ต์ ํ (์ปค์คํ ํจ์ค)
# ์ปค์คํ
ํจ์ค๋ฅผ ํตํ ๊ทธ๋ํ ๋ณํ
edge_program = edge_program.transform(MyCustomPass())
4๋จ๊ณ: ํ๋์จ์ด ๋ก์ด๋ง (to_backend)
# ํํฐ์
๋๋ฅผ ํตํ ๊ทธ๋ํ ๋ถํ ๋ฐ ๋ฐฑ์๋ ๋๋ฆฌ๊ฒ์ดํธ
program = to_edge_transform_and_lower(
aten_program,
partitioner=[XnnpackPartitioner()]
)
5๋จ๊ณ: ExecuTorch ํ๋ก๊ทธ๋จ ์์ฑ (to_executorch)
# Backend ๋ค์ด์ด๋ ํฐ๋ธ โ .pte ํ์ผ ์์ฑ
executorch_program = program.to_executorch()
๋ฉ๋ชจ๋ฆฌ ํ๋๋
ExecuTorch ์ปดํ์ผ๋ฌ๋ ์คํ ์ ๋ฉ๋ชจ๋ฆฌ ํ ๋น์ ์ต์ ํํ๊ธฐ ์ํด ์ ์ ๋ฉ๋ชจ๋ฆฌ ํ๋๋์ ์ํํ๋ค:
| ํ๋๋ ๋จ๊ณ | ์ค๋ช |
|---|---|
| ํ ์ ์๋ช ๋ถ์ | ๊ฐ ํ ์์ ์๋ช ์ฃผ๊ธฐ ๊ณ์ฐ |
| ๋ฒํผ ๊ณต์ | ๋์์ ์ฌ์ฉ๋์ง ์๋ ํ ์ ๊ฐ ๋ฉ๋ชจ๋ฆฌ ๊ณต์ |
| ๋ฉ๋ชจ๋ฆฌ ๋ ์ด์์ ๊ฒฐ์ | ์คํ ์ ํ ๋นํ ๋ฉ๋ชจ๋ฆฌ ์์ญ ๊ฒฐ์ |
| ํฌ๊ธฐ ๊ณ์ฐ | ์ด ํ์ํ ๋ฉ๋ชจ๋ฆฌ ํฌ๊ธฐ ์ฐ์ |
์ฝ๋ ์์ฑ
Backend ๋ค์ด์ด๋ ํฐ๋ธ์์ .pte ํ์ผ๋ก ๋ณํ๋ ๋, ExecuTorch๋ ๋ค์ ์ฝ๋๋ฅผ ์์ฑํ๋ค:
| ์์ฑ ์์ | ์ค๋ช |
|---|---|
| ์ฐ์ฐ์ ์ปค๋ ํธ์ถ | ๊ฐ ์ฐ์ฐ์์ ๋ํ ์ปค๋ ํจ์ ํธ์ถ ์ฝ๋ |
| ํ ์ ๋์คํฌ๋ฆฝํฐ | ๋ฉ๋ชจ๋ฆฌ ํ ๋น ๋ฐ ๋ ์ด์์ ์ ๋ณด |
| ๋ฉ์๋ ํ ์ด๋ธ | ๋ชจ๋ธ์ ๊ฐ ๋ฉ์๋์ ๋ํ ์คํ ์ ๋ณด |
| ์์ ๊ฐ์ค์น | ๋ชจ๋ธ ๊ฐ์ค์น์ ์ง๋ ฌํ๋ ๋ฐ์ดํฐ |
| ํ๋ซ๋ฐ์ด๋๋ฆฌ ํฌ๋งท | ๋๋ฐ์ด์ค์์ ์ง์ ํ์ฑ ๊ฐ๋ฅํ ํ์ |
.pte ํ์ผ ๊ตฌ์กฐ
.pte ํ์ผ ๊ตฌ์กฐ:
โโโ ํค๋ (magic number, ๋ฒ์ , ์ฒดํฌ์ฌ)
โโโ ์ธ๊ทธ๋จผํธ ํ
์ด๋ธ
โ โโโ ํ๋ก๊ทธ๋จ ์ธ๊ทธ๋จผํธ (๊ทธ๋ํ ๊ตฌ์กฐ)
โ โโโ ์ปค๋ ์ธ๊ทธ๋จผํธ (์ฐ์ฐ์ ๊ตฌํ)
โ โโโ ๋ฐ์ดํฐ ์ธ๊ทธ๋จผํธ (๊ฐ์ค์น)
โโโ ๋ฉ์๋ ๋์คํฌ๋ฆฝํฐ
โ โโโ ์
๋ ฅ/์ถ๋ ฅ ์ฌ์
โ โโโ ๋ฉ๋ชจ๋ฆฌ ํ๋๋ ์ ๋ณด
โ โโโ ์คํ ์์
โโโ ๋ฐฑ์๋ ๋๋ฆฌ๊ฒ์ดํธ ์ ๋ณด
๋น๊ต/๋ถ์
์ปดํ์ผ๋ฌ ํ์ดํ๋ผ์ธ ๋น๊ต
| ํน์ฑ | ExecuTorch | TensorRT | ONNX Runtime | TFLite |
|---|---|---|---|---|
| ์ปดํ์ผ ๋ฐฉ์ | AOT (Export IR) | AOT (Layer Fusion) | AOT (ONNX Graph) | AOT (FlatBuffer) |
| ์ค๊ฐ ํํ | EXIR (3๋จ๊ณ ๋ค์ด์ด๋ ํฐ๋ธ) | TensorRT Engine | ONNX Graph | TFLite Model |
| ์ต์ ํ ๋จ๊ณ | Export โ Edge โ Backend โ .pte | Parser โ Fusion โ Tuning | Graph Opt โ Execution | Converter โ Optimizer |
| ๋ฉ๋ชจ๋ฆฌ ํ๋๋ | ์ ์ (์ปดํ์ผ ์) | ์ ์ | ์ ์ | ์ ์ |
| ๋ฐฑ์๋ ํตํฉ | ๋๋ฆฌ๊ฒ์ดํธ ์์คํ | ๋ค์ดํฐ๋ธ ํตํฉ | Execution Provider | Delegate |
์ปค์คํ ํจ์ค ํ๋ ์์ํฌ ๋น๊ต
| ๊ธฐ๋ฅ | ExecuTorch (ExportPass) | TVM (MetaSchedule) | XLA (HLO Pass) |
|---|---|---|---|
| ํจ์ค ์ ํ | ์ธํฐํ๋ฆฌํฐ ๊ธฐ๋ฐ | ๊ฒ์ ๊ธฐ๋ฐ | ๊ทธ๋ํ ๊ธฐ๋ฐ |
| ๋ฉํ๋ฐ์ดํฐ ๋ณด์กด | ์์ ์ง์ | ๋ถ๋ถ ์ง์ | ๋ถ๋ถ ์ง์ |
| IR Spec ์ค์ | ํจ์ค ์ ํ ๊ฒ์ฆ | ๊ฒ์ฆ ๋ถํ์ | ๊ฒ์ฆ ๋ถํ์ |
| ์ปค์คํ ํจ์ค ์์ฑ | ExportPass ์์ | Pass ๊ธฐ๋ฐ | HLO Pass ๊ธฐ๋ฐ |
| ์๋ ํ๋ | ๋ฏธ์ง์ (MetaSchedule) | ํต์ฌ ๊ธฐ๋ฅ | ์ ํ์ |
์ฝ๋ ์์ฑ ์ ๋ต ๋น๊ต
| ์ ๋ต | ExecuTorch | TensorRT | ONNX Runtime |
|---|---|---|---|
| ๋ฐ์ด๋๋ฆฌ ํ์ | FlatBuffer (.pte) | ์ปค์คํ ์์ง (.engine) | FlatBuffer (.ort) |
| ์ปค๋ ํตํฉ | ๋ฐํ์ ์ฐ๊ฒฐ | ์ ์ ์ฐ๊ฒฐ | ๋์ ๋ก๋ |
| ํฌ๊ธฐ ์ต์ ํ | ์์ ์์ถ, ์ธ๊ทธ๋จผํธ ๋ถ๋ฆฌ | ๋ฐํ์ ์ต์ ํ | ๊ทธ๋ํ ์ต์ ํ |
| ์คํ ๋ชจ๋ธ | ์ธํฐํ๋ฆฌํฐ + ๋๋ฆฌ๊ฒ์ดํธ | JIT ์ปดํ์ผ | ์ธ์ ๊ธฐ๋ฐ |
์ฅ๋จ์
์ฅ์
- ๋จ๊ณ์ ๋ก์ด๋ง (Progressive Lowering): ATen โ Edge โ Backend 3๋จ๊ณ๋ฅผ ํตํด ์ ์ง์ ์ผ๋ก ํ๋์จ์ด์ ํนํ๋์ด, ๊ฐ ๋จ๊ณ์์ ๋ ๋ฆฝ์ ์ธ ์ต์ ํ๊ฐ ๊ฐ๋ฅํ๋ค
- IR Spec ๊ธฐ๋ฐ ๊ฒ์ฆ: ๊ฐ ๋ค์ด์ด๋ ํฐ๋ธ์์ IR Spec์ ์ค์ํ๋์ง ๊ฒ์ฆํ์ฌ, ์ปดํ์ผ ์ค๋ฅ๋ฅผ ์กฐ๊ธฐ์ ๋ฐ๊ฒฌํ ์ ์๋ค
- ์ ์ฐํ ์ปค์คํ ํจ์ค: ExportPass, Subgraph Rewriter ๋ฑ ๋ค์ํ ์์ค์ ํจ์ค๋ฅผ ์ ๊ณตํ์ฌ ๊ฐ๋ฐ์๊ฐ ์ธ๋ฐํ ๊ทธ๋ํ ๋ณํ์ ์ํํ ์ ์๋ค
- ์ ์ ๋ฉ๋ชจ๋ฆฌ ํ๋๋: ์คํ ์ ๋์ ํ ๋น ์์ด ๋ฏธ๋ฆฌ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ๊ณํํ์ฌ, ์ฃ์ง ๋๋ฐ์ด์ค์์ ๋ถํ์ํ ์ค๋ฒํค๋๋ฅผ ์ ๊ฑฐํ๋ค
- ์ด๊ฒฝ๋ .pte ํ์ผ: FlatBuffer ๊ธฐ๋ฐ์ ํ๋ซ ๋ฐ์ด๋๋ฆฌ๋ก, ํ์ฑ ์ค๋ฒํค๋๊ฐ ์ต์ํ๋๋ค
๋จ์
- ์ปดํ์ผ ์๊ฐ: AOT ์ปดํ์ผ ๋ฐฉ์์ผ๋ก ์ธํด ๋๊ท๋ชจ ๋ชจ๋ธ์์ ์ปดํ์ผ ์๊ฐ์ด ๊ธธ์ด์ง ์ ์๋ค
- ์ปค์คํ ์ปค๋ ์ ์ฝ: EXIR ์ฐ์ฐ์ ์ธํธ ์ธ์ ์ปค์คํ ์ปค๋์ ๋ณ๋ ๋ฑ๋ก์ด ํ์ํ๋ฉฐ, Edge ๋ค์ด์ด๋ ํฐ๋ธ์์์ dtype ์ ์ฝ์ ์ค์ํด์ผ ํ๋ค
- ๋์ Shape ์ ํ: ์ ์ ๋ฉ๋ชจ๋ฆฌ ํ๋๋ ํน์ฑ์ ๋์ shape ์ง์์ด ์ ํ์ ์ด๋ค
- ํ์ต ๋ฏธ์ง์: ์ถ๋ก ์ ์ฉ ์ปดํ์ผ๋ฌ๋ก, ํ์ต ๊ทธ๋ํ๋ ์ง์ํ์ง ์๋๋ค
- ๋๋ฒ๊น ์ด๋ ค์: AOT ์ปดํ์ผ ๊ณผ์ ์์ ๊ทธ๋ํ ๋ณํ์ด ๋ค์ ๋ฐ์ํ์ฌ, ์๋ณธ ๋ชจ๋ธ๊ณผ์ ๋์ ๊ด๊ณ ์ถ์ ์ด ์ด๋ ค์ธ ์ ์๋ค
๊ด๋ จ ๊ธฐ์
| ๊ธฐ์ | ๊ด๊ณ | ์ค๋ช |
|---|---|---|
| PyTorch Export | ์์ API | torch.export()๋ก ๋ชจ๋ธ ๊ทธ๋ํ ์บก์ฒ |
| EXIR | ์ค๊ฐ ํํ | ExecuTorch์ IR ์ฒด๊ณ (ATen/Edge/Backend ๋ค์ด์ด๋ ํฐ๋ธ) |
| FX Graph | ๊ทธ๋ํ ํ๋ ์์ํฌ | PyTorch์ FX ๊ธฐ๋ฐ ๊ทธ๋ํ representation |
| torchao | ์์ํ | ExecuTorch์ ์์ํ ํ์ดํ๋ผ์ธ ํตํฉ |
| XNNPACK | ๊ธฐ๋ณธ ๋ฐฑ์๋ | ๋ชจ๋ ํ๋ซํผ์์ CPU ํด๋ฐฑ์ผ๋ก ์ฌ์ฉ |
| FlatBuffer | ์ง๋ ฌํ | .pte ํ์ผ์ ๋ฐ์ด๋๋ฆฌ ํ์ |
์ฐธ๊ณ ๋ฌธํ
- ExecuTorch ๊ณต์ ๋ฌธ์ - Export IR
- ExecuTorch ๊ณต์ ๋ฌธ์ - Custom Compiler Passes
- ExecuTorch GitHub
- ExecuTorch: A Unified PyTorch Solution to Run AI Models On-Device (arXiv:2605.08195)
- Meta Engineering Blog - ExecuTorch
ํต์ฌ ์ ๋ฆฌ
- ExecuTorch ์ปดํ์ผ๋ฌ๋ ATen โ Edge โ Backend 3๋จ๊ณ ๋ค์ด์ด๋ ํฐ๋ธ๋ฅผ ํตํด ๋ชจ๋ธ์ ์ ์ง์ ์ผ๋ก ๋ฎ์ถ๋ AOT ์ปดํ์ผ ์์คํ ์ด๋ค.
- EXIR์ ๊ฐ ๋ค์ด์ด๋ ํฐ๋ธ์์ IR Spec์ ์ค์ํ๋๋ก ์ค๊ณ๋์ด, ์ปดํ์ผ ๊ณผ์ ์์์ ์ค๋ฅ๋ฅผ ์กฐ๊ธฐ์ ๋ฐ๊ฒฌํ ์ ์๋ค.
- ExportPass, Subgraph Rewriter ๋ฑ ๋ค์ํ ์ปค์คํ ํจ์ค๋ฅผ ํตํด ๊ทธ๋ํ ์์ค์ ์ธ๋ฐํ ์ต์ ํ๊ฐ ๊ฐ๋ฅํ๋ค.
- ์ ์ ๋ฉ๋ชจ๋ฆฌ ํ๋๋๊ณผ FlatBuffer ๊ธฐ๋ฐ .pte ํ์ผ ์์ฑ์ผ๋ก ์ฃ์ง ๋๋ฐ์ด์ค์ ์ต์ ํ๋ ์คํ ํ๊ฒฝ์ ์ ๊ณตํ๋ค.
- 12๊ฐ ์ด์์ ํ๋์จ์ด ๋ฐฑ์๋๋ฅผ ์ง์ํ๋ฉฐ, ๋๋ฆฌ๊ฒ์ดํธ ์์คํ ์ ํตํด ํ๋์จ์ด ์ ํ์ด ์ฉ์ดํ๋ค.