├── .gitignore ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── GUIDE.md ├── GUIDE.zh_CN.md ├── ISSUE_TEMPLATE.md ├── LICENSE ├── PADockerfile ├── PROTO_VERSION ├── Package.swift ├── Package@swift-4.swift ├── README.md ├── README.zh_CN.md ├── Sources ├── PerfectTensorFlow │ ├── APILoader.swift │ ├── PerfectTensorFlow.swift │ ├── pb.allocation_description.swift │ ├── pb.api_def.swift │ ├── pb.api_objects.swift │ ├── pb.attr_value.swift │ ├── pb.bigquery_table_partition.swift │ ├── pb.checkpoint_state.swift │ ├── pb.checkpointable_object_graph.swift │ ├── pb.cluster.swift │ ├── pb.compare_test.swift │ ├── pb.config.swift │ ├── pb.control_flow.swift │ ├── pb.cost_graph.swift │ ├── pb.cpp_shape_inference.swift │ ├── pb.debug.swift │ ├── pb.debug_service.swift │ ├── pb.debugger_event_metadata.swift │ ├── pb.device_attributes.swift │ ├── pb.device_properties.swift │ ├── pb.error_codes.swift │ ├── pb.event.swift │ ├── pb.example.swift │ ├── pb.example_parser_configuration.swift │ ├── pb.example_proto_fast_parsing_test.swift │ ├── pb.feature.swift │ ├── pb.fertile_stats.swift │ ├── pb.function.swift │ ├── pb.gdr.swift │ ├── pb.generic_tree_model.swift │ ├── pb.generic_tree_model_extensions.swift │ ├── pb.graph.swift │ ├── pb.graph_explorer.swift │ ├── pb.graph_transfer_info.swift │ ├── pb.hlo.swift │ ├── pb.hparam.swift │ ├── pb.iterator.swift │ ├── pb.kernel_def.swift │ ├── pb.learner.swift │ ├── pb.log_memory.swift │ ├── pb.manifest.swift │ ├── pb.master.swift │ ├── pb.master_service.swift │ ├── pb.memmapped_file_system.swift │ ├── pb.meta_graph.swift │ ├── pb.model_flags.swift │ ├── pb.mpi_message.swift │ ├── pb.mpi_msg.swift │ ├── pb.named_tensor.swift │ ├── pb.node_def.swift │ ├── pb.op_def.swift │ ├── pb.op_gen_overrides.swift │ ├── pb.op_performance_data.swift │ ├── pb.op_profile.swift │ ├── pb.profile.swift │ ├── pb.projector_config.swift │ ├── pb.quantiles.swift │ ├── pb.queue_runner.swift │ ├── pb.reader_base.swift │ ├── pb.remote_fused_graph_execute_info.swift │ ├── pb.resource_handle.swift │ ├── pb.rewriter_config.swift │ ├── pb.saved_model.swift │ ├── pb.saved_tensor_slice.swift │ ├── pb.saver.swift │ ├── pb.session.swift │ ├── pb.split_info.swift │ ├── pb.step_stats.swift │ ├── pb.summary.swift │ ├── pb.tensor.swift │ ├── pb.tensor_bundle.swift │ ├── pb.tensor_description.swift │ ├── pb.tensor_forest_params.swift │ ├── pb.tensor_shape.swift │ ├── pb.tensor_slice.swift │ ├── pb.tensorflow_server.swift │ ├── pb.test.swift │ ├── pb.test_log.swift │ ├── pb.tf2xla.swift │ ├── pb.tf_op_stats.swift │ ├── pb.tfcompile.swift │ ├── pb.tfprof_log.swift │ ├── pb.tfprof_options.swift │ ├── pb.tfprof_output.swift │ ├── pb.toco_flags.swift │ ├── pb.topology.swift │ ├── pb.tpu_profiler.swift │ ├── pb.trace_events.swift │ ├── pb.trace_info.swift │ ├── pb.tree_config.swift │ ├── pb.types.swift │ ├── pb.variable.swift │ ├── pb.verbs_service.swift │ ├── pb.versions.swift │ ├── pb.worker.swift │ ├── pb.worker_service.swift │ ├── pb.xla.swift │ └── pb.xla_data.swift └── TensorFlowAPI │ ├── TensorFlowAPI.c │ └── include │ └── TensorFlowAPI.h ├── Tests ├── LinuxMain.swift └── PerfectTensorFlowTests │ └── PerfectTensorFlowTests.swift ├── VERSION ├── cleantest.sh ├── install.sh ├── prepare.sh ├── test.sh ├── testpack.tgz └── updateprotos.sh /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | /.bui* 3 | /Packages 4 | /*.xcodeproj 5 | *.pins 6 | *.pb 7 | *.txt 8 | *.resolved 9 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of experience, 9 | nationality, personal appearance, race, religion, or sexual identity and 10 | orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behaviour that contributes to creating a positive environment 15 | include: 16 | 17 | * Using welcoming and inclusive language 18 | * Being respectful of differing viewpoints and experiences 19 | * Gracefully accepting constructive criticism 20 | * Focusing on what is best for the community 21 | * Showing empathy towards other community members 22 | 23 | Examples of unacceptable behaviour by participants include: 24 | 25 | * The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | * Trolling, insulting/derogatory comments, and personal or political attacks 28 | * Public or private harassment 29 | * Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | * Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behaviour and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behaviour. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or 41 | reject comments, commits, code, wiki edits, issues, and other contributions 42 | that are not aligned to this Code of Conduct, or to ban temporarily or 43 | permanently any contributor for other behaviours that they deem inappropriate, 44 | threatening, offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behaviour may be 58 | reported by contacting the project team at [mailto:info@perfect.org]. All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an incident. 62 | Further details of specific enforcement policies may be posted separately. 63 | 64 | Project maintainers who do not follow or enforce the Code of Conduct in good 65 | faith may face temporary or permanent repercussions as determined by other 66 | members of the project's leadership. 67 | 68 | ## Attribution 69 | 70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, 71 | available at [http://contributor-covenant.org/version/1/4][version] 72 | 73 | [homepage]: http://contributor-covenant.org 74 | [version]: http://contributor-covenant.org/version/1/4/ 75 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | # Join and Contribute to the Community 3 | 4 | The Swift-Perfect developer community is vital to improving Perfect and supporting one another. 5 | 6 | You can help other developers by sharing your expertise and tips, as well as learn from others, by joining the [Perfect Slack channel](http://perfect.ly). Contributions of all kinds are welcome: reporting issues, updating documentation, fixing bugs, building examples, sharing projects, and any other tips that may help the Swift-Perfect community. 7 | 8 | If you would like to report an issue, make a new feature request, or help others by working on a known issue, please see the [Perfect JIRA repository](http://jira.perfect.org:8080/secure/Dashboard.jspa). 9 | 10 | If you would like to share your example project, tutorial, or video, please share the URL of your work on GitHub and [Twitter](https://twitter.com/perfectlysoft), and the Perfect team will highlight it to the community. 11 | 12 | 13 | ## Now WeChat Subscription is Available (Chinese) 14 |

15 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Issues 2 | 3 | We are transitioning to using JIRA for all bugs and support related issues, therefore the GitHub issues has been disabled. 4 | 5 | If you find a mistake, bug, or any other helpful suggestion you'd like to make on the docs please head over to 6 | [Perfect JIRA](http://jira.perfect.org:8080/servicedesk/customer/portal/1) and raise it. 7 | 8 | A comprehensive list of open issues can be found at [JIRA Open Issues](http://jira.perfect.org:8080/projects/ISS/issues) 9 | -------------------------------------------------------------------------------- /PADockerfile: -------------------------------------------------------------------------------- 1 | RUN VER=`cat VERSION` && wget https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-$VER.tar.gz -O /tmp/tflib.tgz && tar xvf /tmp/tflib.tgz -C /usr/local ./lib/libtensorflow.so ./lib/libtensorflow_framework.so && touch /usr/local/lib/libtensorflow.so && touch /usr/local/lib/libtensorflow_framework.so && ldconfig && rm /tmp/tflib.tgz 2 | -------------------------------------------------------------------------------- /PROTO_VERSION: -------------------------------------------------------------------------------- 1 | 1.4.1 2 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.0 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | // 4 | // Package.swift 5 | // Perfect-TensorFlow 6 | // 7 | // Created by Rockford Wei on 2017-05-18. 8 | // Copyright © 2017 PerfectlySoft. All rights reserved. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // This source file is part of the Perfect.org open source project 13 | // 14 | // Copyright (c) 2017 - 2018 PerfectlySoft Inc. and the Perfect project authors 15 | // Licensed under Apache License v2.0 16 | // 17 | // See http://perfect.org/licensing.html for license information 18 | // 19 | //===----------------------------------------------------------------------===// 20 | // 21 | 22 | import PackageDescription 23 | #if os(OSX) 24 | import Darwin 25 | #else 26 | import Glibc 27 | #endif 28 | let package = Package( 29 | name: "PerfectTensorFlow", 30 | products: [ 31 | .library( 32 | name: "PerfectTensorFlow", 33 | targets: ["PerfectTensorFlow"]), 34 | ], 35 | dependencies: [ 36 | .package(url: "https://github.com/apple/swift-protobuf.git", from: "1.0.0") 37 | ], 38 | targets: [ 39 | .target( 40 | name: "TensorFlowAPI", 41 | dependencies: []), 42 | .target( 43 | name: "PerfectTensorFlow", 44 | dependencies: ["TensorFlowAPI", "SwiftProtobuf"], 45 | exclude:[]), 46 | .testTarget( 47 | name: "PerfectTensorFlowTests", 48 | dependencies: ["PerfectTensorFlow"]), 49 | ] 50 | ) 51 | -------------------------------------------------------------------------------- /Package@swift-4.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:4.0 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | // 4 | // Package.swift 5 | // Perfect-TensorFlow 6 | // 7 | // Created by Rockford Wei on 2017-05-18. 8 | // Copyright © 2017 PerfectlySoft. All rights reserved. 9 | // 10 | //===----------------------------------------------------------------------===// 11 | // 12 | // This source file is part of the Perfect.org open source project 13 | // 14 | // Copyright (c) 2017 - 2018 PerfectlySoft Inc. and the Perfect project authors 15 | // Licensed under Apache License v2.0 16 | // 17 | // See http://perfect.org/licensing.html for license information 18 | // 19 | //===----------------------------------------------------------------------===// 20 | // 21 | 22 | import PackageDescription 23 | #if os(OSX) 24 | import Darwin 25 | #else 26 | import Glibc 27 | #endif 28 | let package = Package( 29 | name: "PerfectTensorFlow", 30 | products: [ 31 | .library( 32 | name: "PerfectTensorFlow", 33 | targets: ["PerfectTensorFlow"]), 34 | ], 35 | dependencies: [ 36 | .package(url: "https://github.com/apple/swift-protobuf.git", .exact("1.5.0")) 37 | ], 38 | targets: [ 39 | .target( 40 | name: "TensorFlowAPI", 41 | dependencies: []), 42 | .target( 43 | name: "PerfectTensorFlow", 44 | dependencies: ["TensorFlowAPI", "SwiftProtobuf"], 45 | exclude:[]), 46 | .testTarget( 47 | name: "PerfectTensorFlowTests", 48 | dependencies: ["PerfectTensorFlow"]), 49 | ] 50 | ) 51 | -------------------------------------------------------------------------------- /README.zh_CN.md: -------------------------------------------------------------------------------- 1 | # Perfect TensorFlow 2 | 3 |

4 | 5 | Get Involved with Perfect! 6 | 7 |

8 | 9 |

10 | 11 | Star Perfect On Github 12 | 13 | 14 | Stack Overflow 15 | 16 | 17 | Follow Perfect on Twitter 18 | 19 | 20 | Join the Perfect Slack 21 | 22 |

23 | 24 |

25 | 26 | Swift 4.1 27 | 28 | 29 | Platforms OS X | Linux 30 | 31 | 32 | License Apache 33 | 34 | 35 | PerfectlySoft Twitter 36 | 37 | 38 | Slack Status 39 | 40 |

41 | 42 | 本项目为TensorFlow的C语言接口试验性封装函数库,用于Swift在人工智能深度学习上的应用。 43 | 44 | 本项目需要使用SPM软件包管理器编译并是[Perfect项目](https://github.com/PerfectlySoft/Perfect)的一个组成部分,但也可以独立使用。 45 | 46 | 请确保您的系统已经安装了Swift 4.1.1 / Xcode 9.3 47 | 48 | ## 项目状态 49 | 50 | 目前本函数库遵从 TensorFlow v1.8.0 C语言 API 功能特征。 51 | 52 | ## 关于开发 53 | 54 | 以下文件构成了Perfect-TensorFlow核心: 55 | 56 | ``` 57 | Sources 58 | ├── PerfectTensorFlow 59 | │   ├── APILoader.swift (1000+ 行代码,直接从tensorflow/c/c_api.h翻译而来) 60 | │   ├── PerfectTensorFlow.swift (2700+ 行代码) 61 | └── TensorFlowAPI 62 | ├── TensorFlowAPI.c (72 行代码) 63 | └── include 64 | └── TensorFlowAPI.h (138 行代码) 65 | ``` 66 | 67 | 所有以`pb.*.swift`命名的文件(总共目前超过四万五千行)都是从根目录下的 `updateprotos.sh` 文件自动创建的。很不幸的是,用了这个脚本之后,您仍然需要手工编辑 **PerfectTensorFlow.swift** 中的 `public typealias`部分以保持编译一致。 68 | 69 | 迄今为止暂时没有计划在Swift源代码中创建这些源文件,原因是因为Perfect-TensorFlow是Perfect软件框架体系组成部分之一,虽然可以独立使用,但是也必须符合Perfect的SPM软件包管理器编译标准。尽管如此,我们当然欢迎各类项目合并更新申请、各类意见和建议! 70 | 71 | ## 编程指南 72 | 73 | 详细编程指南请参考这里: [Perfect TensorFlow 编程指南](GUIDE.zh_CN.md)。 74 | 75 | 另外,本项目同样包括了丰富的各种TensorFlow接口特性,比如**TensorFlow event事件** 和 **summary 总结**,用于 **TensorBoard**统计分析模型指标。详见 [Perfect TensorFlow 测试脚本](Tests/PerfectTensorFlowTests/PerfectTensorFlowTests.swift)。 76 | 77 | ## 快速上手 78 | 79 | ### TensorFlow API C语言库函数安装 80 | 81 | Perfect-TensorFlow 是基于其C语言函数库基础上的,简单说来就是您的计算机上在运行时必须安装 `libtensorflow.so` 和 `libtensorflow_framework.so` 动态链接库。 82 | 83 | 本项目包含了一个用于快速安装该链接库 CPU 版本的脚本,默认安装路径为`/usr/local/lib`。您可以根据平台要求下载并运行 [`install.sh`](https://github.com/PerfectlySoft/Perfect-TensorFlow/blob/master/install.sh)。运行该脚本之前请确定 `curl`已经安装到您的计算机上。 84 | 85 | 86 | 更多的安装选项,如需要在同一台计算机上同时安装CPU/GPU或者多个不同版本,请参考官网网站: [Installing TensorFlow for C](https://www.tensorflow.org/install/install_c) 87 | 88 | ### Perfect TensorFlow 应用程序 89 | 90 | 使用之前请在您的项目Package.swift文件中增加依存关系并选择**最新版本**: 91 | 92 | ``` swift 93 | .package(url: "https://github.com/PerfectlySoft/Perfect-TensorFlow.git", from: "1.4.0") 94 | ``` 95 | 同一个文件中还要在`target` 目标段声明依存关系: 96 | 97 | ``` swift 98 | dependencies: ["PerfectTensorFlow"] 99 | ``` 100 | 101 | 然后声明函数库: 102 | 103 | ``` swift 104 | // TensorFlowAPI 就是定义在 libtensorflow.so的部分函数集 105 | import TensorFlowAPI 106 | 107 | // 这是我们主要介绍的TensorFlow对象封装库 108 | import PerfectTensorFlow 109 | 110 | // 为了保持与其他语言函数库版本(比如Python或者Java)的命名规范一致性, 111 | // 为TensorFlow对象取一个缩写名称是个好主意: 112 | public typealias TF = TensorFlow 113 | ``` 114 | 115 | ### 激活函数库 116 | 117 | ⚠️注意⚠️ 在使用 Perfect TensorFlow 的 **任何具体函数之前**,必须首先调用`TF.Open()`方法: 118 | 119 | ``` swift 120 | // 这个操作会打开 /usr/local/lib/libtensorflow.so 动态链接库 121 | try TF.Open() 122 | ``` 123 | 124 | 另外,您还可以激活其他不同规格(CPU/GPU)版本的函数库,所需要的操作就是输入目标函数库路径: 125 | ``` swift 126 | // 以下操作将打开非默认路径下的函数库: 127 | try TF.Open("/path/to/DLL/of/libtensorflow.so") 128 | ``` 129 | 130 | ### "你好,Perfect TensorFlow!" 131 | 132 | 以下是 Swift 版本的 "你好, TensorFlow!": 133 | 134 | ``` swift 135 | // 定义一个字符串型张量: 136 | let tensor = try TF.Tensor.Scalar("你好,Perfect TensorFlow! 🇨🇳🇨🇦") 137 | 138 | // 声明一个流程图 139 | let g = try TF.Graph() 140 | 141 | // 将张量节点加入流程图 142 | let op = try g.const(tensor: tensor, name: "hello") 143 | 144 | // 根据流程图生成会话并运行 145 | let o = try g.runner().fetch(op).addTarget(op).run() 146 | 147 | // 解码 148 | let decoded = try TF.Decode(strings: o[0].data, count: 1) 149 | 150 | // 检查结果 151 | let s2 = decoded[0].string 152 | print(s2) 153 | ``` 154 | 155 | ### 矩阵操作 156 | 157 | 您可以注意到,其实Swift版本的TensorFlow与其原版内容的概念都是完全一致的,比如创建张量节点,保存节点到流程图、定义操作并运行会话、最后检查结果。 158 | 159 | 以下是使用Perfect TensorFlow进行矩阵操作的例子: 160 | 161 | ``` swift 162 | /* 矩阵乘法 163 | | 1 2 | |0 1| |0 1| 164 | | 3 4 | * |0 0| = |0 3| 165 | */ 166 | // 输入矩阵 167 | let tA = try TF.Tensor.Matrix([[1, 2], [3, 4]]) 168 | let tB = try TF.Tensor.Matrix([[0, 0], [1, 0]]) 169 | 170 | // 将张量转化为流程图节点 171 | let g = try TF.Graph() 172 | let A = try g.const(tensor: tA, name: "Const_0") 173 | let B = try g.const(tensor: tB, name: "Const_1") 174 | 175 | // 定义矩阵乘法操作,即 v = A x Bt,B矩阵的转置 176 | let v = try g.matMul(l: A, r: B, name: "v", transposeB: true) 177 | 178 | // 运行会话 179 | let o = try g.runner().fetch(v).addTarget(v).run() 180 | let m:[Float] = try o[0].asArray() 181 | print(m) 182 | // m 的值应该是 [0, 1, 0, 3] 183 | ``` 184 | 185 | ### 动态加载已保存的人工神经网络模型 186 | 187 | 除了动态建立流程图和会话方法之外,Perfect TensorFlow 还提供了将预先保存的模型在运行时加载的简单方法,即从文件中直接还原会话: 188 | 189 | ``` swift 190 | let g = try TF.Graph() 191 | 192 | // 读取模型的签名信息 193 | let metaBuf = try TF.Buffer() 194 | 195 | // 还原会话 196 | let session = try g.load( 197 | exportDir: "/path/to/saved/model", 198 | tags: ["tag1", "tag2", ...], 199 | metaGraphDef: metaBuf) 200 | ``` 201 | 202 | ### 机器视觉服务器展示 203 | 204 | 您可以参考下列网址获得Perfect TensorFlow在人工智能机器视觉服务器上的应用:[Perfect TensorFlow Demo](https://github.com/PerfectExamples/Perfect-TensorFlow-Demo-Vision),在这个服务器上您可以上传或者手绘任何一个图片来测试服务器是否认得这个物品: 205 | 206 | 207 | 208 | ## 更多信息 209 | 关于本项目更多内容,请参考[perfect.org](http://perfect.org). 210 | 211 | ## 扫一扫 Perfect 官网微信号 212 |

