micro_time.cc 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.
  11. ==============================================================================*/
  12. // Reference implementation of timer functions. Platforms are not required to
  13. // implement these timer methods, but they are required to enable profiling.
  14. // On platforms that have a POSIX stack or C library, it can be written using
  15. // methods from <sys/time.h> or clock() from <time.h>.
  16. // To add an equivalent function for your own platform, create your own
  17. // implementation file, and place it in a subfolder with named after the OS
  18. // you're targeting. For example, see the Cortex M bare metal version in
  19. // tensorflow/lite/micro/bluepill/micro_time.cc or the mbed one on
  20. // tensorflow/lite/micro/mbed/micro_time.cc.
  21. #include "tensorflow/lite/micro/micro_time.h"
  22. namespace tflite {
  23. //80MHz
  24. constexpr int kClocksPerSecond = 80e6;
  25. // Reference implementation of the ticks_per_second() function that's required
  26. // for a platform to support Tensorflow Lite for Microcontrollers profiling.
  27. // This returns 0 by default because timing is an optional feature that builds
  28. // without errors on platforms that do not need it.
  29. int32_t ticks_per_second() { return kClocksPerSecond; }
  30. // Reference implementation of the GetCurrentTimeTicks() function that's
  31. // required for a platform to support Tensorflow Lite for Microcontrollers
  32. // profiling. This returns 0 by default because timing is an optional feature
  33. // that builds without errors on platforms that do not need it.
  34. int32_t GetCurrentTimeTicks() { return 0; }
  35. } // namespace tflite