// DO NOT EDIT.
//
// Generated by the Swift generator plugin for the protocol buffer compiler.
// Source: tensorflow/core/protobuf/device_properties.proto
//
// For information on using the generated types, please see the documenation:
//   https://github.com/apple/swift-protobuf/

// Copyright 2017 The TensorFlow Authors. All Rights Reserved.
//
//Licensed under the Apache License, Version 2.0 (the "License");
//you may not use this file except in compliance with the License.
//You may obtain a copy of the License at
//
//http://www.apache.org/licenses/LICENSE-2.0
//
//Unless required by applicable law or agreed to in writing, software
//distributed under the License is distributed on an "AS IS" BASIS,
//WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//See the License for the specific language governing permissions and
//limitations under the License.
//==============================================================================

import Foundation
import SwiftProtobuf

// If the compiler emits an error on this type, it is because this file
// was generated by a version of the `protoc` Swift plug-in that is
// incompatible with the version of SwiftProtobuf to which you are linking.
// Please ensure that your are building against the same version of the API
// that was used to generate this file.
fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck {
  struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {}
  typealias Version = _2
}

public struct Tensorflow_DeviceProperties {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  /// Device type (CPU, GPU, ...)
  public var type: String = String()

  /// Vendor (Intel, nvidia, ...)
  public var vendor: String = String()

  /// Model (Haswell, K40, ...)
  public var model: String = String()

  /// Core Frequency in Mhz
  public var frequency: Int64 = 0

  /// Number of cores
  public var numCores: Int64 = 0

  /// Version of the tools and libraries used with this device (e.g. gcc 4.9,
  /// cudnn 5.1)
  public var environment: Dictionary<String,String> = [:]

  /// Number of registers per core.
  public var numRegisters: Int64 = 0

  /// L1 cache size in bytes
  public var l1CacheSize: Int64 = 0

  /// L2 cache size in bytes
  public var l2CacheSize: Int64 = 0

  /// L3 cache size in bytes
  public var l3CacheSize: Int64 = 0

  /// Shared memory size per multiprocessor in bytes. This field is
  /// applicable to GPUs only.
  public var sharedMemorySizePerMultiprocessor: Int64 = 0

  /// Memory size in bytes
  public var memorySize: Int64 = 0

  /// Memory bandwidth in KB/s
  public var bandwidth: Int64 = 0

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}
}

public struct Tensorflow_NamedDevice {
  // SwiftProtobuf.Message conformance is added in an extension below. See the
  // `Message` and `Message+*Additions` files in the SwiftProtobuf library for
  // methods supported on all messages.

  public var name: String {
    get {return _storage._name}
    set {_uniqueStorage()._name = newValue}
  }

  public var properties: Tensorflow_DeviceProperties {
    get {return _storage._properties ?? Tensorflow_DeviceProperties()}
    set {_uniqueStorage()._properties = newValue}
  }
  /// Returns true if `properties` has been explicitly set.
  public var hasProperties: Bool {return _storage._properties != nil}
  /// Clears the value of `properties`. Subsequent reads from it will return its default value.
  public mutating func clearProperties() {_uniqueStorage()._properties = nil}

  public var unknownFields = SwiftProtobuf.UnknownStorage()

  public init() {}

  fileprivate var _storage = _StorageClass.defaultInstance
}

// MARK: - Code below here is support for the SwiftProtobuf runtime.

fileprivate let _protobuf_package = "tensorflow"

