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 __NNFW_BENCHMARK_PHASES_H__
18 #define __NNFW_BENCHMARK_PHASES_H__
21 #include "MemoryPoller.h"
25 #include <unordered_map>
33 Phases(const PhaseOption &option);
35 using PhaseFunc = std::function<void(const Phase &, uint32_t)>;
37 void run(const std::string &tag, const PhaseFunc &exec, uint32_t loop_num = 1,
38 bool option_disable = false)
40 run(tag, exec, nullptr, loop_num, option_disable);
43 void run(const std::string &tag, const PhaseFunc &exec, const PhaseFunc &post,
44 uint32_t loop_num = 1, bool option_disable = false)
46 run(tag, exec, &post, loop_num, option_disable);
49 const PhaseOption &option() const { return _option; }
50 const MemoryPoller &mem_poll() const { return *_mem_poll; }
51 const Phase &at(const std::string &tag) const { return _phases.at(tag); }
54 void run(const std::string &tag, const PhaseFunc &exec, const PhaseFunc *post, uint32_t loop_num,
58 const PhaseOption _option;
59 std::unordered_map<std::string, Phase> _phases;
60 std::unique_ptr<MemoryPoller> _mem_poll;
63 } // namespace benchmark
65 #endif // __NNFW_BENCHMARK_PHASES_H__