@@ -143,39 +143,16 @@ def ov_infer(inputs, stop_token_ids, fn):
143
143
struct_params , struct_outputs = get_struct_outputs (
144
144
inputs , stop_token_ids , fn
145
145
)
146
-
147
- if not hasattr (ov_infer , "_compiled_models" ):
148
- ov_infer ._compiled_models = {}
149
-
150
- # Create hash based on inputs, inputs shapes, and input dtypes
151
- inputs_shapes = []
152
- inputs_dtypes = []
153
- for k , v in inputs .items ():
154
- inputs_shapes .append (str (v .shape ))
155
- inputs_dtypes .append (str (v .dtype ))
156
- model_signature = (
157
- f"inputs_{ len (inputs )} _"
158
- f"shapes_{ '_' .join (inputs_shapes )} _"
159
- f"dtypes_{ '_' .join (inputs_dtypes )} _"
160
- )
161
-
162
- model_hash = hash (model_signature )
163
-
164
- if model_hash not in ov_infer ._compiled_models :
165
- parameters = [
166
- p .output .get_node () for p in tree .flatten (struct_params )
167
- ]
168
- results = [
169
- ov_opset .result (r .output )
170
- for r in tree .flatten (struct_outputs )
171
- ]
172
-
173
- ov_model = ov .Model (results = results , parameters = parameters )
174
- ov_infer ._compiled_models [model_hash ] = ov .compile_model (
175
- ov_model , "CPU"
176
- )
177
-
178
- compile_ov_model = ov_infer ._compiled_models [model_hash ]
146
+ parameters = [
147
+ p .output .get_node () for p in tree .flatten (struct_params )
148
+ ]
149
+ results = [
150
+ ov_opset .result (r .output )
151
+ for r in tree .flatten (struct_outputs )
152
+ ]
153
+ ov_model = ov .Model (results = results , parameters = parameters )
154
+ ov .save_model (ov_model , "ov_model.xml" )
155
+ compile_ov_model = ov .compile_model (ov_model , "CPU" )
179
156
return get_outputs (inputs , struct_outputs , compile_ov_model )
180
157
181
158
def wrapped_generate_function (inputs , stop_token_ids = None ):
0 commit comments