A concrete
function’s signature records Python values: lists, dicts, namedtuples and
TensorSpecs, so that a loaded model can take the same structures. Those are
StructuredValue messages, from struct.proto.
StructuredValue
One value of a oneof kind.
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | none_value | NoneValue | None. |
| 11 | float64_value | double | A Python float. |
| 12 | int64_value | sint64 | A Python int, limited to 64 bits. |
| 13 | string_value | string | A Python str. |
| 14 | bool_value | bool | A Python bool. |
| 31 | tensor_shape_value | TensorShapeProto | A TensorShape. |
| 32 | tensor_dtype_value | DataType | A dtype. |
| 33 | tensor_spec_value | TensorSpecProto | A tf.TensorSpec. |
| 34 | type_spec_value | TypeSpecProto | A tf.TypeSpec. |
| 35 | bounded_tensor_spec_value | BoundedTensorSpecProto | A tf.BoundedTensorSpec. |
| 51 | list_value | ListValue | A Python list. |
| 52 | tuple_value | TupleValue | A Python tuple. |
| 53 | dict_value | DictValue | A Python dict keyed by str. |
| 54 | named_tuple_value | NamedTupleValue | A Python namedtuple. |
| 55 | tensor_value | TensorProto | A tf.Tensor. |
| 56 | numpy_value | TensorProto | An np.ndarray. |
Containers
| Message | Field | Name | Type | Meaning |
|---|---|---|---|---|
| NoneValue | Python’s None; it has no fields. | |||
| ListValue | 1 | values | repeated StructuredValue | The elements. |
| TupleValue | 1 | values | repeated StructuredValue | The elements. |
| DictValue | 1 | fields | map<string, StructuredValue> | The entries. |
| PairValue | 1 | key | string | The key. |
| 2 | value | StructuredValue | The value. | |
| NamedTupleValue | 1 | name | string | The type’s name. |
| 2 | values | repeated PairValue | The fields. |
TensorSpecProto and BoundedTensorSpecProto
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | name | string | The name. |
| 2 | shape | TensorShapeProto | The shape. |
| 3 | dtype | DataType | The data type. |
BoundedTensorSpecProto has the same three
fields, and minimum (field 4) and maximum (field 5), each
a TensorProto.
TypeSpecProto
| Field | Name | Type | Meaning |
|---|---|---|---|
| 1 | type_spec_class | TypeSpecClass | Which TypeSpec class. |
| 2 | type_state | StructuredValue | The output of TypeSpec._serialize(). |
| 3 | type_spec_class_name | string | The class name, for registered types or error messages. |
| 4 | num_flat_components | int32 | How many flat tensor components it needs. |
| Value | Name | Meaning |
|---|---|---|
| 0 | UNKNOWN | |
| 1 | SPARSE_TENSOR_SPEC | tf.SparseTensorSpec |
| 2 | INDEXED_SLICES_SPEC | tf.IndexedSlicesSpec |
| 3 | RAGGED_TENSOR_SPEC | tf.RaggedTensorSpec |
| 4 | TENSOR_ARRAY_SPEC | tf.TensorArraySpec |
| 5 | DATA_DATASET_SPEC | tf.data.DatasetSpec |
| 6 | DATA_ITERATOR_SPEC | IteratorSpec, from tf.data |
| 7 | OPTIONAL_SPEC | tf.OptionalSpec |
| 8 | PER_REPLICA_SPEC | PerReplicaSpec, from tf.distribute |
| 9 | VARIABLE_SPEC | tf.VariableSpec |
| 10 | ROW_PARTITION_SPEC | RowPartitionSpec, from ragged tensors |
| 12 | REGISTERED_TYPE_SPEC | A type registered under type_spec_class_name |
| 13 | EXTENSION_TYPE_SPEC | A subclass of tf.ExtensionType |