213 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.allocation_description.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/allocation_description.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | public struct Tensorflow_AllocationDescription: SwiftProtobuf.Message { 23 | public static let protoMessageName: String = _protobuf_package + ".AllocationDescription" 24 | 25 | /// Total number of bytes requested 26 | public var requestedBytes: Int64 = 0 27 | 28 | /// Total number of bytes allocated if known 29 | public var allocatedBytes: Int64 = 0 30 | 31 | /// Name of the allocator used 32 | public var allocatorName: String = String() 33 | 34 | /// Identifier of the allocated buffer if known 35 | public var allocationID: Int64 = 0 36 | 37 | /// Set if this tensor only has one remaining reference 38 | public var hasSingleReference_p: Bool = false 39 | 40 | /// Address of the allocation. 41 | public var ptr: UInt64 = 0 42 | 43 | public var unknownFields = SwiftProtobuf.UnknownStorage() 44 | 45 | public init() {} 46 | 47 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 48 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 49 | /// initializers are defined in the SwiftProtobuf library. See the Message and 50 | /// Message+*Additions` files. 51 | public mutating func decodeMessage(decoder: inout D) throws { 52 | while let fieldNumber = try decoder.nextFieldNumber() { 53 | switch fieldNumber { 54 | case 1: try decoder.decodeSingularInt64Field(value: &self.requestedBytes) 55 | case 2: try decoder.decodeSingularInt64Field(value: &self.allocatedBytes) 56 | case 3: try decoder.decodeSingularStringField(value: &self.allocatorName) 57 | case 4: try decoder.decodeSingularInt64Field(value: &self.allocationID) 58 | case 5: try decoder.decodeSingularBoolField(value: &self.hasSingleReference_p) 59 | case 6: try decoder.decodeSingularUInt64Field(value: &self.ptr) 60 | default: break 61 | } 62 | } 63 | } 64 | 65 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 66 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 67 | /// other serializer methods are defined in the SwiftProtobuf library. See the 68 | /// `Message` and `Message+*Additions` files. 69 | public func traverse(visitor: inout V) throws { 70 | if self.requestedBytes != 0 { 71 | try visitor.visitSingularInt64Field(value: self.requestedBytes, fieldNumber: 1) 72 | } 73 | if self.allocatedBytes != 0 { 74 | try visitor.visitSingularInt64Field(value: self.allocatedBytes, fieldNumber: 2) 75 | } 76 | if !self.allocatorName.isEmpty { 77 | try visitor.visitSingularStringField(value: self.allocatorName, fieldNumber: 3) 78 | } 79 | if self.allocationID != 0 { 80 | try visitor.visitSingularInt64Field(value: self.allocationID, fieldNumber: 4) 81 | } 82 | if self.hasSingleReference_p != false { 83 | try visitor.visitSingularBoolField(value: self.hasSingleReference_p, fieldNumber: 5) 84 | } 85 | if self.ptr != 0 { 86 | try visitor.visitSingularUInt64Field(value: self.ptr, fieldNumber: 6) 87 | } 88 | try unknownFields.traverse(visitor: &visitor) 89 | } 90 | } 91 | 92 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 93 | 94 | fileprivate let _protobuf_package = "tensorflow" 95 | 96 | extension Tensorflow_AllocationDescription: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 97 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 98 | 1: .standard(proto: "requested_bytes"), 99 | 2: .standard(proto: "allocated_bytes"), 100 | 3: .standard(proto: "allocator_name"), 101 | 4: .standard(proto: "allocation_id"), 102 | 5: .standard(proto: "has_single_reference"), 103 | 6: .same(proto: "ptr"), 104 | ] 105 | 106 | public func _protobuf_generated_isEqualTo(other: Tensorflow_AllocationDescription) -> Bool { 107 | if self.requestedBytes != other.requestedBytes {return false} 108 | if self.allocatedBytes != other.allocatedBytes {return false} 109 | if self.allocatorName != other.allocatorName {return false} 110 | if self.allocationID != other.allocationID {return false} 111 | if self.hasSingleReference_p != other.hasSingleReference_p {return false} 112 | if self.ptr != other.ptr {return false} 113 | if unknownFields != other.unknownFields {return false} 114 | return true 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.bigquery_table_partition.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/contrib/cloud/kernels/bigquery_table_partition.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// This proto specifies a table partition in BigQuery. 23 | public struct Tensorflow_BigQueryTablePartition: SwiftProtobuf.Message { 24 | public static let protoMessageName: String = _protobuf_package + ".BigQueryTablePartition" 25 | 26 | /// [start_index, end_index] specify the boundaries of a partition. 27 | /// If end_index is -1, every row starting from start_index is part of the 28 | /// partition. 29 | public var startIndex: Int64 = 0 30 | 31 | public var endIndex: Int64 = 0 32 | 33 | public var unknownFields = SwiftProtobuf.UnknownStorage() 34 | 35 | public init() {} 36 | 37 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 38 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 39 | /// initializers are defined in the SwiftProtobuf library. See the Message and 40 | /// Message+*Additions` files. 41 | public mutating func decodeMessage(decoder: inout D) throws { 42 | while let fieldNumber = try decoder.nextFieldNumber() { 43 | switch fieldNumber { 44 | case 1: try decoder.decodeSingularInt64Field(value: &self.startIndex) 45 | case 2: try decoder.decodeSingularInt64Field(value: &self.endIndex) 46 | default: break 47 | } 48 | } 49 | } 50 | 51 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 52 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 53 | /// other serializer methods are defined in the SwiftProtobuf library. See the 54 | /// `Message` and `Message+*Additions` files. 55 | public func traverse(visitor: inout V) throws { 56 | if self.startIndex != 0 { 57 | try visitor.visitSingularInt64Field(value: self.startIndex, fieldNumber: 1) 58 | } 59 | if self.endIndex != 0 { 60 | try visitor.visitSingularInt64Field(value: self.endIndex, fieldNumber: 2) 61 | } 62 | try unknownFields.traverse(visitor: &visitor) 63 | } 64 | } 65 | 66 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 67 | 68 | fileprivate let _protobuf_package = "tensorflow" 69 | 70 | extension Tensorflow_BigQueryTablePartition: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 71 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 72 | 1: .standard(proto: "start_index"), 73 | 2: .standard(proto: "end_index"), 74 | ] 75 | 76 | public func _protobuf_generated_isEqualTo(other: Tensorflow_BigQueryTablePartition) -> Bool { 77 | if self.startIndex != other.startIndex {return false} 78 | if self.endIndex != other.endIndex {return false} 79 | if unknownFields != other.unknownFields {return false} 80 | return true 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.checkpoint_state.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/python/training/checkpoint_state.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// Protocol buffer representing the checkpoint state. 23 | /// 24 | /// TODO(touts): Add other attributes as needed. 25 | public struct Tensorflow_CheckpointState: SwiftProtobuf.Message { 26 | public static let protoMessageName: String = _protobuf_package + ".CheckpointState" 27 | 28 | /// Path to the most-recent model checkpoint. 29 | public var modelCheckpointPath: String = String() 30 | 31 | /// Paths to all not-yet-deleted model checkpoints, sorted from oldest to 32 | /// newest. 33 | /// Note that the value of model_checkpoint_path should be the last item in 34 | /// this list. 35 | public var allModelCheckpointPaths: [String] = [] 36 | 37 | public var unknownFields = SwiftProtobuf.UnknownStorage() 38 | 39 | public init() {} 40 | 41 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 42 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 43 | /// initializers are defined in the SwiftProtobuf library. See the Message and 44 | /// Message+*Additions` files. 45 | public mutating func decodeMessage(decoder: inout D) throws { 46 | while let fieldNumber = try decoder.nextFieldNumber() { 47 | switch fieldNumber { 48 | case 1: try decoder.decodeSingularStringField(value: &self.modelCheckpointPath) 49 | case 2: try decoder.decodeRepeatedStringField(value: &self.allModelCheckpointPaths) 50 | default: break 51 | } 52 | } 53 | } 54 | 55 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 56 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 57 | /// other serializer methods are defined in the SwiftProtobuf library. See the 58 | /// `Message` and `Message+*Additions` files. 59 | public func traverse(visitor: inout V) throws { 60 | if !self.modelCheckpointPath.isEmpty { 61 | try visitor.visitSingularStringField(value: self.modelCheckpointPath, fieldNumber: 1) 62 | } 63 | if !self.allModelCheckpointPaths.isEmpty { 64 | try visitor.visitRepeatedStringField(value: self.allModelCheckpointPaths, fieldNumber: 2) 65 | } 66 | try unknownFields.traverse(visitor: &visitor) 67 | } 68 | } 69 | 70 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 71 | 72 | fileprivate let _protobuf_package = "tensorflow" 73 | 74 | extension Tensorflow_CheckpointState: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 75 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 76 | 1: .standard(proto: "model_checkpoint_path"), 77 | 2: .standard(proto: "all_model_checkpoint_paths"), 78 | ] 79 | 80 | public func _protobuf_generated_isEqualTo(other: Tensorflow_CheckpointState) -> Bool { 81 | if self.modelCheckpointPath != other.modelCheckpointPath {return false} 82 | if self.allModelCheckpointPaths != other.allModelCheckpointPaths {return false} 83 | if unknownFields != other.unknownFields {return false} 84 | return true 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.cluster.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/protobuf/cluster.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | // Copyright 2016 The TensorFlow Authors. All Rights Reserved. 10 | // 11 | //Licensed under the Apache License, Version 2.0 (the "License"); 12 | //you may not use this file except in compliance with the License. 13 | //You may obtain a copy of the License at 14 | // 15 | //http://www.apache.org/licenses/LICENSE-2.0 16 | // 17 | //Unless required by applicable law or agreed to in writing, software 18 | //distributed under the License is distributed on an "AS IS" BASIS, 19 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | //See the License for the specific language governing permissions and 21 | //limitations under the License. 22 | //============================================================================== 23 | 24 | import Foundation 25 | import SwiftProtobuf 26 | 27 | // If the compiler emits an error on this type, it is because this file 28 | // was generated by a version of the `protoc` Swift plug-in that is 29 | // incompatible with the version of SwiftProtobuf to which you are linking. 30 | // Please ensure that your are building against the same version of the API 31 | // that was used to generate this file. 32 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 33 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 34 | typealias Version = _2 35 | } 36 | 37 | /// Defines a single job in a TensorFlow cluster. 38 | public struct Tensorflow_JobDef: SwiftProtobuf.Message { 39 | public static let protoMessageName: String = _protobuf_package + ".JobDef" 40 | 41 | /// The name of this job. 42 | public var name: String = String() 43 | 44 | /// Mapping from task ID to "hostname:port" string. 45 | /// 46 | /// If the `name` field contains "worker", and the `tasks` map contains a 47 | /// mapping from 7 to "example.org:2222", then the device prefix 48 | /// "/job:worker/task:7" will be assigned to "example.org:2222". 49 | public var tasks: Dictionary = [:] 50 | 51 | public var unknownFields = SwiftProtobuf.UnknownStorage() 52 | 53 | public init() {} 54 | 55 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 56 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 57 | /// initializers are defined in the SwiftProtobuf library. See the Message and 58 | /// Message+*Additions` files. 59 | public mutating func decodeMessage(decoder: inout D) throws { 60 | while let fieldNumber = try decoder.nextFieldNumber() { 61 | switch fieldNumber { 62 | case 1: try decoder.decodeSingularStringField(value: &self.name) 63 | case 2: try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.tasks) 64 | default: break 65 | } 66 | } 67 | } 68 | 69 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 70 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 71 | /// other serializer methods are defined in the SwiftProtobuf library. See the 72 | /// `Message` and `Message+*Additions` files. 73 | public func traverse(visitor: inout V) throws { 74 | if !self.name.isEmpty { 75 | try visitor.visitSingularStringField(value: self.name, fieldNumber: 1) 76 | } 77 | if !self.tasks.isEmpty { 78 | try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.tasks, fieldNumber: 2) 79 | } 80 | try unknownFields.traverse(visitor: &visitor) 81 | } 82 | } 83 | 84 | /// Defines a TensorFlow cluster as a set of jobs. 85 | public struct Tensorflow_ClusterDef: SwiftProtobuf.Message { 86 | public static let protoMessageName: String = _protobuf_package + ".ClusterDef" 87 | 88 | /// The jobs that comprise the cluster. 89 | public var job: [Tensorflow_JobDef] = [] 90 | 91 | public var unknownFields = SwiftProtobuf.UnknownStorage() 92 | 93 | public init() {} 94 | 95 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 96 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 97 | /// initializers are defined in the SwiftProtobuf library. See the Message and 98 | /// Message+*Additions` files. 99 | public mutating func decodeMessage(decoder: inout D) throws { 100 | while let fieldNumber = try decoder.nextFieldNumber() { 101 | switch fieldNumber { 102 | case 1: try decoder.decodeRepeatedMessageField(value: &self.job) 103 | default: break 104 | } 105 | } 106 | } 107 | 108 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 109 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 110 | /// other serializer methods are defined in the SwiftProtobuf library. See the 111 | /// `Message` and `Message+*Additions` files. 112 | public func traverse(visitor: inout V) throws { 113 | if !self.job.isEmpty { 114 | try visitor.visitRepeatedMessageField(value: self.job, fieldNumber: 1) 115 | } 116 | try unknownFields.traverse(visitor: &visitor) 117 | } 118 | } 119 | 120 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 121 | 122 | fileprivate let _protobuf_package = "tensorflow" 123 | 124 | extension Tensorflow_JobDef: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 125 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 126 | 1: .same(proto: "name"), 127 | 2: .same(proto: "tasks"), 128 | ] 129 | 130 | public func _protobuf_generated_isEqualTo(other: Tensorflow_JobDef) -> Bool { 131 | if self.name != other.name {return false} 132 | if self.tasks != other.tasks {return false} 133 | if unknownFields != other.unknownFields {return false} 134 | return true 135 | } 136 | } 137 | 138 | extension Tensorflow_ClusterDef: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 139 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 140 | 1: .same(proto: "job"), 141 | ] 142 | 143 | public func _protobuf_generated_isEqualTo(other: Tensorflow_ClusterDef) -> Bool { 144 | if self.job != other.job {return false} 145 | if unknownFields != other.unknownFields {return false} 146 | return true 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.debug.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/protobuf/debug.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// EXPERIMENTAL. Option for watching a node. 23 | public struct Tensorflow_DebugTensorWatch: SwiftProtobuf.Message { 24 | public static let protoMessageName: String = _protobuf_package + ".DebugTensorWatch" 25 | 26 | /// Name of the node to watch. 27 | public var nodeName: String = String() 28 | 29 | /// Output slot to watch. 30 | /// The semantics of output_slot == -1 is that the node is only watched for 31 | /// completion, but not for any output tensors. See NodeCompletionCallback 32 | /// in debug_gateway.h. 33 | /// TODO(cais): Implement this semantics. 34 | public var outputSlot: Int32 = 0 35 | 36 | /// Name(s) of the debugging op(s). 37 | /// One or more than one probes on a tensor. 38 | /// e.g., {"DebugIdentity", "DebugNanCount"} 39 | public var debugOps: [String] = [] 40 | 41 | /// URL(s) for debug targets(s). 42 | /// 43 | /// Supported URL formats are: 44 | /// - file:///foo/tfdbg_dump: Writes out Event content to file 45 | /// /foo/tfdbg_dump. Assumes all directories can be created if they don't 46 | /// already exist. 47 | /// - grpc://localhost:11011: Sends an RPC request to an EventListener 48 | /// service running at localhost:11011 with the event. 49 | /// - memcbk:///event_key: Routes tensors to clients using the 50 | /// callback registered with the DebugCallbackRegistry for event_key. 51 | /// 52 | /// Each debug op listed in debug_ops will publish its output tensor (debug 53 | /// signal) to all URLs in debug_urls. 54 | /// 55 | /// N.B. Session::Run() supports concurrent invocations of the same inputs 56 | /// (feed keys), outputs and target nodes. If such concurrent invocations 57 | /// are to be debugged, the callers of Session::Run() must use distinct 58 | /// debug_urls to make sure that the streamed or dumped events do not overlap 59 | /// among the invocations. 60 | /// TODO(cais): More visible documentation of this in g3docs. 61 | public var debugUrls: [String] = [] 62 | 63 | /// Do not error out if debug op creation fails (e.g., due to dtype 64 | /// incompatibility). Instead, just log the failure. 65 | public var tolerateDebugOpCreationFailures: Bool = false 66 | 67 | public var unknownFields = SwiftProtobuf.UnknownStorage() 68 | 69 | public init() {} 70 | 71 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 72 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 73 | /// initializers are defined in the SwiftProtobuf library. See the Message and 74 | /// Message+*Additions` files. 75 | public mutating func decodeMessage(decoder: inout D) throws { 76 | while let fieldNumber = try decoder.nextFieldNumber() { 77 | switch fieldNumber { 78 | case 1: try decoder.decodeSingularStringField(value: &self.nodeName) 79 | case 2: try decoder.decodeSingularInt32Field(value: &self.outputSlot) 80 | case 3: try decoder.decodeRepeatedStringField(value: &self.debugOps) 81 | case 4: try decoder.decodeRepeatedStringField(value: &self.debugUrls) 82 | case 5: try decoder.decodeSingularBoolField(value: &self.tolerateDebugOpCreationFailures) 83 | default: break 84 | } 85 | } 86 | } 87 | 88 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 89 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 90 | /// other serializer methods are defined in the SwiftProtobuf library. See the 91 | /// `Message` and `Message+*Additions` files. 92 | public func traverse(visitor: inout V) throws { 93 | if !self.nodeName.isEmpty { 94 | try visitor.visitSingularStringField(value: self.nodeName, fieldNumber: 1) 95 | } 96 | if self.outputSlot != 0 { 97 | try visitor.visitSingularInt32Field(value: self.outputSlot, fieldNumber: 2) 98 | } 99 | if !self.debugOps.isEmpty { 100 | try visitor.visitRepeatedStringField(value: self.debugOps, fieldNumber: 3) 101 | } 102 | if !self.debugUrls.isEmpty { 103 | try visitor.visitRepeatedStringField(value: self.debugUrls, fieldNumber: 4) 104 | } 105 | if self.tolerateDebugOpCreationFailures != false { 106 | try visitor.visitSingularBoolField(value: self.tolerateDebugOpCreationFailures, fieldNumber: 5) 107 | } 108 | try unknownFields.traverse(visitor: &visitor) 109 | } 110 | } 111 | 112 | /// EXPERIMENTAL. Options for initializing DebuggerState. 113 | public struct Tensorflow_DebugOptions: SwiftProtobuf.Message { 114 | public static let protoMessageName: String = _protobuf_package + ".DebugOptions" 115 | 116 | /// Debugging options 117 | public var debugTensorWatchOpts: [Tensorflow_DebugTensorWatch] = [] 118 | 119 | /// Caller-specified global step count. 120 | /// Note that this is distinct from the session run count and the executor 121 | /// step count. 122 | public var globalStep: Int64 = 0 123 | 124 | public var unknownFields = SwiftProtobuf.UnknownStorage() 125 | 126 | public init() {} 127 | 128 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 129 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 130 | /// initializers are defined in the SwiftProtobuf library. See the Message and 131 | /// Message+*Additions` files. 132 | public mutating func decodeMessage(decoder: inout D) throws { 133 | while let fieldNumber = try decoder.nextFieldNumber() { 134 | switch fieldNumber { 135 | case 4: try decoder.decodeRepeatedMessageField(value: &self.debugTensorWatchOpts) 136 | case 10: try decoder.decodeSingularInt64Field(value: &self.globalStep) 137 | default: break 138 | } 139 | } 140 | } 141 | 142 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 143 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 144 | /// other serializer methods are defined in the SwiftProtobuf library. See the 145 | /// `Message` and `Message+*Additions` files. 146 | public func traverse(visitor: inout V) throws { 147 | if !self.debugTensorWatchOpts.isEmpty { 148 | try visitor.visitRepeatedMessageField(value: self.debugTensorWatchOpts, fieldNumber: 4) 149 | } 150 | if self.globalStep != 0 { 151 | try visitor.visitSingularInt64Field(value: self.globalStep, fieldNumber: 10) 152 | } 153 | try unknownFields.traverse(visitor: &visitor) 154 | } 155 | } 156 | 157 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 158 | 159 | fileprivate let _protobuf_package = "tensorflow" 160 | 161 | extension Tensorflow_DebugTensorWatch: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 162 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 163 | 1: .standard(proto: "node_name"), 164 | 2: .standard(proto: "output_slot"), 165 | 3: .standard(proto: "debug_ops"), 166 | 4: .standard(proto: "debug_urls"), 167 | 5: .standard(proto: "tolerate_debug_op_creation_failures"), 168 | ] 169 | 170 | public func _protobuf_generated_isEqualTo(other: Tensorflow_DebugTensorWatch) -> Bool { 171 | if self.nodeName != other.nodeName {return false} 172 | if self.outputSlot != other.outputSlot {return false} 173 | if self.debugOps != other.debugOps {return false} 174 | if self.debugUrls != other.debugUrls {return false} 175 | if self.tolerateDebugOpCreationFailures != other.tolerateDebugOpCreationFailures {return false} 176 | if unknownFields != other.unknownFields {return false} 177 | return true 178 | } 179 | } 180 | 181 | extension Tensorflow_DebugOptions: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 182 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 183 | 4: .standard(proto: "debug_tensor_watch_opts"), 184 | 10: .standard(proto: "global_step"), 185 | ] 186 | 187 | public func _protobuf_generated_isEqualTo(other: Tensorflow_DebugOptions) -> Bool { 188 | if self.debugTensorWatchOpts != other.debugTensorWatchOpts {return false} 189 | if self.globalStep != other.globalStep {return false} 190 | if unknownFields != other.unknownFields {return false} 191 | return true 192 | } 193 | } 194 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.debugger_event_metadata.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/debug/debugger_event_metadata.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// Encapsulates per-event data related to debugging. 23 | public struct ThirdParty_Tensorflow_Core_Debug_DebuggerEventMetadata: SwiftProtobuf.Message { 24 | public static let protoMessageName: String = _protobuf_package + ".DebuggerEventMetadata" 25 | 26 | public var device: String = String() 27 | 28 | public var outputSlot: Int32 = 0 29 | 30 | public var numChunks: Int32 = 0 31 | 32 | public var chunkIndex: Int32 = 0 33 | 34 | public var unknownFields = SwiftProtobuf.UnknownStorage() 35 | 36 | public init() {} 37 | 38 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 39 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 40 | /// initializers are defined in the SwiftProtobuf library. See the Message and 41 | /// Message+*Additions` files. 42 | public mutating func decodeMessage(decoder: inout D) throws { 43 | while let fieldNumber = try decoder.nextFieldNumber() { 44 | switch fieldNumber { 45 | case 1: try decoder.decodeSingularStringField(value: &self.device) 46 | case 2: try decoder.decodeSingularInt32Field(value: &self.outputSlot) 47 | case 3: try decoder.decodeSingularInt32Field(value: &self.numChunks) 48 | case 4: try decoder.decodeSingularInt32Field(value: &self.chunkIndex) 49 | default: break 50 | } 51 | } 52 | } 53 | 54 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 55 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 56 | /// other serializer methods are defined in the SwiftProtobuf library. See the 57 | /// `Message` and `Message+*Additions` files. 58 | public func traverse(visitor: inout V) throws { 59 | if !self.device.isEmpty { 60 | try visitor.visitSingularStringField(value: self.device, fieldNumber: 1) 61 | } 62 | if self.outputSlot != 0 { 63 | try visitor.visitSingularInt32Field(value: self.outputSlot, fieldNumber: 2) 64 | } 65 | if self.numChunks != 0 { 66 | try visitor.visitSingularInt32Field(value: self.numChunks, fieldNumber: 3) 67 | } 68 | if self.chunkIndex != 0 { 69 | try visitor.visitSingularInt32Field(value: self.chunkIndex, fieldNumber: 4) 70 | } 71 | try unknownFields.traverse(visitor: &visitor) 72 | } 73 | } 74 | 75 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 76 | 77 | fileprivate let _protobuf_package = "third_party.tensorflow.core.debug" 78 | 79 | extension ThirdParty_Tensorflow_Core_Debug_DebuggerEventMetadata: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 80 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 81 | 1: .same(proto: "device"), 82 | 2: .standard(proto: "output_slot"), 83 | 3: .standard(proto: "num_chunks"), 84 | 4: .standard(proto: "chunk_index"), 85 | ] 86 | 87 | public func _protobuf_generated_isEqualTo(other: ThirdParty_Tensorflow_Core_Debug_DebuggerEventMetadata) -> Bool { 88 | if self.device != other.device {return false} 89 | if self.outputSlot != other.outputSlot {return false} 90 | if self.numChunks != other.numChunks {return false} 91 | if self.chunkIndex != other.chunkIndex {return false} 92 | if unknownFields != other.unknownFields {return false} 93 | return true 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.device_properties.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/protobuf/device_properties.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | // Copyright 2017 The TensorFlow Authors. All Rights Reserved. 10 | // 11 | //Licensed under the Apache License, Version 2.0 (the "License"); 12 | //you may not use this file except in compliance with the License. 13 | //You may obtain a copy of the License at 14 | // 15 | //http://www.apache.org/licenses/LICENSE-2.0 16 | // 17 | //Unless required by applicable law or agreed to in writing, software 18 | //distributed under the License is distributed on an "AS IS" BASIS, 19 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | //See the License for the specific language governing permissions and 21 | //limitations under the License. 22 | //============================================================================== 23 | 24 | import Foundation 25 | import SwiftProtobuf 26 | 27 | // If the compiler emits an error on this type, it is because this file 28 | // was generated by a version of the `protoc` Swift plug-in that is 29 | // incompatible with the version of SwiftProtobuf to which you are linking. 30 | // Please ensure that your are building against the same version of the API 31 | // that was used to generate this file. 32 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 33 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 34 | typealias Version = _2 35 | } 36 | 37 | public struct Tensorflow_DeviceProperties: SwiftProtobuf.Message { 38 | public static let protoMessageName: String = _protobuf_package + ".DeviceProperties" 39 | 40 | /// Device type (CPU, GPU, ...) 41 | public var type: String = String() 42 | 43 | /// Vendor (Intel, nvidia, ...) 44 | public var vendor: String = String() 45 | 46 | /// Model (Haswell, K40, ...) 47 | public var model: String = String() 48 | 49 | /// Core Frequency in Mhz 50 | public var frequency: Int64 = 0 51 | 52 | /// Number of cores 53 | public var numCores: Int64 = 0 54 | 55 | /// Version of the tools and libraries used with this device (e.g. gcc 4.9, 56 | /// cudnn 5.1) 57 | public var environment: Dictionary = [:] 58 | 59 | /// Number of registers per core. 60 | public var numRegisters: Int64 = 0 61 | 62 | /// L1 cache size in bytes 63 | public var l1CacheSize: Int64 = 0 64 | 65 | /// L2 cache size in bytes 66 | public var l2CacheSize: Int64 = 0 67 | 68 | /// L3 cache size in bytes 69 | public var l3CacheSize: Int64 = 0 70 | 71 | /// Shared memory size per multiprocessor in bytes. This field is 72 | /// applicable to GPUs only. 73 | public var sharedMemorySizePerMultiprocessor: Int64 = 0 74 | 75 | /// Memory size in bytes 76 | public var memorySize: Int64 = 0 77 | 78 | /// Memory bandwidth in KB/s 79 | public var bandwidth: Int64 = 0 80 | 81 | public var unknownFields = SwiftProtobuf.UnknownStorage() 82 | 83 | public init() {} 84 | 85 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 86 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 87 | /// initializers are defined in the SwiftProtobuf library. See the Message and 88 | /// Message+*Additions` files. 89 | public mutating func decodeMessage(decoder: inout D) throws { 90 | while let fieldNumber = try decoder.nextFieldNumber() { 91 | switch fieldNumber { 92 | case 1: try decoder.decodeSingularStringField(value: &self.type) 93 | case 2: try decoder.decodeSingularStringField(value: &self.vendor) 94 | case 3: try decoder.decodeSingularStringField(value: &self.model) 95 | case 4: try decoder.decodeSingularInt64Field(value: &self.frequency) 96 | case 5: try decoder.decodeSingularInt64Field(value: &self.numCores) 97 | case 6: try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: &self.environment) 98 | case 7: try decoder.decodeSingularInt64Field(value: &self.numRegisters) 99 | case 8: try decoder.decodeSingularInt64Field(value: &self.l1CacheSize) 100 | case 9: try decoder.decodeSingularInt64Field(value: &self.l2CacheSize) 101 | case 10: try decoder.decodeSingularInt64Field(value: &self.l3CacheSize) 102 | case 11: try decoder.decodeSingularInt64Field(value: &self.sharedMemorySizePerMultiprocessor) 103 | case 12: try decoder.decodeSingularInt64Field(value: &self.memorySize) 104 | case 13: try decoder.decodeSingularInt64Field(value: &self.bandwidth) 105 | default: break 106 | } 107 | } 108 | } 109 | 110 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 111 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 112 | /// other serializer methods are defined in the SwiftProtobuf library. See the 113 | /// `Message` and `Message+*Additions` files. 114 | public func traverse(visitor: inout V) throws { 115 | if !self.type.isEmpty { 116 | try visitor.visitSingularStringField(value: self.type, fieldNumber: 1) 117 | } 118 | if !self.vendor.isEmpty { 119 | try visitor.visitSingularStringField(value: self.vendor, fieldNumber: 2) 120 | } 121 | if !self.model.isEmpty { 122 | try visitor.visitSingularStringField(value: self.model, fieldNumber: 3) 123 | } 124 | if self.frequency != 0 { 125 | try visitor.visitSingularInt64Field(value: self.frequency, fieldNumber: 4) 126 | } 127 | if self.numCores != 0 { 128 | try visitor.visitSingularInt64Field(value: self.numCores, fieldNumber: 5) 129 | } 130 | if !self.environment.isEmpty { 131 | try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMap.self, value: self.environment, fieldNumber: 6) 132 | } 133 | if self.numRegisters != 0 { 134 | try visitor.visitSingularInt64Field(value: self.numRegisters, fieldNumber: 7) 135 | } 136 | if self.l1CacheSize != 0 { 137 | try visitor.visitSingularInt64Field(value: self.l1CacheSize, fieldNumber: 8) 138 | } 139 | if self.l2CacheSize != 0 { 140 | try visitor.visitSingularInt64Field(value: self.l2CacheSize, fieldNumber: 9) 141 | } 142 | if self.l3CacheSize != 0 { 143 | try visitor.visitSingularInt64Field(value: self.l3CacheSize, fieldNumber: 10) 144 | } 145 | if self.sharedMemorySizePerMultiprocessor != 0 { 146 | try visitor.visitSingularInt64Field(value: self.sharedMemorySizePerMultiprocessor, fieldNumber: 11) 147 | } 148 | if self.memorySize != 0 { 149 | try visitor.visitSingularInt64Field(value: self.memorySize, fieldNumber: 12) 150 | } 151 | if self.bandwidth != 0 { 152 | try visitor.visitSingularInt64Field(value: self.bandwidth, fieldNumber: 13) 153 | } 154 | try unknownFields.traverse(visitor: &visitor) 155 | } 156 | } 157 | 158 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 159 | 160 | fileprivate let _protobuf_package = "tensorflow" 161 | 162 | extension Tensorflow_DeviceProperties: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 163 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 164 | 1: .same(proto: "type"), 165 | 2: .same(proto: "vendor"), 166 | 3: .same(proto: "model"), 167 | 4: .same(proto: "frequency"), 168 | 5: .standard(proto: "num_cores"), 169 | 6: .same(proto: "environment"), 170 | 7: .standard(proto: "num_registers"), 171 | 8: .standard(proto: "l1_cache_size"), 172 | 9: .standard(proto: "l2_cache_size"), 173 | 10: .standard(proto: "l3_cache_size"), 174 | 11: .standard(proto: "shared_memory_size_per_multiprocessor"), 175 | 12: .standard(proto: "memory_size"), 176 | 13: .same(proto: "bandwidth"), 177 | ] 178 | 179 | public func _protobuf_generated_isEqualTo(other: Tensorflow_DeviceProperties) -> Bool { 180 | if self.type != other.type {return false} 181 | if self.vendor != other.vendor {return false} 182 | if self.model != other.model {return false} 183 | if self.frequency != other.frequency {return false} 184 | if self.numCores != other.numCores {return false} 185 | if self.environment != other.environment {return false} 186 | if self.numRegisters != other.numRegisters {return false} 187 | if self.l1CacheSize != other.l1CacheSize {return false} 188 | if self.l2CacheSize != other.l2CacheSize {return false} 189 | if self.l3CacheSize != other.l3CacheSize {return false} 190 | if self.sharedMemorySizePerMultiprocessor != other.sharedMemorySizePerMultiprocessor {return false} 191 | if self.memorySize != other.memorySize {return false} 192 | if self.bandwidth != other.bandwidth {return false} 193 | if unknownFields != other.unknownFields {return false} 194 | return true 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.example.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/example/example.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | /// Protocol messages for describing input data Examples for machine learning 10 | /// model training or inference. 11 | 12 | import Foundation 13 | import SwiftProtobuf 14 | 15 | // If the compiler emits an error on this type, it is because this file 16 | // was generated by a version of the `protoc` Swift plug-in that is 17 | // incompatible with the version of SwiftProtobuf to which you are linking. 18 | // Please ensure that your are building against the same version of the API 19 | // that was used to generate this file. 20 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 21 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 22 | typealias Version = _2 23 | } 24 | 25 | public struct Tensorflow_Example: SwiftProtobuf.Message { 26 | public static let protoMessageName: String = _protobuf_package + ".Example" 27 | 28 | public var features: Tensorflow_Features { 29 | get {return _storage._features ?? Tensorflow_Features()} 30 | set {_uniqueStorage()._features = newValue} 31 | } 32 | /// Returns true if `features` has been explicitly set. 33 | public var hasFeatures: Bool {return _storage._features != nil} 34 | /// Clears the value of `features`. Subsequent reads from it will return its default value. 35 | public mutating func clearFeatures() {_storage._features = nil} 36 | 37 | public var unknownFields = SwiftProtobuf.UnknownStorage() 38 | 39 | public init() {} 40 | 41 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 42 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 43 | /// initializers are defined in the SwiftProtobuf library. See the Message and 44 | /// Message+*Additions` files. 45 | public mutating func decodeMessage(decoder: inout D) throws { 46 | _ = _uniqueStorage() 47 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 48 | while let fieldNumber = try decoder.nextFieldNumber() { 49 | switch fieldNumber { 50 | case 1: try decoder.decodeSingularMessageField(value: &_storage._features) 51 | default: break 52 | } 53 | } 54 | } 55 | } 56 | 57 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 58 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 59 | /// other serializer methods are defined in the SwiftProtobuf library. See the 60 | /// `Message` and `Message+*Additions` files. 61 | public func traverse(visitor: inout V) throws { 62 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 63 | if let v = _storage._features { 64 | try visitor.visitSingularMessageField(value: v, fieldNumber: 1) 65 | } 66 | } 67 | try unknownFields.traverse(visitor: &visitor) 68 | } 69 | 70 | fileprivate var _storage = _StorageClass.defaultInstance 71 | } 72 | 73 | public struct Tensorflow_SequenceExample: SwiftProtobuf.Message { 74 | public static let protoMessageName: String = _protobuf_package + ".SequenceExample" 75 | 76 | public var context: Tensorflow_Features { 77 | get {return _storage._context ?? Tensorflow_Features()} 78 | set {_uniqueStorage()._context = newValue} 79 | } 80 | /// Returns true if `context` has been explicitly set. 81 | public var hasContext: Bool {return _storage._context != nil} 82 | /// Clears the value of `context`. Subsequent reads from it will return its default value. 83 | public mutating func clearContext() {_storage._context = nil} 84 | 85 | public var featureLists: Tensorflow_FeatureLists { 86 | get {return _storage._featureLists ?? Tensorflow_FeatureLists()} 87 | set {_uniqueStorage()._featureLists = newValue} 88 | } 89 | /// Returns true if `featureLists` has been explicitly set. 90 | public var hasFeatureLists: Bool {return _storage._featureLists != nil} 91 | /// Clears the value of `featureLists`. Subsequent reads from it will return its default value. 92 | public mutating func clearFeatureLists() {_storage._featureLists = nil} 93 | 94 | public var unknownFields = SwiftProtobuf.UnknownStorage() 95 | 96 | public init() {} 97 | 98 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 99 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 100 | /// initializers are defined in the SwiftProtobuf library. See the Message and 101 | /// Message+*Additions` files. 102 | public mutating func decodeMessage(decoder: inout D) throws { 103 | _ = _uniqueStorage() 104 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 105 | while let fieldNumber = try decoder.nextFieldNumber() { 106 | switch fieldNumber { 107 | case 1: try decoder.decodeSingularMessageField(value: &_storage._context) 108 | case 2: try decoder.decodeSingularMessageField(value: &_storage._featureLists) 109 | default: break 110 | } 111 | } 112 | } 113 | } 114 | 115 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 116 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 117 | /// other serializer methods are defined in the SwiftProtobuf library. See the 118 | /// `Message` and `Message+*Additions` files. 119 | public func traverse(visitor: inout V) throws { 120 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 121 | if let v = _storage._context { 122 | try visitor.visitSingularMessageField(value: v, fieldNumber: 1) 123 | } 124 | if let v = _storage._featureLists { 125 | try visitor.visitSingularMessageField(value: v, fieldNumber: 2) 126 | } 127 | } 128 | try unknownFields.traverse(visitor: &visitor) 129 | } 130 | 131 | fileprivate var _storage = _StorageClass.defaultInstance 132 | } 133 | 134 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 135 | 136 | fileprivate let _protobuf_package = "tensorflow" 137 | 138 | extension Tensorflow_Example: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 139 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 140 | 1: .same(proto: "features"), 141 | ] 142 | 143 | fileprivate class _StorageClass { 144 | var _features: Tensorflow_Features? = nil 145 | 146 | static let defaultInstance = _StorageClass() 147 | 148 | private init() {} 149 | 150 | init(copying source: _StorageClass) { 151 | _features = source._features 152 | } 153 | } 154 | 155 | fileprivate mutating func _uniqueStorage() -> _StorageClass { 156 | if !isKnownUniquelyReferenced(&_storage) { 157 | _storage = _StorageClass(copying: _storage) 158 | } 159 | return _storage 160 | } 161 | 162 | public func _protobuf_generated_isEqualTo(other: Tensorflow_Example) -> Bool { 163 | if _storage !== other._storage { 164 | let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in 165 | let _storage = _args.0 166 | let other_storage = _args.1 167 | if _storage._features != other_storage._features {return false} 168 | return true 169 | } 170 | if !storagesAreEqual {return false} 171 | } 172 | if unknownFields != other.unknownFields {return false} 173 | return true 174 | } 175 | } 176 | 177 | extension Tensorflow_SequenceExample: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 178 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 179 | 1: .same(proto: "context"), 180 | 2: .standard(proto: "feature_lists"), 181 | ] 182 | 183 | fileprivate class _StorageClass { 184 | var _context: Tensorflow_Features? = nil 185 | var _featureLists: Tensorflow_FeatureLists? = nil 186 | 187 | static let defaultInstance = _StorageClass() 188 | 189 | private init() {} 190 | 191 | init(copying source: _StorageClass) { 192 | _context = source._context 193 | _featureLists = source._featureLists 194 | } 195 | } 196 | 197 | fileprivate mutating func _uniqueStorage() -> _StorageClass { 198 | if !isKnownUniquelyReferenced(&_storage) { 199 | _storage = _StorageClass(copying: _storage) 200 | } 201 | return _storage 202 | } 203 | 204 | public func _protobuf_generated_isEqualTo(other: Tensorflow_SequenceExample) -> Bool { 205 | if _storage !== other._storage { 206 | let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in 207 | let _storage = _args.0 208 | let other_storage = _args.1 209 | if _storage._context != other_storage._context {return false} 210 | if _storage._featureLists != other_storage._featureLists {return false} 211 | return true 212 | } 213 | if !storagesAreEqual {return false} 214 | } 215 | if unknownFields != other.unknownFields {return false} 216 | return true 217 | } 218 | } 219 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.example_proto_fast_parsing_test.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/util/example_proto_fast_parsing_test.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | /// Protocol message for the fast Example parse unit test. 10 | 11 | import Foundation 12 | import SwiftProtobuf 13 | 14 | // If the compiler emits an error on this type, it is because this file 15 | // was generated by a version of the `protoc` Swift plug-in that is 16 | // incompatible with the version of SwiftProtobuf to which you are linking. 17 | // Please ensure that your are building against the same version of the API 18 | // that was used to generate this file. 19 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 20 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 21 | typealias Version = _2 22 | } 23 | 24 | /// This message is parallel to Example, but with additional fields to test 25 | /// unknown fields handling in example_proto_fast_parsing_test.cc. 26 | public struct Tensorflow_ExampleWithExtras: SwiftProtobuf.Message { 27 | public static let protoMessageName: String = _protobuf_package + ".ExampleWithExtras" 28 | 29 | public var features: Tensorflow_Features { 30 | get {return _storage._features ?? Tensorflow_Features()} 31 | set {_uniqueStorage()._features = newValue} 32 | } 33 | /// Returns true if `features` has been explicitly set. 34 | public var hasFeatures: Bool {return _storage._features != nil} 35 | /// Clears the value of `features`. Subsequent reads from it will return its default value. 36 | public mutating func clearFeatures() {_storage._features = nil} 37 | 38 | public var extra1: String { 39 | get {return _storage._extra1} 40 | set {_uniqueStorage()._extra1 = newValue} 41 | } 42 | 43 | public var extra2: Int64 { 44 | get {return _storage._extra2} 45 | set {_uniqueStorage()._extra2 = newValue} 46 | } 47 | 48 | public var extra3: UInt32 { 49 | get {return _storage._extra3} 50 | set {_uniqueStorage()._extra3 = newValue} 51 | } 52 | 53 | public var extra4: UInt64 { 54 | get {return _storage._extra4} 55 | set {_uniqueStorage()._extra4 = newValue} 56 | } 57 | 58 | public var extra5: Double { 59 | get {return _storage._extra5} 60 | set {_uniqueStorage()._extra5 = newValue} 61 | } 62 | 63 | public var extra6: [Float] { 64 | get {return _storage._extra6} 65 | set {_uniqueStorage()._extra6 = newValue} 66 | } 67 | 68 | public var extra7: Tensorflow_Features { 69 | get {return _storage._extra7 ?? Tensorflow_Features()} 70 | set {_uniqueStorage()._extra7 = newValue} 71 | } 72 | /// Returns true if `extra7` has been explicitly set. 73 | public var hasExtra7: Bool {return _storage._extra7 != nil} 74 | /// Clears the value of `extra7`. Subsequent reads from it will return its default value. 75 | public mutating func clearExtra7() {_storage._extra7 = nil} 76 | 77 | public var unknownFields = SwiftProtobuf.UnknownStorage() 78 | 79 | public init() {} 80 | 81 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 82 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 83 | /// initializers are defined in the SwiftProtobuf library. See the Message and 84 | /// Message+*Additions` files. 85 | public mutating func decodeMessage(decoder: inout D) throws { 86 | _ = _uniqueStorage() 87 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 88 | while let fieldNumber = try decoder.nextFieldNumber() { 89 | switch fieldNumber { 90 | case 1: try decoder.decodeSingularMessageField(value: &_storage._features) 91 | case 1337: try decoder.decodeSingularStringField(value: &_storage._extra1) 92 | case 1338: try decoder.decodeSingularInt64Field(value: &_storage._extra2) 93 | case 1339: try decoder.decodeSingularFixed32Field(value: &_storage._extra3) 94 | case 1340: try decoder.decodeSingularFixed64Field(value: &_storage._extra4) 95 | case 1341: try decoder.decodeSingularDoubleField(value: &_storage._extra5) 96 | case 1342: try decoder.decodeRepeatedFloatField(value: &_storage._extra6) 97 | case 1343: try decoder.decodeSingularMessageField(value: &_storage._extra7) 98 | default: break 99 | } 100 | } 101 | } 102 | } 103 | 104 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 105 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 106 | /// other serializer methods are defined in the SwiftProtobuf library. See the 107 | /// `Message` and `Message+*Additions` files. 108 | public func traverse(visitor: inout V) throws { 109 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 110 | if let v = _storage._features { 111 | try visitor.visitSingularMessageField(value: v, fieldNumber: 1) 112 | } 113 | if !_storage._extra1.isEmpty { 114 | try visitor.visitSingularStringField(value: _storage._extra1, fieldNumber: 1337) 115 | } 116 | if _storage._extra2 != 0 { 117 | try visitor.visitSingularInt64Field(value: _storage._extra2, fieldNumber: 1338) 118 | } 119 | if _storage._extra3 != 0 { 120 | try visitor.visitSingularFixed32Field(value: _storage._extra3, fieldNumber: 1339) 121 | } 122 | if _storage._extra4 != 0 { 123 | try visitor.visitSingularFixed64Field(value: _storage._extra4, fieldNumber: 1340) 124 | } 125 | if _storage._extra5 != 0 { 126 | try visitor.visitSingularDoubleField(value: _storage._extra5, fieldNumber: 1341) 127 | } 128 | if !_storage._extra6.isEmpty { 129 | try visitor.visitPackedFloatField(value: _storage._extra6, fieldNumber: 1342) 130 | } 131 | if let v = _storage._extra7 { 132 | try visitor.visitSingularMessageField(value: v, fieldNumber: 1343) 133 | } 134 | } 135 | try unknownFields.traverse(visitor: &visitor) 136 | } 137 | 138 | fileprivate var _storage = _StorageClass.defaultInstance 139 | } 140 | 141 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 142 | 143 | fileprivate let _protobuf_package = "tensorflow" 144 | 145 | extension Tensorflow_ExampleWithExtras: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 146 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 147 | 1: .same(proto: "features"), 148 | 1337: .same(proto: "extra1"), 149 | 1338: .same(proto: "extra2"), 150 | 1339: .same(proto: "extra3"), 151 | 1340: .same(proto: "extra4"), 152 | 1341: .same(proto: "extra5"), 153 | 1342: .same(proto: "extra6"), 154 | 1343: .same(proto: "extra7"), 155 | ] 156 | 157 | fileprivate class _StorageClass { 158 | var _features: Tensorflow_Features? = nil 159 | var _extra1: String = String() 160 | var _extra2: Int64 = 0 161 | var _extra3: UInt32 = 0 162 | var _extra4: UInt64 = 0 163 | var _extra5: Double = 0 164 | var _extra6: [Float] = [] 165 | var _extra7: Tensorflow_Features? = nil 166 | 167 | static let defaultInstance = _StorageClass() 168 | 169 | private init() {} 170 | 171 | init(copying source: _StorageClass) { 172 | _features = source._features 173 | _extra1 = source._extra1 174 | _extra2 = source._extra2 175 | _extra3 = source._extra3 176 | _extra4 = source._extra4 177 | _extra5 = source._extra5 178 | _extra6 = source._extra6 179 | _extra7 = source._extra7 180 | } 181 | } 182 | 183 | fileprivate mutating func _uniqueStorage() -> _StorageClass { 184 | if !isKnownUniquelyReferenced(&_storage) { 185 | _storage = _StorageClass(copying: _storage) 186 | } 187 | return _storage 188 | } 189 | 190 | public func _protobuf_generated_isEqualTo(other: Tensorflow_ExampleWithExtras) -> Bool { 191 | if _storage !== other._storage { 192 | let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in 193 | let _storage = _args.0 194 | let other_storage = _args.1 195 | if _storage._features != other_storage._features {return false} 196 | if _storage._extra1 != other_storage._extra1 {return false} 197 | if _storage._extra2 != other_storage._extra2 {return false} 198 | if _storage._extra3 != other_storage._extra3 {return false} 199 | if _storage._extra4 != other_storage._extra4 {return false} 200 | if _storage._extra5 != other_storage._extra5 {return false} 201 | if _storage._extra6 != other_storage._extra6 {return false} 202 | if _storage._extra7 != other_storage._extra7 {return false} 203 | return true 204 | } 205 | if !storagesAreEqual {return false} 206 | } 207 | if unknownFields != other.unknownFields {return false} 208 | return true 209 | } 210 | } 211 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.gdr.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/contrib/gdr/gdr.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | public struct Tensorflow_RemoteMemoryRegion: SwiftProtobuf.Message { 23 | public static let protoMessageName: String = _protobuf_package + ".RemoteMemoryRegion" 24 | 25 | public var host: String = String() 26 | 27 | public var port: String = String() 28 | 29 | public var addr: UInt64 = 0 30 | 31 | public var rkey: UInt32 = 0 32 | 33 | public var tensorKey: UInt32 = 0 34 | 35 | public var checksum: UInt64 = 0 36 | 37 | public var unknownFields = SwiftProtobuf.UnknownStorage() 38 | 39 | public init() {} 40 | 41 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 42 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 43 | /// initializers are defined in the SwiftProtobuf library. See the Message and 44 | /// Message+*Additions` files. 45 | public mutating func decodeMessage(decoder: inout D) throws { 46 | while let fieldNumber = try decoder.nextFieldNumber() { 47 | switch fieldNumber { 48 | case 1: try decoder.decodeSingularStringField(value: &self.host) 49 | case 2: try decoder.decodeSingularStringField(value: &self.port) 50 | case 3: try decoder.decodeSingularUInt64Field(value: &self.addr) 51 | case 4: try decoder.decodeSingularUInt32Field(value: &self.rkey) 52 | case 5: try decoder.decodeSingularUInt32Field(value: &self.tensorKey) 53 | case 6: try decoder.decodeSingularUInt64Field(value: &self.checksum) 54 | default: break 55 | } 56 | } 57 | } 58 | 59 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 60 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 61 | /// other serializer methods are defined in the SwiftProtobuf library. See the 62 | /// `Message` and `Message+*Additions` files. 63 | public func traverse(visitor: inout V) throws { 64 | if !self.host.isEmpty { 65 | try visitor.visitSingularStringField(value: self.host, fieldNumber: 1) 66 | } 67 | if !self.port.isEmpty { 68 | try visitor.visitSingularStringField(value: self.port, fieldNumber: 2) 69 | } 70 | if self.addr != 0 { 71 | try visitor.visitSingularUInt64Field(value: self.addr, fieldNumber: 3) 72 | } 73 | if self.rkey != 0 { 74 | try visitor.visitSingularUInt32Field(value: self.rkey, fieldNumber: 4) 75 | } 76 | if self.tensorKey != 0 { 77 | try visitor.visitSingularUInt32Field(value: self.tensorKey, fieldNumber: 5) 78 | } 79 | if self.checksum != 0 { 80 | try visitor.visitSingularUInt64Field(value: self.checksum, fieldNumber: 6) 81 | } 82 | try unknownFields.traverse(visitor: &visitor) 83 | } 84 | } 85 | 86 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 87 | 88 | fileprivate let _protobuf_package = "tensorflow" 89 | 90 | extension Tensorflow_RemoteMemoryRegion: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 91 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 92 | 1: .same(proto: "host"), 93 | 2: .same(proto: "port"), 94 | 3: .same(proto: "addr"), 95 | 4: .same(proto: "rkey"), 96 | 5: .standard(proto: "tensor_key"), 97 | 6: .same(proto: "checksum"), 98 | ] 99 | 100 | public func _protobuf_generated_isEqualTo(other: Tensorflow_RemoteMemoryRegion) -> Bool { 101 | if self.host != other.host {return false} 102 | if self.port != other.port {return false} 103 | if self.addr != other.addr {return false} 104 | if self.rkey != other.rkey {return false} 105 | if self.tensorKey != other.tensorKey {return false} 106 | if self.checksum != other.checksum {return false} 107 | if unknownFields != other.unknownFields {return false} 108 | return true 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.generic_tree_model_extensions.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/contrib/decision_trees/proto/generic_tree_model_extensions.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | // Messages in this file are not part of the basic standard established by 10 | // generic_tree_model.proto (see the toplevel comment in that file). 11 | 12 | import Foundation 13 | import SwiftProtobuf 14 | 15 | // If the compiler emits an error on this type, it is because this file 16 | // was generated by a version of the `protoc` Swift plug-in that is 17 | // incompatible with the version of SwiftProtobuf to which you are linking. 18 | // Please ensure that your are building against the same version of the API 19 | // that was used to generate this file. 20 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 21 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 22 | typealias Version = _2 23 | } 24 | 25 | /// Used in generic_tree_model.BinaryNode.left_child_test. 26 | /// Tests whether the feature's value belongs to the specified list, 27 | /// (or does not belong if inverse=True). 28 | public struct Tensorflow_DecisionTrees_MatchingValuesTest: SwiftProtobuf.Message { 29 | public static let protoMessageName: String = _protobuf_package + ".MatchingValuesTest" 30 | 31 | /// When the feature is missing, the test's outcome is undefined. 32 | public var featureID: Tensorflow_DecisionTrees_FeatureId { 33 | get {return _storage._featureID ?? Tensorflow_DecisionTrees_FeatureId()} 34 | set {_uniqueStorage()._featureID = newValue} 35 | } 36 | /// Returns true if `featureID` has been explicitly set. 37 | public var hasFeatureID: Bool {return _storage._featureID != nil} 38 | /// Clears the value of `featureID`. Subsequent reads from it will return its default value. 39 | public mutating func clearFeatureID() {_storage._featureID = nil} 40 | 41 | public var value: [Tensorflow_DecisionTrees_Value] { 42 | get {return _storage._value} 43 | set {_uniqueStorage()._value = newValue} 44 | } 45 | 46 | public var inverse: Bool { 47 | get {return _storage._inverse} 48 | set {_uniqueStorage()._inverse = newValue} 49 | } 50 | 51 | public var unknownFields = SwiftProtobuf.UnknownStorage() 52 | 53 | public init() {} 54 | 55 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 56 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 57 | /// initializers are defined in the SwiftProtobuf library. See the Message and 58 | /// Message+*Additions` files. 59 | public mutating func decodeMessage(decoder: inout D) throws { 60 | _ = _uniqueStorage() 61 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 62 | while let fieldNumber = try decoder.nextFieldNumber() { 63 | switch fieldNumber { 64 | case 1: try decoder.decodeSingularMessageField(value: &_storage._featureID) 65 | case 2: try decoder.decodeRepeatedMessageField(value: &_storage._value) 66 | case 3: try decoder.decodeSingularBoolField(value: &_storage._inverse) 67 | default: break 68 | } 69 | } 70 | } 71 | } 72 | 73 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 74 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 75 | /// other serializer methods are defined in the SwiftProtobuf library. See the 76 | /// `Message` and `Message+*Additions` files. 77 | public func traverse(visitor: inout V) throws { 78 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 79 | if let v = _storage._featureID { 80 | try visitor.visitSingularMessageField(value: v, fieldNumber: 1) 81 | } 82 | if !_storage._value.isEmpty { 83 | try visitor.visitRepeatedMessageField(value: _storage._value, fieldNumber: 2) 84 | } 85 | if _storage._inverse != false { 86 | try visitor.visitSingularBoolField(value: _storage._inverse, fieldNumber: 3) 87 | } 88 | } 89 | try unknownFields.traverse(visitor: &visitor) 90 | } 91 | 92 | fileprivate var _storage = _StorageClass.defaultInstance 93 | } 94 | 95 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 96 | 97 | fileprivate let _protobuf_package = "tensorflow.decision_trees" 98 | 99 | extension Tensorflow_DecisionTrees_MatchingValuesTest: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 100 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 101 | 1: .standard(proto: "feature_id"), 102 | 2: .same(proto: "value"), 103 | 3: .same(proto: "inverse"), 104 | ] 105 | 106 | fileprivate class _StorageClass { 107 | var _featureID: Tensorflow_DecisionTrees_FeatureId? = nil 108 | var _value: [Tensorflow_DecisionTrees_Value] = [] 109 | var _inverse: Bool = false 110 | 111 | static let defaultInstance = _StorageClass() 112 | 113 | private init() {} 114 | 115 | init(copying source: _StorageClass) { 116 | _featureID = source._featureID 117 | _value = source._value 118 | _inverse = source._inverse 119 | } 120 | } 121 | 122 | fileprivate mutating func _uniqueStorage() -> _StorageClass { 123 | if !isKnownUniquelyReferenced(&_storage) { 124 | _storage = _StorageClass(copying: _storage) 125 | } 126 | return _storage 127 | } 128 | 129 | public func _protobuf_generated_isEqualTo(other: Tensorflow_DecisionTrees_MatchingValuesTest) -> Bool { 130 | if _storage !== other._storage { 131 | let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in 132 | let _storage = _args.0 133 | let other_storage = _args.1 134 | if _storage._featureID != other_storage._featureID {return false} 135 | if _storage._value != other_storage._value {return false} 136 | if _storage._inverse != other_storage._inverse {return false} 137 | return true 138 | } 139 | if !storagesAreEqual {return false} 140 | } 141 | if unknownFields != other.unknownFields {return false} 142 | return true 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.graph.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/graph.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// Represents the graph of operations 23 | public struct Tensorflow_GraphDef: SwiftProtobuf.Message { 24 | public static let protoMessageName: String = _protobuf_package + ".GraphDef" 25 | 26 | public var node: [Tensorflow_NodeDef] { 27 | get {return _storage._node} 28 | set {_uniqueStorage()._node = newValue} 29 | } 30 | 31 | /// Compatibility versions of the graph. See core/public/version.h for version 32 | /// history. The GraphDef version is distinct from the TensorFlow version, and 33 | /// each release of TensorFlow will support a range of GraphDef versions. 34 | public var versions: Tensorflow_VersionDef { 35 | get {return _storage._versions ?? Tensorflow_VersionDef()} 36 | set {_uniqueStorage()._versions = newValue} 37 | } 38 | /// Returns true if `versions` has been explicitly set. 39 | public var hasVersions: Bool {return _storage._versions != nil} 40 | /// Clears the value of `versions`. Subsequent reads from it will return its default value. 41 | public mutating func clearVersions() {_storage._versions = nil} 42 | 43 | /// Deprecated single version field; use versions above instead. Since all 44 | /// GraphDef changes before "versions" was introduced were forward 45 | /// compatible, this field is entirely ignored. 46 | public var version: Int32 { 47 | get {return _storage._version} 48 | set {_uniqueStorage()._version = newValue} 49 | } 50 | 51 | /// EXPERIMENTAL. DO NOT USE OR DEPEND ON THIS YET. 52 | /// 53 | /// "library" provides user-defined functions. 54 | /// 55 | /// Naming: 56 | /// * library.function.name are in a flat namespace. 57 | /// NOTE: We may need to change it to be hierarchical to support 58 | /// different orgs. E.g., 59 | /// { "/google/nn", { ... }}, 60 | /// { "/google/vision", { ... }} 61 | /// { "/org_foo/module_bar", { ... }} 62 | /// map named_lib; 63 | /// * If node[i].op is the name of one function in "library", 64 | /// node[i] is deemed as a function call. Otherwise, node[i].op 65 | /// must be a primitive operation supported by the runtime. 66 | /// 67 | /// 68 | /// Function call semantics: 69 | /// 70 | /// * The callee may start execution as soon as some of its inputs 71 | /// are ready. The caller may want to use Tuple() mechanism to 72 | /// ensure all inputs are ready in the same time. 73 | /// 74 | /// * The consumer of return values may start executing as soon as 75 | /// the return values the consumer depends on are ready. The 76 | /// consumer may want to use Tuple() mechanism to ensure the 77 | /// consumer does not start until all return values of the callee 78 | /// function are ready. 79 | public var library: Tensorflow_FunctionDefLibrary { 80 | get {return _storage._library ?? Tensorflow_FunctionDefLibrary()} 81 | set {_uniqueStorage()._library = newValue} 82 | } 83 | /// Returns true if `library` has been explicitly set. 84 | public var hasLibrary: Bool {return _storage._library != nil} 85 | /// Clears the value of `library`. Subsequent reads from it will return its default value. 86 | public mutating func clearLibrary() {_storage._library = nil} 87 | 88 | public var unknownFields = SwiftProtobuf.UnknownStorage() 89 | 90 | public init() {} 91 | 92 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 93 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 94 | /// initializers are defined in the SwiftProtobuf library. See the Message and 95 | /// Message+*Additions` files. 96 | public mutating func decodeMessage(decoder: inout D) throws { 97 | _ = _uniqueStorage() 98 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 99 | while let fieldNumber = try decoder.nextFieldNumber() { 100 | switch fieldNumber { 101 | case 1: try decoder.decodeRepeatedMessageField(value: &_storage._node) 102 | case 2: try decoder.decodeSingularMessageField(value: &_storage._library) 103 | case 3: try decoder.decodeSingularInt32Field(value: &_storage._version) 104 | case 4: try decoder.decodeSingularMessageField(value: &_storage._versions) 105 | default: break 106 | } 107 | } 108 | } 109 | } 110 | 111 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 112 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 113 | /// other serializer methods are defined in the SwiftProtobuf library. See the 114 | /// `Message` and `Message+*Additions` files. 115 | public func traverse(visitor: inout V) throws { 116 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 117 | if !_storage._node.isEmpty { 118 | try visitor.visitRepeatedMessageField(value: _storage._node, fieldNumber: 1) 119 | } 120 | if let v = _storage._library { 121 | try visitor.visitSingularMessageField(value: v, fieldNumber: 2) 122 | } 123 | if _storage._version != 0 { 124 | try visitor.visitSingularInt32Field(value: _storage._version, fieldNumber: 3) 125 | } 126 | if let v = _storage._versions { 127 | try visitor.visitSingularMessageField(value: v, fieldNumber: 4) 128 | } 129 | } 130 | try unknownFields.traverse(visitor: &visitor) 131 | } 132 | 133 | fileprivate var _storage = _StorageClass.defaultInstance 134 | } 135 | 136 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 137 | 138 | fileprivate let _protobuf_package = "tensorflow" 139 | 140 | extension Tensorflow_GraphDef: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 141 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 142 | 1: .same(proto: "node"), 143 | 4: .same(proto: "versions"), 144 | 3: .same(proto: "version"), 145 | 2: .same(proto: "library"), 146 | ] 147 | 148 | fileprivate class _StorageClass { 149 | var _node: [Tensorflow_NodeDef] = [] 150 | var _versions: Tensorflow_VersionDef? = nil 151 | var _version: Int32 = 0 152 | var _library: Tensorflow_FunctionDefLibrary? = nil 153 | 154 | static let defaultInstance = _StorageClass() 155 | 156 | private init() {} 157 | 158 | init(copying source: _StorageClass) { 159 | _node = source._node 160 | _versions = source._versions 161 | _version = source._version 162 | _library = source._library 163 | } 164 | } 165 | 166 | fileprivate mutating func _uniqueStorage() -> _StorageClass { 167 | if !isKnownUniquelyReferenced(&_storage) { 168 | _storage = _StorageClass(copying: _storage) 169 | } 170 | return _storage 171 | } 172 | 173 | public func _protobuf_generated_isEqualTo(other: Tensorflow_GraphDef) -> Bool { 174 | if _storage !== other._storage { 175 | let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in 176 | let _storage = _args.0 177 | let other_storage = _args.1 178 | if _storage._node != other_storage._node {return false} 179 | if _storage._versions != other_storage._versions {return false} 180 | if _storage._version != other_storage._version {return false} 181 | if _storage._library != other_storage._library {return false} 182 | return true 183 | } 184 | if !storagesAreEqual {return false} 185 | } 186 | if unknownFields != other.unknownFields {return false} 187 | return true 188 | } 189 | } 190 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.iterator.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/iterator.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// Protocol buffer representing the metadata for an iterator's state stored 23 | /// as a Variant tensor. 24 | public struct Tensorflow_IteratorStateMetadata: SwiftProtobuf.Message { 25 | public static let protoMessageName: String = _protobuf_package + ".IteratorStateMetadata" 26 | 27 | /// A user-specified version string. 28 | public var version: String = String() 29 | 30 | /// Keys for tensors in the VariantTensorDataProto. 31 | public var keys: [String] = [] 32 | 33 | public var unknownFields = SwiftProtobuf.UnknownStorage() 34 | 35 | public init() {} 36 | 37 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 38 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 39 | /// initializers are defined in the SwiftProtobuf library. See the Message and 40 | /// Message+*Additions` files. 41 | public mutating func decodeMessage(decoder: inout D) throws { 42 | while let fieldNumber = try decoder.nextFieldNumber() { 43 | switch fieldNumber { 44 | case 1: try decoder.decodeSingularStringField(value: &self.version) 45 | case 2: try decoder.decodeRepeatedStringField(value: &self.keys) 46 | default: break 47 | } 48 | } 49 | } 50 | 51 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 52 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 53 | /// other serializer methods are defined in the SwiftProtobuf library. See the 54 | /// `Message` and `Message+*Additions` files. 55 | public func traverse(visitor: inout V) throws { 56 | if !self.version.isEmpty { 57 | try visitor.visitSingularStringField(value: self.version, fieldNumber: 1) 58 | } 59 | if !self.keys.isEmpty { 60 | try visitor.visitRepeatedStringField(value: self.keys, fieldNumber: 2) 61 | } 62 | try unknownFields.traverse(visitor: &visitor) 63 | } 64 | } 65 | 66 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 67 | 68 | fileprivate let _protobuf_package = "tensorflow" 69 | 70 | extension Tensorflow_IteratorStateMetadata: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 71 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 72 | 1: .same(proto: "version"), 73 | 2: .same(proto: "keys"), 74 | ] 75 | 76 | public func _protobuf_generated_isEqualTo(other: Tensorflow_IteratorStateMetadata) -> Bool { 77 | if self.version != other.version {return false} 78 | if self.keys != other.keys {return false} 79 | if unknownFields != other.unknownFields {return false} 80 | return true 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.master_service.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/protobuf/master_service.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | // Copyright 2016 The TensorFlow Authors. All Rights Reserved. 10 | // 11 | //Licensed under the Apache License, Version 2.0 (the "License"); 12 | //you may not use this file except in compliance with the License. 13 | //You may obtain a copy of the License at 14 | // 15 | //http://www.apache.org/licenses/LICENSE-2.0 16 | // 17 | //Unless required by applicable law or agreed to in writing, software 18 | //distributed under the License is distributed on an "AS IS" BASIS, 19 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | //See the License for the specific language governing permissions and 21 | //limitations under the License. 22 | //============================================================================== 23 | 24 | import Foundation 25 | import SwiftProtobuf 26 | 27 | // If the compiler emits an error on this type, it is because this file 28 | // was generated by a version of the `protoc` Swift plug-in that is 29 | // incompatible with the version of SwiftProtobuf to which you are linking. 30 | // Please ensure that your are building against the same version of the API 31 | // that was used to generate this file. 32 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 33 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 34 | typealias Version = _2 35 | } 36 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.memmapped_file_system.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/util/memmapped_file_system.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | /// Copyright 2016 The TensorFlow Authors. All Rights Reserved. 10 | /// 11 | ///Licensed under the Apache License, Version 2.0 (the "License"); 12 | ///you may not use this file except in compliance with the License. 13 | ///You may obtain a copy of the License at 14 | /// 15 | ///http://www.apache.org/licenses/LICENSE-2.0 16 | /// 17 | ///Unless required by applicable law or agreed to in writing, software 18 | ///distributed under the License is distributed on an "AS IS" BASIS, 19 | ///WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | ///See the License for the specific language governing permissions and 21 | ///limitations under the License. 22 | ///============================================================================== 23 | 24 | import Foundation 25 | import SwiftProtobuf 26 | 27 | // If the compiler emits an error on this type, it is because this file 28 | // was generated by a version of the `protoc` Swift plug-in that is 29 | // incompatible with the version of SwiftProtobuf to which you are linking. 30 | // Please ensure that your are building against the same version of the API 31 | // that was used to generate this file. 32 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 33 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 34 | typealias Version = _2 35 | } 36 | 37 | /// A message that describes one region of memmapped file. 38 | public struct Tensorflow_MemmappedFileSystemDirectoryElement: SwiftProtobuf.Message { 39 | public static let protoMessageName: String = _protobuf_package + ".MemmappedFileSystemDirectoryElement" 40 | 41 | public var offset: UInt64 = 0 42 | 43 | public var name: String = String() 44 | 45 | public var unknownFields = SwiftProtobuf.UnknownStorage() 46 | 47 | public init() {} 48 | 49 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 50 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 51 | /// initializers are defined in the SwiftProtobuf library. See the Message and 52 | /// Message+*Additions` files. 53 | public mutating func decodeMessage(decoder: inout D) throws { 54 | while let fieldNumber = try decoder.nextFieldNumber() { 55 | switch fieldNumber { 56 | case 1: try decoder.decodeSingularUInt64Field(value: &self.offset) 57 | case 2: try decoder.decodeSingularStringField(value: &self.name) 58 | default: break 59 | } 60 | } 61 | } 62 | 63 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 64 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 65 | /// other serializer methods are defined in the SwiftProtobuf library. See the 66 | /// `Message` and `Message+*Additions` files. 67 | public func traverse(visitor: inout V) throws { 68 | if self.offset != 0 { 69 | try visitor.visitSingularUInt64Field(value: self.offset, fieldNumber: 1) 70 | } 71 | if !self.name.isEmpty { 72 | try visitor.visitSingularStringField(value: self.name, fieldNumber: 2) 73 | } 74 | try unknownFields.traverse(visitor: &visitor) 75 | } 76 | } 77 | 78 | /// A directory of regions in a memmapped file. 79 | public struct Tensorflow_MemmappedFileSystemDirectory: SwiftProtobuf.Message { 80 | public static let protoMessageName: String = _protobuf_package + ".MemmappedFileSystemDirectory" 81 | 82 | public var element: [Tensorflow_MemmappedFileSystemDirectoryElement] = [] 83 | 84 | public var unknownFields = SwiftProtobuf.UnknownStorage() 85 | 86 | public init() {} 87 | 88 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 89 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 90 | /// initializers are defined in the SwiftProtobuf library. See the Message and 91 | /// Message+*Additions` files. 92 | public mutating func decodeMessage(decoder: inout D) throws { 93 | while let fieldNumber = try decoder.nextFieldNumber() { 94 | switch fieldNumber { 95 | case 1: try decoder.decodeRepeatedMessageField(value: &self.element) 96 | default: break 97 | } 98 | } 99 | } 100 | 101 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 102 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 103 | /// other serializer methods are defined in the SwiftProtobuf library. See the 104 | /// `Message` and `Message+*Additions` files. 105 | public func traverse(visitor: inout V) throws { 106 | if !self.element.isEmpty { 107 | try visitor.visitRepeatedMessageField(value: self.element, fieldNumber: 1) 108 | } 109 | try unknownFields.traverse(visitor: &visitor) 110 | } 111 | } 112 | 113 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 114 | 115 | fileprivate let _protobuf_package = "tensorflow" 116 | 117 | extension Tensorflow_MemmappedFileSystemDirectoryElement: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 118 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 119 | 1: .same(proto: "offset"), 120 | 2: .same(proto: "name"), 121 | ] 122 | 123 | public func _protobuf_generated_isEqualTo(other: Tensorflow_MemmappedFileSystemDirectoryElement) -> Bool { 124 | if self.offset != other.offset {return false} 125 | if self.name != other.name {return false} 126 | if unknownFields != other.unknownFields {return false} 127 | return true 128 | } 129 | } 130 | 131 | extension Tensorflow_MemmappedFileSystemDirectory: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 132 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 133 | 1: .same(proto: "element"), 134 | ] 135 | 136 | public func _protobuf_generated_isEqualTo(other: Tensorflow_MemmappedFileSystemDirectory) -> Bool { 137 | if self.element != other.element {return false} 138 | if unknownFields != other.unknownFields {return false} 139 | return true 140 | } 141 | } 142 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.mpi_msg.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/contrib/mpi/mpi_msg.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | public struct Tensorflow_MPIRecvTensorResponse: SwiftProtobuf.Message { 23 | public static let protoMessageName: String = _protobuf_package + ".MPIRecvTensorResponse" 24 | 25 | public var response: Tensorflow_RecvTensorResponse { 26 | get {return _storage._response ?? Tensorflow_RecvTensorResponse()} 27 | set {_uniqueStorage()._response = newValue} 28 | } 29 | /// Returns true if `response` has been explicitly set. 30 | public var hasResponse: Bool {return _storage._response != nil} 31 | /// Clears the value of `response`. Subsequent reads from it will return its default value. 32 | public mutating func clearResponse() {_storage._response = nil} 33 | 34 | public var singleSend: Bool { 35 | get {return _storage._singleSend} 36 | set {_uniqueStorage()._singleSend = newValue} 37 | } 38 | 39 | public var key: String { 40 | get {return _storage._key} 41 | set {_uniqueStorage()._key = newValue} 42 | } 43 | 44 | public var stepID: Int64 { 45 | get {return _storage._stepID} 46 | set {_uniqueStorage()._stepID = newValue} 47 | } 48 | 49 | public var checksum: UInt64 { 50 | get {return _storage._checksum} 51 | set {_uniqueStorage()._checksum = newValue} 52 | } 53 | 54 | public var unknownFields = SwiftProtobuf.UnknownStorage() 55 | 56 | public init() {} 57 | 58 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 59 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 60 | /// initializers are defined in the SwiftProtobuf library. See the Message and 61 | /// Message+*Additions` files. 62 | public mutating func decodeMessage(decoder: inout D) throws { 63 | _ = _uniqueStorage() 64 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 65 | while let fieldNumber = try decoder.nextFieldNumber() { 66 | switch fieldNumber { 67 | case 1: try decoder.decodeSingularMessageField(value: &_storage._response) 68 | case 2: try decoder.decodeSingularBoolField(value: &_storage._singleSend) 69 | case 3: try decoder.decodeSingularStringField(value: &_storage._key) 70 | case 4: try decoder.decodeSingularInt64Field(value: &_storage._stepID) 71 | case 5: try decoder.decodeSingularUInt64Field(value: &_storage._checksum) 72 | default: break 73 | } 74 | } 75 | } 76 | } 77 | 78 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 79 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 80 | /// other serializer methods are defined in the SwiftProtobuf library. See the 81 | /// `Message` and `Message+*Additions` files. 82 | public func traverse(visitor: inout V) throws { 83 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 84 | if let v = _storage._response { 85 | try visitor.visitSingularMessageField(value: v, fieldNumber: 1) 86 | } 87 | if _storage._singleSend != false { 88 | try visitor.visitSingularBoolField(value: _storage._singleSend, fieldNumber: 2) 89 | } 90 | if !_storage._key.isEmpty { 91 | try visitor.visitSingularStringField(value: _storage._key, fieldNumber: 3) 92 | } 93 | if _storage._stepID != 0 { 94 | try visitor.visitSingularInt64Field(value: _storage._stepID, fieldNumber: 4) 95 | } 96 | if _storage._checksum != 0 { 97 | try visitor.visitSingularUInt64Field(value: _storage._checksum, fieldNumber: 5) 98 | } 99 | } 100 | try unknownFields.traverse(visitor: &visitor) 101 | } 102 | 103 | fileprivate var _storage = _StorageClass.defaultInstance 104 | } 105 | 106 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 107 | 108 | fileprivate let _protobuf_package = "tensorflow" 109 | 110 | extension Tensorflow_MPIRecvTensorResponse: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 111 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 112 | 1: .same(proto: "response"), 113 | 2: .same(proto: "singleSend"), 114 | 3: .same(proto: "key"), 115 | 4: .standard(proto: "step_id"), 116 | 5: .same(proto: "checksum"), 117 | ] 118 | 119 | fileprivate class _StorageClass { 120 | var _response: Tensorflow_RecvTensorResponse? = nil 121 | var _singleSend: Bool = false 122 | var _key: String = String() 123 | var _stepID: Int64 = 0 124 | var _checksum: UInt64 = 0 125 | 126 | static let defaultInstance = _StorageClass() 127 | 128 | private init() {} 129 | 130 | init(copying source: _StorageClass) { 131 | _response = source._response 132 | _singleSend = source._singleSend 133 | _key = source._key 134 | _stepID = source._stepID 135 | _checksum = source._checksum 136 | } 137 | } 138 | 139 | fileprivate mutating func _uniqueStorage() -> _StorageClass { 140 | if !isKnownUniquelyReferenced(&_storage) { 141 | _storage = _StorageClass(copying: _storage) 142 | } 143 | return _storage 144 | } 145 | 146 | public func _protobuf_generated_isEqualTo(other: Tensorflow_MPIRecvTensorResponse) -> Bool { 147 | if _storage !== other._storage { 148 | let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in 149 | let _storage = _args.0 150 | let other_storage = _args.1 151 | if _storage._response != other_storage._response {return false} 152 | if _storage._singleSend != other_storage._singleSend {return false} 153 | if _storage._key != other_storage._key {return false} 154 | if _storage._stepID != other_storage._stepID {return false} 155 | if _storage._checksum != other_storage._checksum {return false} 156 | return true 157 | } 158 | if !storagesAreEqual {return false} 159 | } 160 | if unknownFields != other.unknownFields {return false} 161 | return true 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.named_tensor.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/protobuf/named_tensor.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// A pair of tensor name and tensor values. 23 | public struct Tensorflow_NamedTensorProto: SwiftProtobuf.Message { 24 | public static let protoMessageName: String = _protobuf_package + ".NamedTensorProto" 25 | 26 | /// Name of the tensor. 27 | public var name: String { 28 | get {return _storage._name} 29 | set {_uniqueStorage()._name = newValue} 30 | } 31 | 32 | /// The client can populate a TensorProto using a tensorflow::Tensor`, or 33 | /// directly using the protobuf field accessors. 34 | /// 35 | /// The client specifies whether the returned tensor values should be 36 | /// filled tensor fields (float_val, int_val, etc.) or encoded in a 37 | /// compact form in tensor.tensor_content. 38 | public var tensor: Tensorflow_TensorProto { 39 | get {return _storage._tensor ?? Tensorflow_TensorProto()} 40 | set {_uniqueStorage()._tensor = newValue} 41 | } 42 | /// Returns true if `tensor` has been explicitly set. 43 | public var hasTensor: Bool {return _storage._tensor != nil} 44 | /// Clears the value of `tensor`. Subsequent reads from it will return its default value. 45 | public mutating func clearTensor() {_storage._tensor = nil} 46 | 47 | public var unknownFields = SwiftProtobuf.UnknownStorage() 48 | 49 | public init() {} 50 | 51 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 52 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 53 | /// initializers are defined in the SwiftProtobuf library. See the Message and 54 | /// Message+*Additions` files. 55 | public mutating func decodeMessage(decoder: inout D) throws { 56 | _ = _uniqueStorage() 57 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 58 | while let fieldNumber = try decoder.nextFieldNumber() { 59 | switch fieldNumber { 60 | case 1: try decoder.decodeSingularStringField(value: &_storage._name) 61 | case 2: try decoder.decodeSingularMessageField(value: &_storage._tensor) 62 | default: break 63 | } 64 | } 65 | } 66 | } 67 | 68 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 69 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 70 | /// other serializer methods are defined in the SwiftProtobuf library. See the 71 | /// `Message` and `Message+*Additions` files. 72 | public func traverse(visitor: inout V) throws { 73 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 74 | if !_storage._name.isEmpty { 75 | try visitor.visitSingularStringField(value: _storage._name, fieldNumber: 1) 76 | } 77 | if let v = _storage._tensor { 78 | try visitor.visitSingularMessageField(value: v, fieldNumber: 2) 79 | } 80 | } 81 | try unknownFields.traverse(visitor: &visitor) 82 | } 83 | 84 | fileprivate var _storage = _StorageClass.defaultInstance 85 | } 86 | 87 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 88 | 89 | fileprivate let _protobuf_package = "tensorflow" 90 | 91 | extension Tensorflow_NamedTensorProto: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 92 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 93 | 1: .same(proto: "name"), 94 | 2: .same(proto: "tensor"), 95 | ] 96 | 97 | fileprivate class _StorageClass { 98 | var _name: String = String() 99 | var _tensor: Tensorflow_TensorProto? = nil 100 | 101 | static let defaultInstance = _StorageClass() 102 | 103 | private init() {} 104 | 105 | init(copying source: _StorageClass) { 106 | _name = source._name 107 | _tensor = source._tensor 108 | } 109 | } 110 | 111 | fileprivate mutating func _uniqueStorage() -> _StorageClass { 112 | if !isKnownUniquelyReferenced(&_storage) { 113 | _storage = _StorageClass(copying: _storage) 114 | } 115 | return _storage 116 | } 117 | 118 | public func _protobuf_generated_isEqualTo(other: Tensorflow_NamedTensorProto) -> Bool { 119 | if _storage !== other._storage { 120 | let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in 121 | let _storage = _args.0 122 | let other_storage = _args.1 123 | if _storage._name != other_storage._name {return false} 124 | if _storage._tensor != other_storage._tensor {return false} 125 | return true 126 | } 127 | if !storagesAreEqual {return false} 128 | } 129 | if unknownFields != other.unknownFields {return false} 130 | return true 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.node_def.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/node_def.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | public struct Tensorflow_NodeDef: SwiftProtobuf.Message { 23 | public static let protoMessageName: String = _protobuf_package + ".NodeDef" 24 | 25 | /// The name given to this operator. Used for naming inputs, 26 | /// logging, visualization, etc. Unique within a single GraphDef. 27 | /// Must match the regexp "[A-Za-z0-9.][A-Za-z0-9_./]*". 28 | public var name: String = String() 29 | 30 | /// The operation name. There may be custom parameters in attrs. 31 | /// Op names starting with an underscore are reserved for internal use. 32 | public var op: String = String() 33 | 34 | /// Each input is "node:src_output" with "node" being a string name and 35 | /// "src_output" indicating which output tensor to use from "node". If 36 | /// "src_output" is 0 the ":0" suffix can be omitted. Regular inputs 37 | /// may optionally be followed by control inputs that have the format 38 | /// "^node". 39 | public var input: [String] = [] 40 | 41 | /// A (possibly partial) specification for the device on which this 42 | /// node should be placed. 43 | /// The expected syntax for this string is as follows: 44 | /// 45 | /// DEVICE_SPEC ::= PARTIAL_SPEC 46 | /// 47 | /// PARTIAL_SPEC ::= ("/" CONSTRAINT) * 48 | /// CONSTRAINT ::= ("job:" JOB_NAME) 49 | /// | ("replica:" [1-9][0-9]*) 50 | /// | ("task:" [1-9][0-9]*) 51 | /// | ( ("gpu" | "cpu") ":" ([1-9][0-9]* | "*") ) 52 | /// 53 | /// Valid values for this string include: 54 | /// * "/job:worker/replica:0/task:1/device:GPU:3" (full specification) 55 | /// * "/job:worker/device:GPU:3" (partial specification) 56 | /// * "" (no specification) 57 | /// 58 | /// If the constraints do not resolve to a single device (or if this 59 | /// field is empty or not present), the runtime will attempt to 60 | /// choose a device automatically. 61 | public var device: String = String() 62 | 63 | /// Operation-specific graph-construction-time configuration. 64 | /// Note that this should include all attrs defined in the 65 | /// corresponding OpDef, including those with a value matching 66 | /// the default -- this allows the default to change and makes 67 | /// NodeDefs easier to interpret on their own. However, if 68 | /// an attr with a default is not specified in this list, the 69 | /// default will be used. 70 | /// The "names" (keys) must match the regexp "[a-z][a-z0-9_]+" (and 71 | /// one of the names from the corresponding OpDef's attr field). 72 | /// The values must have a type matching the corresponding OpDef 73 | /// attr's type field. 74 | /// TODO(josh11b): Add some examples here showing best practices. 75 | public var attr: Dictionary = [:] 76 | 77 | public var unknownFields = SwiftProtobuf.UnknownStorage() 78 | 79 | public init() {} 80 | 81 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 82 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 83 | /// initializers are defined in the SwiftProtobuf library. See the Message and 84 | /// Message+*Additions` files. 85 | public mutating func decodeMessage(decoder: inout D) throws { 86 | while let fieldNumber = try decoder.nextFieldNumber() { 87 | switch fieldNumber { 88 | case 1: try decoder.decodeSingularStringField(value: &self.name) 89 | case 2: try decoder.decodeSingularStringField(value: &self.op) 90 | case 3: try decoder.decodeRepeatedStringField(value: &self.input) 91 | case 4: try decoder.decodeSingularStringField(value: &self.device) 92 | case 5: try decoder.decodeMapField(fieldType: SwiftProtobuf._ProtobufMessageMap.self, value: &self.attr) 93 | default: break 94 | } 95 | } 96 | } 97 | 98 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 99 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 100 | /// other serializer methods are defined in the SwiftProtobuf library. See the 101 | /// `Message` and `Message+*Additions` files. 102 | public func traverse(visitor: inout V) throws { 103 | if !self.name.isEmpty { 104 | try visitor.visitSingularStringField(value: self.name, fieldNumber: 1) 105 | } 106 | if !self.op.isEmpty { 107 | try visitor.visitSingularStringField(value: self.op, fieldNumber: 2) 108 | } 109 | if !self.input.isEmpty { 110 | try visitor.visitRepeatedStringField(value: self.input, fieldNumber: 3) 111 | } 112 | if !self.device.isEmpty { 113 | try visitor.visitSingularStringField(value: self.device, fieldNumber: 4) 114 | } 115 | if !self.attr.isEmpty { 116 | try visitor.visitMapField(fieldType: SwiftProtobuf._ProtobufMessageMap.self, value: self.attr, fieldNumber: 5) 117 | } 118 | try unknownFields.traverse(visitor: &visitor) 119 | } 120 | } 121 | 122 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 123 | 124 | fileprivate let _protobuf_package = "tensorflow" 125 | 126 | extension Tensorflow_NodeDef: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 127 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 128 | 1: .same(proto: "name"), 129 | 2: .same(proto: "op"), 130 | 3: .same(proto: "input"), 131 | 4: .same(proto: "device"), 132 | 5: .same(proto: "attr"), 133 | ] 134 | 135 | public func _protobuf_generated_isEqualTo(other: Tensorflow_NodeDef) -> Bool { 136 | if self.name != other.name {return false} 137 | if self.op != other.op {return false} 138 | if self.input != other.input {return false} 139 | if self.device != other.device {return false} 140 | if self.attr != other.attr {return false} 141 | if unknownFields != other.unknownFields {return false} 142 | return true 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.queue_runner.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/protobuf/queue_runner.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// Protocol buffer representing a QueueRunner. 23 | public struct Tensorflow_QueueRunnerDef: SwiftProtobuf.Message { 24 | public static let protoMessageName: String = _protobuf_package + ".QueueRunnerDef" 25 | 26 | /// Queue name. 27 | public var queueName: String = String() 28 | 29 | /// A list of enqueue operations. 30 | public var enqueueOpName: [String] = [] 31 | 32 | /// The operation to run to close the queue. 33 | public var closeOpName: String = String() 34 | 35 | /// The operation to run to cancel the queue. 36 | public var cancelOpName: String = String() 37 | 38 | /// A list of exception types considered to signal a safely closed queue 39 | /// if raised during enqueue operations. 40 | public var queueClosedExceptionTypes: [Tensorflow_Error_Code] = [] 41 | 42 | public var unknownFields = SwiftProtobuf.UnknownStorage() 43 | 44 | public init() {} 45 | 46 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 47 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 48 | /// initializers are defined in the SwiftProtobuf library. See the Message and 49 | /// Message+*Additions` files. 50 | public mutating func decodeMessage(decoder: inout D) throws { 51 | while let fieldNumber = try decoder.nextFieldNumber() { 52 | switch fieldNumber { 53 | case 1: try decoder.decodeSingularStringField(value: &self.queueName) 54 | case 2: try decoder.decodeRepeatedStringField(value: &self.enqueueOpName) 55 | case 3: try decoder.decodeSingularStringField(value: &self.closeOpName) 56 | case 4: try decoder.decodeSingularStringField(value: &self.cancelOpName) 57 | case 5: try decoder.decodeRepeatedEnumField(value: &self.queueClosedExceptionTypes) 58 | default: break 59 | } 60 | } 61 | } 62 | 63 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 64 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 65 | /// other serializer methods are defined in the SwiftProtobuf library. See the 66 | /// `Message` and `Message+*Additions` files. 67 | public func traverse(visitor: inout V) throws { 68 | if !self.queueName.isEmpty { 69 | try visitor.visitSingularStringField(value: self.queueName, fieldNumber: 1) 70 | } 71 | if !self.enqueueOpName.isEmpty { 72 | try visitor.visitRepeatedStringField(value: self.enqueueOpName, fieldNumber: 2) 73 | } 74 | if !self.closeOpName.isEmpty { 75 | try visitor.visitSingularStringField(value: self.closeOpName, fieldNumber: 3) 76 | } 77 | if !self.cancelOpName.isEmpty { 78 | try visitor.visitSingularStringField(value: self.cancelOpName, fieldNumber: 4) 79 | } 80 | if !self.queueClosedExceptionTypes.isEmpty { 81 | try visitor.visitPackedEnumField(value: self.queueClosedExceptionTypes, fieldNumber: 5) 82 | } 83 | try unknownFields.traverse(visitor: &visitor) 84 | } 85 | } 86 | 87 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 88 | 89 | fileprivate let _protobuf_package = "tensorflow" 90 | 91 | extension Tensorflow_QueueRunnerDef: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 92 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 93 | 1: .standard(proto: "queue_name"), 94 | 2: .standard(proto: "enqueue_op_name"), 95 | 3: .standard(proto: "close_op_name"), 96 | 4: .standard(proto: "cancel_op_name"), 97 | 5: .standard(proto: "queue_closed_exception_types"), 98 | ] 99 | 100 | public func _protobuf_generated_isEqualTo(other: Tensorflow_QueueRunnerDef) -> Bool { 101 | if self.queueName != other.queueName {return false} 102 | if self.enqueueOpName != other.enqueueOpName {return false} 103 | if self.closeOpName != other.closeOpName {return false} 104 | if self.cancelOpName != other.cancelOpName {return false} 105 | if self.queueClosedExceptionTypes != other.queueClosedExceptionTypes {return false} 106 | if unknownFields != other.unknownFields {return false} 107 | return true 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.reader_base.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/reader_base.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// For serializing and restoring the state of ReaderBase, see 23 | /// reader_base.h for details. 24 | public struct Tensorflow_ReaderBaseState: SwiftProtobuf.Message { 25 | public static let protoMessageName: String = _protobuf_package + ".ReaderBaseState" 26 | 27 | public var workStarted: Int64 = 0 28 | 29 | public var workFinished: Int64 = 0 30 | 31 | public var numRecordsProduced: Int64 = 0 32 | 33 | public var currentWork: Data = SwiftProtobuf.Internal.emptyData 34 | 35 | public var unknownFields = SwiftProtobuf.UnknownStorage() 36 | 37 | public init() {} 38 | 39 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 40 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 41 | /// initializers are defined in the SwiftProtobuf library. See the Message and 42 | /// Message+*Additions` files. 43 | public mutating func decodeMessage(decoder: inout D) throws { 44 | while let fieldNumber = try decoder.nextFieldNumber() { 45 | switch fieldNumber { 46 | case 1: try decoder.decodeSingularInt64Field(value: &self.workStarted) 47 | case 2: try decoder.decodeSingularInt64Field(value: &self.workFinished) 48 | case 3: try decoder.decodeSingularInt64Field(value: &self.numRecordsProduced) 49 | case 4: try decoder.decodeSingularBytesField(value: &self.currentWork) 50 | default: break 51 | } 52 | } 53 | } 54 | 55 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 56 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 57 | /// other serializer methods are defined in the SwiftProtobuf library. See the 58 | /// `Message` and `Message+*Additions` files. 59 | public func traverse(visitor: inout V) throws { 60 | if self.workStarted != 0 { 61 | try visitor.visitSingularInt64Field(value: self.workStarted, fieldNumber: 1) 62 | } 63 | if self.workFinished != 0 { 64 | try visitor.visitSingularInt64Field(value: self.workFinished, fieldNumber: 2) 65 | } 66 | if self.numRecordsProduced != 0 { 67 | try visitor.visitSingularInt64Field(value: self.numRecordsProduced, fieldNumber: 3) 68 | } 69 | if !self.currentWork.isEmpty { 70 | try visitor.visitSingularBytesField(value: self.currentWork, fieldNumber: 4) 71 | } 72 | try unknownFields.traverse(visitor: &visitor) 73 | } 74 | } 75 | 76 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 77 | 78 | fileprivate let _protobuf_package = "tensorflow" 79 | 80 | extension Tensorflow_ReaderBaseState: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 81 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 82 | 1: .standard(proto: "work_started"), 83 | 2: .standard(proto: "work_finished"), 84 | 3: .standard(proto: "num_records_produced"), 85 | 4: .standard(proto: "current_work"), 86 | ] 87 | 88 | public func _protobuf_generated_isEqualTo(other: Tensorflow_ReaderBaseState) -> Bool { 89 | if self.workStarted != other.workStarted {return false} 90 | if self.workFinished != other.workFinished {return false} 91 | if self.numRecordsProduced != other.numRecordsProduced {return false} 92 | if self.currentWork != other.currentWork {return false} 93 | if unknownFields != other.unknownFields {return false} 94 | return true 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.resource_handle.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/resource_handle.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// Protocol buffer representing a handle to a tensorflow resource. Handles are 23 | /// not valid across executions, but can be serialized back and forth from within 24 | /// a single run. 25 | public struct Tensorflow_ResourceHandleProto: SwiftProtobuf.Message { 26 | public static let protoMessageName: String = _protobuf_package + ".ResourceHandleProto" 27 | 28 | /// Unique name for the device containing the resource. 29 | public var device: String = String() 30 | 31 | /// Container in which this resource is placed. 32 | public var container: String = String() 33 | 34 | /// Unique name of this resource. 35 | public var name: String = String() 36 | 37 | /// Hash code for the type of the resource. Is only valid in the same device 38 | /// and in the same execution. 39 | public var hashCode: UInt64 = 0 40 | 41 | /// For debug-only, the name of the type pointed to by this handle, if 42 | /// available. 43 | public var maybeTypeName: String = String() 44 | 45 | public var unknownFields = SwiftProtobuf.UnknownStorage() 46 | 47 | public init() {} 48 | 49 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 50 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 51 | /// initializers are defined in the SwiftProtobuf library. See the Message and 52 | /// Message+*Additions` files. 53 | public mutating func decodeMessage(decoder: inout D) throws { 54 | while let fieldNumber = try decoder.nextFieldNumber() { 55 | switch fieldNumber { 56 | case 1: try decoder.decodeSingularStringField(value: &self.device) 57 | case 2: try decoder.decodeSingularStringField(value: &self.container) 58 | case 3: try decoder.decodeSingularStringField(value: &self.name) 59 | case 4: try decoder.decodeSingularUInt64Field(value: &self.hashCode) 60 | case 5: try decoder.decodeSingularStringField(value: &self.maybeTypeName) 61 | default: break 62 | } 63 | } 64 | } 65 | 66 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 67 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 68 | /// other serializer methods are defined in the SwiftProtobuf library. See the 69 | /// `Message` and `Message+*Additions` files. 70 | public func traverse(visitor: inout V) throws { 71 | if !self.device.isEmpty { 72 | try visitor.visitSingularStringField(value: self.device, fieldNumber: 1) 73 | } 74 | if !self.container.isEmpty { 75 | try visitor.visitSingularStringField(value: self.container, fieldNumber: 2) 76 | } 77 | if !self.name.isEmpty { 78 | try visitor.visitSingularStringField(value: self.name, fieldNumber: 3) 79 | } 80 | if self.hashCode != 0 { 81 | try visitor.visitSingularUInt64Field(value: self.hashCode, fieldNumber: 4) 82 | } 83 | if !self.maybeTypeName.isEmpty { 84 | try visitor.visitSingularStringField(value: self.maybeTypeName, fieldNumber: 5) 85 | } 86 | try unknownFields.traverse(visitor: &visitor) 87 | } 88 | } 89 | 90 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 91 | 92 | fileprivate let _protobuf_package = "tensorflow" 93 | 94 | extension Tensorflow_ResourceHandleProto: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 95 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 96 | 1: .same(proto: "device"), 97 | 2: .same(proto: "container"), 98 | 3: .same(proto: "name"), 99 | 4: .standard(proto: "hash_code"), 100 | 5: .standard(proto: "maybe_type_name"), 101 | ] 102 | 103 | public func _protobuf_generated_isEqualTo(other: Tensorflow_ResourceHandleProto) -> Bool { 104 | if self.device != other.device {return false} 105 | if self.container != other.container {return false} 106 | if self.name != other.name {return false} 107 | if self.hashCode != other.hashCode {return false} 108 | if self.maybeTypeName != other.maybeTypeName {return false} 109 | if unknownFields != other.unknownFields {return false} 110 | return true 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.saved_model.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/protobuf/saved_model.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// SavedModel is the high level serialization format for TensorFlow Models. 23 | /// See [todo: doc links, similar to session_bundle] for more information. 24 | public struct Tensorflow_SavedModel: SwiftProtobuf.Message { 25 | public static let protoMessageName: String = _protobuf_package + ".SavedModel" 26 | 27 | /// The schema version of the SavedModel instance. Used for versioning when 28 | /// making future changes to the specification/implementation. Initial value 29 | /// at release will be 1. 30 | public var savedModelSchemaVersion: Int64 = 0 31 | 32 | /// One or more MetaGraphs. 33 | public var metaGraphs: [Tensorflow_MetaGraphDef] = [] 34 | 35 | public var unknownFields = SwiftProtobuf.UnknownStorage() 36 | 37 | public init() {} 38 | 39 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 40 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 41 | /// initializers are defined in the SwiftProtobuf library. See the Message and 42 | /// Message+*Additions` files. 43 | public mutating func decodeMessage(decoder: inout D) throws { 44 | while let fieldNumber = try decoder.nextFieldNumber() { 45 | switch fieldNumber { 46 | case 1: try decoder.decodeSingularInt64Field(value: &self.savedModelSchemaVersion) 47 | case 2: try decoder.decodeRepeatedMessageField(value: &self.metaGraphs) 48 | default: break 49 | } 50 | } 51 | } 52 | 53 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 54 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 55 | /// other serializer methods are defined in the SwiftProtobuf library. See the 56 | /// `Message` and `Message+*Additions` files. 57 | public func traverse(visitor: inout V) throws { 58 | if self.savedModelSchemaVersion != 0 { 59 | try visitor.visitSingularInt64Field(value: self.savedModelSchemaVersion, fieldNumber: 1) 60 | } 61 | if !self.metaGraphs.isEmpty { 62 | try visitor.visitRepeatedMessageField(value: self.metaGraphs, fieldNumber: 2) 63 | } 64 | try unknownFields.traverse(visitor: &visitor) 65 | } 66 | } 67 | 68 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 69 | 70 | fileprivate let _protobuf_package = "tensorflow" 71 | 72 | extension Tensorflow_SavedModel: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 73 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 74 | 1: .standard(proto: "saved_model_schema_version"), 75 | 2: .standard(proto: "meta_graphs"), 76 | ] 77 | 78 | public func _protobuf_generated_isEqualTo(other: Tensorflow_SavedModel) -> Bool { 79 | if self.savedModelSchemaVersion != other.savedModelSchemaVersion {return false} 80 | if self.metaGraphs != other.metaGraphs {return false} 81 | if unknownFields != other.unknownFields {return false} 82 | return true 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.saver.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/protobuf/saver.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// Protocol buffer representing the configuration of a Saver. 23 | public struct Tensorflow_SaverDef: SwiftProtobuf.Message { 24 | public static let protoMessageName: String = _protobuf_package + ".SaverDef" 25 | 26 | /// The name of the tensor in which to specify the filename when saving or 27 | /// restoring a model checkpoint. 28 | public var filenameTensorName: String = String() 29 | 30 | /// The operation to run when saving a model checkpoint. 31 | public var saveTensorName: String = String() 32 | 33 | /// The operation to run when restoring a model checkpoint. 34 | public var restoreOpName: String = String() 35 | 36 | /// Maximum number of checkpoints to keep. If 0, no checkpoints are deleted. 37 | public var maxToKeep: Int32 = 0 38 | 39 | /// Shard the save files, one per device that has Variable nodes. 40 | public var sharded: Bool = false 41 | 42 | /// How often to keep an additional checkpoint. If not specified, only the last 43 | /// "max_to_keep" checkpoints are kept; if specified, in addition to keeping 44 | /// the last "max_to_keep" checkpoints, an additional checkpoint will be kept 45 | /// for every n hours of training. 46 | public var keepCheckpointEveryNHours: Float = 0 47 | 48 | public var version: Tensorflow_SaverDef.CheckpointFormatVersion = .legacy 49 | 50 | public var unknownFields = SwiftProtobuf.UnknownStorage() 51 | 52 | /// A version number that identifies a different on-disk checkpoint format. 53 | /// Usually, each subclass of BaseSaverBuilder works with a particular 54 | /// version/format. However, it is possible that the same builder may be 55 | /// upgraded to support a newer checkpoint format in the future. 56 | public enum CheckpointFormatVersion: SwiftProtobuf.Enum { 57 | public typealias RawValue = Int 58 | 59 | /// Internal legacy format. 60 | case legacy // = 0 61 | 62 | /// Deprecated format: tf.Saver() which works with tensorflow::table::Table. 63 | case v1 // = 1 64 | 65 | /// Current format: more efficient. 66 | case v2 // = 2 67 | case UNRECOGNIZED(Int) 68 | 69 | public init() { 70 | self = .legacy 71 | } 72 | 73 | public init?(rawValue: Int) { 74 | switch rawValue { 75 | case 0: self = .legacy 76 | case 1: self = .v1 77 | case 2: self = .v2 78 | default: self = .UNRECOGNIZED(rawValue) 79 | } 80 | } 81 | 82 | public var rawValue: Int { 83 | switch self { 84 | case .legacy: return 0 85 | case .v1: return 1 86 | case .v2: return 2 87 | case .UNRECOGNIZED(let i): return i 88 | } 89 | } 90 | 91 | } 92 | 93 | public init() {} 94 | 95 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 96 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 97 | /// initializers are defined in the SwiftProtobuf library. See the Message and 98 | /// Message+*Additions` files. 99 | public mutating func decodeMessage(decoder: inout D) throws { 100 | while let fieldNumber = try decoder.nextFieldNumber() { 101 | switch fieldNumber { 102 | case 1: try decoder.decodeSingularStringField(value: &self.filenameTensorName) 103 | case 2: try decoder.decodeSingularStringField(value: &self.saveTensorName) 104 | case 3: try decoder.decodeSingularStringField(value: &self.restoreOpName) 105 | case 4: try decoder.decodeSingularInt32Field(value: &self.maxToKeep) 106 | case 5: try decoder.decodeSingularBoolField(value: &self.sharded) 107 | case 6: try decoder.decodeSingularFloatField(value: &self.keepCheckpointEveryNHours) 108 | case 7: try decoder.decodeSingularEnumField(value: &self.version) 109 | default: break 110 | } 111 | } 112 | } 113 | 114 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 115 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 116 | /// other serializer methods are defined in the SwiftProtobuf library. See the 117 | /// `Message` and `Message+*Additions` files. 118 | public func traverse(visitor: inout V) throws { 119 | if !self.filenameTensorName.isEmpty { 120 | try visitor.visitSingularStringField(value: self.filenameTensorName, fieldNumber: 1) 121 | } 122 | if !self.saveTensorName.isEmpty { 123 | try visitor.visitSingularStringField(value: self.saveTensorName, fieldNumber: 2) 124 | } 125 | if !self.restoreOpName.isEmpty { 126 | try visitor.visitSingularStringField(value: self.restoreOpName, fieldNumber: 3) 127 | } 128 | if self.maxToKeep != 0 { 129 | try visitor.visitSingularInt32Field(value: self.maxToKeep, fieldNumber: 4) 130 | } 131 | if self.sharded != false { 132 | try visitor.visitSingularBoolField(value: self.sharded, fieldNumber: 5) 133 | } 134 | if self.keepCheckpointEveryNHours != 0 { 135 | try visitor.visitSingularFloatField(value: self.keepCheckpointEveryNHours, fieldNumber: 6) 136 | } 137 | if self.version != .legacy { 138 | try visitor.visitSingularEnumField(value: self.version, fieldNumber: 7) 139 | } 140 | try unknownFields.traverse(visitor: &visitor) 141 | } 142 | } 143 | 144 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 145 | 146 | fileprivate let _protobuf_package = "tensorflow" 147 | 148 | extension Tensorflow_SaverDef: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 149 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 150 | 1: .standard(proto: "filename_tensor_name"), 151 | 2: .standard(proto: "save_tensor_name"), 152 | 3: .standard(proto: "restore_op_name"), 153 | 4: .standard(proto: "max_to_keep"), 154 | 5: .same(proto: "sharded"), 155 | 6: .standard(proto: "keep_checkpoint_every_n_hours"), 156 | 7: .same(proto: "version"), 157 | ] 158 | 159 | public func _protobuf_generated_isEqualTo(other: Tensorflow_SaverDef) -> Bool { 160 | if self.filenameTensorName != other.filenameTensorName {return false} 161 | if self.saveTensorName != other.saveTensorName {return false} 162 | if self.restoreOpName != other.restoreOpName {return false} 163 | if self.maxToKeep != other.maxToKeep {return false} 164 | if self.sharded != other.sharded {return false} 165 | if self.keepCheckpointEveryNHours != other.keepCheckpointEveryNHours {return false} 166 | if self.version != other.version {return false} 167 | if unknownFields != other.unknownFields {return false} 168 | return true 169 | } 170 | } 171 | 172 | extension Tensorflow_SaverDef.CheckpointFormatVersion: SwiftProtobuf._ProtoNameProviding { 173 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 174 | 0: .same(proto: "LEGACY"), 175 | 1: .same(proto: "V1"), 176 | 2: .same(proto: "V2"), 177 | ] 178 | } 179 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.split_info.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/contrib/boosted_trees/proto/split_info.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// Gathered information for a split node. 23 | public struct Tensorflow_BoostedTrees_Learner_SplitInfo: SwiftProtobuf.Message { 24 | public static let protoMessageName: String = _protobuf_package + ".SplitInfo" 25 | 26 | /// The split node without the child nodes attached. 27 | public var splitNode: Tensorflow_BoostedTrees_Trees_TreeNode { 28 | get {return _storage._splitNode ?? Tensorflow_BoostedTrees_Trees_TreeNode()} 29 | set {_uniqueStorage()._splitNode = newValue} 30 | } 31 | /// Returns true if `splitNode` has been explicitly set. 32 | public var hasSplitNode: Bool {return _storage._splitNode != nil} 33 | /// Clears the value of `splitNode`. Subsequent reads from it will return its default value. 34 | public mutating func clearSplitNode() {_storage._splitNode = nil} 35 | 36 | /// Left Leaf node. 37 | public var leftChild: Tensorflow_BoostedTrees_Trees_Leaf { 38 | get {return _storage._leftChild ?? Tensorflow_BoostedTrees_Trees_Leaf()} 39 | set {_uniqueStorage()._leftChild = newValue} 40 | } 41 | /// Returns true if `leftChild` has been explicitly set. 42 | public var hasLeftChild: Bool {return _storage._leftChild != nil} 43 | /// Clears the value of `leftChild`. Subsequent reads from it will return its default value. 44 | public mutating func clearLeftChild() {_storage._leftChild = nil} 45 | 46 | /// Right Leaf node. 47 | public var rightChild: Tensorflow_BoostedTrees_Trees_Leaf { 48 | get {return _storage._rightChild ?? Tensorflow_BoostedTrees_Trees_Leaf()} 49 | set {_uniqueStorage()._rightChild = newValue} 50 | } 51 | /// Returns true if `rightChild` has been explicitly set. 52 | public var hasRightChild: Bool {return _storage._rightChild != nil} 53 | /// Clears the value of `rightChild`. Subsequent reads from it will return its default value. 54 | public mutating func clearRightChild() {_storage._rightChild = nil} 55 | 56 | public var unknownFields = SwiftProtobuf.UnknownStorage() 57 | 58 | public init() {} 59 | 60 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 61 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 62 | /// initializers are defined in the SwiftProtobuf library. See the Message and 63 | /// Message+*Additions` files. 64 | public mutating func decodeMessage(decoder: inout D) throws { 65 | _ = _uniqueStorage() 66 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 67 | while let fieldNumber = try decoder.nextFieldNumber() { 68 | switch fieldNumber { 69 | case 1: try decoder.decodeSingularMessageField(value: &_storage._splitNode) 70 | case 2: try decoder.decodeSingularMessageField(value: &_storage._leftChild) 71 | case 3: try decoder.decodeSingularMessageField(value: &_storage._rightChild) 72 | default: break 73 | } 74 | } 75 | } 76 | } 77 | 78 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 79 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 80 | /// other serializer methods are defined in the SwiftProtobuf library. See the 81 | /// `Message` and `Message+*Additions` files. 82 | public func traverse(visitor: inout V) throws { 83 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 84 | if let v = _storage._splitNode { 85 | try visitor.visitSingularMessageField(value: v, fieldNumber: 1) 86 | } 87 | if let v = _storage._leftChild { 88 | try visitor.visitSingularMessageField(value: v, fieldNumber: 2) 89 | } 90 | if let v = _storage._rightChild { 91 | try visitor.visitSingularMessageField(value: v, fieldNumber: 3) 92 | } 93 | } 94 | try unknownFields.traverse(visitor: &visitor) 95 | } 96 | 97 | fileprivate var _storage = _StorageClass.defaultInstance 98 | } 99 | 100 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 101 | 102 | fileprivate let _protobuf_package = "tensorflow.boosted_trees.learner" 103 | 104 | extension Tensorflow_BoostedTrees_Learner_SplitInfo: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 105 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 106 | 1: .standard(proto: "split_node"), 107 | 2: .standard(proto: "left_child"), 108 | 3: .standard(proto: "right_child"), 109 | ] 110 | 111 | fileprivate class _StorageClass { 112 | var _splitNode: Tensorflow_BoostedTrees_Trees_TreeNode? = nil 113 | var _leftChild: Tensorflow_BoostedTrees_Trees_Leaf? = nil 114 | var _rightChild: Tensorflow_BoostedTrees_Trees_Leaf? = nil 115 | 116 | static let defaultInstance = _StorageClass() 117 | 118 | private init() {} 119 | 120 | init(copying source: _StorageClass) { 121 | _splitNode = source._splitNode 122 | _leftChild = source._leftChild 123 | _rightChild = source._rightChild 124 | } 125 | } 126 | 127 | fileprivate mutating func _uniqueStorage() -> _StorageClass { 128 | if !isKnownUniquelyReferenced(&_storage) { 129 | _storage = _StorageClass(copying: _storage) 130 | } 131 | return _storage 132 | } 133 | 134 | public func _protobuf_generated_isEqualTo(other: Tensorflow_BoostedTrees_Learner_SplitInfo) -> Bool { 135 | if _storage !== other._storage { 136 | let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in 137 | let _storage = _args.0 138 | let other_storage = _args.1 139 | if _storage._splitNode != other_storage._splitNode {return false} 140 | if _storage._leftChild != other_storage._leftChild {return false} 141 | if _storage._rightChild != other_storage._rightChild {return false} 142 | return true 143 | } 144 | if !storagesAreEqual {return false} 145 | } 146 | if unknownFields != other.unknownFields {return false} 147 | return true 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.tensor_description.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/tensor_description.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | public struct Tensorflow_TensorDescription: SwiftProtobuf.Message { 23 | public static let protoMessageName: String = _protobuf_package + ".TensorDescription" 24 | 25 | /// Data type of tensor elements 26 | public var dtype: Tensorflow_DataType { 27 | get {return _storage._dtype} 28 | set {_uniqueStorage()._dtype = newValue} 29 | } 30 | 31 | /// Shape of the tensor. 32 | public var shape: Tensorflow_TensorShapeProto { 33 | get {return _storage._shape ?? Tensorflow_TensorShapeProto()} 34 | set {_uniqueStorage()._shape = newValue} 35 | } 36 | /// Returns true if `shape` has been explicitly set. 37 | public var hasShape: Bool {return _storage._shape != nil} 38 | /// Clears the value of `shape`. Subsequent reads from it will return its default value. 39 | public mutating func clearShape() {_storage._shape = nil} 40 | 41 | /// Information about the size and allocator used for the data 42 | public var allocationDescription: Tensorflow_AllocationDescription { 43 | get {return _storage._allocationDescription ?? Tensorflow_AllocationDescription()} 44 | set {_uniqueStorage()._allocationDescription = newValue} 45 | } 46 | /// Returns true if `allocationDescription` has been explicitly set. 47 | public var hasAllocationDescription: Bool {return _storage._allocationDescription != nil} 48 | /// Clears the value of `allocationDescription`. Subsequent reads from it will return its default value. 49 | public mutating func clearAllocationDescription() {_storage._allocationDescription = nil} 50 | 51 | public var unknownFields = SwiftProtobuf.UnknownStorage() 52 | 53 | public init() {} 54 | 55 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 56 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 57 | /// initializers are defined in the SwiftProtobuf library. See the Message and 58 | /// Message+*Additions` files. 59 | public mutating func decodeMessage(decoder: inout D) throws { 60 | _ = _uniqueStorage() 61 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 62 | while let fieldNumber = try decoder.nextFieldNumber() { 63 | switch fieldNumber { 64 | case 1: try decoder.decodeSingularEnumField(value: &_storage._dtype) 65 | case 2: try decoder.decodeSingularMessageField(value: &_storage._shape) 66 | case 4: try decoder.decodeSingularMessageField(value: &_storage._allocationDescription) 67 | default: break 68 | } 69 | } 70 | } 71 | } 72 | 73 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 74 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 75 | /// other serializer methods are defined in the SwiftProtobuf library. See the 76 | /// `Message` and `Message+*Additions` files. 77 | public func traverse(visitor: inout V) throws { 78 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 79 | if _storage._dtype != .dtInvalid { 80 | try visitor.visitSingularEnumField(value: _storage._dtype, fieldNumber: 1) 81 | } 82 | if let v = _storage._shape { 83 | try visitor.visitSingularMessageField(value: v, fieldNumber: 2) 84 | } 85 | if let v = _storage._allocationDescription { 86 | try visitor.visitSingularMessageField(value: v, fieldNumber: 4) 87 | } 88 | } 89 | try unknownFields.traverse(visitor: &visitor) 90 | } 91 | 92 | fileprivate var _storage = _StorageClass.defaultInstance 93 | } 94 | 95 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 96 | 97 | fileprivate let _protobuf_package = "tensorflow" 98 | 99 | extension Tensorflow_TensorDescription: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 100 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 101 | 1: .same(proto: "dtype"), 102 | 2: .same(proto: "shape"), 103 | 4: .standard(proto: "allocation_description"), 104 | ] 105 | 106 | fileprivate class _StorageClass { 107 | var _dtype: Tensorflow_DataType = .dtInvalid 108 | var _shape: Tensorflow_TensorShapeProto? = nil 109 | var _allocationDescription: Tensorflow_AllocationDescription? = nil 110 | 111 | static let defaultInstance = _StorageClass() 112 | 113 | private init() {} 114 | 115 | init(copying source: _StorageClass) { 116 | _dtype = source._dtype 117 | _shape = source._shape 118 | _allocationDescription = source._allocationDescription 119 | } 120 | } 121 | 122 | fileprivate mutating func _uniqueStorage() -> _StorageClass { 123 | if !isKnownUniquelyReferenced(&_storage) { 124 | _storage = _StorageClass(copying: _storage) 125 | } 126 | return _storage 127 | } 128 | 129 | public func _protobuf_generated_isEqualTo(other: Tensorflow_TensorDescription) -> Bool { 130 | if _storage !== other._storage { 131 | let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in 132 | let _storage = _args.0 133 | let other_storage = _args.1 134 | if _storage._dtype != other_storage._dtype {return false} 135 | if _storage._shape != other_storage._shape {return false} 136 | if _storage._allocationDescription != other_storage._allocationDescription {return false} 137 | return true 138 | } 139 | if !storagesAreEqual {return false} 140 | } 141 | if unknownFields != other.unknownFields {return false} 142 | return true 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.tensor_shape.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/tensor_shape.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | // Protocol buffer representing the shape of tensors. 10 | 11 | import Foundation 12 | import SwiftProtobuf 13 | 14 | // If the compiler emits an error on this type, it is because this file 15 | // was generated by a version of the `protoc` Swift plug-in that is 16 | // incompatible with the version of SwiftProtobuf to which you are linking. 17 | // Please ensure that your are building against the same version of the API 18 | // that was used to generate this file. 19 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 20 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 21 | typealias Version = _2 22 | } 23 | 24 | /// Dimensions of a tensor. 25 | public struct Tensorflow_TensorShapeProto: SwiftProtobuf.Message { 26 | public static let protoMessageName: String = _protobuf_package + ".TensorShapeProto" 27 | 28 | /// Dimensions of the tensor, such as {"input", 30}, {"output", 40} 29 | /// for a 30 x 40 2D tensor. If an entry has size -1, this 30 | /// corresponds to a dimension of unknown size. The names are 31 | /// optional. 32 | /// 33 | /// The order of entries in "dim" matters: It indicates the layout of the 34 | /// values in the tensor in-memory representation. 35 | /// 36 | /// The first entry in "dim" is the outermost dimension used to layout the 37 | /// values, the last entry is the innermost dimension. This matches the 38 | /// in-memory layout of RowMajor Eigen tensors. 39 | /// 40 | /// If "dim.size()" > 0, "unknown_rank" must be false. 41 | public var dim: [Tensorflow_TensorShapeProto.Dim] = [] 42 | 43 | /// If true, the number of dimensions in the shape is unknown. 44 | /// 45 | /// If true, "dim.size()" must be 0. 46 | public var unknownRank: Bool = false 47 | 48 | public var unknownFields = SwiftProtobuf.UnknownStorage() 49 | 50 | /// One dimension of the tensor. 51 | public struct Dim: SwiftProtobuf.Message { 52 | public static let protoMessageName: String = Tensorflow_TensorShapeProto.protoMessageName + ".Dim" 53 | 54 | /// Size of the tensor in that dimension. 55 | /// This value must be >= -1, but values of -1 are reserved for "unknown" 56 | /// shapes (values of -1 mean "unknown" dimension). Certain wrappers 57 | /// that work with TensorShapeProto may fail at runtime when deserializing 58 | /// a TensorShapeProto containing a dim value of -1. 59 | public var size: Int64 = 0 60 | 61 | /// Optional name of the tensor dimension. 62 | public var name: String = String() 63 | 64 | public var unknownFields = SwiftProtobuf.UnknownStorage() 65 | 66 | public init() {} 67 | 68 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 69 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 70 | /// initializers are defined in the SwiftProtobuf library. See the Message and 71 | /// Message+*Additions` files. 72 | public mutating func decodeMessage(decoder: inout D) throws { 73 | while let fieldNumber = try decoder.nextFieldNumber() { 74 | switch fieldNumber { 75 | case 1: try decoder.decodeSingularInt64Field(value: &self.size) 76 | case 2: try decoder.decodeSingularStringField(value: &self.name) 77 | default: break 78 | } 79 | } 80 | } 81 | 82 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 83 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 84 | /// other serializer methods are defined in the SwiftProtobuf library. See the 85 | /// `Message` and `Message+*Additions` files. 86 | public func traverse(visitor: inout V) throws { 87 | if self.size != 0 { 88 | try visitor.visitSingularInt64Field(value: self.size, fieldNumber: 1) 89 | } 90 | if !self.name.isEmpty { 91 | try visitor.visitSingularStringField(value: self.name, fieldNumber: 2) 92 | } 93 | try unknownFields.traverse(visitor: &visitor) 94 | } 95 | } 96 | 97 | public init() {} 98 | 99 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 100 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 101 | /// initializers are defined in the SwiftProtobuf library. See the Message and 102 | /// Message+*Additions` files. 103 | public mutating func decodeMessage(decoder: inout D) throws { 104 | while let fieldNumber = try decoder.nextFieldNumber() { 105 | switch fieldNumber { 106 | case 2: try decoder.decodeRepeatedMessageField(value: &self.dim) 107 | case 3: try decoder.decodeSingularBoolField(value: &self.unknownRank) 108 | default: break 109 | } 110 | } 111 | } 112 | 113 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 114 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 115 | /// other serializer methods are defined in the SwiftProtobuf library. See the 116 | /// `Message` and `Message+*Additions` files. 117 | public func traverse(visitor: inout V) throws { 118 | if !self.dim.isEmpty { 119 | try visitor.visitRepeatedMessageField(value: self.dim, fieldNumber: 2) 120 | } 121 | if self.unknownRank != false { 122 | try visitor.visitSingularBoolField(value: self.unknownRank, fieldNumber: 3) 123 | } 124 | try unknownFields.traverse(visitor: &visitor) 125 | } 126 | } 127 | 128 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 129 | 130 | fileprivate let _protobuf_package = "tensorflow" 131 | 132 | extension Tensorflow_TensorShapeProto: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 133 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 134 | 2: .same(proto: "dim"), 135 | 3: .standard(proto: "unknown_rank"), 136 | ] 137 | 138 | public func _protobuf_generated_isEqualTo(other: Tensorflow_TensorShapeProto) -> Bool { 139 | if self.dim != other.dim {return false} 140 | if self.unknownRank != other.unknownRank {return false} 141 | if unknownFields != other.unknownFields {return false} 142 | return true 143 | } 144 | } 145 | 146 | extension Tensorflow_TensorShapeProto.Dim: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 147 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 148 | 1: .same(proto: "size"), 149 | 2: .same(proto: "name"), 150 | ] 151 | 152 | public func _protobuf_generated_isEqualTo(other: Tensorflow_TensorShapeProto.Dim) -> Bool { 153 | if self.size != other.size {return false} 154 | if self.name != other.name {return false} 155 | if unknownFields != other.unknownFields {return false} 156 | return true 157 | } 158 | } 159 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.tensor_slice.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/tensor_slice.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | // Protocol buffer representing slices of a tensor 10 | 11 | import Foundation 12 | import SwiftProtobuf 13 | 14 | // If the compiler emits an error on this type, it is because this file 15 | // was generated by a version of the `protoc` Swift plug-in that is 16 | // incompatible with the version of SwiftProtobuf to which you are linking. 17 | // Please ensure that your are building against the same version of the API 18 | // that was used to generate this file. 19 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 20 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 21 | typealias Version = _2 22 | } 23 | 24 | /// Can only be interpreted if you know the corresponding TensorShape. 25 | public struct Tensorflow_TensorSliceProto: SwiftProtobuf.Message { 26 | public static let protoMessageName: String = _protobuf_package + ".TensorSliceProto" 27 | 28 | /// Extent of the slice in all tensor dimensions. 29 | /// 30 | /// Must have one entry for each of the dimension of the tensor that this 31 | /// slice belongs to. The order of sizes is the same as the order of 32 | /// dimensions in the TensorShape. 33 | public var extent: [Tensorflow_TensorSliceProto.Extent] = [] 34 | 35 | public var unknownFields = SwiftProtobuf.UnknownStorage() 36 | 37 | /// Extent of the slice in one dimension. 38 | public struct Extent: SwiftProtobuf.Message { 39 | public static let protoMessageName: String = Tensorflow_TensorSliceProto.protoMessageName + ".Extent" 40 | 41 | /// Start index of the slice, starting at 0. 42 | public var start: Int64 = 0 43 | 44 | /// Length of the slice: if the length is missing or -1 we will 45 | /// interpret this as "everything in this dimension". We use 46 | /// "oneof" to preserve information about whether the length is 47 | /// present without changing the serialization format from the 48 | /// prior proto2 version of this proto. 49 | public var hasLength_p: Tensorflow_TensorSliceProto.Extent.OneOf_HasLength? = nil 50 | 51 | public var length: Int64 { 52 | get { 53 | if case .length(let v)? = hasLength_p {return v} 54 | return 0 55 | } 56 | set {hasLength_p = .length(newValue)} 57 | } 58 | 59 | public var unknownFields = SwiftProtobuf.UnknownStorage() 60 | 61 | /// Length of the slice: if the length is missing or -1 we will 62 | /// interpret this as "everything in this dimension". We use 63 | /// "oneof" to preserve information about whether the length is 64 | /// present without changing the serialization format from the 65 | /// prior proto2 version of this proto. 66 | public enum OneOf_HasLength: Equatable { 67 | case length(Int64) 68 | 69 | public static func ==(lhs: Tensorflow_TensorSliceProto.Extent.OneOf_HasLength, rhs: Tensorflow_TensorSliceProto.Extent.OneOf_HasLength) -> Bool { 70 | switch (lhs, rhs) { 71 | case (.length(let l), .length(let r)): return l == r 72 | } 73 | } 74 | } 75 | 76 | public init() {} 77 | 78 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 79 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 80 | /// initializers are defined in the SwiftProtobuf library. See the Message and 81 | /// Message+*Additions` files. 82 | public mutating func decodeMessage(decoder: inout D) throws { 83 | while let fieldNumber = try decoder.nextFieldNumber() { 84 | switch fieldNumber { 85 | case 1: try decoder.decodeSingularInt64Field(value: &self.start) 86 | case 2: 87 | if self.hasLength_p != nil {try decoder.handleConflictingOneOf()} 88 | var v: Int64? 89 | try decoder.decodeSingularInt64Field(value: &v) 90 | if let v = v {self.hasLength_p = .length(v)} 91 | default: break 92 | } 93 | } 94 | } 95 | 96 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 97 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 98 | /// other serializer methods are defined in the SwiftProtobuf library. See the 99 | /// `Message` and `Message+*Additions` files. 100 | public func traverse(visitor: inout V) throws { 101 | if self.start != 0 { 102 | try visitor.visitSingularInt64Field(value: self.start, fieldNumber: 1) 103 | } 104 | if case .length(let v)? = self.hasLength_p { 105 | try visitor.visitSingularInt64Field(value: v, fieldNumber: 2) 106 | } 107 | try unknownFields.traverse(visitor: &visitor) 108 | } 109 | } 110 | 111 | public init() {} 112 | 113 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 114 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 115 | /// initializers are defined in the SwiftProtobuf library. See the Message and 116 | /// Message+*Additions` files. 117 | public mutating func decodeMessage(decoder: inout D) throws { 118 | while let fieldNumber = try decoder.nextFieldNumber() { 119 | switch fieldNumber { 120 | case 1: try decoder.decodeRepeatedMessageField(value: &self.extent) 121 | default: break 122 | } 123 | } 124 | } 125 | 126 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 127 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 128 | /// other serializer methods are defined in the SwiftProtobuf library. See the 129 | /// `Message` and `Message+*Additions` files. 130 | public func traverse(visitor: inout V) throws { 131 | if !self.extent.isEmpty { 132 | try visitor.visitRepeatedMessageField(value: self.extent, fieldNumber: 1) 133 | } 134 | try unknownFields.traverse(visitor: &visitor) 135 | } 136 | } 137 | 138 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 139 | 140 | fileprivate let _protobuf_package = "tensorflow" 141 | 142 | extension Tensorflow_TensorSliceProto: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 143 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 144 | 1: .same(proto: "extent"), 145 | ] 146 | 147 | public func _protobuf_generated_isEqualTo(other: Tensorflow_TensorSliceProto) -> Bool { 148 | if self.extent != other.extent {return false} 149 | if unknownFields != other.unknownFields {return false} 150 | return true 151 | } 152 | } 153 | 154 | extension Tensorflow_TensorSliceProto.Extent: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 155 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 156 | 1: .same(proto: "start"), 157 | 2: .same(proto: "length"), 158 | ] 159 | 160 | public func _protobuf_generated_isEqualTo(other: Tensorflow_TensorSliceProto.Extent) -> Bool { 161 | if self.start != other.start {return false} 162 | if self.hasLength_p != other.hasLength_p {return false} 163 | if unknownFields != other.unknownFields {return false} 164 | return true 165 | } 166 | } 167 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.tensorflow_server.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/protobuf/tensorflow_server.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | // Copyright 2016 The TensorFlow Authors. All Rights Reserved. 10 | // 11 | //Licensed under the Apache License, Version 2.0 (the "License"); 12 | //you may not use this file except in compliance with the License. 13 | //You may obtain a copy of the License at 14 | // 15 | //http://www.apache.org/licenses/LICENSE-2.0 16 | // 17 | //Unless required by applicable law or agreed to in writing, software 18 | //distributed under the License is distributed on an "AS IS" BASIS, 19 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | //See the License for the specific language governing permissions and 21 | //limitations under the License. 22 | //============================================================================== 23 | 24 | import Foundation 25 | import SwiftProtobuf 26 | 27 | // If the compiler emits an error on this type, it is because this file 28 | // was generated by a version of the `protoc` Swift plug-in that is 29 | // incompatible with the version of SwiftProtobuf to which you are linking. 30 | // Please ensure that your are building against the same version of the API 31 | // that was used to generate this file. 32 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 33 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 34 | typealias Version = _2 35 | } 36 | 37 | /// Defines the configuration of a single TensorFlow server. 38 | public struct Tensorflow_ServerDef: SwiftProtobuf.Message { 39 | public static let protoMessageName: String = _protobuf_package + ".ServerDef" 40 | 41 | /// The cluster of which this server is a member. 42 | public var cluster: Tensorflow_ClusterDef { 43 | get {return _storage._cluster ?? Tensorflow_ClusterDef()} 44 | set {_uniqueStorage()._cluster = newValue} 45 | } 46 | /// Returns true if `cluster` has been explicitly set. 47 | public var hasCluster: Bool {return _storage._cluster != nil} 48 | /// Clears the value of `cluster`. Subsequent reads from it will return its default value. 49 | public mutating func clearCluster() {_storage._cluster = nil} 50 | 51 | /// The name of the job of which this server is a member. 52 | /// 53 | /// NOTE(mrry): The `cluster` field must contain a `JobDef` with a `name` field 54 | /// that matches this name. 55 | public var jobName: String { 56 | get {return _storage._jobName} 57 | set {_uniqueStorage()._jobName = newValue} 58 | } 59 | 60 | /// The task index of this server in its job. 61 | /// 62 | /// NOTE: The `cluster` field must contain a `JobDef` with a matching `name` 63 | /// and a mapping in its `tasks` field for this index. 64 | public var taskIndex: Int32 { 65 | get {return _storage._taskIndex} 66 | set {_uniqueStorage()._taskIndex = newValue} 67 | } 68 | 69 | /// The default configuration for sessions that run on this server. 70 | public var defaultSessionConfig: Tensorflow_ConfigProto { 71 | get {return _storage._defaultSessionConfig ?? Tensorflow_ConfigProto()} 72 | set {_uniqueStorage()._defaultSessionConfig = newValue} 73 | } 74 | /// Returns true if `defaultSessionConfig` has been explicitly set. 75 | public var hasDefaultSessionConfig: Bool {return _storage._defaultSessionConfig != nil} 76 | /// Clears the value of `defaultSessionConfig`. Subsequent reads from it will return its default value. 77 | public mutating func clearDefaultSessionConfig() {_storage._defaultSessionConfig = nil} 78 | 79 | /// The protocol to be used by this server. 80 | /// 81 | /// Acceptable values include: "grpc". 82 | public var `protocol`: String { 83 | get {return _storage._protocol} 84 | set {_uniqueStorage()._protocol = newValue} 85 | } 86 | 87 | public var unknownFields = SwiftProtobuf.UnknownStorage() 88 | 89 | public init() {} 90 | 91 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 92 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 93 | /// initializers are defined in the SwiftProtobuf library. See the Message and 94 | /// Message+*Additions` files. 95 | public mutating func decodeMessage(decoder: inout D) throws { 96 | _ = _uniqueStorage() 97 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 98 | while let fieldNumber = try decoder.nextFieldNumber() { 99 | switch fieldNumber { 100 | case 1: try decoder.decodeSingularMessageField(value: &_storage._cluster) 101 | case 2: try decoder.decodeSingularStringField(value: &_storage._jobName) 102 | case 3: try decoder.decodeSingularInt32Field(value: &_storage._taskIndex) 103 | case 4: try decoder.decodeSingularMessageField(value: &_storage._defaultSessionConfig) 104 | case 5: try decoder.decodeSingularStringField(value: &_storage._protocol) 105 | default: break 106 | } 107 | } 108 | } 109 | } 110 | 111 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 112 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 113 | /// other serializer methods are defined in the SwiftProtobuf library. See the 114 | /// `Message` and `Message+*Additions` files. 115 | public func traverse(visitor: inout V) throws { 116 | try withExtendedLifetime(_storage) { (_storage: _StorageClass) in 117 | if let v = _storage._cluster { 118 | try visitor.visitSingularMessageField(value: v, fieldNumber: 1) 119 | } 120 | if !_storage._jobName.isEmpty { 121 | try visitor.visitSingularStringField(value: _storage._jobName, fieldNumber: 2) 122 | } 123 | if _storage._taskIndex != 0 { 124 | try visitor.visitSingularInt32Field(value: _storage._taskIndex, fieldNumber: 3) 125 | } 126 | if let v = _storage._defaultSessionConfig { 127 | try visitor.visitSingularMessageField(value: v, fieldNumber: 4) 128 | } 129 | if !_storage._protocol.isEmpty { 130 | try visitor.visitSingularStringField(value: _storage._protocol, fieldNumber: 5) 131 | } 132 | } 133 | try unknownFields.traverse(visitor: &visitor) 134 | } 135 | 136 | fileprivate var _storage = _StorageClass.defaultInstance 137 | } 138 | 139 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 140 | 141 | fileprivate let _protobuf_package = "tensorflow" 142 | 143 | extension Tensorflow_ServerDef: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 144 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 145 | 1: .same(proto: "cluster"), 146 | 2: .standard(proto: "job_name"), 147 | 3: .standard(proto: "task_index"), 148 | 4: .standard(proto: "default_session_config"), 149 | 5: .same(proto: "protocol"), 150 | ] 151 | 152 | fileprivate class _StorageClass { 153 | var _cluster: Tensorflow_ClusterDef? = nil 154 | var _jobName: String = String() 155 | var _taskIndex: Int32 = 0 156 | var _defaultSessionConfig: Tensorflow_ConfigProto? = nil 157 | var _protocol: String = String() 158 | 159 | static let defaultInstance = _StorageClass() 160 | 161 | private init() {} 162 | 163 | init(copying source: _StorageClass) { 164 | _cluster = source._cluster 165 | _jobName = source._jobName 166 | _taskIndex = source._taskIndex 167 | _defaultSessionConfig = source._defaultSessionConfig 168 | _protocol = source._protocol 169 | } 170 | } 171 | 172 | fileprivate mutating func _uniqueStorage() -> _StorageClass { 173 | if !isKnownUniquelyReferenced(&_storage) { 174 | _storage = _StorageClass(copying: _storage) 175 | } 176 | return _storage 177 | } 178 | 179 | public func _protobuf_generated_isEqualTo(other: Tensorflow_ServerDef) -> Bool { 180 | if _storage !== other._storage { 181 | let storagesAreEqual: Bool = withExtendedLifetime((_storage, other._storage)) { (_args: (_StorageClass, _StorageClass)) in 182 | let _storage = _args.0 183 | let other_storage = _args.1 184 | if _storage._cluster != other_storage._cluster {return false} 185 | if _storage._jobName != other_storage._jobName {return false} 186 | if _storage._taskIndex != other_storage._taskIndex {return false} 187 | if _storage._defaultSessionConfig != other_storage._defaultSessionConfig {return false} 188 | if _storage._protocol != other_storage._protocol {return false} 189 | return true 190 | } 191 | if !storagesAreEqual {return false} 192 | } 193 | if unknownFields != other.unknownFields {return false} 194 | return true 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.topology.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/contrib/tpu/proto/topology.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// Describes the geometry of a TPU mesh. 23 | public struct Tensorflow_Tpu_TopologyProto: SwiftProtobuf.Message { 24 | public static let protoMessageName: String = _protobuf_package + ".TopologyProto" 25 | 26 | /// The dimensions of the TPU topology, in cores. Typically, this is a 3D 27 | /// topology [x, y, core], where the major dimensions correspond to TPU chips, 28 | /// and the minor dimension describes the number of cores on a multicore chip. 29 | public var meshShape: [Int32] = [] 30 | 31 | /// Number of TensorFlow tasks in the cluster. 32 | public var numTasks: Int32 = 0 33 | 34 | /// Number of TPU devices per task. 35 | public var numTpuDevicesPerTask: Int32 = 0 36 | 37 | /// A flattened rank 3 int32 array with shape 38 | /// [num_tasks, num_tpu_devices_per_task, len(mesh_shape)]. 39 | /// `tasks` is the number of tasks in the TPU cluster, `devices` is the number 40 | /// of TPU devices per task, and the minor dimension corresponds to a position 41 | /// in the TPU mesh topology. Each entry [task, device, axis] gives the 42 | /// `axis`-th coordinate in the topology of a task/device pair. 43 | public var deviceCoordinates: [Int32] = [] 44 | 45 | public var unknownFields = SwiftProtobuf.UnknownStorage() 46 | 47 | public init() {} 48 | 49 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 50 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 51 | /// initializers are defined in the SwiftProtobuf library. See the Message and 52 | /// Message+*Additions` files. 53 | public mutating func decodeMessage(decoder: inout D) throws { 54 | while let fieldNumber = try decoder.nextFieldNumber() { 55 | switch fieldNumber { 56 | case 1: try decoder.decodeRepeatedInt32Field(value: &self.meshShape) 57 | case 2: try decoder.decodeSingularInt32Field(value: &self.numTasks) 58 | case 3: try decoder.decodeSingularInt32Field(value: &self.numTpuDevicesPerTask) 59 | case 4: try decoder.decodeRepeatedInt32Field(value: &self.deviceCoordinates) 60 | default: break 61 | } 62 | } 63 | } 64 | 65 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 66 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 67 | /// other serializer methods are defined in the SwiftProtobuf library. See the 68 | /// `Message` and `Message+*Additions` files. 69 | public func traverse(visitor: inout V) throws { 70 | if !self.meshShape.isEmpty { 71 | try visitor.visitPackedInt32Field(value: self.meshShape, fieldNumber: 1) 72 | } 73 | if self.numTasks != 0 { 74 | try visitor.visitSingularInt32Field(value: self.numTasks, fieldNumber: 2) 75 | } 76 | if self.numTpuDevicesPerTask != 0 { 77 | try visitor.visitSingularInt32Field(value: self.numTpuDevicesPerTask, fieldNumber: 3) 78 | } 79 | if !self.deviceCoordinates.isEmpty { 80 | try visitor.visitPackedInt32Field(value: self.deviceCoordinates, fieldNumber: 4) 81 | } 82 | try unknownFields.traverse(visitor: &visitor) 83 | } 84 | } 85 | 86 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 87 | 88 | fileprivate let _protobuf_package = "tensorflow.tpu" 89 | 90 | extension Tensorflow_Tpu_TopologyProto: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 91 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 92 | 1: .standard(proto: "mesh_shape"), 93 | 2: .standard(proto: "num_tasks"), 94 | 3: .standard(proto: "num_tpu_devices_per_task"), 95 | 4: .standard(proto: "device_coordinates"), 96 | ] 97 | 98 | public func _protobuf_generated_isEqualTo(other: Tensorflow_Tpu_TopologyProto) -> Bool { 99 | if self.meshShape != other.meshShape {return false} 100 | if self.numTasks != other.numTasks {return false} 101 | if self.numTpuDevicesPerTask != other.numTpuDevicesPerTask {return false} 102 | if self.deviceCoordinates != other.deviceCoordinates {return false} 103 | if unknownFields != other.unknownFields {return false} 104 | return true 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.types.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/types.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// LINT.IfChange 23 | public enum Tensorflow_DataType: SwiftProtobuf.Enum { 24 | public typealias RawValue = Int 25 | 26 | /// Not a legal value for DataType. Used to indicate a DataType field 27 | /// has not been set. 28 | case dtInvalid // = 0 29 | 30 | /// Data types that all computation devices are expected to be 31 | /// capable to support. 32 | case dtFloat // = 1 33 | case dtDouble // = 2 34 | case dtInt32 // = 3 35 | case dtUint8 // = 4 36 | case dtInt16 // = 5 37 | case dtInt8 // = 6 38 | case dtString // = 7 39 | 40 | /// Single-precision complex 41 | case dtComplex64 // = 8 42 | case dtInt64 // = 9 43 | case dtBool // = 10 44 | 45 | /// Quantized int8 46 | case dtQint8 // = 11 47 | 48 | /// Quantized uint8 49 | case dtQuint8 // = 12 50 | 51 | /// Quantized int32 52 | case dtQint32 // = 13 53 | 54 | /// Float32 truncated to 16 bits. Only for cast ops. 55 | case dtBfloat16 // = 14 56 | 57 | /// Quantized int16 58 | case dtQint16 // = 15 59 | 60 | /// Quantized uint16 61 | case dtQuint16 // = 16 62 | case dtUint16 // = 17 63 | 64 | /// Double-precision complex 65 | case dtComplex128 // = 18 66 | case dtHalf // = 19 67 | case dtResource // = 20 68 | 69 | /// Arbitrary C++ data types 70 | case dtVariant // = 21 71 | 72 | /// Do not use! These are only for parameters. Every enum above 73 | /// should have a corresponding value below (verified by types_test). 74 | case dtFloatRef // = 101 75 | case dtDoubleRef // = 102 76 | case dtInt32Ref // = 103 77 | case dtUint8Ref // = 104 78 | case dtInt16Ref // = 105 79 | case dtInt8Ref // = 106 80 | case dtStringRef // = 107 81 | case dtComplex64Ref // = 108 82 | case dtInt64Ref // = 109 83 | case dtBoolRef // = 110 84 | case dtQint8Ref // = 111 85 | case dtQuint8Ref // = 112 86 | case dtQint32Ref // = 113 87 | case dtBfloat16Ref // = 114 88 | case dtQint16Ref // = 115 89 | case dtQuint16Ref // = 116 90 | case dtUint16Ref // = 117 91 | case dtComplex128Ref // = 118 92 | case dtHalfRef // = 119 93 | case dtResourceRef // = 120 94 | case dtVariantRef // = 121 95 | case UNRECOGNIZED(Int) 96 | 97 | public init() { 98 | self = .dtInvalid 99 | } 100 | 101 | public init?(rawValue: Int) { 102 | switch rawValue { 103 | case 0: self = .dtInvalid 104 | case 1: self = .dtFloat 105 | case 2: self = .dtDouble 106 | case 3: self = .dtInt32 107 | case 4: self = .dtUint8 108 | case 5: self = .dtInt16 109 | case 6: self = .dtInt8 110 | case 7: self = .dtString 111 | case 8: self = .dtComplex64 112 | case 9: self = .dtInt64 113 | case 10: self = .dtBool 114 | case 11: self = .dtQint8 115 | case 12: self = .dtQuint8 116 | case 13: self = .dtQint32 117 | case 14: self = .dtBfloat16 118 | case 15: self = .dtQint16 119 | case 16: self = .dtQuint16 120 | case 17: self = .dtUint16 121 | case 18: self = .dtComplex128 122 | case 19: self = .dtHalf 123 | case 20: self = .dtResource 124 | case 21: self = .dtVariant 125 | case 101: self = .dtFloatRef 126 | case 102: self = .dtDoubleRef 127 | case 103: self = .dtInt32Ref 128 | case 104: self = .dtUint8Ref 129 | case 105: self = .dtInt16Ref 130 | case 106: self = .dtInt8Ref 131 | case 107: self = .dtStringRef 132 | case 108: self = .dtComplex64Ref 133 | case 109: self = .dtInt64Ref 134 | case 110: self = .dtBoolRef 135 | case 111: self = .dtQint8Ref 136 | case 112: self = .dtQuint8Ref 137 | case 113: self = .dtQint32Ref 138 | case 114: self = .dtBfloat16Ref 139 | case 115: self = .dtQint16Ref 140 | case 116: self = .dtQuint16Ref 141 | case 117: self = .dtUint16Ref 142 | case 118: self = .dtComplex128Ref 143 | case 119: self = .dtHalfRef 144 | case 120: self = .dtResourceRef 145 | case 121: self = .dtVariantRef 146 | default: self = .UNRECOGNIZED(rawValue) 147 | } 148 | } 149 | 150 | public var rawValue: Int { 151 | switch self { 152 | case .dtInvalid: return 0 153 | case .dtFloat: return 1 154 | case .dtDouble: return 2 155 | case .dtInt32: return 3 156 | case .dtUint8: return 4 157 | case .dtInt16: return 5 158 | case .dtInt8: return 6 159 | case .dtString: return 7 160 | case .dtComplex64: return 8 161 | case .dtInt64: return 9 162 | case .dtBool: return 10 163 | case .dtQint8: return 11 164 | case .dtQuint8: return 12 165 | case .dtQint32: return 13 166 | case .dtBfloat16: return 14 167 | case .dtQint16: return 15 168 | case .dtQuint16: return 16 169 | case .dtUint16: return 17 170 | case .dtComplex128: return 18 171 | case .dtHalf: return 19 172 | case .dtResource: return 20 173 | case .dtVariant: return 21 174 | case .dtFloatRef: return 101 175 | case .dtDoubleRef: return 102 176 | case .dtInt32Ref: return 103 177 | case .dtUint8Ref: return 104 178 | case .dtInt16Ref: return 105 179 | case .dtInt8Ref: return 106 180 | case .dtStringRef: return 107 181 | case .dtComplex64Ref: return 108 182 | case .dtInt64Ref: return 109 183 | case .dtBoolRef: return 110 184 | case .dtQint8Ref: return 111 185 | case .dtQuint8Ref: return 112 186 | case .dtQint32Ref: return 113 187 | case .dtBfloat16Ref: return 114 188 | case .dtQint16Ref: return 115 189 | case .dtQuint16Ref: return 116 190 | case .dtUint16Ref: return 117 191 | case .dtComplex128Ref: return 118 192 | case .dtHalfRef: return 119 193 | case .dtResourceRef: return 120 194 | case .dtVariantRef: return 121 195 | case .UNRECOGNIZED(let i): return i 196 | } 197 | } 198 | 199 | } 200 | 201 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 202 | 203 | extension Tensorflow_DataType: SwiftProtobuf._ProtoNameProviding { 204 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 205 | 0: .same(proto: "DT_INVALID"), 206 | 1: .same(proto: "DT_FLOAT"), 207 | 2: .same(proto: "DT_DOUBLE"), 208 | 3: .same(proto: "DT_INT32"), 209 | 4: .same(proto: "DT_UINT8"), 210 | 5: .same(proto: "DT_INT16"), 211 | 6: .same(proto: "DT_INT8"), 212 | 7: .same(proto: "DT_STRING"), 213 | 8: .same(proto: "DT_COMPLEX64"), 214 | 9: .same(proto: "DT_INT64"), 215 | 10: .same(proto: "DT_BOOL"), 216 | 11: .same(proto: "DT_QINT8"), 217 | 12: .same(proto: "DT_QUINT8"), 218 | 13: .same(proto: "DT_QINT32"), 219 | 14: .same(proto: "DT_BFLOAT16"), 220 | 15: .same(proto: "DT_QINT16"), 221 | 16: .same(proto: "DT_QUINT16"), 222 | 17: .same(proto: "DT_UINT16"), 223 | 18: .same(proto: "DT_COMPLEX128"), 224 | 19: .same(proto: "DT_HALF"), 225 | 20: .same(proto: "DT_RESOURCE"), 226 | 21: .same(proto: "DT_VARIANT"), 227 | 101: .same(proto: "DT_FLOAT_REF"), 228 | 102: .same(proto: "DT_DOUBLE_REF"), 229 | 103: .same(proto: "DT_INT32_REF"), 230 | 104: .same(proto: "DT_UINT8_REF"), 231 | 105: .same(proto: "DT_INT16_REF"), 232 | 106: .same(proto: "DT_INT8_REF"), 233 | 107: .same(proto: "DT_STRING_REF"), 234 | 108: .same(proto: "DT_COMPLEX64_REF"), 235 | 109: .same(proto: "DT_INT64_REF"), 236 | 110: .same(proto: "DT_BOOL_REF"), 237 | 111: .same(proto: "DT_QINT8_REF"), 238 | 112: .same(proto: "DT_QUINT8_REF"), 239 | 113: .same(proto: "DT_QINT32_REF"), 240 | 114: .same(proto: "DT_BFLOAT16_REF"), 241 | 115: .same(proto: "DT_QINT16_REF"), 242 | 116: .same(proto: "DT_QUINT16_REF"), 243 | 117: .same(proto: "DT_UINT16_REF"), 244 | 118: .same(proto: "DT_COMPLEX128_REF"), 245 | 119: .same(proto: "DT_HALF_REF"), 246 | 120: .same(proto: "DT_RESOURCE_REF"), 247 | 121: .same(proto: "DT_VARIANT_REF"), 248 | ] 249 | } 250 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.versions.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/framework/versions.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | import Foundation 10 | import SwiftProtobuf 11 | 12 | // If the compiler emits an error on this type, it is because this file 13 | // was generated by a version of the `protoc` Swift plug-in that is 14 | // incompatible with the version of SwiftProtobuf to which you are linking. 15 | // Please ensure that your are building against the same version of the API 16 | // that was used to generate this file. 17 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 18 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 19 | typealias Version = _2 20 | } 21 | 22 | /// Version information for a piece of serialized data 23 | /// 24 | /// There are different types of versions for each type of data 25 | /// (GraphDef, etc.), but they all have the same common shape 26 | /// described here. 27 | /// 28 | /// Each consumer has "consumer" and "min_producer" versions (specified 29 | /// elsewhere). A consumer is allowed to consume this data if 30 | /// 31 | /// producer >= min_producer 32 | /// consumer >= min_consumer 33 | /// consumer not in bad_consumers 34 | public struct Tensorflow_VersionDef: SwiftProtobuf.Message { 35 | public static let protoMessageName: String = _protobuf_package + ".VersionDef" 36 | 37 | /// The version of the code that produced this data. 38 | public var producer: Int32 = 0 39 | 40 | /// Any consumer below this version is not allowed to consume this data. 41 | public var minConsumer: Int32 = 0 42 | 43 | /// Specific consumer versions which are disallowed (e.g. due to bugs). 44 | public var badConsumers: [Int32] = [] 45 | 46 | public var unknownFields = SwiftProtobuf.UnknownStorage() 47 | 48 | public init() {} 49 | 50 | /// Used by the decoding initializers in the SwiftProtobuf library, not generally 51 | /// used directly. `init(serializedData:)`, `init(jsonUTF8Data:)`, and other decoding 52 | /// initializers are defined in the SwiftProtobuf library. See the Message and 53 | /// Message+*Additions` files. 54 | public mutating func decodeMessage(decoder: inout D) throws { 55 | while let fieldNumber = try decoder.nextFieldNumber() { 56 | switch fieldNumber { 57 | case 1: try decoder.decodeSingularInt32Field(value: &self.producer) 58 | case 2: try decoder.decodeSingularInt32Field(value: &self.minConsumer) 59 | case 3: try decoder.decodeRepeatedInt32Field(value: &self.badConsumers) 60 | default: break 61 | } 62 | } 63 | } 64 | 65 | /// Used by the encoding methods of the SwiftProtobuf library, not generally 66 | /// used directly. `Message.serializedData()`, `Message.jsonUTF8Data()`, and 67 | /// other serializer methods are defined in the SwiftProtobuf library. See the 68 | /// `Message` and `Message+*Additions` files. 69 | public func traverse(visitor: inout V) throws { 70 | if self.producer != 0 { 71 | try visitor.visitSingularInt32Field(value: self.producer, fieldNumber: 1) 72 | } 73 | if self.minConsumer != 0 { 74 | try visitor.visitSingularInt32Field(value: self.minConsumer, fieldNumber: 2) 75 | } 76 | if !self.badConsumers.isEmpty { 77 | try visitor.visitPackedInt32Field(value: self.badConsumers, fieldNumber: 3) 78 | } 79 | try unknownFields.traverse(visitor: &visitor) 80 | } 81 | } 82 | 83 | // MARK: - Code below here is support for the SwiftProtobuf runtime. 84 | 85 | fileprivate let _protobuf_package = "tensorflow" 86 | 87 | extension Tensorflow_VersionDef: SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding { 88 | public static let _protobuf_nameMap: SwiftProtobuf._NameMap = [ 89 | 1: .same(proto: "producer"), 90 | 2: .standard(proto: "min_consumer"), 91 | 3: .standard(proto: "bad_consumers"), 92 | ] 93 | 94 | public func _protobuf_generated_isEqualTo(other: Tensorflow_VersionDef) -> Bool { 95 | if self.producer != other.producer {return false} 96 | if self.minConsumer != other.minConsumer {return false} 97 | if self.badConsumers != other.badConsumers {return false} 98 | if unknownFields != other.unknownFields {return false} 99 | return true 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /Sources/PerfectTensorFlow/pb.worker_service.swift: -------------------------------------------------------------------------------- 1 | // DO NOT EDIT. 2 | // 3 | // Generated by the Swift generator plugin for the protocol buffer compiler. 4 | // Source: tensorflow/core/protobuf/worker_service.proto 5 | // 6 | // For information on using the generated types, please see the documenation: 7 | // https://github.com/apple/swift-protobuf/ 8 | 9 | // Copyright 2016 The TensorFlow Authors. All Rights Reserved. 10 | // 11 | //Licensed under the Apache License, Version 2.0 (the "License"); 12 | //you may not use this file except in compliance with the License. 13 | //You may obtain a copy of the License at 14 | // 15 | //http://www.apache.org/licenses/LICENSE-2.0 16 | // 17 | //Unless required by applicable law or agreed to in writing, software 18 | //distributed under the License is distributed on an "AS IS" BASIS, 19 | //WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 | //See the License for the specific language governing permissions and 21 | //limitations under the License. 22 | //============================================================================== 23 | 24 | import Foundation 25 | import SwiftProtobuf 26 | 27 | // If the compiler emits an error on this type, it is because this file 28 | // was generated by a version of the `protoc` Swift plug-in that is 29 | // incompatible with the version of SwiftProtobuf to which you are linking. 30 | // Please ensure that your are building against the same version of the API 31 | // that was used to generate this file. 32 | fileprivate struct _GeneratedWithProtocGenSwiftVersion: SwiftProtobuf.ProtobufAPIVersionCheck { 33 | struct _2: SwiftProtobuf.ProtobufAPIVersion_2 {} 34 | typealias Version = _2 35 | } 36 | -------------------------------------------------------------------------------- /Sources/TensorFlowAPI/TensorFlowAPI.c: -------------------------------------------------------------------------------- 1 | // 2 | // TensorFlowAPI.c 3 | // Perfect-TensorFlow 4 | // 5 | // Created by Rockford Wei on 2017-05-18. 6 | // Copyright © 2017 PerfectlySoft. All rights reserved. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This source file is part of the Perfect.org open source project 11 | // 12 | // Copyright (c) 2017 - 2018 PerfectlySoft Inc. and the Perfect project authors 13 | // Licensed under Apache License v2.0 14 | // 15 | // See http://perfect.org/licensing.html for license information 16 | // 17 | //===----------------------------------------------------------------------===// 18 | // 19 | 20 | #include "TensorFlowAPI.h" 21 | #include 22 | #include 23 | #include 24 | 25 | void * libraryHandle = NULL; 26 | typedef void* (*TF_NewTensor_t) 27 | (int, const int64_t* dims, int num_dims, 28 | void* data, size_t len,void (*deallocator)(void* data, size_t len, 29 | void* arg), void* deallocator_arg); 30 | 31 | TF_NewTensor_t TF_NewTensorOrg = NULL; 32 | 33 | typedef void (*TF_DeleteTensor_t) (void *); 34 | TF_DeleteTensor_t TF_DeleteTensorOrg = NULL; 35 | 36 | typedef TF_Operation * (*TF_GraphNextOperation_t)(TF_Graph * graph, size_t * pos); 37 | TF_GraphNextOperation_t TF_GraphNextOperationOrg = NULL; 38 | 39 | TF_Operation * TF_NextGraphOperation(TF_Graph * graph, size_t * pos) 40 | { return TF_GraphNextOperationOrg && graph && pos 41 | ? (*TF_GraphNextOperationOrg)(graph, pos) : NULL; } 42 | 43 | typedef void * (*TF_NewStatus_t) (); 44 | TF_NewStatus_t TF_NewStatusOrg = NULL; 45 | 46 | typedef void (*TF_DeleteStatus_t) (void *); 47 | TF_DeleteStatus_t TF_DeleteStatusOrg = NULL; 48 | 49 | 50 | int TF_LoadPatchLibrary(const char * path) 51 | { 52 | if (!path) return -1; 53 | libraryHandle = dlopen(path, RTLD_LAZY); 54 | if (!libraryHandle) return -2; 55 | TF_NewTensorOrg = (TF_NewTensor_t) dlsym(libraryHandle, "TF_NewTensor"); 56 | TF_DeleteTensorOrg = (TF_DeleteTensor_t) dlsym(libraryHandle, "TF_DeleteTensor"); 57 | TF_GraphNextOperationOrg = (TF_GraphNextOperation_t) dlsym(libraryHandle, "TF_GraphNextOperation"); 58 | TF_NewStatusOrg = (TF_NewStatus_t) dlsym(libraryHandle, "TF_NewStatus"); 59 | TF_DeleteStatusOrg = (TF_DeleteStatus_t) dlsym(libraryHandle, "TF_DeleteStatus"); 60 | if (TF_NewTensorOrg && TF_DeleteTensorOrg 61 | && TF_GraphNextOperationOrg && TF_NewStatusOrg && TF_DeleteStatusOrg) 62 | return 0; 63 | return -3; 64 | } 65 | 66 | void TF_ClosePatchLibrary(void) 67 | { 68 | if (libraryHandle) dlclose(libraryHandle); 69 | libraryHandle = NULL; 70 | TF_NewTensorOrg = NULL; 71 | TF_DeleteTensorOrg = NULL; 72 | } 73 | -------------------------------------------------------------------------------- /Sources/TensorFlowAPI/include/TensorFlowAPI.h: -------------------------------------------------------------------------------- 1 | // 2 | // TensorFlowAPI.h 3 | // Perfect-TensorFlow 4 | // 5 | // Created by Rockford Wei on 2017-05-18. 6 | // Copyright © 2017 PerfectlySoft. All rights reserved. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This source file is part of the Perfect.org open source project 11 | // 12 | // Copyright (c) 2017 - 2018 PerfectlySoft Inc. and the Perfect project authors 13 | // Licensed under Apache License v2.0 14 | // 15 | // See http://perfect.org/licensing.html for license information 16 | // 17 | //===----------------------------------------------------------------------===// 18 | // 19 | 20 | #ifndef __TENSOR_FLOW_STRUCT__ 21 | #define __TENSOR_FLOW_STRUCT__ 22 | #include 23 | #include 24 | // -------------------------------------------------------------------------- 25 | // TF_Buffer holds a pointer to a block of data and its associated length. 26 | // Typically, the data consists of a serialized protocol buffer, but other data 27 | // may also be held in a buffer. 28 | // 29 | // By default, TF_Buffer itself does not do any memory management of the 30 | // pointed-to block. If need be, users of this struct should specify how to 31 | // deallocate the block by setting the `data_deallocator` function pointer. 32 | typedef struct TF_Buffer { 33 | const void* data; 34 | size_t length; 35 | void (*data_deallocator)(void* data, size_t length); 36 | } TF_Buffer; 37 | 38 | // -------------------------------------------------------------------------- 39 | // The new graph construction API, still under development. 40 | 41 | // Represents a computation graph. Graphs may be shared between sessions. 42 | // Graphs are thread-safe when used as directed below. 43 | typedef struct TF_Graph TF_Graph; 44 | 45 | // Operation being built. The underlying graph must outlive this. 46 | typedef struct TF_OperationDescription TF_OperationDescription; 47 | 48 | // Operation that has been added to the graph. Valid until the graph is 49 | // deleted -- in particular adding a new operation to the graph does not 50 | // invalidate old TF_Operation* pointers. 51 | typedef struct TF_Operation TF_Operation; 52 | 53 | // Represents a specific input of an operation. 54 | typedef struct TF_Input { 55 | TF_Operation* oper; 56 | int index; // The index of the input within oper. 57 | } TF_Input; 58 | 59 | // Represents a specific output of an operation. 60 | typedef struct TF_Output { 61 | TF_Operation* oper; 62 | int index; // The index of the output within oper. 63 | } TF_Output; 64 | 65 | 66 | // TF_AttrMetadata describes the value of an attribute on an operation. 67 | typedef struct TF_AttrMetadata { 68 | // A boolean: 1 if the attribute value is a list, 0 otherwise. 69 | unsigned char is_list; 70 | 71 | // Length of the list if is_list is true. Undefined otherwise. 72 | int64_t list_size; 73 | 74 | // Type of elements of the list if is_list != 0. 75 | // Type of the single value stored in the attribute if is_list == 0. 76 | int type; 77 | 78 | // Total size the attribute value. 79 | // The units of total_size depend on is_list and type. 80 | // (1) If type == TF_ATTR_STRING and is_list == 0 81 | // then total_size is the byte size of the string 82 | // valued attribute. 83 | // (2) If type == TF_ATTR_STRING and is_list == 1 84 | // then total_size is the cumulative byte size 85 | // of all the strings in the list. 86 | // (3) If type == TF_ATTR_SHAPE and is_list == 0 87 | // then total_size is the number of dimensions 88 | // of the shape valued attribute, or -1 89 | // if its rank is unknown. 90 | // (4) If type == TF_ATTR_SHAPE and is_list == 1 91 | // then total_size is the cumulative number 92 | // of dimensions of all shapes in the list. 93 | // (5) Otherwise, total_size is undefined. 94 | int64_t total_size; 95 | } TF_AttrMetadata; 96 | 97 | // TF_ImportGraphDefOptions holds options that can be passed to 98 | // TF_GraphImportGraphDef. 99 | typedef struct TF_ImportGraphDefOptions TF_ImportGraphDefOptions; 100 | 101 | typedef struct TF_WhileParams { 102 | // The number of inputs to the while loop, i.e. the number of loop variables. 103 | // This is the size of cond_inputs, body_inputs, and body_outputs. 104 | const int ninputs; 105 | 106 | // The while condition graph. The inputs are the current values of the loop 107 | // variables. The output should be a scalar boolean. 108 | TF_Graph* const cond_graph; 109 | const TF_Output* const cond_inputs; 110 | TF_Output cond_output; 111 | 112 | // The loop body graph. The inputs are the current values of the loop 113 | // variables. The outputs are the updated values of the loop variables. 114 | TF_Graph* const body_graph; 115 | const TF_Output* const body_inputs; 116 | TF_Output* const body_outputs; 117 | 118 | // Unique null-terminated name for this while loop. This is used as a prefix 119 | // for created operations. 120 | const char* name; 121 | } TF_WhileParams; 122 | 123 | // -------------------------------------------------------------------------- 124 | // API for driving Graph execution. 125 | 126 | typedef struct TF_Session TF_Session; 127 | typedef struct TF_DeviceList TF_DeviceList; 128 | 129 | // Load plugins containing custom ops and kernels 130 | 131 | // TF_Library holds information about dynamically loaded TensorFlow plugins. 132 | typedef struct TF_Library TF_Library; 133 | 134 | extern TF_Operation * TF_NextGraphOperation(TF_Graph * graph, size_t * pos); 135 | 136 | extern int TF_LoadPatchLibrary(const char * path); 137 | extern void TF_ClosePatchLibrary(void); 138 | #endif 139 | -------------------------------------------------------------------------------- /Tests/LinuxMain.swift: -------------------------------------------------------------------------------- 1 | import XCTest 2 | @testable import PerfectTensorFlowTests 3 | 4 | XCTMain([ 5 | testCase(PerfectTensorFlowTests.allTests), 6 | ]) 7 | -------------------------------------------------------------------------------- /VERSION: -------------------------------------------------------------------------------- 1 | 1.9.0 2 | -------------------------------------------------------------------------------- /cleantest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script is for CI Server 3 | echo "clean up" 4 | rm -rf .build 5 | rm -rf Package.pins 6 | rm -rf Package.resolved 7 | echo "build release" 8 | time swift build -c release 9 | echo "perform test" 10 | time swift test > test-results.txt 11 | cat test-results.txt 12 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | OSABR=$(echo $(uname)|tr '[:upper:]' '[:lower:]') 3 | DWN=/tmp/libtensorflow.tgz 4 | if [ -z "$1" ] 5 | then 6 | LOC=/usr/local 7 | else 8 | LOC=$1 9 | fi 10 | VERSION=`cat VERSION` 11 | URL=https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-$OSABR-x86_64-$VERSION.tar.gz 12 | echo $URL 13 | curl $URL -o $DWN 14 | echo "installing binaries ..." 15 | tar xf $DWN -C $LOC ./lib/libtensorflow.so ./lib/libtensorflow_framework.so 16 | touch $LOC/lib/libtensorflow.so 17 | touch $LOC/lib/libtensorflow_framework.so 18 | rm -f $DWN -------------------------------------------------------------------------------- /prepare.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script is for CI Server 3 | VERSION=`cat VERSION` 4 | echo 'Clean Temp Files' 5 | rm -rf /tmp/testdata 6 | echo 'Unzip test pack' 7 | tar xzf testpack.tgz -C /tmp/ 8 | echo 'download AI model' 9 | curl https://storage.googleapis.com/download.tensorflow.org/models/inception5h.zip -o /tmp/testdata/in.zip 10 | echo 'unzip model file' 11 | unzip /tmp/testdata/in.zip -d /tmp/testdata/ 12 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This script is for CI Server 3 | ./prepare.sh && ./install.sh /tmp/testdata && ./cleantest.sh 4 | -------------------------------------------------------------------------------- /testpack.tgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PerfectlySoft/Perfect-TensorFlow/dbbbedcfc541fd7dbda63c3350941ad1d2ba728c/testpack.tgz -------------------------------------------------------------------------------- /updateprotos.sh: -------------------------------------------------------------------------------- 1 | PROJ_BASE=$PWD 2 | TF=/tmp/tf 3 | PTF=/tmp/ptf 4 | OUTP=/tmp/pbout 5 | VERSION=`cat PROTO_VERSION` 6 | rm -rf $TF 7 | rm -rf $PTF 8 | rm -rf $OUTP 9 | mkdir $OUTP 10 | if [[ $OSTYPE =~ darwin* ]]; then 11 | brew install protobuf 12 | brew upgrade protobuf 13 | brew link --overwrite protobuf 14 | else 15 | sudo apt-get install protobuf-compiler 16 | fi 17 | git clone "https://github.com/tensorflow/tensorflow.git" $TF 18 | pushd $TF 19 | git checkout tags/v$VERSION 20 | popd 21 | git clone "https://github.com/apple/swift-protobuf.git" $PTF 22 | pushd ./ 23 | cd $PTF 24 | swift build -c release 25 | popd 26 | find $TF -type f -iname "*.proto" -print0 | while IFS= read -r -d $'\0' LINE; do 27 | protoc --plugin=$PTF/.build/release/protoc-gen-swift --swift_opt=Visibility=Public --swift_out=$OUTP --proto_path=$TF $LINE 28 | done 29 | find $OUTP -type f -iname "*.pb.swift" -print0 | while IFS= read -r -d $'\0' LINE; do 30 | FILE=$(basename $LINE) 31 | DEST=$(sed 's#.pb.swift#.swift#g' <<< $FILE) 32 | cp $LINE Sources/PerfectTensorFlow/pb.$DEST 33 | done 34 | --------------------------------------------------------------------------------