* Create a data bucket in cpu backend. * @param shape Shape of the `TensorInfo`. * @param dtype DType of the `TensorInfo`. * @param values The value of the `TensorInfo` stored as a flattened array.
(
shape: number[], dtype: DataType,
values?: backend_util.BackendValues|string[])
| 77 | * @param values The value of the `TensorInfo` stored as a flattened array. |
| 78 | */ |
| 79 | makeTensorInfo( |
| 80 | shape: number[], dtype: DataType, |
| 81 | values?: backend_util.BackendValues|string[]): TensorInfo { |
| 82 | let outId; |
| 83 | if (dtype === 'string' && values != null && values.length > 0 && |
| 84 | util.isString(values[0])) { |
| 85 | const encodedValues = |
| 86 | (values as unknown as string[]).map(d => util.encodeString(d)); |
| 87 | |
| 88 | outId = this.write(encodedValues, shape, dtype); |
| 89 | } else { |
| 90 | outId = this.write(values as TypedArray, shape, dtype); |
| 91 | } |
| 92 | |
| 93 | return {dataId: outId, shape, dtype}; |
| 94 | } |
| 95 | |
| 96 | /** Return refCount of a `TensorData`. */ |
| 97 | override refCount(dataId: DataId): number { |
no test coverage detected