aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/tools/accuracy/run_tflite_model_stage.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/contrib/lite/tools/accuracy/run_tflite_model_stage.cc')
-rw-r--r--tensorflow/contrib/lite/tools/accuracy/run_tflite_model_stage.cc45
1 files changed, 45 insertions, 0 deletions
diff --git a/tensorflow/contrib/lite/tools/accuracy/run_tflite_model_stage.cc b/tensorflow/contrib/lite/tools/accuracy/run_tflite_model_stage.cc
new file mode 100644
index 0000000000..c96795d499
--- /dev/null
+++ b/tensorflow/contrib/lite/tools/accuracy/run_tflite_model_stage.cc
@@ -0,0 +1,45 @@
+/* Copyright 2018 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.
+==============================================================================*/
+
+#include "tensorflow/contrib/lite/tools/accuracy/run_tflite_model_stage.h"
+
+#include <vector>
+
+#include "tensorflow/cc/framework/scope.h"
+#include "tensorflow/cc/ops/standard_ops.h"
+
+namespace tensorflow {
+namespace metrics {
+void RunTFLiteModelStage::AddToGraph(const Scope& scope, const Input& input) {
+ if (!scope.ok()) return;
+ Scope s = scope.WithOpName(name());
+
+ std::vector<NodeBuilder::NodeOut> _data = {ops::AsNodeOut(s, input)};
+ ::tensorflow::Node* ret;
+ auto builder = NodeBuilder(output_name(), "RunTFLiteModel")
+ .Input(_data)
+ .Attr("model_file_path", params_.model_file_path)
+ .Attr("input_type", params_.input_type)
+ .Attr("output_type", params_.output_type);
+
+ s.UpdateBuilder(&builder);
+ s.UpdateStatus(builder.Finalize(s.graph(), &ret));
+ if (!s.ok()) return;
+ s.UpdateStatus(s.DoShapeInference(ret));
+ this->stage_output_ = ::tensorflow::Output(ret, 0);
+}
+
+} // namespace metrics
+} // namespace tensorflow