| 87 | .SetShapeFn(shape_inference::ScalarShape); |
| 88 | |
| 89 | Output ConstructOp(const Scope& scope, const string& op_type, |
| 90 | const string &device, |
| 91 | const gtl::ArraySlice<Input>& inputs, |
| 92 | const gtl::ArraySlice<Node*>& control_inputs = {}) { |
| 93 | |
| 94 | if (op_type == "VariableV2") { |
| 95 | auto v = ops::Variable(scope, {}, DT_FLOAT); |
| 96 | v.node()->set_assigned_device_name(device); |
| 97 | return v; |
| 98 | } |
| 99 | if (!scope.ok()) { |
| 100 | return Output(); |
| 101 | } |
| 102 | const string unique_name = scope.GetUniqueNameForOp(op_type); |
| 103 | auto builder = |
| 104 | NodeBuilder(unique_name, op_type, scope.graph()->op_registry()); |
| 105 | builder.Device(device); |
| 106 | for (auto const& input : inputs) { |
| 107 | builder.Input(ops::NodeOut(input.node(), input.index())); |
| 108 | } |
| 109 | if (!control_inputs.empty()) { |
| 110 | builder.ControlInputs(control_inputs); |
| 111 | } |
| 112 | scope.UpdateBuilder(&builder); |
| 113 | Node* ret; |
| 114 | scope.UpdateStatus(builder.Finalize(scope.graph(), &ret)); |
| 115 | if (!scope.ok()) { |
| 116 | return Output(); |
| 117 | } |
| 118 | scope.UpdateStatus(scope.DoShapeInference(ret)); |
| 119 | return Output(ret); |
| 120 | } |
| 121 | |
| 122 | Output FloatInput(const Scope& scope, const string &device) { |
| 123 | return ConstructOp(scope, "FloatInput", device, {}); |
no test coverage detected