| 22 | namespace { |
| 23 | template <typename T> |
| 24 | Output ConstHelper(const Scope& scope, const T& value, DataType dtype) { |
| 25 | if (!scope.ok()) return Output(); |
| 26 | |
| 27 | Node* ret; |
| 28 | Graph* graph = scope.graph(); |
| 29 | const string unique_name = scope.GetUniqueNameForOp("Const"); |
| 30 | auto builder = NodeBuilder(unique_name, "Const") |
| 31 | .Attr("value", value) |
| 32 | .Attr("dtype", dtype); |
| 33 | scope.UpdateBuilder(&builder); |
| 34 | scope.UpdateStatus(builder.Finalize(graph, &ret)); |
| 35 | if (!scope.ok()) return Output(); |
| 36 | |
| 37 | scope.UpdateStatus(scope.DoShapeInference(ret)); |
| 38 | if (!scope.ok()) return Output(); |
| 39 | |
| 40 | return Output(ret); |
| 41 | } |
| 42 | } // namespace |
| 43 | |
| 44 | Output Const(const Scope& scope, const Input::Initializer& val) { |
no test coverage detected