Skip to content

Commit f638c65

Browse files
authored
Merge pull request #1 from tengyifei/master
Update Swift Protobuf to 1.0.0
2 parents c82e0c1 + 9ce3b8a commit f638c65

63 files changed

Lines changed: 4544 additions & 980 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ let package = Package(
2525
Target(name: "PerfectTensorFlow", dependencies: ["TensorFlowAPI"])
2626
],
2727
dependencies: [
28-
.Package(url: "https://github.com/apple/swift-protobuf.git", majorVersion:0)
28+
.Package(url: "https://github.com/apple/swift-protobuf.git", majorVersion:1)
2929
]
3030
)

Sources/PerfectTensorFlow/PerfectTensorFlow.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ public class TensorFlow {
201201
public typealias QueueRunnerDef = Tensorflow_QueueRunnerDef
202202
public typealias ReaderBaseState = Tensorflow_ReaderBaseState
203203
public typealias RemoteFusedGraphExecuteInfo = Tensorflow_RemoteFusedGraphExecuteInfo
204-
public typealias ResourceHandle = Tensorflow_ResourceHandle
204+
public typealias ResourceHandle = Tensorflow_ResourceHandleProto
205205
public typealias AutoParallelOptions = Tensorflow_AutoParallelOptions
206206
public typealias RewriterConfig = Tensorflow_RewriterConfig
207207
public typealias SavedModel = Tensorflow_SavedModel
@@ -249,10 +249,10 @@ public class TensorFlow {
249249
public typealias Tfcompile_Config = Tensorflow_Tfcompile_Config
250250
public typealias Tfprof_CodeDef = Tensorflow_Tfprof_CodeDef
251251
public typealias Tfprof_OpLogEntry = Tensorflow_Tfprof_OpLogEntry
252-
public typealias Tfprof_OpLog = Tensorflow_Tfprof_OpLog
252+
public typealias Tfprof_OpLog = Tensorflow_Tfprof_OpLogProto
253253
public typealias Tfprof_OptionsProto = Tensorflow_Tfprof_OptionsProto
254254
public typealias Tfprof_TFProfTensorProto = Tensorflow_Tfprof_TFProfTensorProto
255-
public typealias Tfprof_TFGraphNodeProto = Tensorflow_Tfprof_TFGraphNodeProto
255+
//public typealias Tfprof_TFGraphNodeProto = Tensorflow_Tfprof_TFGraphNodeProto
256256
//public typealias Tfprof_TFCodeNodeProto = Tensorflow_Tfprof_TFCodeNodeProto
257257
public typealias Contrib_Tensorboard_TraceInfo = Tensorflow_Contrib_Tensorboard_TraceInfo
258258
public typealias Contrib_Tensorboard_OpInfo = Tensorflow_Contrib_Tensorboard_OpInfo

Sources/PerfectTensorFlow/pb.api_objects.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,8 +403,9 @@ extension ThirdParty_Tensorflow_Tools_Api_TFAPIObject: SwiftProtobuf._MessageImp
403403

404404
public func _protobuf_generated_isEqualTo(other: ThirdParty_Tensorflow_Tools_Api_TFAPIObject) -> Bool {
405405
if _storage !== other._storage {
406-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
407-
let _storage = _args.0; let other_storage = _args.1
406+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
407+
let _storage = _args.0
408+
let other_storage = _args.1
408409
if _storage._path != other_storage._path {return false}
409410
if _storage._tfModule != other_storage._tfModule {return false}
410411
if _storage._tfClass != other_storage._tfClass {return false}

Sources/PerfectTensorFlow/pb.attr_value.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,9 @@ extension Tensorflow_AttrValue: SwiftProtobuf._MessageImplementationBase, SwiftP
460460

461461
public func _protobuf_generated_isEqualTo(other: Tensorflow_AttrValue) -> Bool {
462462
if _storage !== other._storage {
463-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
464-
let _storage = _args.0; let other_storage = _args.1
463+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
464+
let _storage = _args.0
465+
let other_storage = _args.1
465466
if _storage._value != other_storage._value {return false}
466467
return true
467468
}

Sources/PerfectTensorFlow/pb.compare_test.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,9 @@ extension CompareTest_Large: SwiftProtobuf._MessageImplementationBase, SwiftProt
617617

618618
public func _protobuf_generated_isEqualTo(other: CompareTest_Large) -> Bool {
619619
if _storage !== other._storage {
620-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
621-
let _storage = _args.0; let other_storage = _args.1
620+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
621+
let _storage = _args.0
622+
let other_storage = _args.1
622623
if _storage._string_ != other_storage._string_ {return false}
623624
if _storage._int64_ != other_storage._int64_ {return false}
624625
if _storage._float_ != other_storage._float_ {return false}

Sources/PerfectTensorFlow/pb.config.swift

Lines changed: 51 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@ public struct Tensorflow_GraphOptions: SwiftProtobuf.Message {
351351
}
352352

353353
/// Options that control the type and amount of graph rewriting.
354+
/// Not currently configurable via the public Python API (i.e. there is no API
355+
/// stability guarantee if you import RewriterConfig explicitly).
354356
public var rewriteOptions: Tensorflow_RewriterConfig {
355357
get {return _storage._rewriteOptions ?? Tensorflow_RewriterConfig()}
356358
set {_uniqueStorage()._rewriteOptions = newValue}
@@ -437,6 +439,23 @@ public struct Tensorflow_ThreadPoolOptionProto: SwiftProtobuf.Message {
437439
/// (see the declaration of the specific field for more info).
438440
public var numThreads: Int32 = 0
439441

442+
/// The global name of the threadpool.
443+
///
444+
/// If empty, then the threadpool is made and used according to the scope it's
445+
/// in - e.g., for a session threadpool, it is used by that session only.
446+
///
447+
/// If non-empty, then:
448+
/// - a global threadpool associated with this name is looked
449+
/// up or created. This allows, for example, sharing one threadpool across
450+
/// many sessions (e.g., like the default behavior, if
451+
/// inter_op_parallelism_threads is not configured), but still partitioning
452+
/// into a large and small pool.
453+
/// - if the threadpool for this global_name already exists, then it is an
454+
/// error if the existing pool was created using a different num_threads
455+
/// value as is specified on this call.
456+
/// - threadpools created this way are never garbage collected.
457+
public var globalName: String = String()
458+
440459
public var unknownFields = SwiftProtobuf.UnknownStorage()
441460

442461
public init() {}
@@ -449,6 +468,7 @@ public struct Tensorflow_ThreadPoolOptionProto: SwiftProtobuf.Message {
449468
while let fieldNumber = try decoder.nextFieldNumber() {
450469
switch fieldNumber {
451470
case 1: try decoder.decodeSingularInt32Field(value: &self.numThreads)
471+
case 2: try decoder.decodeSingularStringField(value: &self.globalName)
452472
default: break
453473
}
454474
}
@@ -462,6 +482,9 @@ public struct Tensorflow_ThreadPoolOptionProto: SwiftProtobuf.Message {
462482
if self.numThreads != 0 {
463483
try visitor.visitSingularInt32Field(value: self.numThreads, fieldNumber: 1)
464484
}
485+
if !self.globalName.isEmpty {
486+
try visitor.visitSingularStringField(value: self.globalName, fieldNumber: 2)
487+
}
465488
try unknownFields.traverse(visitor: &visitor)
466489
}
467490
}
@@ -555,13 +578,24 @@ public struct Tensorflow_ConfigProto: SwiftProtobuf.Message {
555578
}
556579

557580
/// This option is experimental - it may be replaced with a different mechanism
558-
/// in the future. The intended use is for when some session invocations need
559-
/// to run in a background pool limited to a small number of threads.
581+
/// in the future.
560582
///
561583
/// Configures session thread pools. If this is configured, then RunOptions for
562584
/// a Run call can select the thread pool to use.
563585
///
564-
/// If a pool's num_threads is 0, then inter_op_parallelism_threads is used.
586+
/// The intended use is for when some session invocations need to run in a
587+
/// background pool limited to a small number of threads:
588+
/// - For example, a session may be configured to have one large pool (for
589+
/// regular compute) and one small pool (for periodic, low priority work);
590+
/// using the small pool is currently the mechanism for limiting the inter-op
591+
/// parallelism of the low priority work. Note that it does not limit the
592+
/// parallelism of work spawned by a single op kernel implementation.
593+
/// - Using this setting is normally not needed in training, but may help some
594+
/// serving use cases.
595+
/// - It is also generally recommended to set the global_name field of this
596+
/// proto, to avoid creating multiple large pools. It is typically better to
597+
/// run the non-low-priority work, even across sessions, in a single large
598+
/// pool.
565599
public var sessionInterOpThreadPool: [Tensorflow_ThreadPoolOptionProto] {
566600
get {return _storage._sessionInterOpThreadPool}
567601
set {_uniqueStorage()._sessionInterOpThreadPool = newValue}
@@ -1055,8 +1089,9 @@ extension Tensorflow_GraphOptions: SwiftProtobuf._MessageImplementationBase, Swi
10551089

10561090
public func _protobuf_generated_isEqualTo(other: Tensorflow_GraphOptions) -> Bool {
10571091
if _storage !== other._storage {
1058-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
1059-
let _storage = _args.0; let other_storage = _args.1
1092+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
1093+
let _storage = _args.0
1094+
let other_storage = _args.1
10601095
if _storage._enableRecvScheduling != other_storage._enableRecvScheduling {return false}
10611096
if _storage._optimizerOptions != other_storage._optimizerOptions {return false}
10621097
if _storage._buildCostModel != other_storage._buildCostModel {return false}
@@ -1078,10 +1113,12 @@ extension Tensorflow_GraphOptions: SwiftProtobuf._MessageImplementationBase, Swi
10781113
extension Tensorflow_ThreadPoolOptionProto: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
10791114
public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [
10801115
1: .standard(proto: "num_threads"),
1116+
2: .standard(proto: "global_name"),
10811117
]
10821118

10831119
public func _protobuf_generated_isEqualTo(other: Tensorflow_ThreadPoolOptionProto) -> Bool {
10841120
if self.numThreads != other.numThreads {return false}
1121+
if self.globalName != other.globalName {return false}
10851122
if unknownFields != other.unknownFields {return false}
10861123
return true
10871124
}
@@ -1164,8 +1201,9 @@ extension Tensorflow_ConfigProto: SwiftProtobuf._MessageImplementationBase, Swif
11641201

11651202
public func _protobuf_generated_isEqualTo(other: Tensorflow_ConfigProto) -> Bool {
11661203
if _storage !== other._storage {
1167-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
1168-
let _storage = _args.0; let other_storage = _args.1
1204+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
1205+
let _storage = _args.0
1206+
let other_storage = _args.1
11691207
if _storage._deviceCount != other_storage._deviceCount {return false}
11701208
if _storage._intraOpParallelismThreads != other_storage._intraOpParallelismThreads {return false}
11711209
if _storage._interOpParallelismThreads != other_storage._interOpParallelismThreads {return false}
@@ -1227,8 +1265,9 @@ extension Tensorflow_RunOptions: SwiftProtobuf._MessageImplementationBase, Swift
12271265

12281266
public func _protobuf_generated_isEqualTo(other: Tensorflow_RunOptions) -> Bool {
12291267
if _storage !== other._storage {
1230-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
1231-
let _storage = _args.0; let other_storage = _args.1
1268+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
1269+
let _storage = _args.0
1270+
let other_storage = _args.1
12321271
if _storage._traceLevel != other_storage._traceLevel {return false}
12331272
if _storage._timeoutInMs != other_storage._timeoutInMs {return false}
12341273
if _storage._interOpThreadPool != other_storage._interOpThreadPool {return false}
@@ -1284,8 +1323,9 @@ extension Tensorflow_RunMetadata: SwiftProtobuf._MessageImplementationBase, Swif
12841323

12851324
public func _protobuf_generated_isEqualTo(other: Tensorflow_RunMetadata) -> Bool {
12861325
if _storage !== other._storage {
1287-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
1288-
let _storage = _args.0; let other_storage = _args.1
1326+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
1327+
let _storage = _args.0
1328+
let other_storage = _args.1
12891329
if _storage._stepStats != other_storage._stepStats {return false}
12901330
if _storage._costGraph != other_storage._costGraph {return false}
12911331
if _storage._partitionGraphs != other_storage._partitionGraphs {return false}

Sources/PerfectTensorFlow/pb.control_flow.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,9 @@ extension Tensorflow_CondContextDef: SwiftProtobuf._MessageImplementationBase, S
348348

349349
public func _protobuf_generated_isEqualTo(other: Tensorflow_CondContextDef) -> Bool {
350350
if _storage !== other._storage {
351-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
352-
let _storage = _args.0; let other_storage = _args.1
351+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
352+
let _storage = _args.0
353+
let other_storage = _args.1
353354
if _storage._contextName != other_storage._contextName {return false}
354355
if _storage._predName != other_storage._predName {return false}
355356
if _storage._pivotName != other_storage._pivotName {return false}
@@ -417,8 +418,9 @@ extension Tensorflow_WhileContextDef: SwiftProtobuf._MessageImplementationBase,
417418

418419
public func _protobuf_generated_isEqualTo(other: Tensorflow_WhileContextDef) -> Bool {
419420
if _storage !== other._storage {
420-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
421-
let _storage = _args.0; let other_storage = _args.1
421+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
422+
let _storage = _args.0
423+
let other_storage = _args.1
422424
if _storage._contextName != other_storage._contextName {return false}
423425
if _storage._parallelIterations != other_storage._parallelIterations {return false}
424426
if _storage._backProp != other_storage._backProp {return false}

Sources/PerfectTensorFlow/pb.cost_graph.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,8 +411,9 @@ extension Tensorflow_CostGraphDef.Node.OutputInfo: SwiftProtobuf._MessageImpleme
411411

412412
public func _protobuf_generated_isEqualTo(other: Tensorflow_CostGraphDef.Node.OutputInfo) -> Bool {
413413
if _storage !== other._storage {
414-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
415-
let _storage = _args.0; let other_storage = _args.1
414+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
415+
let _storage = _args.0
416+
let other_storage = _args.1
416417
if _storage._size != other_storage._size {return false}
417418
if _storage._aliasInputPort != other_storage._aliasInputPort {return false}
418419
if _storage._shape != other_storage._shape {return false}

Sources/PerfectTensorFlow/pb.cpp_shape_inference.swift

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,9 @@ extension Tensorflow_CppShapeInferenceResult: SwiftProtobuf._MessageImplementati
251251

252252
public func _protobuf_generated_isEqualTo(other: Tensorflow_CppShapeInferenceResult) -> Bool {
253253
if _storage !== other._storage {
254-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
255-
let _storage = _args.0; let other_storage = _args.1
254+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
255+
let _storage = _args.0
256+
let other_storage = _args.1
256257
if _storage._shape != other_storage._shape {return false}
257258
if _storage._handleData != other_storage._handleData {return false}
258259
return true
@@ -293,8 +294,9 @@ extension Tensorflow_CppShapeInferenceResult.HandleShapeAndType: SwiftProtobuf._
293294

294295
public func _protobuf_generated_isEqualTo(other: Tensorflow_CppShapeInferenceResult.HandleShapeAndType) -> Bool {
295296
if _storage !== other._storage {
296-
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) -> Bool in
297-
let _storage = _args.0; let other_storage = _args.1
297+
let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in
298+
let _storage = _args.0
299+
let other_storage = _args.1
298300
if _storage._shape != other_storage._shape {return false}
299301
if _storage._dtype != other_storage._dtype {return false}
300302
return true

0 commit comments

Comments
 (0)