Cast - 6 vs 9#
Next section compares an older to a newer version of the same operator after both definition are converted into markdown text. Green means an addition to the newer version, red means a deletion. Anything else is unchanged.
- Cast6 → Cast9 +5 -19
Cast6 → Cast9
RENAMED
@@ -1 +1 @@
|
|
1
1
|
The operator casts the elements of a given input tensor to a data type
|
2
2
|
specified by the 'to' argument and returns an output tensor of the same size in
|
3
3
|
the converted type. The 'to' argument must be one of the data types specified
|
4
4
|
in the 'DataType' enum field in the TensorProto message.
|
5
|
+
NOTE: Casting to and from strings is not supported yet.
|
5
|
-
|
6
|
-
Casting from string tensor in plain (e.g., "3.14" and "1000") and scientific numeric representations
|
7
|
-
(e.g., "1e-5" and "1E8") to float types is supported. For example, converting string "100.5" to an integer may
|
8
|
-
result 100. There are some string literals reserved for special floating-point values;
|
9
|
-
"+INF" (and "INF"), "-INF", and "NaN" are positive infinity, negative infinity, and not-a-number, respectively.
|
10
|
-
Any string which can exactly match "+INF" in a case-insensitive way would be mapped to positive infinite. Similarly,
|
11
|
-
this case-insensitive rule is applied to "INF" and "NaN". When casting from numeric tensors
|
12
|
-
to string tensors, plain floating-point representation (such as "314.15926") would be used.
|
13
|
-
Converting non-numerical-literal string such as "Hello World!" is an undefined behavior. Cases
|
14
|
-
of converting string representing floating-point arithmetic value, such as "2.718", to INT is an undefined behavior.
|
15
|
-
|
16
|
-
Conversion from a numerical type to any numerical type is always allowed.
|
17
|
-
User must be aware of precision loss and value change caused by range difference between two types.
|
18
|
-
For example, a 64-bit float 3.1415926459 may be round to a 32-bit float 3.141592. Similarly, converting
|
19
|
-
an integer 36 to Boolean may produce 1 because we truncate bits which can't be stored in the targeted type.
|
20
6
|
**Attributes**
|
21
7
|
* **to** (required):
|
22
8
|
The data type to which the elements of the input tensor are cast.
|
23
9
|
Strictly must be one of the types from DataType enum in TensorProto
|
24
10
|
**Inputs**
|
25
11
|
* **input** (heterogeneous) - **T1**:
|
26
12
|
Input tensor to be cast.
|
27
13
|
**Outputs**
|
28
14
|
* **output** (heterogeneous) - **T2**:
|
29
15
|
Output tensor with the same shape as input with type specified by
|
30
16
|
the 'to' argument
|
31
17
|
**Type Constraints**
|
32
18
|
* **T1** in (
|
33
19
|
tensor(bool),
|
34
20
|
tensor(double),
|
35
21
|
tensor(float),
|
36
22
|
tensor(float16),
|
37
23
|
tensor(int16),
|
38
24
|
tensor(int32),
|
39
25
|
tensor(int64),
|
40
26
|
tensor(int8),
|
41
|
-
tensor(string),
|
42
27
|
tensor(uint16),
|
43
28
|
tensor(uint32),
|
44
29
|
tensor(uint64),
|
45
30
|
tensor(uint8)
|
46
31
|
):
|
47
|
-
Constrain input types. Casting from complex
|
32
|
+
Constrain input types. Casting from strings and complex are not
|
33
|
+
supported.
|
48
34
|
* **T2** in (
|
49
35
|
tensor(bool),
|
50
36
|
tensor(double),
|
51
37
|
tensor(float),
|
52
38
|
tensor(float16),
|
53
39
|
tensor(int16),
|
54
40
|
tensor(int32),
|
55
41
|
tensor(int64),
|
56
42
|
tensor(int8),
|
57
|
-
tensor(string),
|
58
43
|
tensor(uint16),
|
59
44
|
tensor(uint32),
|
60
45
|
tensor(uint64),
|
61
46
|
tensor(uint8)
|
62
47
|
):
|
63
|
-
Constrain output types. Casting to complex
|
48
|
+
Constrain output types. Casting to strings and complex are not
|
49
|
+
supported.
|