/*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved
- * Copyright 2019 The TensorFlow Authors. All Rights Reserved.
+ * Copyright (c) 2023 Samsung Electronics Co., Ltd. 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.
#ifndef LUCI_INTERPRETER_PAL_NEG_H
#define LUCI_INTERPRETER_PAL_NEG_H
-#include <tensorflow/lite/kernels/internal/optimized/optimized_ops.h>
-
namespace luci_interpreter_pal
{
template <typename T>
-static inline void Negate(const tflite::RuntimeShape &input_shape, const T *input_data,
- const tflite::RuntimeShape &output_shape, T *output_data)
+inline void Negate(const luci_interpreter::RuntimeShape &input_shape, const T *input_data,
+ const luci_interpreter::RuntimeShape &output_shape, T *output_data)
+
{
- tflite::reference_ops::Negate(input_shape, input_data, output_shape, output_data);
+ // check that input and output dimensions are equal
+ int N = input_shape.dimensionsCount();
+ assert(N == output_shape.dimensionsCount());
+
+ // check that sizes of all dimensions are equal
+ for (int i = 0; i < N; ++i)
+ {
+ assert(input_shape.dims(i) == output_shape.dims(i));
+ }
+
+ const int flat_size = input_shape.flatSize();
+
+ for (int i = 0; i < flat_size; ++i)
+ {
+ output_data[i] = -input_data[i];
+ }
}
} // namespace luci_interpreter_pal