2 * Copyright (c) 2019 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 "exec/FunctionSequence.h"
19 #include "backend/ITensorRegistry.h"
20 #include "util/logging.h"
27 void FunctionSequence::run()
29 if (_enable_dynamic_shape_inferer && _dynamic_tensor_ctx)
31 // acl_cl and acl_neon backend don't support dynamic shape.
32 // _dynamic_tensor_ctx is always nullptr for acl_cl and acl_neon
33 // Thus, those two bakends cannot reach here.
35 // Do dynamic shape inference
36 _dynamic_tensor_ctx->op->accept(*_dynamic_tensor_ctx->dynamic_shape_inferer);
38 for (const auto &function : _functions)
40 // NOTE the function could be also FunctionSequence so we do this
41 // TODO Remove this or do this recursively
42 auto *sub_func_seq = dynamic_cast<FunctionSequence *>(function.get());
43 if (sub_func_seq != nullptr)
45 sub_func_seq->enableDynamicShapeInferer(true);
46 sub_func_seq->dynamic_tensor_ctx(dynamic_tensor_ctx());
55 for (const auto &function : _functions)
62 void FunctionSequence::prepare()
64 for (const auto &function : _functions)
70 void FunctionSequence::append(std::unique_ptr<IFunction> &&function)
72 _functions.push_back(std::move(function));
75 void FunctionSequence::iterate(const std::function<void(IFunction &)> &fn)
77 for (const auto &func : _functions)