Jens Elofsson | 955288a | 2021-04-22 20:57:15 +0200 | [diff] [blame] | 1 | /* |
| 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(). |
| 28 | namespace tflite { |
| 29 | class EthosUProfiler : public MicroProfiler { |
| 30 | public: |
Jens Elofsson | de044c3 | 2021-05-06 16:21:29 +0200 | [diff] [blame] | 31 | EthosUProfiler(size_t max_events = 200); |
Jens Elofsson | 955288a | 2021-04-22 20:57:15 +0200 | [diff] [blame] | 32 | uint32_t BeginEvent(const char *tag); |
| 33 | void EndEvent(uint32_t event_handle); |
| 34 | uint64_t GetTotalTicks() const; |
| 35 | void Log() const; |
Jens Elofsson | 955288a | 2021-04-22 20:57:15 +0200 | [diff] [blame] | 36 | |
| 37 | private: |
Jens Elofsson | 955288a | 2021-04-22 20:57:15 +0200 | [diff] [blame] | 38 | 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_; |
Kristofer Jonsson | 44d6e22 | 2021-05-21 18:59:18 +0200 | [diff] [blame^] | 42 | size_t num_events_; |
Jens Elofsson | 955288a | 2021-04-22 20:57:15 +0200 | [diff] [blame] | 43 | |
Jens Elofsson | 955288a | 2021-04-22 20:57:15 +0200 | [diff] [blame] | 44 | TF_LITE_REMOVE_VIRTUAL_DELETE; |
| 45 | }; |
| 46 | |
| 47 | } // namespace tflite |
| 48 | |
| 49 | #endif |