1 | /* Copyright 2022 The TensorFlow Authors. All Rights Reserved. |
2 | |
3 | Licensed under the Apache License, Version 2.0 (the "License"); |
4 | you may not use this file except in compliance with the License. |
5 | You may obtain a copy of the License at |
6 | |
7 | http://www.apache.org/licenses/LICENSE-2.0 |
8 | |
9 | Unless required by applicable law or agreed to in writing, software |
10 | distributed under the License is distributed on an "AS IS" BASIS, |
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
12 | See the License for the specific language governing permissions and |
13 | limitations under the License. |
14 | ==============================================================================*/ |
15 | |
16 | #include "tensorflow/lite/core/macros.h" |
17 | #include "tensorflow/lite/tensorflow_profiler_logger.h" |
18 | |
19 | // Use weak symbols here (even though they are guarded by macros) to avoid |
20 | // build breakage when building a benchmark requires TFLite runs. The main |
21 | // benchmark library should have tensor_profiler_logger dependency. |
22 | // Strong symbol definitions can be found in tensorflow_profiler_logger.cc. |
23 | |
24 | namespace tflite { |
25 | |
26 | // No-op for the weak symbol. Overridden by a strong symbol in |
27 | // tensorflow_profiler_logger.cc. |
28 | TFLITE_ATTRIBUTE_WEAK void OnTfLiteOpPrepare(const char* op_name, |
29 | int subgraph_index, |
30 | int node_index) {} |
31 | |
32 | // No-op for the weak symbol. Overridden by a strong symbol in |
33 | // tensorflow_profiler_logger.cc. |
34 | TFLITE_ATTRIBUTE_WEAK tensorflow::profiler::TraceMe* OnTfLiteSubgraphInvoke( |
35 | const char* subgraph_name, int subgraph_index) { |
36 | return nullptr; |
37 | } |
38 | |
39 | // No-op for the weak symbol. Overridden by a strong symbol in |
40 | // tensorflow_profiler_logger.cc. |
41 | TFLITE_ATTRIBUTE_WEAK void OnTfLiteSubgraphInvokeEnd( |
42 | tensorflow::profiler::TraceMe* trace_me) {} |
43 | |
44 | // No-op for the weak symbol. Overridden by a strong symbol in |
45 | // tensorflow_profiler_logger.cc. |
46 | TFLITE_ATTRIBUTE_WEAK tensorflow::profiler::TraceMe* OnTfLiteOpInvoke( |
47 | const char* op_name, int subgraph_index, int node_index) { |
48 | return nullptr; |
49 | } |
50 | |
51 | // No-op for the weak symbol. Overridden by a strong symbol in |
52 | // tensorflow_profiler_logger.cc. |
53 | TFLITE_ATTRIBUTE_WEAK void OnTfLiteOpInvokeEnd( |
54 | tensorflow::profiler::TraceMe* trace_me) {} |
55 | |
56 | // No-op for the weak symbol. Overridden by a strong symbol in |
57 | // tensorflow_profiler_logger.cc. |
58 | TFLITE_ATTRIBUTE_WEAK void OnTfLiteTensorAlloc(TfLiteTensor* tensor, |
59 | size_t num_bytes) {} |
60 | |
61 | // No-op for the weak symbol. Overridden by a strong symbol in |
62 | // tensorflow_profiler_logger.cc. |
63 | TFLITE_ATTRIBUTE_WEAK void OnTfLiteTensorDealloc(TfLiteTensor* tensor) {} |
64 | |
65 | // No-op for the weak symbol. Overridden by a strong symbol in |
66 | // tensorflow_profiler_logger.cc. |
67 | TFLITE_ATTRIBUTE_WEAK void OnTfLiteArenaAlloc(int subgraph_index, int arena_id, |
68 | size_t num_bytes) {} |
69 | |
70 | // No-op for the weak symbol. Overridden by a strong symbol in |
71 | // tensorflow_profiler_logger.cc. |
72 | TFLITE_ATTRIBUTE_WEAK void OnTfLiteArenaDealloc(int subgraph_index, |
73 | int arena_id, |
74 | size_t num_bytes) {} |
75 | |
76 | } // namespace tflite |
77 | |