Client class for invoking RPCs to the server.
Methods
call
call(
method_name: str,
args: Optional[Sequence[core_tf_types.Tensor]] = None,
output_specs=None,
timeout_in_ms=0
)
Method for making RPC calls to remote server.
This invokes RPC to the server, executing the registered method_name remotely. Args: method_name: Remote registered method to invoke args: List of arguments for the registered method. output_specs: Output specs for the output from method. For example, if tf.function is: @tf.function(input_signature=[ tf.TensorSpec([], tf.int32), tf.TensorSpec([], tf.int32) ]) def multiply_fn(a, b): return tf.math.multiply(a, b) output_spec is: tf.TensorSpec((), tf.int32) If you have access to TF Function, the output specs can be generated from tf.function by calling: output_specs = tf.nest.map_structure(tf.type_spec_from_value, tf_function.get_concrete_function().structured_outputs If output_specs are not provided, flattened list of tensors will be returned in response. timeout_in_ms: Timeout for this call. If 0, default client timeout will be used.
Returns | |
---|---|
An instance of StatusOrResult class with the following available
methods.
Calling any of the above methods will block till RPC is completed and result is available. |
create
@staticmethod
create( rpc_layer, address, name='', timeout_in_ms=0 )
Create TF RPC client to connect to the given address.
Args | |
---|---|
rpc_layer
|
Communication layer between client and server. Only "grpc" rpc layer is supported at the moment. |
address
|
Address of the server to connect the RPC client to. |
name
|
Name of the RPC Client. You can create multiple clients connecting to same server and distinguish them using different names. |
timeout_in_ms
|
The default timeout to use for outgoing RPCs from client. 0 indicates no timeout. Exceeding timeout during RPC will raise DeadlineExceeded error. |
Returns | |
---|---|
An instance of tf.distribute.experimental.rpc.Client with the following
dynamically added methods for eagerly created clients:
|
Raises | |
---|---|
A ValueError if rpc_layer other than "grpc" is used. Only GRPC is supported at the moment. A DeadlineExceeded exception in eager mode if timeout exceeds while creating and listing client methods. |
Example usage | |
---|---|
|