2 * Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "compiler/CompilerFactory.h"
19 #include "MultiModelCompiler.h"
21 #include "train/TrainingCompiler.h"
24 #include "compiler/Compiler.h"
31 CompilerFactory &CompilerFactory::get()
33 static CompilerFactory singleton;
37 std::unique_ptr<ICompiler>
38 CompilerFactory::create(const std::shared_ptr<ir::NNPkg> &nnpkg,
39 std::vector<std::unique_ptr<CompilerOptions>> &copts,
40 const compiler::train::TrainingInfo *training_info)
43 // Returing compiler for training
45 return std::make_unique<train::TrainingCompiler>(nnpkg, copts, *training_info);
50 // Returing compiler for inference
51 if (nnpkg->model_count() == 1)
52 return std::make_unique<Compiler>(nnpkg, copts);
54 return std::make_unique<MultiModelCompiler>(nnpkg, copts);
57 } // namespace compiler