Commit f5cacb3
committed
Fix
When packing a given NumPy array into a Tensor message, we use the array's dtype to determine which `Packer` to use. For some types (e.g. NumPy strings) we need to determine the base type rather than the concrete type (i.e. `np.str_`) using the `dtype.type` attribute. This can cause some oddities with integer types, e.g:
```
np.array(2**64-1).dtype == np.uint64
np.array(2**64-1).dtype.type == np.ulonglong
np.array(2**64-1 dtype=np.uint64).dtype.type == np.uint64
```
Therefore we re-cast as a dtype (i.e. `dtype(array.dtype.type)`) before looking up the packer.
PiperOrigin-RevId: 410004520
Change-Id: I92cb480bfd0949d021c01d8b41345132cda730ddtensor_utils.pack() to correctly pack uint64 scalars.1 parent 71076a6 commit f5cacb3
2 files changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
146 | | - | |
| 146 | + | |
147 | 147 | | |
148 | 148 | | |
149 | 149 | | |
| |||
216 | 216 | | |
217 | 217 | | |
218 | 218 | | |
219 | | - | |
| 219 | + | |
220 | 220 | | |
221 | 221 | | |
222 | 222 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
0 commit comments