def experimental_as_proto(self) -> struct_pb2.BoundedTensorSpecProto: """Returns a proto representation of the BoundedTensorSpec instance.""" return struct_pb2.BoundedTensorSpecProto( shape=self.shape.experimental_as_proto(), dtype=self.dtype.experimental_as_proto().datatype, minimum=tensor_util.make_tensor_proto(self._minimum), maximum=tensor_util.make_tensor_proto(self._maximum), name=self.name)
def do_encode(self, bounded_tensor_spec_value, encode_fn): """Returns an encoded proto for the given `tf.BoundedTensorSpec`.""" encoded_bounded_tensor_spec = struct_pb2.StructuredValue() encoded_bounded_tensor_spec.bounded_tensor_spec_value.CopyFrom( struct_pb2.BoundedTensorSpecProto( shape=encode_fn(bounded_tensor_spec_value.shape).tensor_shape_value, dtype=encode_fn(bounded_tensor_spec_value.dtype).tensor_dtype_value, name=bounded_tensor_spec_value.name, minimum=tensor_util.make_tensor_proto( bounded_tensor_spec_value.minimum), maximum=tensor_util.make_tensor_proto( bounded_tensor_spec_value.maximum))) return encoded_bounded_tensor_spec