1 /* Copyright 2017 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #include "tensorflow/compiler/xla/service/hlo_proto_util.h"
17 
18 namespace xla {
19 
20 HloProto MakeHloProto(const HloModule& module,
21                       const BufferAssignment& assignment) {
22   HloOrderingProto proto_ordering =
23       assignment.liveness().hlo_ordering().ToProto();
24   BufferAssignmentProto proto_assignment = assignment.ToProto();
25   HloProto proto = MakeHloProto(module);
26   proto.mutable_hlo_ordering()->Swap(&proto_ordering);
27   proto.mutable_buffer_assignment()->Swap(&proto_assignment);
28   return proto;
29 }
30 
31 HloProto MakeHloProto(const HloModule& module) {
32   HloModuleProto proto_module = module.ToProto();
33   HloProto proto;
34   proto.mutable_hlo_module()->Swap(&proto_module);
35   return proto;
36 }
37 
38 }  // namespace xla
39