1/* Copyright 2022 The TensorFlow Authors. All Rights Reserved.
2
3Licensed under the Apache License, Version 2.0 (the "License");
4you may not use this file except in compliance with the License.
5You may obtain a copy of the License at
6
7 http://www.apache.org/licenses/LICENSE-2.0
8
9Unless required by applicable law or agreed to in writing, software
10distributed under the License is distributed on an "AS IS" BASIS,
11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12See the License for the specific language governing permissions and
13limitations 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
24namespace tflite {
25
26// No-op for the weak symbol. Overridden by a strong symbol in
27// tensorflow_profiler_logger.cc.
28TFLITE_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.
34TFLITE_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.
41TFLITE_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.
46TFLITE_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.
53TFLITE_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.
58TFLITE_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.
63TFLITE_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.
67TFLITE_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.
72TFLITE_ATTRIBUTE_WEAK void OnTfLiteArenaDealloc(int subgraph_index,
73 int arena_id,
74 size_t num_bytes) {}
75
76} // namespace tflite
77