CastMap#
Domain:
ai.onnx.mlSince version: 1
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.
Inputs
X (T1): The input map that is to be cast to a tensor
Outputs
Y (T2): A tensor representing the same data as the input map, ordered by their keys
Type Constraints
T1: The input must be an integer map to either string or float. Allowed types: map(int64, float), map(int64, string).
T2: The output is a 1-D tensor of string, float, or integer. Allowed types: tensor(float), tensor(int64), tensor(string).
Examples#
test_cc_cast_map_int64_float_dense
Node:
ai.onnx.ml.CastMap(x) -> (y)
Attributes:
cast_to = "TO_FLOAT"
map_form = "DENSE"
Inputs:
x: shape=(3,), dtype=int64
[2, 0, 1]
input_1: shape=(3,), dtype=float32
[2.5, 0.5, 1.5]
Outputs:
y: shape=(3,), dtype=float32
[0.5, 1.5, 2.5]
test_cc_cast_map_int64_float_sparse
Node:
ai.onnx.ml.CastMap(x) -> (y)
Attributes:
cast_to = "TO_FLOAT"
map_form = "SPARSE"
max_map = 5
Inputs:
x: shape=(2,), dtype=int64
[1, 3]
input_1: shape=(2,), dtype=float32
[10., 30.]
Outputs:
y: shape=(5,), dtype=float32
[ 0., 10., 0., 30., 0.]
test_cc_cast_map_int64_string_dense
Node:
ai.onnx.ml.CastMap(x) -> (y)
Attributes:
cast_to = "TO_STRING"
map_form = "DENSE"
Inputs:
x: shape=(2,), dtype=int64
[1, 0]
input_1: shape=(2,), dtype=object
['b', 'a']
Outputs:
y: shape=(2,), dtype=object
['a', 'b']