Warning: This API is deprecated and will be removed in a future version of TensorFlow after the replacement is stable.

Rpc

public final class Rpc

Perform batches of RPC requests.

This op asynchronously performs either a single RPC request, or a batch of requests. RPC requests are defined by three main parameters:

- `address` (the host+port or BNS address of the request) - `method` (the RPC method name for the request) - `request` (the serialized proto string, or vector of strings, of the RPC request argument).

For example, if you have an RPC service running on port localhost:2345, and its interface is configured with the following proto declaration:

service MyService {
   rpc MyMethod(MyRequestProto) returns (MyResponseProto) {
   
 };
 }
then call this op with arguments:
address = "localhost:2345"
 method = "MyService/MyMethod"
 
The `request` tensor is a string tensor representing serialized `MyRequestProto` strings; and the output string tensor `response` will have the same shape and contain (upon successful completion) corresponding serialized `MyResponseProto` strings.

For example, to send a single, empty, `MyRequestProto`, call this op with `request = ""`. To send 5 parallel empty requests, call this op with `request = ["", "", "", "", ""]`.

More generally, one can create a batch of `MyRequestProto` serialized protos from regular batched tensors using the `encode_proto` op, and convert the response `MyResponseProto` serialized protos to batched tensors using the `decode_proto` op.

NOTE Working with serialized proto strings is faster than instantiating actual proto objects in memory, so no performance degradation is expected compared to writing custom kernels for this workflow.

If the connection fails or the remote worker returns an error status, the op reraises this exception locally.

See the `TryRpc` op if you prefer to handle RPC failures manually in the graph.

Nested Classes

class Rpc.Options Optional attributes for Rpc  

Public Methods

Output<String>
asOutput()
Returns the symbolic handle of a tensor.
static Rpc
create(Scope scope, Operand<String> address, Operand<String> method, Operand<String> request, Options... options)
Factory method to create a class wrapping a new Rpc operation.
static Rpc.Options
failFast(Boolean failFast)
static Rpc.Options
protocol(String protocol)
Output<String>
response()
Same shape as `request`.
static Rpc.Options
timeoutInMs(Long timeoutInMs)

Inherited Methods

Public Methods

public Output<String> asOutput ()

Returns the symbolic handle of a tensor.

Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is used to obtain a symbolic handle that represents the computation of the input.

public static Rpc create (Scope scope, Operand<String> address, Operand<String> method, Operand<String> request, Options... options)

Factory method to create a class wrapping a new Rpc operation.

Parameters
scope current scope
address `0-D` or `1-D`. The address (i.e. host_name:port) of the RPC server. If this tensor has more than 1 element, then multiple parallel rpc requests are sent. This argument broadcasts with `method` and `request`.
method `0-D` or `1-D`. The method address on the RPC server. If this tensor has more than 1 element, then multiple parallel rpc requests are sent. This argument broadcasts with `address` and `request`.
request `0-D` or `1-D`. Serialized proto strings: the rpc request argument. If this tensor has more than 1 element, then multiple parallel rpc requests are sent. This argument broadcasts with `address` and `method`.
options carries optional attributes values
Returns
  • a new instance of Rpc

public static Rpc.Options failFast (Boolean failFast)

Parameters
failFast `boolean`. If `true` (default), then failures to connect (i.e., the server does not immediately respond) cause an RPC failure.

public static Rpc.Options protocol (String protocol)

Parameters
protocol RPC protocol to use. Empty string means use the default protocol. Options include 'grpc'.

public Output<String> response ()

Same shape as `request`. Serialized proto strings: the rpc responses.

public static Rpc.Options timeoutInMs (Long timeoutInMs)

Parameters
timeoutInMs `int`. If `0` (default), then the kernel will run the RPC request and only time out if the RPC deadline passes or the session times out. If this value is greater than `0`, then the op will raise an exception if the RPC takes longer than `timeout_in_ms`.