Skip to content

Commit b32397f

Browse files
committed
Reduce Operator code cleaned and fixed the warning for int to size_t when (n==dim-1)
1 parent ac7392a commit b32397f

File tree

1 file changed

+1
-46
lines changed

1 file changed

+1
-46
lines changed

tmva/sofie/inc/TMVA/ROperator_Reduce.hxx

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -95,23 +95,7 @@ public:
9595
out << "\n//---- operator " << Name() << " " << OpName << "\n";
9696
out << SP << "for (size_t i = 0; i < " << outputLength << "; i++) {\n";
9797

98-
// write here according to size of shape
99-
// in generation code can be done automatically
100-
// i0 = i / s0 ; i1 = (i % s0) / s1 ; i2 = ( (i % s0) % s1 ) / s2 and so on
101-
// and we have for the inverse
102-
// i = i0 * s0 + i1 * s1 + i2 * s2 + i3 * s3 ....
103-
104-
// don't need to divide by last stride s[n-1] since it is 1 by definition
105-
10698
size_t dim = fShapeX.size(); // this is the input dimension (e.g. 2, 3 or 4 or more)
107-
// out << SP << "std::vector<size_t> outputStrides = {" ;
108-
// for (size_t k = 0; k < dim; k++) {
109-
// out << outputStrides[k] ;
110-
// if (k < dim-1)
111-
// out << " ,";
112-
// else
113-
// out << " };\n";
114-
// }
11599

116100
// here we find output indices
117101
out << SP << SP << "size_t idx_0 = i / " << outputStrides[0] << ";\n" ;
@@ -125,50 +109,21 @@ public:
125109
out << SP << SP << "size_t idx_" << k << " = itmp;\n";
126110
}
127111

128-
129-
// for (size_t k = 0; k < dim; k++) {
130-
// size_t j;
131-
// out << SP << "size_t idx_" << k <<" = i;\n";
132-
// for(j = 0; j < k; j++ )
133-
// out << SP << "idx_" << k << " = idx_" << k <<" % outputStrides[" << j << "];\n" ;
134-
135-
// out << SP << "idx_" << k << " = idx_" << k << "/ outputStrides[" << j << "];\n";
136-
// }
137-
138-
// out << SP << "assert(idx[" << fAttrAxes << "] == 0);\n"; // we can avoid computing this for the reduction axis which by definition is always zero
139-
140112
// compute reduction
141113

142114
out << SP << SP << "float sum = 0;\n";
143115
out << SP << SP << "for (size_t k = 0; k < " << fShapeX[fAttrAxes] <<"; k++) { \n";
144116
out << SP << SP << SP << "idx_" << fAttrAxes << " = k;\n";
145117
// compute input index j
146118
out << SP << SP << SP << "size_t l = ";
147-
for(int n = dim-1; n >= 0; n-- ) {
119+
for(size_t n = dim-1; n >= 0; n-- ) {
148120
if (n == dim-1)
149121
out << "idx_" << n;
150122
else
151123
out << " + " << "idx_" << n << " * " << inputStrides[n];
152124
}
153125
out << ";\n";
154126

155-
156-
// out << SP << "std::vector<size_t> inputStrides = {" ;
157-
// for (size_t k = 0; k < dim; k++) {
158-
// out << inputStrides[k] ;
159-
// if (k < dim-1)
160-
// out << " ,";
161-
// else
162-
// out << " };\n";
163-
// }
164-
// out << SP << SP << "size_t l = 0;\n";
165-
166-
// size_t n ;
167-
// for(n = 0; n < dim-1; n++ )
168-
// out << SP << "l += idx_" << n << " * inputStrides[" << n << "];\n";
169-
170-
// out << SP << "l += idx_" << n << ";\n";
171-
172127
if(fReduceOpMode == ReduceMean){
173128
out << SP << SP << SP << "sum += tensor_" << fNX << "[l];\n";
174129
out << SP << SP << "}\n";

0 commit comments

Comments
 (0)