aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/compiler/xla/service/shape_inference.cc
diff options
context:
space:
mode:
authorGravatar A. Unique TensorFlower <gardener@tensorflow.org>2018-06-19 07:34:09 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-06-19 07:38:03 -0700
commit124fadcf1cc6a4b95f91c69e67b5fb592556e363 (patch)
treeb9d277d0cb2ee4deec3e950b5d259dbff2d38c49 /tensorflow/compiler/xla/service/shape_inference.cc
parent1e3caf55ba86cd6ea36b8b9dfe5e7670ace29c05 (diff)
Performance microtweaks: Pass by reference rather than by value; pre-reserve capacity when total vectoroid size is known.
PiperOrigin-RevId: 201172723
Diffstat (limited to 'tensorflow/compiler/xla/service/shape_inference.cc')
-rw-r--r--tensorflow/compiler/xla/service/shape_inference.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/tensorflow/compiler/xla/service/shape_inference.cc b/tensorflow/compiler/xla/service/shape_inference.cc
index e25f5e67c7..4606d8f202 100644
--- a/tensorflow/compiler/xla/service/shape_inference.cc
+++ b/tensorflow/compiler/xla/service/shape_inference.cc
@@ -939,6 +939,7 @@ ShapeInference::InferDegenerateDimensionBroadcastShape(HloOpcode operation,
HloOpcode opcode,
tensorflow::gtl::ArraySlice<const HloInstruction*> operands) {
std::vector<const Shape*> operand_shapes;
+ operand_shapes.reserve(operands.size());
for (const HloInstruction* operand : operands) {
operand_shapes.push_back(&operand->shape());
}
@@ -954,6 +955,7 @@ ShapeInference::InferDegenerateDimensionBroadcastShape(HloOpcode operation,
switch (opcode) {
case HloOpcode::kTuple: {
Shape result = ShapeUtil::MakeTupleShape({});
+ result.mutable_tuple_shapes()->Reserve(operand_shapes.size());
for (const Shape* shape : operand_shapes) {
ShapeUtil::AppendShapeToTuple(*shape, &result);
}