extension Tensorflow_DeviceProperties: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = _protobuf_package + ".DeviceProperties"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "type"),
    2: .same(proto: "vendor"),
    3: .same(proto: "model"),
    4: .same(proto: "frequency"),
    5: .standard(proto: "num_cores"),
    6: .same(proto: "environment"),
    7: .standard(proto: "num_registers"),
    8: .standard(proto: "l1_cache_size"),
    9: .standard(proto: "l2_cache_size"),
    10: .standard(proto: "l3_cache_size"),
    11: .standard(proto: "shared_memory_size_per_multiprocessor"),
    12: .standard(proto: "memory_size"),
    13: .same(proto: "bandwidth"),
  ]

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    while let fieldNumber = try decoder.nextFieldNumber() {
      switch fieldNumber {
      case 1: try decoder.decodeSingularStringField(value: &self.type)
      case 2: try decoder.decodeSingularStringField(value: &self.vendor)
      case 3: try decoder.decodeSingularStringField(value: &self.model)
      case 4: try decoder.decodeSingularInt64Field(value: &self.frequency)
      case 5: try decoder.decodeSingularInt64Field(value: &self.numCores)
      case 6: try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufString,SwiftProtobuf.ProtobufString>.self, value: &self.environment)
      case 7: try decoder.decodeSingularInt64Field(value: &self.numRegisters)
      case 8: try decoder.decodeSingularInt64Field(value: &self.l1CacheSize)
      case 9: try decoder.decodeSingularInt64Field(value: &self.l2CacheSize)
      case 10: try decoder.decodeSingularInt64Field(value: &self.l3CacheSize)
      case 11: try decoder.decodeSingularInt64Field(value: &self.sharedMemorySizePerMultiprocessor)
      case 12: try decoder.decodeSingularInt64Field(value: &self.memorySize)
      case 13: try decoder.decodeSingularInt64Field(value: &self.bandwidth)
      default: break
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    if !self.type.isEmpty {
      try visitor.visitSingularStringField(value: self.type, fieldNumber: 1)
    }
    if !self.vendor.isEmpty {
      try visitor.visitSingularStringField(value: self.vendor, fieldNumber: 2)
    }
    if !self.model.isEmpty {
      try visitor.visitSingularStringField(value: self.model, fieldNumber: 3)
    }
    if self.frequency != 0 {
      try visitor.visitSingularInt64Field(value: self.frequency, fieldNumber: 4)
    }
    if self.numCores != 0 {
      try visitor.visitSingularInt64Field(value: self.numCores, fieldNumber: 5)
    }
    if !self.environment.isEmpty {
      try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap<SwiftProtobuf.ProtobufString,SwiftProtobuf.ProtobufString>.self, value: self.environment, fieldNumber: 6)
    }
    if self.numRegisters != 0 {
      try visitor.visitSingularInt64Field(value: self.numRegisters, fieldNumber: 7)
    }
    if self.l1CacheSize != 0 {
      try visitor.visitSingularInt64Field(value: self.l1CacheSize, fieldNumber: 8)
    }
    if self.l2CacheSize != 0 {
      try visitor.visitSingularInt64Field(value: self.l2CacheSize, fieldNumber: 9)
    }
    if self.l3CacheSize != 0 {
      try visitor.visitSingularInt64Field(value: self.l3CacheSize, fieldNumber: 10)
    }
    if self.sharedMemorySizePerMultiprocessor != 0 {
      try visitor.visitSingularInt64Field(value: self.sharedMemorySizePerMultiprocessor, fieldNumber: 11)
    }
    if self.memorySize != 0 {
      try visitor.visitSingularInt64Field(value: self.memorySize, fieldNumber: 12)
    }
    if self.bandwidth != 0 {
      try visitor.visitSingularInt64Field(value: self.bandwidth, fieldNumber: 13)
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: Tensorflow_DeviceProperties, rhs: Tensorflow_DeviceProperties) -> Bool {
    if lhs.type != rhs.type {return false}
    if lhs.vendor != rhs.vendor {return false}
    if lhs.model != rhs.model {return false}
    if lhs.frequency != rhs.frequency {return false}
    if lhs.numCores != rhs.numCores {return false}
    if lhs.environment != rhs.environment {return false}
    if lhs.numRegisters != rhs.numRegisters {return false}
    if lhs.l1CacheSize != rhs.l1CacheSize {return false}
    if lhs.l2CacheSize != rhs.l2CacheSize {return false}
    if lhs.l3CacheSize != rhs.l3CacheSize {return false}
    if lhs.sharedMemorySizePerMultiprocessor != rhs.sharedMemorySizePerMultiprocessor {return false}
    if lhs.memorySize != rhs.memorySize {return false}
    if lhs.bandwidth != rhs.bandwidth {return false}
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}

extension Tensorflow_NamedDevice: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
  public static let protoMessageName: String = _protobuf_package + ".NamedDevice"
  public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
    1: .same(proto: "name"),
    2: .same(proto: "properties"),
  ]

  fileprivate class _StorageClass {
    var _name: String = String()
    var _properties: Tensorflow_DeviceProperties? = nil

    static let defaultInstance = _StorageClass()

    private init() {}

    init(copying source: _StorageClass) {
      _name = source._name
      _properties = source._properties
    }
  }

  fileprivate mutating func _uniqueStorage() -> _StorageClass {
    if !isKnownUniquelyReferenced(&_storage) {
      _storage = _StorageClass(copying: _storage)
    }
    return _storage
  }

  public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
    _ = _uniqueStorage()
    try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
      while let fieldNumber = try decoder.nextFieldNumber() {
        switch fieldNumber {
        case 1: try decoder.decodeSingularStringField(value: &_storage._name)
        case 2: try decoder.decodeSingularMessageField(value: &_storage._properties)
        default: break
        }
      }
    }
  }

  public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
    try withExtendedLifetime(_storage) { (_storage: _StorageClass) in
      if !_storage._name.isEmpty {
        try visitor.visitSingularStringField(value: _storage._name, fieldNumber: 1)
      }
      if let v = _storage._properties {
        try visitor.visitSingularMessageField(value: v, fieldNumber: 2)
      }
    }
    try unknownFields.traverse(visitor: &visitor)
  }

  public static func ==(lhs: Tensorflow_NamedDevice, rhs: Tensorflow_NamedDevice) -> Bool {
    if lhs._storage !== rhs._storage {
      let storagesAreEqual: Bool = withExtendedLifetime((lhs._storage, rhs._storage)) { (_args: (_StorageClass, _StorageClass)) in
        let _storage = _args.0
        let rhs_storage = _args.1
        if _storage._name != rhs_storage._name {return false}
        if _storage._properties != rhs_storage._properties {return false}
        return true
      }
      if !storagesAreEqual {return false}
    }
    if lhs.unknownFields != rhs.unknownFields {return false}
    return true
  }
}
