File tree Expand file tree Collapse file tree 1 file changed +4
-12
lines changed
kernels/portable/cpu/util Expand file tree Collapse file tree 1 file changed +4
-12
lines changed Original file line number Diff line number Diff line change @@ -83,12 +83,8 @@ size_t get_reduced_dim_product(
83
83
if (in.dim () == 0 ) {
84
84
return 1 ;
85
85
}
86
- size_t dim_product = 1 ;
87
86
if (!dim.has_value ()) {
88
- for (size_t i = 0 ; i < static_cast <size_t >(in.dim ()); ++i) {
89
- dim_product *= in.size (i);
90
- }
91
- return dim_product;
87
+ return in.numel ();
92
88
}
93
89
const size_t d = _normalize_non_neg_d (dim.value (), in.dim ());
94
90
return in.size (d);
@@ -104,16 +100,12 @@ size_t get_reduced_dim_product(
104
100
if (in.dim () == 0 ) {
105
101
return 1 ;
106
102
}
107
- size_t dim_product = 1 ;
108
- const size_t in_dim = in.dim ();
109
103
if (!dim_list.has_value () || dim_list.value ().size () == 0 ) {
110
- for (size_t i = 0 ; i < static_cast <size_t >(in.dim ()); ++i) {
111
- dim_product *= in.size (i);
112
- }
113
- return dim_product;
104
+ return in.numel ();
114
105
}
106
+ size_t dim_product = 1 ;
115
107
for (const auto & d : dim_list.value ()) {
116
- const size_t non_neg_d = _normalize_non_neg_d (d, in_dim );
108
+ const size_t non_neg_d = _normalize_non_neg_d (d, in. dim () );
117
109
dim_product *= in.size (non_neg_d);
118
110
}
119
111
return dim_product;
You can’t perform that action at this time.
0 commit comments