Extract reference for operator FLOOR_DIV to standalone header
Move the reference implementation to its own header so that micro can use it without the unrelated depedencies of reference_ops.h. PR step 2 for issue #45657
This commit is contained in:
parent
ca7c72bbbd
commit
f5377c9901
@ -41,12 +41,6 @@ struct OpData {
|
||||
bool requires_broadcast;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
T FloorDiv(T input1, T input2) {
|
||||
return std::floor(std::divides<double>()(static_cast<double>(input1),
|
||||
static_cast<double>(input2)));
|
||||
}
|
||||
|
||||
void* Init(TfLiteContext* context, const char* buffer, size_t length) {
|
||||
auto* data = new OpData;
|
||||
data->requires_broadcast = false;
|
||||
@ -118,12 +112,13 @@ TfLiteStatus EvalImpl(TfLiteContext* context, bool requires_broadcast,
|
||||
reference_ops::BroadcastBinaryFunction4DSlow<T, T, T>(
|
||||
GetTensorShape(input1), GetTensorData<T>(input1),
|
||||
GetTensorShape(input2), denominator_data, GetTensorShape(output),
|
||||
GetTensorData<T>(output), FloorDiv<T>);
|
||||
GetTensorData<T>(output), reference_ops::FloorDiv<T>);
|
||||
} else {
|
||||
reference_ops::BinaryFunction<T, T, T>(
|
||||
GetTensorShape(input1), GetTensorData<T>(input1),
|
||||
GetTensorShape(input2), GetTensorData<T>(input2),
|
||||
GetTensorShape(output), GetTensorData<T>(output), FloorDiv<T>);
|
||||
GetTensorShape(output), GetTensorData<T>(output),
|
||||
reference_ops::FloorDiv<T>);
|
||||
}
|
||||
|
||||
return kTfLiteOk;
|
||||
|
@ -466,6 +466,7 @@ cc_library(
|
||||
"reference/fill.h",
|
||||
"reference/floor.h",
|
||||
"reference/floor_mod.h",
|
||||
"reference/floor_div.h",
|
||||
"reference/fully_connected.h",
|
||||
"reference/hard_swish.h",
|
||||
"reference/integer_ops/add.h",
|
||||
@ -573,6 +574,7 @@ cc_library(
|
||||
"reference/fill.h",
|
||||
"reference/floor.h",
|
||||
"reference/floor_mod.h",
|
||||
"reference/floor_div.h",
|
||||
"reference/fully_connected.h",
|
||||
"reference/hard_swish.h",
|
||||
"reference/l2normalization.h",
|
||||
|
35
tensorflow/lite/kernels/internal/reference/floor_div.h
Normal file
35
tensorflow/lite/kernels/internal/reference/floor_div.h
Normal file
@ -0,0 +1,35 @@
|
||||
/* Copyright 2020 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_FLOOR_DIV_H_
|
||||
#define TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_DIV_H_
|
||||
|
||||
#include <cmath>
|
||||
#include <functional>
|
||||
|
||||
#include "tensorflow/lite/kernels/internal/types.h"
|
||||
|
||||
namespace tflite {
|
||||
namespace reference_ops {
|
||||
|
||||
template <typename T>
|
||||
T FloorDiv(T input1, T input2) {
|
||||
return std::floor(std::divides<double>()(static_cast<double>(input1),
|
||||
static_cast<double>(input2)));
|
||||
}
|
||||
|
||||
} // namespace reference_ops
|
||||
} // namespace tflite
|
||||
|
||||
#endif // TENSORFLOW_LITE_KERNELS_INTERNAL_REFERENCE_FLOOR_DIV_H_
|
@ -45,6 +45,7 @@ limitations under the License.
|
||||
#include "tensorflow/lite/kernels/internal/reference/fill.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/floor.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/floor_mod.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/floor_div.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/fully_connected.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/hard_swish.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/l2normalization.h"
|
||||
|
Loading…
Reference in New Issue
Block a user