8
8
from typing import Optional
9
9
10
10
import torch
11
+ import torch ._inductor
11
12
import torch .nn as nn
12
13
13
14
from torch .export import Dim
14
- import torch ._inductor
15
15
16
16
from torchchat .cli .builder import (
17
17
_initialize_model ,
@@ -68,20 +68,24 @@ def export_for_server(
68
68
69
69
with torch .nn .attention .sdpa_kernel ([torch .nn .attention .SDPBackend .MATH ]):
70
70
metadata = {} # TODO: put more metadata here
71
- options = {"aot_inductor.package" : package , "aot_inductor. metadata" : metadata }
71
+ options = {"aot_inductor.metadata" : metadata }
72
72
if not package :
73
73
options = {"aot_inductor.output_path" : output_path }
74
74
75
- path = torch ._export . aot_compile (
75
+ ep = torch .export . export (
76
76
model ,
77
77
example_inputs ,
78
78
dynamic_shapes = dynamic_shapes ,
79
- options = options ,
80
79
)
81
80
82
81
if package :
83
- from torch ._inductor .package import package_aoti
84
- path = package_aoti (output_path , path )
82
+ path = torch ._inductor .aoti_compile_and_package (
83
+ ep , package_path = output_path , inductor_configs = options
84
+ )
85
+ else :
86
+ path = torch ._inductor .aot_compile (
87
+ ep .module (), example_inputs , options = options
88
+ )
85
89
86
90
print (f"The generated packaged model can be found at: { path } " )
87
91
return path
@@ -106,9 +110,6 @@ def export_for_server(
106
110
from executorch .backends .xnnpack .partition .xnnpack_partitioner import (
107
111
XnnpackDynamicallyQuantizedPartitioner ,
108
112
)
109
- from executorch .backends .xnnpack ._passes .convert_to_linear import (
110
- ConvertToLinearPass ,
111
- )
112
113
from executorch .exir import EdgeProgramManager , to_edge
113
114
114
115
from executorch .exir .capture ._config import (
0 commit comments