exp.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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_KERNELS_INTERNAL_REFERENCE_EXP_H_
  13. #define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_EXP_H_
  14. #include <cmath>
  15. #include "ruy/profiler/instrumentation.h" // from @ruy
  16. #include "tensorflow/lite/kernels/internal/types.h"
  17. namespace tflite {
  18. namespace reference_ops {
  19. template <typename T>
  20. inline void Exp(const T* input_data, const size_t num_elements,
  21. T* output_data) {
  22. ruy::profiler::ScopeLabel label("Exp");
  23. for (size_t idx = 0; idx < num_elements; ++idx) {
  24. output_data[idx] = std::exp(input_data[idx]);
  25. }
  26. }
  27. } // namespace reference_ops
  28. } // namespace tflite
  29. #endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_EXP_H_