// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: tensorflow/contrib/tpu/proto/topology.proto

package tensorflow.tpu;

public final class Topology {
  private Topology() {}
  public static void registerAllExtensions(
      com.google.protobuf.ExtensionRegistryLite registry) {
  }

  public static void registerAllExtensions(
      com.google.protobuf.ExtensionRegistry registry) {
    registerAllExtensions(
        (com.google.protobuf.ExtensionRegistryLite) registry);
  }
  public interface TopologyProtoOrBuilder extends
      // @@protoc_insertion_point(interface_extends:tensorflow.tpu.TopologyProto)
      com.google.protobuf.MessageOrBuilder {

    /**
     * <pre>
     * The dimensions of the TPU topology, in cores. Typically, this is a 3D
     * topology [x, y, core], where the major dimensions correspond to TPU chips,
     * and the minor dimension describes the number of cores on a multicore chip.
     * </pre>
     *
     * <code>repeated int32 mesh_shape = 1;</code>
     */
    java.util.List<java.lang.Integer> getMeshShapeList();
    /**
     * <pre>
     * The dimensions of the TPU topology, in cores. Typically, this is a 3D
     * topology [x, y, core], where the major dimensions correspond to TPU chips,
     * and the minor dimension describes the number of cores on a multicore chip.
     * </pre>
     *
     * <code>repeated int32 mesh_shape = 1;</code>
     */
    int getMeshShapeCount();
    /**
     * <pre>
     * The dimensions of the TPU topology, in cores. Typically, this is a 3D
     * topology [x, y, core], where the major dimensions correspond to TPU chips,
     * and the minor dimension describes the number of cores on a multicore chip.
     * </pre>
     *
     * <code>repeated int32 mesh_shape = 1;</code>
     */
    int getMeshShape(int index);

    /**
     * <pre>
     * Number of TensorFlow tasks in the cluster.
     * </pre>
     *
     * <code>int32 num_tasks = 2;</code>
     */
    int getNumTasks();

    /**
     * <pre>
     * Number of TPU devices per task.
     * </pre>
     *
     * <code>int32 num_tpu_devices_per_task = 3;</code>
     */
    int getNumTpuDevicesPerTask();

    /**
     * <pre>
     * A flattened rank 3 int32 array with shape
     * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
     * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
     * of TPU devices per task, and the minor dimension corresponds to a position
     * in the TPU mesh topology. Each entry [task, device, axis] gives the
     * `axis`-th coordinate in the topology of a task/device pair.
     * </pre>
     *
     * <code>repeated int32 device_coordinates = 4;</code>
     */
    java.util.List<java.lang.Integer> getDeviceCoordinatesList();
    /**
     * <pre>
     * A flattened rank 3 int32 array with shape
     * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
     * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
     * of TPU devices per task, and the minor dimension corresponds to a position
     * in the TPU mesh topology. Each entry [task, device, axis] gives the
     * `axis`-th coordinate in the topology of a task/device pair.
     * </pre>
     *
     * <code>repeated int32 device_coordinates = 4;</code>
     */
    int getDeviceCoordinatesCount();
    /**
     * <pre>
     * A flattened rank 3 int32 array with shape
     * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
     * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
     * of TPU devices per task, and the minor dimension corresponds to a position
     * in the TPU mesh topology. Each entry [task, device, axis] gives the
     * `axis`-th coordinate in the topology of a task/device pair.
     * </pre>
     *
     * <code>repeated int32 device_coordinates = 4;</code>
     */
    int getDeviceCoordinates(int index);
  }
  /**
   * <pre>
   * Describes the geometry of a TPU mesh.
   * </pre>
   *
   * Protobuf type {@code tensorflow.tpu.TopologyProto}
   */
  public  static final class TopologyProto extends
      com.google.protobuf.GeneratedMessageV3 implements
      // @@protoc_insertion_point(message_implements:tensorflow.tpu.TopologyProto)
      TopologyProtoOrBuilder {
    // Use TopologyProto.newBuilder() to construct.
    private TopologyProto(com.google.protobuf.GeneratedMessageV3.Builder<?> builder) {
      super(builder);
    }
    private TopologyProto() {
      meshShape_ = java.util.Collections.emptyList();
      numTasks_ = 0;
      numTpuDevicesPerTask_ = 0;
      deviceCoordinates_ = java.util.Collections.emptyList();
    }

    @java.lang.Override
    public final com.google.protobuf.UnknownFieldSet
    getUnknownFields() {
      return com.google.protobuf.UnknownFieldSet.getDefaultInstance();
    }
    private TopologyProto(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      this();
      int mutable_bitField0_ = 0;
      try {
        boolean done = false;
        while (!done) {
          int tag = input.readTag();
          switch (tag) {
            case 0:
              done = true;
              break;
            default: {
              if (!input.skipField(tag)) {
                done = true;
              }
              break;
            }
            case 8: {
              if (!((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
                meshShape_ = new java.util.ArrayList<java.lang.Integer>();
                mutable_bitField0_ |= 0x00000001;
              }
              meshShape_.add(input.readInt32());
              break;
            }
            case 10: {
              int length = input.readRawVarint32();
              int limit = input.pushLimit(length);
              if (!((mutable_bitField0_ & 0x00000001) == 0x00000001) && input.getBytesUntilLimit() > 0) {
                meshShape_ = new java.util.ArrayList<java.lang.Integer>();
                mutable_bitField0_ |= 0x00000001;
              }
              while (input.getBytesUntilLimit() > 0) {
                meshShape_.add(input.readInt32());
              }
              input.popLimit(limit);
              break;
            }
            case 16: {

              numTasks_ = input.readInt32();
              break;
            }
            case 24: {

              numTpuDevicesPerTask_ = input.readInt32();
              break;
            }
            case 32: {
              if (!((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
                deviceCoordinates_ = new java.util.ArrayList<java.lang.Integer>();
                mutable_bitField0_ |= 0x00000008;
              }
              deviceCoordinates_.add(input.readInt32());
              break;
            }
            case 34: {
              int length = input.readRawVarint32();
              int limit = input.pushLimit(length);
              if (!((mutable_bitField0_ & 0x00000008) == 0x00000008) && input.getBytesUntilLimit() > 0) {
                deviceCoordinates_ = new java.util.ArrayList<java.lang.Integer>();
                mutable_bitField0_ |= 0x00000008;
              }
              while (input.getBytesUntilLimit() > 0) {
                deviceCoordinates_.add(input.readInt32());
              }
              input.popLimit(limit);
              break;
            }
          }
        }
      } catch (com.google.protobuf.InvalidProtocolBufferException e) {
        throw e.setUnfinishedMessage(this);
      } catch (java.io.IOException e) {
        throw new com.google.protobuf.InvalidProtocolBufferException(
            e).setUnfinishedMessage(this);
      } finally {
        if (((mutable_bitField0_ & 0x00000001) == 0x00000001)) {
          meshShape_ = java.util.Collections.unmodifiableList(meshShape_);
        }
        if (((mutable_bitField0_ & 0x00000008) == 0x00000008)) {
          deviceCoordinates_ = java.util.Collections.unmodifiableList(deviceCoordinates_);
        }
        makeExtensionsImmutable();
      }
    }
    public static final com.google.protobuf.Descriptors.Descriptor
        getDescriptor() {
      return tensorflow.tpu.Topology.internal_static_tensorflow_tpu_TopologyProto_descriptor;
    }

    protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
        internalGetFieldAccessorTable() {
      return tensorflow.tpu.Topology.internal_static_tensorflow_tpu_TopologyProto_fieldAccessorTable
          .ensureFieldAccessorsInitialized(
              tensorflow.tpu.Topology.TopologyProto.class, tensorflow.tpu.Topology.TopologyProto.Builder.class);
    }

    private int bitField0_;
    public static final int MESH_SHAPE_FIELD_NUMBER = 1;
    private java.util.List<java.lang.Integer> meshShape_;
    /**
     * <pre>
     * The dimensions of the TPU topology, in cores. Typically, this is a 3D
     * topology [x, y, core], where the major dimensions correspond to TPU chips,
     * and the minor dimension describes the number of cores on a multicore chip.
     * </pre>
     *
     * <code>repeated int32 mesh_shape = 1;</code>
     */
    public java.util.List<java.lang.Integer>
        getMeshShapeList() {
      return meshShape_;
    }
    /**
     * <pre>
     * The dimensions of the TPU topology, in cores. Typically, this is a 3D
     * topology [x, y, core], where the major dimensions correspond to TPU chips,
     * and the minor dimension describes the number of cores on a multicore chip.
     * </pre>
     *
     * <code>repeated int32 mesh_shape = 1;</code>
     */
    public int getMeshShapeCount() {
      return meshShape_.size();
    }
    /**
     * <pre>
     * The dimensions of the TPU topology, in cores. Typically, this is a 3D
     * topology [x, y, core], where the major dimensions correspond to TPU chips,
     * and the minor dimension describes the number of cores on a multicore chip.
     * </pre>
     *
     * <code>repeated int32 mesh_shape = 1;</code>
     */
    public int getMeshShape(int index) {
      return meshShape_.get(index);
    }
    private int meshShapeMemoizedSerializedSize = -1;

    public static final int NUM_TASKS_FIELD_NUMBER = 2;
    private int numTasks_;
    /**
     * <pre>
     * Number of TensorFlow tasks in the cluster.
     * </pre>
     *
     * <code>int32 num_tasks = 2;</code>
     */
    public int getNumTasks() {
      return numTasks_;
    }

    public static final int NUM_TPU_DEVICES_PER_TASK_FIELD_NUMBER = 3;
    private int numTpuDevicesPerTask_;
    /**
     * <pre>
     * Number of TPU devices per task.
     * </pre>
     *
     * <code>int32 num_tpu_devices_per_task = 3;</code>
     */
    public int getNumTpuDevicesPerTask() {
      return numTpuDevicesPerTask_;
    }

    public static final int DEVICE_COORDINATES_FIELD_NUMBER = 4;
    private java.util.List<java.lang.Integer> deviceCoordinates_;
    /**
     * <pre>
     * A flattened rank 3 int32 array with shape
     * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
     * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
     * of TPU devices per task, and the minor dimension corresponds to a position
     * in the TPU mesh topology. Each entry [task, device, axis] gives the
     * `axis`-th coordinate in the topology of a task/device pair.
     * </pre>
     *
     * <code>repeated int32 device_coordinates = 4;</code>
     */
    public java.util.List<java.lang.Integer>
        getDeviceCoordinatesList() {
      return deviceCoordinates_;
    }
    /**
     * <pre>
     * A flattened rank 3 int32 array with shape
     * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
     * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
     * of TPU devices per task, and the minor dimension corresponds to a position
     * in the TPU mesh topology. Each entry [task, device, axis] gives the
     * `axis`-th coordinate in the topology of a task/device pair.
     * </pre>
     *
     * <code>repeated int32 device_coordinates = 4;</code>
     */
    public int getDeviceCoordinatesCount() {
      return deviceCoordinates_.size();
    }
    /**
     * <pre>
     * A flattened rank 3 int32 array with shape
     * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
     * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
     * of TPU devices per task, and the minor dimension corresponds to a position
     * in the TPU mesh topology. Each entry [task, device, axis] gives the
     * `axis`-th coordinate in the topology of a task/device pair.
     * </pre>
     *
     * <code>repeated int32 device_coordinates = 4;</code>
     */
    public int getDeviceCoordinates(int index) {
      return deviceCoordinates_.get(index);
    }
    private int deviceCoordinatesMemoizedSerializedSize = -1;

    private byte memoizedIsInitialized = -1;
    public final boolean isInitialized() {
      byte isInitialized = memoizedIsInitialized;
      if (isInitialized == 1) return true;
      if (isInitialized == 0) return false;

      memoizedIsInitialized = 1;
      return true;
    }

    public void writeTo(com.google.protobuf.CodedOutputStream output)
                        throws java.io.IOException {
      getSerializedSize();
      if (getMeshShapeList().size() > 0) {
        output.writeUInt32NoTag(10);
        output.writeUInt32NoTag(meshShapeMemoizedSerializedSize);
      }
      for (int i = 0; i < meshShape_.size(); i++) {
        output.writeInt32NoTag(meshShape_.get(i));
      }
      if (numTasks_ != 0) {
        output.writeInt32(2, numTasks_);
      }
      if (numTpuDevicesPerTask_ != 0) {
        output.writeInt32(3, numTpuDevicesPerTask_);
      }
      if (getDeviceCoordinatesList().size() > 0) {
        output.writeUInt32NoTag(34);
        output.writeUInt32NoTag(deviceCoordinatesMemoizedSerializedSize);
      }
      for (int i = 0; i < deviceCoordinates_.size(); i++) {
        output.writeInt32NoTag(deviceCoordinates_.get(i));
      }
    }

    public int getSerializedSize() {
      int size = memoizedSize;
      if (size != -1) return size;

      size = 0;
      {
        int dataSize = 0;
        for (int i = 0; i < meshShape_.size(); i++) {
          dataSize += com.google.protobuf.CodedOutputStream
            .computeInt32SizeNoTag(meshShape_.get(i));
        }
        size += dataSize;
        if (!getMeshShapeList().isEmpty()) {
          size += 1;
          size += com.google.protobuf.CodedOutputStream
              .computeInt32SizeNoTag(dataSize);
        }
        meshShapeMemoizedSerializedSize = dataSize;
      }
      if (numTasks_ != 0) {
        size += com.google.protobuf.CodedOutputStream
          .computeInt32Size(2, numTasks_);
      }
      if (numTpuDevicesPerTask_ != 0) {
        size += com.google.protobuf.CodedOutputStream
          .computeInt32Size(3, numTpuDevicesPerTask_);
      }
      {
        int dataSize = 0;
        for (int i = 0; i < deviceCoordinates_.size(); i++) {
          dataSize += com.google.protobuf.CodedOutputStream
            .computeInt32SizeNoTag(deviceCoordinates_.get(i));
        }
        size += dataSize;
        if (!getDeviceCoordinatesList().isEmpty()) {
          size += 1;
          size += com.google.protobuf.CodedOutputStream
              .computeInt32SizeNoTag(dataSize);
        }
        deviceCoordinatesMemoizedSerializedSize = dataSize;
      }
      memoizedSize = size;
      return size;
    }

    private static final long serialVersionUID = 0L;
    @java.lang.Override
    public boolean equals(final java.lang.Object obj) {
      if (obj == this) {
       return true;
      }
      if (!(obj instanceof tensorflow.tpu.Topology.TopologyProto)) {
        return super.equals(obj);
      }
      tensorflow.tpu.Topology.TopologyProto other = (tensorflow.tpu.Topology.TopologyProto) obj;

      boolean result = true;
      result = result && getMeshShapeList()
          .equals(other.getMeshShapeList());
      result = result && (getNumTasks()
          == other.getNumTasks());
      result = result && (getNumTpuDevicesPerTask()
          == other.getNumTpuDevicesPerTask());
      result = result && getDeviceCoordinatesList()
          .equals(other.getDeviceCoordinatesList());
      return result;
    }

    @java.lang.Override
    public int hashCode() {
      if (memoizedHashCode != 0) {
        return memoizedHashCode;
      }
      int hash = 41;
      hash = (19 * hash) + getDescriptor().hashCode();
      if (getMeshShapeCount() > 0) {
        hash = (37 * hash) + MESH_SHAPE_FIELD_NUMBER;
        hash = (53 * hash) + getMeshShapeList().hashCode();
      }
      hash = (37 * hash) + NUM_TASKS_FIELD_NUMBER;
      hash = (53 * hash) + getNumTasks();
      hash = (37 * hash) + NUM_TPU_DEVICES_PER_TASK_FIELD_NUMBER;
      hash = (53 * hash) + getNumTpuDevicesPerTask();
      if (getDeviceCoordinatesCount() > 0) {
        hash = (37 * hash) + DEVICE_COORDINATES_FIELD_NUMBER;
        hash = (53 * hash) + getDeviceCoordinatesList().hashCode();
      }
      hash = (29 * hash) + unknownFields.hashCode();
      memoizedHashCode = hash;
      return hash;
    }

    public static tensorflow.tpu.Topology.TopologyProto parseFrom(
        com.google.protobuf.ByteString data)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data);
    }
    public static tensorflow.tpu.Topology.TopologyProto parseFrom(
        com.google.protobuf.ByteString data,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data, extensionRegistry);
    }
    public static tensorflow.tpu.Topology.TopologyProto parseFrom(byte[] data)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data);
    }
    public static tensorflow.tpu.Topology.TopologyProto parseFrom(
        byte[] data,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws com.google.protobuf.InvalidProtocolBufferException {
      return PARSER.parseFrom(data, extensionRegistry);
    }
    public static tensorflow.tpu.Topology.TopologyProto parseFrom(java.io.InputStream input)
        throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3
          .parseWithIOException(PARSER, input);
    }
    public static tensorflow.tpu.Topology.TopologyProto parseFrom(
        java.io.InputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3
          .parseWithIOException(PARSER, input, extensionRegistry);
    }
    public static tensorflow.tpu.Topology.TopologyProto parseDelimitedFrom(java.io.InputStream input)
        throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3
          .parseDelimitedWithIOException(PARSER, input);
    }
    public static tensorflow.tpu.Topology.TopologyProto parseDelimitedFrom(
        java.io.InputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3
          .parseDelimitedWithIOException(PARSER, input, extensionRegistry);
    }
    public static tensorflow.tpu.Topology.TopologyProto parseFrom(
        com.google.protobuf.CodedInputStream input)
        throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3
          .parseWithIOException(PARSER, input);
    }
    public static tensorflow.tpu.Topology.TopologyProto parseFrom(
        com.google.protobuf.CodedInputStream input,
        com.google.protobuf.ExtensionRegistryLite extensionRegistry)
        throws java.io.IOException {
      return com.google.protobuf.GeneratedMessageV3
          .parseWithIOException(PARSER, input, extensionRegistry);
    }

    public Builder newBuilderForType() { return newBuilder(); }
    public static Builder newBuilder() {
      return DEFAULT_INSTANCE.toBuilder();
    }
    public static Builder newBuilder(tensorflow.tpu.Topology.TopologyProto prototype) {
      return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype);
    }
    public Builder toBuilder() {
      return this == DEFAULT_INSTANCE
          ? new Builder() : new Builder().mergeFrom(this);
    }

    @java.lang.Override
    protected Builder newBuilderForType(
        com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
      Builder builder = new Builder(parent);
      return builder;
    }
    /**
     * <pre>
     * Describes the geometry of a TPU mesh.
     * </pre>
     *
     * Protobuf type {@code tensorflow.tpu.TopologyProto}
     */
    public static final class Builder extends
        com.google.protobuf.GeneratedMessageV3.Builder<Builder> implements
        // @@protoc_insertion_point(builder_implements:tensorflow.tpu.TopologyProto)
        tensorflow.tpu.Topology.TopologyProtoOrBuilder {
      public static final com.google.protobuf.Descriptors.Descriptor
          getDescriptor() {
        return tensorflow.tpu.Topology.internal_static_tensorflow_tpu_TopologyProto_descriptor;
      }

      protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
          internalGetFieldAccessorTable() {
        return tensorflow.tpu.Topology.internal_static_tensorflow_tpu_TopologyProto_fieldAccessorTable
            .ensureFieldAccessorsInitialized(
                tensorflow.tpu.Topology.TopologyProto.class, tensorflow.tpu.Topology.TopologyProto.Builder.class);
      }

      // Construct using tensorflow.tpu.Topology.TopologyProto.newBuilder()
      private Builder() {
        maybeForceBuilderInitialization();
      }

      private Builder(
          com.google.protobuf.GeneratedMessageV3.BuilderParent parent) {
        super(parent);
        maybeForceBuilderInitialization();
      }
      private void maybeForceBuilderInitialization() {
        if (com.google.protobuf.GeneratedMessageV3
                .alwaysUseFieldBuilders) {
        }
      }
      public Builder clear() {
        super.clear();
        meshShape_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
        numTasks_ = 0;

        numTpuDevicesPerTask_ = 0;

        deviceCoordinates_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000008);
        return this;
      }

      public com.google.protobuf.Descriptors.Descriptor
          getDescriptorForType() {
        return tensorflow.tpu.Topology.internal_static_tensorflow_tpu_TopologyProto_descriptor;
      }

      public tensorflow.tpu.Topology.TopologyProto getDefaultInstanceForType() {
        return tensorflow.tpu.Topology.TopologyProto.getDefaultInstance();
      }

      public tensorflow.tpu.Topology.TopologyProto build() {
        tensorflow.tpu.Topology.TopologyProto result = buildPartial();
        if (!result.isInitialized()) {
          throw newUninitializedMessageException(result);
        }
        return result;
      }

      public tensorflow.tpu.Topology.TopologyProto buildPartial() {
        tensorflow.tpu.Topology.TopologyProto result = new tensorflow.tpu.Topology.TopologyProto(this);
        int from_bitField0_ = bitField0_;
        int to_bitField0_ = 0;
        if (((bitField0_ & 0x00000001) == 0x00000001)) {
          meshShape_ = java.util.Collections.unmodifiableList(meshShape_);
          bitField0_ = (bitField0_ & ~0x00000001);
        }
        result.meshShape_ = meshShape_;
        result.numTasks_ = numTasks_;
        result.numTpuDevicesPerTask_ = numTpuDevicesPerTask_;
        if (((bitField0_ & 0x00000008) == 0x00000008)) {
          deviceCoordinates_ = java.util.Collections.unmodifiableList(deviceCoordinates_);
          bitField0_ = (bitField0_ & ~0x00000008);
        }
        result.deviceCoordinates_ = deviceCoordinates_;
        result.bitField0_ = to_bitField0_;
        onBuilt();
        return result;
      }

      public Builder clone() {
        return (Builder) super.clone();
      }
      public Builder setField(
          com.google.protobuf.Descriptors.FieldDescriptor field,
          Object value) {
        return (Builder) super.setField(field, value);
      }
      public Builder clearField(
          com.google.protobuf.Descriptors.FieldDescriptor field) {
        return (Builder) super.clearField(field);
      }
      public Builder clearOneof(
          com.google.protobuf.Descriptors.OneofDescriptor oneof) {
        return (Builder) super.clearOneof(oneof);
      }
      public Builder setRepeatedField(
          com.google.protobuf.Descriptors.FieldDescriptor field,
          int index, Object value) {
        return (Builder) super.setRepeatedField(field, index, value);
      }
      public Builder addRepeatedField(
          com.google.protobuf.Descriptors.FieldDescriptor field,
          Object value) {
        return (Builder) super.addRepeatedField(field, value);
      }
      public Builder mergeFrom(com.google.protobuf.Message other) {
        if (other instanceof tensorflow.tpu.Topology.TopologyProto) {
          return mergeFrom((tensorflow.tpu.Topology.TopologyProto)other);
        } else {
          super.mergeFrom(other);
          return this;
        }
      }

      public Builder mergeFrom(tensorflow.tpu.Topology.TopologyProto other) {
        if (other == tensorflow.tpu.Topology.TopologyProto.getDefaultInstance()) return this;
        if (!other.meshShape_.isEmpty()) {
          if (meshShape_.isEmpty()) {
            meshShape_ = other.meshShape_;
            bitField0_ = (bitField0_ & ~0x00000001);
          } else {
            ensureMeshShapeIsMutable();
            meshShape_.addAll(other.meshShape_);
          }
          onChanged();
        }
        if (other.getNumTasks() != 0) {
          setNumTasks(other.getNumTasks());
        }
        if (other.getNumTpuDevicesPerTask() != 0) {
          setNumTpuDevicesPerTask(other.getNumTpuDevicesPerTask());
        }
        if (!other.deviceCoordinates_.isEmpty()) {
          if (deviceCoordinates_.isEmpty()) {
            deviceCoordinates_ = other.deviceCoordinates_;
            bitField0_ = (bitField0_ & ~0x00000008);
          } else {
            ensureDeviceCoordinatesIsMutable();
            deviceCoordinates_.addAll(other.deviceCoordinates_);
          }
          onChanged();
        }
        onChanged();
        return this;
      }

      public final boolean isInitialized() {
        return true;
      }

      public Builder mergeFrom(
          com.google.protobuf.CodedInputStream input,
          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
          throws java.io.IOException {
        tensorflow.tpu.Topology.TopologyProto parsedMessage = null;
        try {
          parsedMessage = PARSER.parsePartialFrom(input, extensionRegistry);
        } catch (com.google.protobuf.InvalidProtocolBufferException e) {
          parsedMessage = (tensorflow.tpu.Topology.TopologyProto) e.getUnfinishedMessage();
          throw e.unwrapIOException();
        } finally {
          if (parsedMessage != null) {
            mergeFrom(parsedMessage);
          }
        }
        return this;
      }
      private int bitField0_;

      private java.util.List<java.lang.Integer> meshShape_ = java.util.Collections.emptyList();
      private void ensureMeshShapeIsMutable() {
        if (!((bitField0_ & 0x00000001) == 0x00000001)) {
          meshShape_ = new java.util.ArrayList<java.lang.Integer>(meshShape_);
          bitField0_ |= 0x00000001;
         }
      }
      /**
       * <pre>
       * The dimensions of the TPU topology, in cores. Typically, this is a 3D
       * topology [x, y, core], where the major dimensions correspond to TPU chips,
       * and the minor dimension describes the number of cores on a multicore chip.
       * </pre>
       *
       * <code>repeated int32 mesh_shape = 1;</code>
       */
      public java.util.List<java.lang.Integer>
          getMeshShapeList() {
        return java.util.Collections.unmodifiableList(meshShape_);
      }
      /**
       * <pre>
       * The dimensions of the TPU topology, in cores. Typically, this is a 3D
       * topology [x, y, core], where the major dimensions correspond to TPU chips,
       * and the minor dimension describes the number of cores on a multicore chip.
       * </pre>
       *
       * <code>repeated int32 mesh_shape = 1;</code>
       */
      public int getMeshShapeCount() {
        return meshShape_.size();
      }
      /**
       * <pre>
       * The dimensions of the TPU topology, in cores. Typically, this is a 3D
       * topology [x, y, core], where the major dimensions correspond to TPU chips,
       * and the minor dimension describes the number of cores on a multicore chip.
       * </pre>
       *
       * <code>repeated int32 mesh_shape = 1;</code>
       */
      public int getMeshShape(int index) {
        return meshShape_.get(index);
      }
      /**
       * <pre>
       * The dimensions of the TPU topology, in cores. Typically, this is a 3D
       * topology [x, y, core], where the major dimensions correspond to TPU chips,
       * and the minor dimension describes the number of cores on a multicore chip.
       * </pre>
       *
       * <code>repeated int32 mesh_shape = 1;</code>
       */
      public Builder setMeshShape(
          int index, int value) {
        ensureMeshShapeIsMutable();
        meshShape_.set(index, value);
        onChanged();
        return this;
      }
      /**
       * <pre>
       * The dimensions of the TPU topology, in cores. Typically, this is a 3D
       * topology [x, y, core], where the major dimensions correspond to TPU chips,
       * and the minor dimension describes the number of cores on a multicore chip.
       * </pre>
       *
       * <code>repeated int32 mesh_shape = 1;</code>
       */
      public Builder addMeshShape(int value) {
        ensureMeshShapeIsMutable();
        meshShape_.add(value);
        onChanged();
        return this;
      }
      /**
       * <pre>
       * The dimensions of the TPU topology, in cores. Typically, this is a 3D
       * topology [x, y, core], where the major dimensions correspond to TPU chips,
       * and the minor dimension describes the number of cores on a multicore chip.
       * </pre>
       *
       * <code>repeated int32 mesh_shape = 1;</code>
       */
      public Builder addAllMeshShape(
          java.lang.Iterable<? extends java.lang.Integer> values) {
        ensureMeshShapeIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(
            values, meshShape_);
        onChanged();
        return this;
      }
      /**
       * <pre>
       * The dimensions of the TPU topology, in cores. Typically, this is a 3D
       * topology [x, y, core], where the major dimensions correspond to TPU chips,
       * and the minor dimension describes the number of cores on a multicore chip.
       * </pre>
       *
       * <code>repeated int32 mesh_shape = 1;</code>
       */
      public Builder clearMeshShape() {
        meshShape_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000001);
        onChanged();
        return this;
      }

      private int numTasks_ ;
      /**
       * <pre>
       * Number of TensorFlow tasks in the cluster.
       * </pre>
       *
       * <code>int32 num_tasks = 2;</code>
       */
      public int getNumTasks() {
        return numTasks_;
      }
      /**
       * <pre>
       * Number of TensorFlow tasks in the cluster.
       * </pre>
       *
       * <code>int32 num_tasks = 2;</code>
       */
      public Builder setNumTasks(int value) {
        
        numTasks_ = value;
        onChanged();
        return this;
      }
      /**
       * <pre>
       * Number of TensorFlow tasks in the cluster.
       * </pre>
       *
       * <code>int32 num_tasks = 2;</code>
       */
      public Builder clearNumTasks() {
        
        numTasks_ = 0;
        onChanged();
        return this;
      }

      private int numTpuDevicesPerTask_ ;
      /**
       * <pre>
       * Number of TPU devices per task.
       * </pre>
       *
       * <code>int32 num_tpu_devices_per_task = 3;</code>
       */
      public int getNumTpuDevicesPerTask() {
        return numTpuDevicesPerTask_;
      }
      /**
       * <pre>
       * Number of TPU devices per task.
       * </pre>
       *
       * <code>int32 num_tpu_devices_per_task = 3;</code>
       */
      public Builder setNumTpuDevicesPerTask(int value) {
        
        numTpuDevicesPerTask_ = value;
        onChanged();
        return this;
      }
      /**
       * <pre>
       * Number of TPU devices per task.
       * </pre>
       *
       * <code>int32 num_tpu_devices_per_task = 3;</code>
       */
      public Builder clearNumTpuDevicesPerTask() {
        
        numTpuDevicesPerTask_ = 0;
        onChanged();
        return this;
      }

      private java.util.List<java.lang.Integer> deviceCoordinates_ = java.util.Collections.emptyList();
      private void ensureDeviceCoordinatesIsMutable() {
        if (!((bitField0_ & 0x00000008) == 0x00000008)) {
          deviceCoordinates_ = new java.util.ArrayList<java.lang.Integer>(deviceCoordinates_);
          bitField0_ |= 0x00000008;
         }
      }
      /**
       * <pre>
       * A flattened rank 3 int32 array with shape
       * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
       * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
       * of TPU devices per task, and the minor dimension corresponds to a position
       * in the TPU mesh topology. Each entry [task, device, axis] gives the
       * `axis`-th coordinate in the topology of a task/device pair.
       * </pre>
       *
       * <code>repeated int32 device_coordinates = 4;</code>
       */
      public java.util.List<java.lang.Integer>
          getDeviceCoordinatesList() {
        return java.util.Collections.unmodifiableList(deviceCoordinates_);
      }
      /**
       * <pre>
       * A flattened rank 3 int32 array with shape
       * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
       * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
       * of TPU devices per task, and the minor dimension corresponds to a position
       * in the TPU mesh topology. Each entry [task, device, axis] gives the
       * `axis`-th coordinate in the topology of a task/device pair.
       * </pre>
       *
       * <code>repeated int32 device_coordinates = 4;</code>
       */
      public int getDeviceCoordinatesCount() {
        return deviceCoordinates_.size();
      }
      /**
       * <pre>
       * A flattened rank 3 int32 array with shape
       * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
       * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
       * of TPU devices per task, and the minor dimension corresponds to a position
       * in the TPU mesh topology. Each entry [task, device, axis] gives the
       * `axis`-th coordinate in the topology of a task/device pair.
       * </pre>
       *
       * <code>repeated int32 device_coordinates = 4;</code>
       */
      public int getDeviceCoordinates(int index) {
        return deviceCoordinates_.get(index);
      }
      /**
       * <pre>
       * A flattened rank 3 int32 array with shape
       * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
       * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
       * of TPU devices per task, and the minor dimension corresponds to a position
       * in the TPU mesh topology. Each entry [task, device, axis] gives the
       * `axis`-th coordinate in the topology of a task/device pair.
       * </pre>
       *
       * <code>repeated int32 device_coordinates = 4;</code>
       */
      public Builder setDeviceCoordinates(
          int index, int value) {
        ensureDeviceCoordinatesIsMutable();
        deviceCoordinates_.set(index, value);
        onChanged();
        return this;
      }
      /**
       * <pre>
       * A flattened rank 3 int32 array with shape
       * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
       * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
       * of TPU devices per task, and the minor dimension corresponds to a position
       * in the TPU mesh topology. Each entry [task, device, axis] gives the
       * `axis`-th coordinate in the topology of a task/device pair.
       * </pre>
       *
       * <code>repeated int32 device_coordinates = 4;</code>
       */
      public Builder addDeviceCoordinates(int value) {
        ensureDeviceCoordinatesIsMutable();
        deviceCoordinates_.add(value);
        onChanged();
        return this;
      }
      /**
       * <pre>
       * A flattened rank 3 int32 array with shape
       * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
       * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
       * of TPU devices per task, and the minor dimension corresponds to a position
       * in the TPU mesh topology. Each entry [task, device, axis] gives the
       * `axis`-th coordinate in the topology of a task/device pair.
       * </pre>
       *
       * <code>repeated int32 device_coordinates = 4;</code>
       */
      public Builder addAllDeviceCoordinates(
          java.lang.Iterable<? extends java.lang.Integer> values) {
        ensureDeviceCoordinatesIsMutable();
        com.google.protobuf.AbstractMessageLite.Builder.addAll(
            values, deviceCoordinates_);
        onChanged();
        return this;
      }
      /**
       * <pre>
       * A flattened rank 3 int32 array with shape
       * [num_tasks, num_tpu_devices_per_task, len(mesh_shape)].
       * `tasks` is the number of tasks in the TPU cluster, `devices` is the number
       * of TPU devices per task, and the minor dimension corresponds to a position
       * in the TPU mesh topology. Each entry [task, device, axis] gives the
       * `axis`-th coordinate in the topology of a task/device pair.
       * </pre>
       *
       * <code>repeated int32 device_coordinates = 4;</code>
       */
      public Builder clearDeviceCoordinates() {
        deviceCoordinates_ = java.util.Collections.emptyList();
        bitField0_ = (bitField0_ & ~0x00000008);
        onChanged();
        return this;
      }
      public final Builder setUnknownFields(
          final com.google.protobuf.UnknownFieldSet unknownFields) {
        return this;
      }

      public final Builder mergeUnknownFields(
          final com.google.protobuf.UnknownFieldSet unknownFields) {
        return this;
      }


      // @@protoc_insertion_point(builder_scope:tensorflow.tpu.TopologyProto)
    }

    // @@protoc_insertion_point(class_scope:tensorflow.tpu.TopologyProto)
    private static final tensorflow.tpu.Topology.TopologyProto DEFAULT_INSTANCE;
    static {
      DEFAULT_INSTANCE = new tensorflow.tpu.Topology.TopologyProto();
    }

    public static tensorflow.tpu.Topology.TopologyProto getDefaultInstance() {
      return DEFAULT_INSTANCE;
    }

    private static final com.google.protobuf.Parser<TopologyProto>
        PARSER = new com.google.protobuf.AbstractParser<TopologyProto>() {
      public TopologyProto parsePartialFrom(
          com.google.protobuf.CodedInputStream input,
          com.google.protobuf.ExtensionRegistryLite extensionRegistry)
          throws com.google.protobuf.InvalidProtocolBufferException {
          return new TopologyProto(input, extensionRegistry);
      }
    };

    public static com.google.protobuf.Parser<TopologyProto> parser() {
      return PARSER;
    }

    @java.lang.Override
    public com.google.protobuf.Parser<TopologyProto> getParserForType() {
      return PARSER;
    }

    public tensorflow.tpu.Topology.TopologyProto getDefaultInstanceForType() {
      return DEFAULT_INSTANCE;
    }

  }

  private static final com.google.protobuf.Descriptors.Descriptor
    internal_static_tensorflow_tpu_TopologyProto_descriptor;
  private static final 
    com.google.protobuf.GeneratedMessageV3.FieldAccessorTable
      internal_static_tensorflow_tpu_TopologyProto_fieldAccessorTable;

  public static com.google.protobuf.Descriptors.FileDescriptor
      getDescriptor() {
    return descriptor;
  }
  private static  com.google.protobuf.Descriptors.FileDescriptor
      descriptor;
  static {
    java.lang.String[] descriptorData = {
      "\n+tensorflow/contrib/tpu/proto/topology." +
      "proto\022\016tensorflow.tpu\"t\n\rTopologyProto\022\022" +
      "\n\nmesh_shape\030\001 \003(\005\022\021\n\tnum_tasks\030\002 \001(\005\022 \n" +
      "\030num_tpu_devices_per_task\030\003 \001(\005\022\032\n\022devic" +
      "e_coordinates\030\004 \003(\005B\003\370\001\001b\006proto3"
    };
    com.google.protobuf.Descriptors.FileDescriptor.InternalDescriptorAssigner assigner =
        new com.google.protobuf.Descriptors.FileDescriptor.    InternalDescriptorAssigner() {
          public com.google.protobuf.ExtensionRegistry assignDescriptors(
              com.google.protobuf.Descriptors.FileDescriptor root) {
            descriptor = root;
            return null;
          }
        };
    com.google.protobuf.Descriptors.FileDescriptor
      .internalBuildGeneratedFileFrom(descriptorData,
        new com.google.protobuf.Descriptors.FileDescriptor[] {
        }, assigner);
    internal_static_tensorflow_tpu_TopologyProto_descriptor =
      getDescriptor().getMessageTypes().get(0);
    internal_static_tensorflow_tpu_TopologyProto_fieldAccessorTable = new
      com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(
        internal_static_tensorflow_tpu_TopologyProto_descriptor,
        new java.lang.String[] { "MeshShape", "NumTasks", "NumTpuDevicesPerTask", "DeviceCoordinates", });
  }

  // @@protoc_insertion_point(outer_class_scope)
}
