Fix mac build
clone from meheff's change: [XLA] Change return type of DeviceAssignment::Deserialize to fix build breakage on mac. The mac build had the following error: error: incomplete type 'xla::DeviceAssignment' used in type trait expression This was due to a static method returning a StatusOr<DeviceAssignment> inside of the definition of DeviceAssignment.
This commit is contained in:
parent
a54d43fa40
commit
15a8df724a
@ -49,17 +49,18 @@ Status DeviceAssignment::Serialize(DeviceAssignmentProto* proto) const {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
/* static */ StatusOr<DeviceAssignment> DeviceAssignment::Deserialize(
|
||||
const DeviceAssignmentProto& proto) {
|
||||
/* static */ StatusOr<std::unique_ptr<DeviceAssignment>>
|
||||
DeviceAssignment::Deserialize(const DeviceAssignmentProto& proto) {
|
||||
TF_RET_CHECK(proto.computation_devices_size() == proto.computation_count());
|
||||
DeviceAssignment assignment(proto.replica_count(), proto.computation_count());
|
||||
auto assignment = MakeUnique<DeviceAssignment>(proto.replica_count(),
|
||||
proto.computation_count());
|
||||
for (int computation = 0; computation < proto.computation_count();
|
||||
++computation) {
|
||||
const auto& computation_device = proto.computation_devices(computation);
|
||||
TF_RET_CHECK(computation_device.replica_device_ids_size() ==
|
||||
proto.replica_count());
|
||||
for (int replica = 0; replica < proto.replica_count(); ++replica) {
|
||||
assignment(replica, computation) =
|
||||
(*assignment)(replica, computation) =
|
||||
computation_device.replica_device_ids(replica);
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,11 @@ class DeviceAssignment : public Array2D<int> {
|
||||
|
||||
// Protocol buffer serialization and deserialization.
|
||||
Status Serialize(DeviceAssignmentProto* proto) const;
|
||||
static StatusOr<DeviceAssignment> Deserialize(
|
||||
|
||||
// Return a std::unique_ptr<DeviceAssignment> instead of a DeviceAssignment
|
||||
// directly because one of the supported TF platforms (mac) does not compile
|
||||
// due to a StatusOr of an incomplete type (DeviceAssignment).
|
||||
static StatusOr<std::unique_ptr<DeviceAssignment>> Deserialize(
|
||||
const DeviceAssignmentProto& proto);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user