chromium/third_party/tflite/src/tensorflow/lite/kernels/internal/reference/integer_ops/add.h

/* Copyright 2019 The TensorFlow Authors. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
#ifndef TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_ADD_H_
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_ADD_H_

#include <algorithm>
#include <cstddef>
#include <limits>

#include "tensorflow/lite/kernels/internal/common.h"
#include "tensorflow/lite/kernels/internal/types.h"

namespace tflite {
namespace reference_integer_ops {

inline void CheckArithmeticParams(const ArithmeticParams& params) {}

// TODO: b/270589088 - move to a more appropriate file (b/270589088#comment2)
template <typename T>
void BroadcastInput1(int size, const ArithmeticParams& params,
                     const T* input1_data, const T* input2_data, T* output_data,
                     void (*check_arithmetic_params)(const ArithmeticParams&),
                     T (*binary_func)(T, T, const ArithmeticParams&)) {}

template <typename T>
void BroadcastInput2(int size, const ArithmeticParams& params,
                     const T* input1_data, const T* input2_data, T* output_data,
                     void (*check_arithmetic_params)(const ArithmeticParams&),
                     T (*binary_func)(T, T, const ArithmeticParams&)) {}

// TODO: b/270589088 - move to a more appropriate file (b/270589088#comment2)
template <typename T>
void ElementWise(int size, const ArithmeticParams& params, const T* input1_data,
                 const T* input2_data, T* output_data,
                 void (*check_arithmetic_params)(const ArithmeticParams&),
                 T (*binary_func)(T, T, const ArithmeticParams&)) {}

template <typename T>
inline void BroadcastAddRecursiveDimensions(
    const ArithmeticParams& params, int dimension, size_t* input1_offset_p,
    size_t* input2_offset_p, size_t* output_offset,
    size_t* compressed_input1_stride, size_t* compressed_input2_stride,
    size_t* compressed_output_shape, const T* input1_data, const T* input2_data,
    T* output_data, void (*check_arithmetic_params)(const ArithmeticParams&),
    T (*binary_func)(T, T, const ArithmeticParams&)) {}

// TODO: b/270589088 - move to a more appropriate file. (b/270589088#comment2)
template <typename T>
void BroadcastBinaryFunction6DSlow(
    const ArithmeticParams& params, const RuntimeShape& input1_shape,
    const T* input1_data, const RuntimeShape& input2_shape,
    const T* input2_data, const RuntimeShape& output_shape, T* output_data,
    void (*check_arithmetic_params)(const ArithmeticParams&),
    T (*binary_func)(T, T, const ArithmeticParams&)) {}

template <typename T>
void BroadcastBinaryFunction4DSlow(
    const ArithmeticParams& params, const RuntimeShape& input1_shape,
    const T* input1_data, const RuntimeShape& input2_shape,
    const T* input2_data, const RuntimeShape& output_shape, T* output_data,
    void (*check_arithmetic_params)(const ArithmeticParams&),
    T (*binary_func)(T, T, const ArithmeticParams&)) {}

inline int8_t AddFunc(int8_t x, int8_t y, const ArithmeticParams& params) {}

// Element-wise add that can often be used for inner loop of broadcast add as
// well as the non-broadcast add.
inline void AddElementwise(int size, const ArithmeticParams& params,
                           const int8_t* input1_data, const int8_t* input2_data,
                           int8_t* output_data) {}

inline void Add(const ArithmeticParams& params,
                const RuntimeShape& input1_shape, const int8_t* input1_data,
                const RuntimeShape& input2_shape, const int8_t* input2_data,
                const RuntimeShape& output_shape, int8_t* output_data) {}

inline void BroadcastAdd6DSlow(const ArithmeticParams& params,
                               const RuntimeShape& input1_shape,
                               const int8_t* input1_data,
                               const RuntimeShape& input2_shape,
                               const int8_t* input2_data,
                               const RuntimeShape& output_shape,
                               int8_t* output_data) {}

inline void BroadcastAdd4DSlow(const ArithmeticParams& params,
                               const RuntimeShape& input1_shape,
                               const int8_t* input1_data,
                               const RuntimeShape& input2_shape,
                               const int8_t* input2_data,
                               const RuntimeShape& output_shape,
                               int8_t* output_data) {}

}  // namespace reference_integer_ops
}  // namespace tflite

#endif  // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_INTEGER_OPS_ADD_H_