Skip to content

Reconcile the two parallel DType enums (NumpyTypes.DType and TensorFlowTypes.DType) #563

@khatchad

Description

@khatchad

There are two separate DType enumerations in the codebase:

  • TensorFlowTypes.DType — the one actually consumed by the tensor-type system: TensorType carries it as its cell type, and every TensorGenerator (getDefaultDTypes) emits it, including the numpy generators (NpArray, and the new NpOnes/NpZeros).
  • NumpyTypes.DType — a parallel enum with numeric/floatingPoint/precision fields plus canConvertTo(...) and the FIELD_REFERENCE_TO_DTYPE map.

The two overlap heavily (FLOAT32, FLOAT64, INT32, INT64, UNKNOWN, ...). Numpy-producing code reads numpy dtype fields but must emit TensorFlowTypes.DType to interoperate with TensorType, so NumpyTypes.DType is effectively a second source of truth that does not flow into the analysis.

This surfaced while consolidating the numpy method references into NumpyTypes for #539. The dtype side was deliberately left untouched there to keep that change focused.

Suggested direction

Unify on a single DType enum (or have NumpyTypes.DType delegate to / be replaced by TensorFlowTypes.DType), folding in the numpy-specific canConvertTo/precision metadata so there is one authoritative dtype lattice. Worth confirming whether NumpyTypes.DType.'s canConvertTo semantics are used anywhere before collapsing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions