- CastMap

CastMap - 1 (


  • name: CastMap (GitHub)

  • domain:

  • since_version: 1

  • function: False

  • support_level: SupportType.COMMON

  • shape inference: True

This version of the operator has been available since version 1 of domain


Converts a map to a tensor.
The map key must be an int64 and the values will be ordered in ascending order based on this key.
The operator supports dense packing or sparse packing. If using sparse packing, the key cannot exceed the max_map-1 value.


  • cast_to - STRING (default is 'TO_FLOAT'):

    A string indicating the desired element type of the output tensor, one of ‘TO_FLOAT’, ‘TO_STRING’, ‘TO_INT64’.

  • map_form - STRING (default is 'DENSE'):

    Indicates whether to only output as many values as are in the input (dense), or position the input based on using the key of the map as the index of the output (sparse).
    One of ‘DENSE’, ‘SPARSE’.

  • max_map - INT (default is '1'):

    If the value of map_form is ‘SPARSE,’ this attribute indicates the total length of the output tensor.


  • X (heterogeneous) - T1:

    The input map that is to be cast to a tensor


  • Y (heterogeneous) - T2:

    A tensor representing the same data as the input map, ordered by their keys

Type Constraints

  • T1 in ( map(int64, float), map(int64, string) ):

    The input must be an integer map to either string or float.

  • T2 in ( tensor(float), tensor(int64), tensor(string) ):

    The output is a 1-D tensor of string, float, or integer.