Merge pull request #45870 from ddavis-2015:FloorDiv-pr2
PiperOrigin-RevId: 352003292 Change-Id: I888ae62e4f75f61b4260929d657e043deabac18b
This commit is contained in:
commit
f18495306f
tensorflow/lite/kernels
@ -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;
|
||||
|
@ -469,6 +469,7 @@ cc_library(
|
||||
"reference/exp.h",
|
||||
"reference/fill.h",
|
||||
"reference/floor.h",
|
||||
"reference/floor_div.h",
|
||||
"reference/floor_mod.h",
|
||||
"reference/fully_connected.h",
|
||||
"reference/hard_swish.h",
|
||||
@ -583,6 +584,7 @@ cc_library(
|
||||
"reference/exp.h",
|
||||
"reference/fill.h",
|
||||
"reference/floor.h",
|
||||
"reference/floor_div.h",
|
||||
"reference/floor_mod.h",
|
||||
"reference/fully_connected.h",
|
||||
"reference/hard_swish.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_
|
@ -48,6 +48,7 @@ limitations under the License.
|
||||
#include "tensorflow/lite/kernels/internal/reference/exp.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/fill.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/floor.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/floor_div.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/floor_mod.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/fully_connected.h"
|
||||
#include "tensorflow/lite/kernels/internal/reference/hard_swish.h"
|
||||
|
Loading…
Reference in New Issue
Block a user