Skip to content

Commit 3daf152

Browse files
Quote props of DataType enum to prevent name mangling (#8361)
BUG These properties must be quoted since they are used by parseDtypeParam in tfjs-converter/src/operations/operation_mapper.ts to look up dtypes by string name. If they are not quoted, Closure will mangle their names.
1 parent 936b448 commit 3daf152

File tree

1 file changed

+51
-47
lines changed

1 file changed

+51
-47
lines changed

tfjs-converter/src/data/compiled_api.ts

+51-47
Original file line numberDiff line numberDiff line change
@@ -29,61 +29,65 @@ export declare interface IAny {
2929

3030
/** DataType enum. */
3131
export enum DataType {
32+
// These properties must be quoted since they are used by parseDtypeParam
33+
// in tfjs-converter/src/operations/operation_mapper.ts to look up dtypes
34+
// by string name. If they are not quoted, Closure will mangle their names.
35+
3236
// Not a legal value for DataType. Used to indicate a DataType field
3337
// has not been set.
34-
DT_INVALID = 0,
38+
'DT_INVALID' = 0,
3539

3640
// Data types that all computation devices are expected to be
3741
// capable to support.
38-
DT_FLOAT = 1,
39-
DT_DOUBLE = 2,
40-
DT_INT32 = 3,
41-
DT_UINT8 = 4,
42-
DT_INT16 = 5,
43-
DT_INT8 = 6,
44-
DT_STRING = 7,
45-
DT_COMPLEX64 = 8, // Single-precision complex
46-
DT_INT64 = 9,
47-
DT_BOOL = 10,
48-
DT_QINT8 = 11, // Quantized int8
49-
DT_QUINT8 = 12, // Quantized uint8
50-
DT_QINT32 = 13, // Quantized int32
51-
DT_BFLOAT16 = 14, // Float32 truncated to 16 bits. Only for cast ops.
52-
DT_QINT16 = 15, // Quantized int16
53-
DT_QUINT16 = 16, // Quantized uint16
54-
DT_UINT16 = 17,
55-
DT_COMPLEX128 = 18, // Double-precision complex
56-
DT_HALF = 19,
57-
DT_RESOURCE = 20,
58-
DT_VARIANT = 21, // Arbitrary C++ data types
59-
DT_UINT32 = 22,
60-
DT_UINT64 = 23,
42+
'DT_FLOAT' = 1,
43+
'DT_DOUBLE' = 2,
44+
'DT_INT32' = 3,
45+
'DT_UINT8' = 4,
46+
'DT_INT16' = 5,
47+
'DT_INT8' = 6,
48+
'DT_STRING' = 7,
49+
'DT_COMPLEX64' = 8, // Single-precision complex
50+
'DT_INT64' = 9,
51+
'DT_BOOL' = 10,
52+
'DT_QINT8' = 11, // Quantized int8
53+
'DT_QUINT8' = 12, // Quantized uint8
54+
'DT_QINT32' = 13, // Quantized int32
55+
'DT_BFLOAT16' = 14, // Float32 truncated to 16 bits. Only for cast ops.
56+
'DT_QINT16' = 15, // Quantized int16
57+
'DT_QUINT16' = 16, // Quantized uint16
58+
'DT_UINT16' = 17,
59+
'DT_COMPLEX128' = 18, // Double-precision complex
60+
'DT_HALF' = 19,
61+
'DT_RESOURCE' = 20,
62+
'DT_VARIANT' = 21, // Arbitrary C++ data types
63+
'DT_UINT32' = 22,
64+
'DT_UINT64' = 23,
6165

6266
// Do not use! These are only for parameters. Every enum above
6367
// should have a corresponding value below (verified by types_test).
64-
DT_FLOAT_REF = 101,
65-
DT_DOUBLE_REF = 102,
66-
DT_INT32_REF = 103,
67-
DT_UINT8_REF = 104,
68-
DT_INT16_REF = 105,
69-
DT_INT8_REF = 106,
70-
DT_STRING_REF = 107,
71-
DT_COMPLEX64_REF = 108,
72-
DT_INT64_REF = 109,
73-
DT_BOOL_REF = 110,
74-
DT_QINT8_REF = 111,
75-
DT_QUINT8_REF = 112,
76-
DT_QINT32_REF = 113,
77-
DT_BFLOAT16_REF = 114,
78-
DT_QINT16_REF = 115,
79-
DT_QUINT16_REF = 116,
80-
DT_UINT16_REF = 117,
81-
DT_COMPLEX128_REF = 118,
82-
DT_HALF_REF = 119,
83-
DT_RESOURCE_REF = 120,
84-
DT_VARIANT_REF = 121,
85-
DT_UINT32_REF = 122,
86-
DT_UINT64_REF = 123,
68+
'DT_FLOAT_REF' = 101,
69+
'DT_DOUBLE_REF' = 102,
70+
'DT_INT32_REF' = 103,
71+
'DT_UINT8_REF' = 104,
72+
'DT_INT16_REF' = 105,
73+
'DT_INT8_REF' = 106,
74+
'DT_STRING_REF' = 107,
75+
'DT_COMPLEX64_REF' = 108,
76+
'DT_INT64_REF' = 109,
77+
'DT_BOOL_REF' = 110,
78+
'DT_QINT8_REF' = 111,
79+
'DT_QUINT8_REF' = 112,
80+
'DT_QINT32_REF' = 113,
81+
'DT_BFLOAT16_REF' = 114,
82+
'DT_QINT16_REF' = 115,
83+
'DT_QUINT16_REF' = 116,
84+
'DT_UINT16_REF' = 117,
85+
'DT_COMPLEX128_REF' = 118,
86+
'DT_HALF_REF' = 119,
87+
'DT_RESOURCE_REF' = 120,
88+
'DT_VARIANT_REF' = 121,
89+
'DT_UINT32_REF' = 122,
90+
'DT_UINT64_REF' = 123,
8791
}
8892

8993
/** Properties of a TensorShape. */

0 commit comments

Comments
 (0)