tfgnn.ContextSpec

December 14, 2023 ยท View on GitHub

View source on GitHub

A type spec for tfgnn.Context.

features_spec A read-only mapping of feature name to feature spec.
indices_dtype The dtype for graph items indexing. One of tf.int32 or tf.int64.
rank The rank of the GraphPiece. Guaranteed not to be None.
row_splits_dtype The dtype for ragged row partitions. One of tf.int32 or tf.int64.
shape A possibly-partial shape specification of the GraphPiece.

The returned tf.TensorShape is guaranteed to have a known rank and no unknown dimensions except possibly the outermost.

sizes_spec The type spec for the sizes that provides num. elements per component.
total_num_components The total number of graph components if known.
total_size The total number of graph items if known.
value_type The Python type for values that are compatible with this TypeSpec.

In particular, all values that are compatible with this TypeSpec must be an instance of this type.

Methods

experimental_as_proto

Returns a proto representation of the TypeSpec instance.

Do NOT override for custom non-TF types.

experimental_from_proto

Returns a TypeSpec instance based on the serialized proto.

Do NOT override for custom non-TF types.

Args
proto Proto generated using 'experimental_as_proto'.

experimental_type_proto

Returns the type of proto associated with TypeSpec serialization.

Do NOT override for custom non-TF types.

from_field_specs

View source

The counterpart of Context.from_fields() for field type specs.

from_value

View source

Extension Types API: Factory method.

is_compatible_with

Returns true if spec_or_value is compatible with this TypeSpec.

Prefer using "is_subtype_of" and "most_specific_common_supertype" wherever possible.

Args
spec_or_value A TypeSpec or TypeSpec associated value to compare against.

is_subtype_of

Returns True if self is a subtype of other.

Implements the tf.types.experimental.func.TraceType interface.

If not overridden by a subclass, the default behavior is to assume the TypeSpec is covariant upon attributes that implement TraceType and invariant upon rest of the attributes as well as the structure and type of the TypeSpec.

Args
other A TraceType object.

most_specific_common_supertype

Returns the most specific supertype TypeSpec of self and others.

Implements the tf.types.experimental.func.TraceType interface.

If not overridden by a subclass, the default behavior is to assume the TypeSpec is covariant upon attributes that implement TraceType and invariant upon rest of the attributes as well as the structure and type of the TypeSpec.

Args
others A sequence of TraceTypes.

most_specific_compatible_type

Returns the most specific TypeSpec compatible with self and other. (deprecated)

Deprecated: THIS FUNCTION IS DEPRECATED. It will be removed in a future version. Instructions for updating: Use most_specific_common_supertype instead.

Deprecated. Please use most_specific_common_supertype instead. Do not override this function.

Args
other A TypeSpec.
Raises
ValueError If there is no TypeSpec that is compatible with both self and other.

relax

View source

Allows variable number of graph components.

Calling with all default parameters keeps the spec unchanged.

Args
num_components if True, allows variable number of graph components by setting the outermost sizes dimension to None.
Returns
Relaxed compatible context spec.
Raises
ValueError if context is not scalar (rank > 0).

with_indices_dtype

View source

Returns a copy of this piece spec with the given indices dtype.

with_row_splits_dtype

View source

Returns a copy of this piece spec with the given row splits dtype.

with_shape

View source

Enforce the common prefix shape on all the contained features.

__eq__

Return self==value.

__getitem__

View source

__ne__

Return self!=value.