@@ -322,6 +322,13 @@ ModelProto model_merge(
322
322
return model;
323
323
}
324
324
325
+ ModelProto opt_model (
326
+ ModelProto* m
327
+ ){
328
+ auto new_model = OptimizeFixed (*m, GetFuseAndEliminationPass ());
329
+ return new_model;
330
+ }
331
+
325
332
void OptimizeWithModels (
326
333
std::string& mp_in_path1,
327
334
std::string& mp_in_path2,
@@ -341,4 +348,28 @@ void OptimizeWithModels(
341
348
// onnx::optimization::saveModel(&model,"../examples/onnx_output_model/model_merged.onnx");
342
349
}
343
350
351
+ void MergeWithModels (
352
+ std::string& mp_in_path1,
353
+ std::string& mp_in_path2,
354
+ std::string& mp_name1,
355
+ std::string& mp_name2,
356
+ std::string& mp_out_path) {
357
+ ONNX_NAMESPACE::ModelProto model1,model2;
358
+ onnx::optimization::loadModel (&model1, mp_in_path1, true );
359
+ onnx::optimization::loadModel (&model2, mp_in_path2, true );
360
+ ModelProto model=model_merge (&model1,&model2,mp_name1,mp_name2);
361
+ onnx::checker::check_model (model);
362
+ onnx::optimization::saveModel (&model,mp_out_path);
363
+ // onnx::optimization::saveModel(&model,"../examples/onnx_output_model/model_merged.onnx");
364
+ }
365
+
366
+ void OptimizeOnMergedModel (
367
+ std::string& mp_in_path,
368
+ std::string& mp_out_path) {
369
+ ONNX_NAMESPACE::ModelProto model;
370
+ onnx::optimization::loadModel (&model, mp_in_path, true );
371
+ ModelProto model_opted=opt_model (&model);
372
+ onnx::checker::check_model (model_opted);
373
+ onnx::optimization::saveModel (&model_opted,mp_out_path);
374
+ }
344
375
}// end namespace
0 commit comments