diff options
author | A. Unique TensorFlower <gardener@tensorflow.org> | 2018-06-19 09:49:17 -0700 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2018-06-19 09:54:05 -0700 |
commit | 5fc2bdd2d5f624a6bad9e83b992029e3799ab64e (patch) | |
tree | 576404472bd26801fe2fce6f6385669aef1f42e4 /tensorflow/contrib/lite/kernels/elementwise.cc | |
parent | c532c3f319c72074e6fb8cb10c6d05a3839bcc0a (diff) |
Implement TFLite sqrt/rsqrt unary operators
PiperOrigin-RevId: 201191877
Diffstat (limited to 'tensorflow/contrib/lite/kernels/elementwise.cc')
-rw-r--r-- | tensorflow/contrib/lite/kernels/elementwise.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tensorflow/contrib/lite/kernels/elementwise.cc b/tensorflow/contrib/lite/kernels/elementwise.cc index 98c21ce9d3..59bab3c4ec 100644 --- a/tensorflow/contrib/lite/kernels/elementwise.cc +++ b/tensorflow/contrib/lite/kernels/elementwise.cc @@ -64,6 +64,14 @@ TfLiteStatus LogEval(TfLiteContext* context, TfLiteNode* node) { return Eval(context, node, std::log); } +TfLiteStatus SqrtEval(TfLiteContext* context, TfLiteNode* node) { + return Eval(context, node, std::sqrt); +} + +TfLiteStatus RsqrtEval(TfLiteContext* context, TfLiteNode* node) { + return Eval(context, node, [](float f) { return 1.f / std::sqrt(f); }); +} + } // namespace elementwise TfLiteRegistration* Register_SIN() { @@ -78,6 +86,18 @@ TfLiteRegistration* Register_LOG() { return &r; } +TfLiteRegistration* Register_SQRT() { + static TfLiteRegistration r = {nullptr, nullptr, elementwise::GenericPrepare, + elementwise::SqrtEval}; + return &r; +} + +TfLiteRegistration* Register_RSQRT() { + static TfLiteRegistration r = {nullptr, nullptr, elementwise::GenericPrepare, + elementwise::RsqrtEval}; + return &r; +} + } // namespace builtin } // namespace ops } // namespace tflite |