Skip to content

Commit ec1f96a

Browse files
Document that GetShapePtr() won't return null.
PiperOrigin-RevId: 772692021
1 parent 4d54d42 commit ec1f96a

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

third_party/xla/xla/hlo/builder/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ cc_library(
163163
"//xla/service:shape_inference",
164164
"//xla/tsl/lib/core:bitmap",
165165
"@com_google_absl//absl/algorithm:container",
166+
"@com_google_absl//absl/base:nullability",
166167
"@com_google_absl//absl/container:flat_hash_map",
167168
"@com_google_absl//absl/container:flat_hash_set",
168169
"@com_google_absl//absl/container:inlined_vector",

third_party/xla/xla/hlo/builder/xla_builder.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ limitations under the License.
2828
#include <utility>
2929
#include <vector>
3030

31+
#include "absl/base/nullability.h"
3132
#include "absl/container/flat_hash_map.h"
3233
#include "absl/container/flat_hash_set.h"
3334
#include "absl/functional/function_ref.h"
@@ -454,7 +455,7 @@ class XlaBuilder {
454455
absl::StatusOr<Shape> GetShape(XlaOp op) const;
455456

456457
// Returns the shape of the given op.
457-
virtual absl::StatusOr<const Shape*> GetShapePtr(XlaOp op) const;
458+
virtual absl::StatusOr<const Shape* absl_nonnull> GetShapePtr(XlaOp op) const;
458459

459460
// Returns the OpSharding of the given op. If "op" has no sharding, return
460461
// std::nullopt.
@@ -1246,7 +1247,7 @@ class XlaBuilder {
12461247
std::deque<HloInstructionProto> instructions_;
12471248
// A cache for the HloInstructionProto shapes, to avoid recreating Shape
12481249
// objects from protos and to support the GetShapePtr() API.
1249-
std::vector<std::unique_ptr<Shape>> instruction_shapes_;
1250+
std::vector<absl_nonnull std::unique_ptr<Shape>> instruction_shapes_;
12501251

12511252
// Dynamic parameter configuration of this computation.
12521253
DynamicParameterBinding dynamic_parameter_binding_;

0 commit comments

Comments
 (0)