Use TensorShape::num_elements() instead of loop

This commit is contained in:
Ben Barsdell 2019-04-24 10:46:47 -07:00
parent 7008e41f18
commit a9261f1243

View File

@ -2394,15 +2394,9 @@ bool ConstantFolding::IsReductionWithConstantIndices(
!reductions_indices->attr().count("value")) {
return false;
}
const TensorProto& reduction_indices_tensor =
reductions_indices->attr().at("value").tensor();
*indices_is_empty = false;
for (const auto& dim : reduction_indices_tensor.tensor_shape().dim()) {
if (dim.size() == 0) {
*indices_is_empty = true;
break;
}
}
const TensorShapeProto& reduction_indices_shape =
reductions_indices->attr().at("value").tensor().tensor_shape();
*indices_is_empty = TensorShape(reduction_indices_shape).num_elements() == 0;
return true;
}