1/* Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 3Licensed under the Apache License, Version 2.0 (the "License"); 4you may not use this file except in compliance with the License. 5You may obtain a copy of the License at 6 7 http://www.apache.org/licenses/LICENSE-2.0 8 9Unless required by applicable law or agreed to in writing, software 10distributed under the License is distributed on an "AS IS" BASIS, 11WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12See the License for the specific language governing permissions and 13limitations under the License. 14==============================================================================*/ 15 16syntax = "proto3"; 17 18package tensorflow; 19 20import "tensorflow/core/framework/device_attributes.proto"; 21import "tensorflow/core/framework/graph.proto"; 22import "tensorflow/core/framework/tensor.proto"; 23import "tensorflow/core/protobuf/config.proto"; 24import "tensorflow/core/protobuf/error_codes.proto"; 25import "tensorflow/core/protobuf/named_tensor.proto"; 26 27option cc_enable_arenas = true; 28option java_outer_classname = "DistributedRuntimeProtos"; 29option java_multiple_files = true; 30option java_package = "org.tensorflow.distruntime"; 31option go_package = "github.com/tensorflow/tensorflow/tensorflow/go/core/protobuf/for_core_protos_go_proto"; 32 33//////////////////////////////////////////////////////////////////////////////// 34// 35// CreateSession method request/response protos. 36// 37//////////////////////////////////////////////////////////////////////////////// 38 39message CreateSessionRequest { 40 // The initial graph definition. 41 GraphDef graph_def = 1; 42 43 // Configuration options. 44 ConfigProto config = 2; 45 46 // The target string used from the client's perspective. 47 string target = 3; 48} 49 50message CreateSessionResponse { 51 // The session handle to be used in subsequent calls for the created session. 52 // 53 // The client must arrange to call CloseSession with this returned 54 // session handle to close the session. 55 string session_handle = 1; 56 57 // The initial version number for the graph, to be used in the next call 58 // to ExtendSession. 59 int64 graph_version = 2; 60} 61 62//////////////////////////////////////////////////////////////////////////////// 63// 64// ExtendSession method request/response protos. 65// 66// The "graph_def" specifies a set of nodes to be added to the session's graph. 67// 68// A typical "graph_def" will contain: 69// 70// * Zero or more new nodes with names that do not exist in the server-side 71// graph. These will be added to the graph. 72// 73// PRECONDITION: The server-side current version is req.current_version. 74// None of the names in req.graph_def appeared in previous successful calls to 75// CreateSession or ExtendSession with the same session_handle. 76// POSTCONDITION: The server-side current version is resp.new_version. 77// 78//////////////////////////////////////////////////////////////////////////////// 79 80message ExtendSessionRequest { 81 // REQUIRED: session_handle must be returned by a CreateSession call 82 // to the same master service. 83 string session_handle = 1; 84 85 // REQUIRED: The nodes to be added to the session's graph. If any node has 86 // the same name as an existing node, the operation will fail with 87 // ILLEGAL_ARGUMENT. 88 GraphDef graph_def = 2; 89 90 // REQUIRED: The version number of the graph to be extended. This will be 91 // tested against the current server-side version number, and the operation 92 // will fail with FAILED_PRECONDITION if they do not match. 93 int64 current_graph_version = 3; 94} 95 96message ExtendSessionResponse { 97 // TODO(mrry): Return something about the operation? 98 99 // The new version number for the extended graph, to be used in the next call 100 // to ExtendSession. 101 int64 new_graph_version = 4; 102} 103 104//////////////////////////////////////////////////////////////////////////////// 105// 106// RunStep method request/response protos. 107// 108// The caller should provide the feeds needed by the graph and specify 109// what nodes should be fetched. 110// 111//////////////////////////////////////////////////////////////////////////////// 112 113message RunStepRequest { 114 // REQUIRED: session_handle must be returned by a CreateSession call 115 // to the same master service. 116 string session_handle = 1; 117 118 // Tensors to be fed in the step. Each feed is a named tensor. 119 repeated NamedTensorProto feed = 2; 120 121 // Fetches. A list of tensor names. The caller expects a tensor to 122 // be returned for each fetch[i] (see RunStepResponse.tensor). The 123 // order of specified fetches does not change the execution order. 124 repeated string fetch = 3; 125 126 // Target Nodes. A list of node names. The named nodes will be run 127 // to but their outputs will not be fetched. 128 repeated string target = 4; 129 130 // Options for the run call. 131 RunOptions options = 5; 132 133 // Partial run handle (optional). If specified, this will be a partial run 134 // execution, run up to the specified fetches. 135 string partial_run_handle = 6; 136 137 // If true then some errors, e.g., execution errors that have long 138 // error messages, may return an OK RunStepResponse with the actual 139 // error saved in the status_code/status_error_message fields of the 140 // response body. This is a workaround since the RPC subsystem may 141 // truncate long metadata messages. 142 bool store_errors_in_response_body = 7; 143 144 // Unique identifier for this request. Every RunStepRequest must 145 // have a unique request_id, and retried RunStepRequest must have 146 // the same request_id. If request_id is zero, retry detection is disabled. 147 int64 request_id = 8; 148} 149 150message RunStepResponse { 151 // NOTE: The order of the returned tensors may or may not match 152 // the fetch order specified in RunStepRequest. 153 repeated NamedTensorProto tensor = 1; 154 155 // Returned metadata if requested in the options. 156 RunMetadata metadata = 2; 157 158 // If store_errors_in_response_body is true in the request, then 159 // optionally the server may return an OK status for the RPC and 160 // fill the true status into the fields below, to allow for messages 161 // that are too long to fit in metadata. 162 error.Code status_code = 3; 163 string status_error_message = 4; 164} 165 166//////////////////////////////////////////////////////////////////////////////// 167// 168// PartialRunSetup method request/response protos. 169// 170// The caller should provide the future partial run feeds, fetches, and targets. 171// Then the caller can use RunStepRequest with is_partial set to make partial 172// run calls. 173// 174//////////////////////////////////////////////////////////////////////////////// 175 176message PartialRunSetupRequest { 177 // REQUIRED: session_handle must be returned by a CreateSession call 178 // to the same master service. 179 string session_handle = 1; 180 181 // Tensors to be fed in future steps. 182 repeated string feed = 2; 183 184 // Fetches. A list of tensor names. The caller expects a tensor to be returned 185 // for each fetch[i] (see RunStepResponse.tensor), for corresponding partial 186 // RunStepRequests. The order of specified fetches does not change the 187 // execution order. 188 repeated string fetch = 3; 189 190 // Target Nodes. A list of node names. The named nodes will be run in future 191 // steps, but their outputs will not be fetched. 192 repeated string target = 4; 193 194 // Unique identifier for this request. Every PartialRunSetupRequest must 195 // have a unique request_id, and retried PartialRunSetupRequest must have 196 // the same request_id. If request_id is zero, retry detection is disabled. 197 int64 request_id = 5; 198} 199 200message PartialRunSetupResponse { 201 // The unique handle corresponding to the ongoing partial run call setup by 202 // the invocation to PartialRunSetup. This handle may be passed to 203 // RunStepRequest to send and receive tensors for this partial run. 204 string partial_run_handle = 1; 205} 206 207//////////////////////////////////////////////////////////////////////////////// 208// 209// CloseSession method request/response protos. 210// 211//////////////////////////////////////////////////////////////////////////////// 212 213message CloseSessionRequest { 214 // REQUIRED: session_handle must be returned by a CreateSession call 215 // to the same master service. 216 string session_handle = 1; 217} 218 219message CloseSessionResponse {} 220 221// Reset() allows misbehaving or slow sessions to be aborted and closed, and 222// causes their resources eventually to be released. Reset() does not wait 223// for the computations in old sessions to cease; it merely starts the 224// process of tearing them down. However, if a new session is started after 225// a Reset(), the new session is isolated from changes that old sessions 226// (started prior to the Reset()) may continue to make to resources, provided 227// all those resources are in containers listed in "containers". 228// 229// Old sessions may continue to have side-effects on resources not in 230// containers listed in "containers", and thus may affect future 231// sessions' results in ways that are hard to predict. Thus, if well-defined 232// behavior is desired, is it recommended that all containers be listed in 233// "containers". Similarly, if a device_filter is specified, results may be 234// hard to predict. 235message ResetRequest { 236 // A list of container names, which may be empty. 237 // 238 // If 'container' is not empty, releases resources in the given 239 // containers in all devices. 240 // 241 // If 'container' is empty, releases resources in the default 242 // container in all devices. 243 repeated string container = 1; 244 245 // When any filters are present, only devices that match the filters 246 // will be reset. Each filter can be partially specified, 247 // e.g. "/job:ps" "/job:worker/replica:3", etc. 248 repeated string device_filters = 2; 249} 250 251message ResetResponse {} 252 253//////////////////////////////////////////////////////////////////////////////// 254// 255// ListDevices method request/response protos. 256// 257// Returns information about the TensorFlow devices that are available 258// to this master. 259// 260//////////////////////////////////////////////////////////////////////////////// 261 262message ListDevicesRequest { 263 // Optional: session_handle must be returned by a CreateSession call to the 264 // same master service. 265 // 266 // When session_handle is empty, the ClusterSpec provided when the master was 267 // started is used to compute the available devices. If the session_handle is 268 // provided but not recognized, an error is returned. Finally, if a valid 269 // session_handle is provided, the cluster configuration for that session is 270 // used when computing the response. 271 string session_handle = 1; 272} 273 274message ListDevicesResponse { 275 repeated DeviceAttributes local_device = 1; 276 repeated DeviceAttributes remote_device = 2; 277} 278 279//////////////////////////////////////////////////////////////////////////////// 280// 281// MakeCallable method request/response protos. 282// 283//////////////////////////////////////////////////////////////////////////////// 284 285message MakeCallableRequest { 286 // REQUIRED: session_handle must be returned by a CreateSession call 287 // to the same master service. 288 string session_handle = 1; 289 290 // Options that define the behavior of the created callable. 291 CallableOptions options = 2; 292 293 // Unique identifier for this request. Every MakeCallableRequest must 294 // have a unique request_id, and retried MakeCallableRequest must have 295 // the same request_id. If request_id is zero, retry detection is disabled. 296 int64 request_id = 3; 297} 298 299message MakeCallableResponse { 300 // A handle to the created callable. 301 int64 handle = 1; 302} 303 304//////////////////////////////////////////////////////////////////////////////// 305// 306// RunCallable method request/response protos. 307// 308//////////////////////////////////////////////////////////////////////////////// 309 310message RunCallableRequest { 311 // REQUIRED: session_handle must be returned by a CreateSession call 312 // to the same master service. 313 string session_handle = 1; 314 // REQUIRED: handle must be returned by a MakeCallable call to the same 315 // master service. 316 int64 handle = 2; 317 318 // Values of the tensors passed as arguments to the callable, in the order 319 // defined in the CallableOptions.feed field passed to MakeCallable. 320 repeated TensorProto feed = 3; 321 322 // Unique identifier for this request. Every RunCallableRequest must 323 // have a unique request_id, and retried RunCallableRequest must have 324 // the same request_id. If request_id is zero, retry detection is disabled. 325 int64 request_id = 4; 326} 327 328message RunCallableResponse { 329 // Values of the tensors returned by the callable, in the order defined in the 330 // CallableOptions.fetch field passed to MakeCallable. 331 repeated TensorProto fetch = 1; 332 333 // Returned metadata if requested in the options. 334 RunMetadata metadata = 2; 335} 336 337//////////////////////////////////////////////////////////////////////////////// 338// 339// ReleaseCallable method request/response protos. 340// 341//////////////////////////////////////////////////////////////////////////////// 342 343message ReleaseCallableRequest { 344 // REQUIRED: session_handle must be returned by a CreateSession call 345 // to the same master service. 346 string session_handle = 1; 347 348 // REQUIRED: handle must be returned by a MakeCallable call to the same 349 // master service. 350 int64 handle = 2; 351} 352 353message ReleaseCallableResponse {} 354