fully_connected.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. #ifndef TENSORFLOW_LITE_MICRO_KERNELS_FULLY_CONNECTED_H_
  13. #define TENSORFLOW_LITE_MICRO_KERNELS_FULLY_CONNECTED_H_
  14. #include "tensorflow/lite/c/common.h"
  15. namespace tflite {
  16. // This is the most generic TfLiteRegistration. The actual supported types may
  17. // still be target dependent. The only requirement is that every implementation
  18. // (reference or optimized) must define this function.
  19. TfLiteRegistration Register_FULLY_CONNECTED();
  20. #if defined(CMSIS_NN) || defined(ARDUINO)
  21. // The Arduino is a special case where we use the CMSIS kernels, but because of
  22. // the current approach to building for Arduino, we do not support -DCMSIS_NN as
  23. // part of the build. As a result, we use defined(ARDUINO) as proxy for the
  24. // CMSIS kernels for this one special case.
  25. // Returns a TfLiteRegistration struct for cmsis-nn kernel variant that only
  26. // supports int8.
  27. TfLiteRegistration Register_FULLY_CONNECTED_INT8();
  28. #else
  29. // Note that while this block gets used for both reference and optimized kernels
  30. // that do not have any specialized implementations, the only goal here is to
  31. // define fallback implementation that allow reference kernels to still be used
  32. // from applications that call a more specific kernel variant.
  33. inline TfLiteRegistration Register_FULLY_CONNECTED_INT8() {
  34. return Register_FULLY_CONNECTED();
  35. }
  36. #endif
  37. } // namespace tflite
  38. #endif // TENSORFLOW_LITE_MICRO_KERNELS_FULLY_CONNECTED_H_