aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/lite/toco/graph_transformations/reorder_elementwise_unary.cc
diff options
context:
space:
mode:
Diffstat (limited to 'tensorflow/contrib/lite/toco/graph_transformations/reorder_elementwise_unary.cc')
-rw-r--r--tensorflow/contrib/lite/toco/graph_transformations/reorder_elementwise_unary.cc18
1 files changed, 11 insertions, 7 deletions
diff --git a/tensorflow/contrib/lite/toco/graph_transformations/reorder_elementwise_unary.cc b/tensorflow/contrib/lite/toco/graph_transformations/reorder_elementwise_unary.cc
index 550de83018..3c8d411089 100644
--- a/tensorflow/contrib/lite/toco/graph_transformations/reorder_elementwise_unary.cc
+++ b/tensorflow/contrib/lite/toco/graph_transformations/reorder_elementwise_unary.cc
@@ -63,29 +63,32 @@ bool IsMoveOperator(OperatorType optype) {
// Swap elementwise operators such that all value operators occur before all
// element move operators, e.g. negation then transpose.
-bool ReorderElementwiseUnary::Run(Model* model, std::size_t op_index) {
+::tensorflow::Status ReorderElementwiseUnary::Run(Model* model,
+ std::size_t op_index,
+ bool* modified) {
+ *modified = false;
const auto element_op_it = model->operators.begin() + op_index;
std::unique_ptr<Operator>& element_op = *element_op_it;
if (!IsElementwiseOperator(element_op->type)) {
- return false;
+ return ::tensorflow::Status::OK();
}
const string intermediate_name = element_op->inputs[0];
auto it = FindOpWithOutput(*model, intermediate_name);
if (it == model->operators.end()) {
AddMessageF("No preceding operator");
- return false;
+ return ::tensorflow::Status::OK();
}
std::unique_ptr<Operator>& move_op = *it;
if (!IsMoveOperator(move_op->type)) {
AddMessageF("Preceding operator is not a move operator");
- return false;
+ return ::tensorflow::Status::OK();
}
if (CountOpsWithInput(*model, intermediate_name) != 1) {
AddMessageF("Input %s used elsewhere", intermediate_name);
- return false;
+ return ::tensorflow::Status::OK();
}
// Check that the intermediate is discardable.
@@ -94,7 +97,7 @@ bool ReorderElementwiseUnary::Run(Model* model, std::size_t op_index) {
"Cannot swap elementwise as it would invalidate %s which is "
"an output array.",
intermediate_name);
- return false;
+ return ::tensorflow::Status::OK();
}
// op->inputs may change so we need to keep a value by copy.
@@ -147,7 +150,8 @@ bool ReorderElementwiseUnary::Run(Model* model, std::size_t op_index) {
// Swap the order of the operators.
element_op.swap(move_op);
- return true;
+ *modified = true;
+ return ::tensorflow::Status::OK();
}
} // namespace toco