MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ConvertRelu1Operator

Function ConvertRelu1Operator

tensorflow/lite/toco/export_tensorflow.cc:734–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

732}
733
734void ConvertRelu1Operator(const Relu1Operator& src_op,
735 GraphDef* tensorflow_graph) {
736 const string max_bounds = src_op.outputs[0] + "/max_bounds";
737 const string min_bounds = src_op.outputs[0] + "/min_bounds";
738 const string max_output = src_op.outputs[0] + "/max_output";
739
740 tensorflow::NodeDef* max_bounds_const_op = tensorflow_graph->add_node();
741 max_bounds_const_op->set_op("Const");
742 max_bounds_const_op->set_name(max_bounds);
743 (*max_bounds_const_op->mutable_attr())["dtype"].set_type(DT_FLOAT);
744 auto* max_bounds_const_op_tensor =
745 (*max_bounds_const_op->mutable_attr())["value"].mutable_tensor();
746 max_bounds_const_op_tensor->set_dtype(DT_FLOAT);
747 max_bounds_const_op_tensor->add_float_val(-1.0f);
748
749 tensorflow::NodeDef* min_bounds_const_op = tensorflow_graph->add_node();
750 min_bounds_const_op->set_op("Const");
751 min_bounds_const_op->set_name(min_bounds);
752 (*min_bounds_const_op->mutable_attr())["dtype"].set_type(DT_FLOAT);
753 auto* min_bounds_const_op_tensor =
754 (*min_bounds_const_op->mutable_attr())["value"].mutable_tensor();
755 min_bounds_const_op_tensor->set_dtype(DT_FLOAT);
756 min_bounds_const_op_tensor->add_float_val(1.0f);
757
758 tensorflow::NodeDef* max_op = tensorflow_graph->add_node();
759 max_op->set_op("Maximum");
760 max_op->set_name(max_output);
761 *max_op->add_input() = src_op.inputs[0];
762 *max_op->add_input() = max_bounds;
763 (*max_op->mutable_attr())["T"].set_type(DT_FLOAT);
764
765 tensorflow::NodeDef* min_op = tensorflow_graph->add_node();
766 min_op->set_op("Minimum");
767 min_op->set_name(src_op.outputs[0]);
768 *min_op->add_input() = max_output;
769 *min_op->add_input() = min_bounds;
770 (*min_op->mutable_attr())["T"].set_type(DT_FLOAT);
771}
772
773void ConvertRelu6Operator(const Relu6Operator& src_op,
774 GraphDef* tensorflow_graph) {

Callers 1

ConvertOperatorFunction · 0.85

Calls 4

set_opMethod · 0.80
set_nameMethod · 0.45
set_dtypeMethod · 0.45
add_inputMethod · 0.45

Tested by

no test coverage detected