blob: 503ebba4f8190b07892feb923808e10d3a31cc44 [file] [log] [blame]
Jens Elofsson955288a2021-04-22 20:57:15 +02001/*
2 * Copyright (c) 2021 Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19#ifndef ETHOSU_PROFILER_H
20#define ETHOSU_PROFILER_H
21
22#include "tensorflow/lite/kernels/internal/compatibility.h"
23#include <memory>
24#include <pmu_ethosu.h>
25
26// NOTE: This profiler only works on systems with 1 NPU due to the use of
27// ethosu_reserve_driver().
28namespace tflite {
29class EthosUProfiler : public MicroProfiler {
30public:
Jens Elofssonde044c32021-05-06 16:21:29 +020031 EthosUProfiler(size_t max_events = 200);
Jens Elofsson955288a2021-04-22 20:57:15 +020032 uint32_t BeginEvent(const char *tag);
33 void EndEvent(uint32_t event_handle);
34 uint64_t GetTotalTicks() const;
35 void Log() const;
Jens Elofsson955288a2021-04-22 20:57:15 +020036
37private:
Jens Elofsson955288a2021-04-22 20:57:15 +020038 size_t max_events_;
39 std::unique_ptr<const char *[]> tags_;
40 std::unique_ptr<uint64_t[]> start_ticks_;
41 std::unique_ptr<uint64_t[]> end_ticks_;
42
43 int num_events_ = 0;
44
Jens Elofsson955288a2021-04-22 20:57:15 +020045 TF_LITE_REMOVE_VIRTUAL_DELETE;
46};
47
48} // namespace tflite
49
50#endif