Use TensorShape::num_elements() instead of loop
This commit is contained in:
parent
7008e41f18
commit
a9261f1243
@ -2394,15 +2394,9 @@ bool ConstantFolding::IsReductionWithConstantIndices(
|
|||||||
!reductions_indices->attr().count("value")) {
|
!reductions_indices->attr().count("value")) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const TensorProto& reduction_indices_tensor =
|
const TensorShapeProto& reduction_indices_shape =
|
||||||
reductions_indices->attr().at("value").tensor();
|
reductions_indices->attr().at("value").tensor().tensor_shape();
|
||||||
*indices_is_empty = false;
|
*indices_is_empty = TensorShape(reduction_indices_shape).num_elements() == 0;
|
||||||
for (const auto& dim : reduction_indices_tensor.tensor_shape().dim()) {
|
|
||||||
if (dim.size() == 0) {
|
|
||||||
*indices_is_empty = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user