[xla::Shape::Shape] Emplace tuple shapes into tuple_shapes_
.
This avoids creating and destroying a temporary `Shape` in `add_tuple_shapes()`, then move-assigning and destroying each tuple-shape in the constructor. PiperOrigin-RevId: 298703231 Change-Id: I793742c163cf24780b0764aa6c3846715517f99d
This commit is contained in:
parent
3421416220
commit
a8ac8f901a
@ -48,7 +48,7 @@ Shape::Shape(const ShapeProto& shape_proto) {
|
||||
}
|
||||
tuple_shapes_.reserve(shape_proto.tuple_shapes_size());
|
||||
for (const ShapeProto& element_shape : shape_proto.tuple_shapes()) {
|
||||
*add_tuple_shapes() = Shape(element_shape);
|
||||
tuple_shapes_.emplace_back(element_shape);
|
||||
}
|
||||
if (shape_proto.has_layout()) {
|
||||
*mutable_layout() = Layout::CreateFromProto(shape_proto.layout());
|
||||
|
Loading…
Reference in New Issue
Block a user