xref: /aosp_15_r20/external/federated-compute/fcp/tensorflow/testing/tf_helper.cc (revision 14675a029014e728ec732f129a32e299b2da0601)
1 /*
2  * Copyright 2020 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "fcp/tensorflow/testing/tf_helper.h"
18 
19 namespace fcp {
20 
CreateGraph(tensorflow::Scope * root)21 absl::Cord CreateGraph(tensorflow::Scope* root) {
22   tensorflow::GraphDef def;
23   tensorflow::Status to_graph_status = root->ToGraphDef(&def);
24   EXPECT_TRUE(to_graph_status.ok()) << to_graph_status;
25   // TODO(team): Use SerializeAsCord when available.
26   return absl::Cord(def.SerializeAsString());
27 }
28 
29 }  // namespace fcp
30