Skip to content

Latest commit

 

History

History
428 lines (323 loc) · 11.7 KB

EdgeSetSpec.md

File metadata and controls

428 lines (323 loc) · 11.7 KB

tfgnn.EdgeSetSpec

View source on GitHub

A type spec for tfgnn.EdgeSet.

tfgnn.EdgeSetSpec(
    data_spec: DataSpec,
    shape: tf.TensorShape,
    indices_dtype: tf.dtypes.DType,
    row_splits_dtype: tf.dtypes.DType,
    metadata: Metadata = None,
    check_consistent_indices_dtype: bool = False,
    check_consistent_row_splits_dtype: bool = False
)

Attributes

adjacency_spec A type spec for the adjacency composite tensor.
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 edges 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

experimental_as_proto() -> struct_pb2.TypeSpecProto

Returns a proto representation of the TypeSpec instance.

Do NOT override for custom non-TF types.

experimental_from_proto

@classmethod
experimental_from_proto(
    proto: struct_pb2.TypeSpecProto
) -> 'TypeSpec'

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

@classmethod
experimental_type_proto() -> Type[struct_pb2.TypeSpecProto]

Returns the type of proto associated with TypeSpec serialization.

Do NOT override for custom non-TF types.

from_field_specs

View source

@classmethod
from_field_specs(
    *,
    features_spec: Optional[FieldsSpec] = None,
    sizes_spec: FieldSpec,
    adjacency_spec: AdjacencySpec
) -> 'EdgeSetSpec'

The counterpart of EdgeSet.from_fields() for values type specs.

from_value

View source

@classmethod
from_value(
    value: GraphPieceBase
)

Extension Types API: Factory method.

is_compatible_with

is_compatible_with(
    spec_or_value
)

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

is_subtype_of(
    other: trace.TraceType
) -> bool

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

most_specific_common_supertype(
    others: Sequence[trace.TraceType]
) -> Optional['TypeSpec']

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

most_specific_compatible_type(
    other: 'TypeSpec'
) -> 'TypeSpec'

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

relax(
    *, num_components: bool = False, num_edges: bool = False
) -> 'EdgeSetSpec'

Allows variable number of edge or/and 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.
num_edges if True, allows variable number of edges by setting the outermost features dimensions to None.
Returns
Relaxed compatible edge set spec.
Raises
ValueError if edge set is not scalar (rank > 0).

with_indices_dtype

View source

with_indices_dtype(
    dtype: tf.dtypes.DType
) -> 'GraphPieceSpecBase'

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

with_row_splits_dtype

View source

with_row_splits_dtype(
    dtype: tf.dtypes.DType
) -> 'GraphPieceSpecBase'

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

with_shape

View source

with_shape(
    new_shape: ShapeLike
) -> 'GraphPieceSpecBase'

Enforce the common prefix shape on all the contained features.

__eq__

__eq__(
    other
) -> bool

Return self==value.

__getitem__

View source

__getitem__(
    feature_name: FieldName
) -> FieldSpec

__ne__

__ne__(
    other
) -> bool

Return self!=value.