Commit d116bab
committed
If the
Some callers call the `Shape(element_type, dimensions, dynamic_dimensions)` ctor with a non-empty `dimensions` and an empty `dynamic_dimensions`. This breaks the shape object's invariant that the two should have the same size.
We have two options for fixing this:
1. Force the caller to always provide a `dynamic_dimensions` whose size matches that of `dimensions`.
2. Provide a sensible default behavior when `dynamic_dimensions` is empty.
I chose #2 as:
1. #1 is more risky as it may cause the compiler to crash in production (e.g. if we don't have adequate test coverage).
2. It's very common for an array to have only static dimensions. Therefore it's good to optimize the user experience for this common case.
PiperOrigin-RevId: 739197635dynamic_dimensions parameter is empty in the Shape ctor, assume all dimensions are static.1 parent 5725d19 commit d116bab
3 files changed
+15
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
63 | 66 | | |
64 | 67 | | |
65 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
70 | | - | |
| 70 | + | |
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
49 | 59 | | |
50 | 60 | | |
51 | 61 | | |
| |||
0 commit comments