2 * Copyright (c) 2020 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 #ifndef __ONERT_COMPILER_TENSOR_BUILDERS_H__
18 #define __ONERT_COMPILER_TENSOR_BUILDERS_H__
20 #include <unordered_set>
22 #include "backend/BackendContext.h"
23 #include "backend/Backend.h"
24 #include "backend/controlflow/Config.h"
25 #include "backend/controlflow/TensorBuilder.h"
35 TensorBuilders() = default;
37 TensorBuilders(const onert::backend::BackendContexts &backend_contexts, bool include_controlflow)
39 for (const auto &e : backend_contexts)
41 if (e.first->config()->id() == backend::controlflow::Config::ID)
43 _cf_tensor_builder = std::dynamic_pointer_cast<backend::controlflow::TensorBuilder>(
44 e.second->tensor_builder);
45 if (include_controlflow)
46 _tensor_builders.insert(e.second->tensor_builder);
50 _tensor_builders.insert(e.second->tensor_builder);
55 std::unordered_set<std::shared_ptr<onert::backend::ITensorBuilder>>::const_iterator begin() const
57 return _tensor_builders.cbegin();
59 std::unordered_set<std::shared_ptr<onert::backend::ITensorBuilder>>::const_iterator end() const
61 return _tensor_builders.cend();
64 std::shared_ptr<backend::controlflow::TensorBuilder> getControlflowTensorBuilder() const
66 return _cf_tensor_builder;
70 std::unordered_set<std::shared_ptr<backend::ITensorBuilder>> _tensor_builders;
71 std::shared_ptr<backend::controlflow::TensorBuilder> _cf_tensor_builder;
74 } // namespace compiler
77 #endif // __ONERT_COMPILER_TENSOR_BUILDERS_H__