Calculates the number of bytes required to store the data within the specified shape. In case of a (nested) tuple shape this is the total byte size of all sub-shapes within the tuple.
| 34 | // specified shape. In case of a (nested) tuple shape this is the total byte |
| 35 | // size of all sub-shapes within the tuple. |
| 36 | int64 DataSizeOfShape(const Shape& shape) { |
| 37 | if (shape.IsArray()) { |
| 38 | return ShapeUtil::ByteSizeOf(shape); |
| 39 | } |
| 40 | |
| 41 | int64 total_size = 0; |
| 42 | for (const Shape& s : shape.tuple_shapes()) { |
| 43 | total_size += DataSizeOfShape(s); |
| 44 | } |
| 45 | return total_size; |
| 46 | } |
| 47 | |
| 48 | // Creates a XlaOp for an op what generates fake data with the given shape. |
| 49 | XlaOp BuildFakeDataOpOnDevice(const Shape& shape, XlaBuilder* builder) { |
no test coverage detected