@@ -83,18 +83,18 @@ class Tensor { |
83 | 83 | * |
84 | 84 | * Data will be hold by a std::vector with 64bytes alignment. |
85 | 85 | */ |
86 | | - explicit Tensor(const serial_size_t d0, |
87 | | - const serial_size_t d1, |
88 | | - const serial_size_t d2, |
89 | | - const serial_size_t d3) { |
| 86 | + explicit Tensor(const size_t d0, |
| 87 | + const size_t d1, |
| 88 | + const size_t d2, |
| 89 | + const size_t d3) { |
90 | 90 | reshape(d0, d1, d2, d3); |
91 | 91 | } |
92 | 92 |
|
93 | | - explicit Tensor(const std::array<serial_size_t, 4>& shape) { |
| 93 | + explicit Tensor(const std::array<size_t, 4>& shape) { |
94 | 94 | reshape(shape[0], shape[1], shape[2], shape[3]); |
95 | 95 | } |
96 | 96 |
|
97 | | - explicit Tensor(const std::vector<serial_size_t>& shape) { |
| 97 | + explicit Tensor(const std::vector<size_t>& shape) { |
98 | 98 | assert(shape.size() == 4); |
99 | 99 | reshape(shape[0], shape[1], shape[2], shape[3]); |
100 | 100 | } |
@@ -148,30 +148,30 @@ class Tensor { |
148 | 148 | #endif |
149 | 149 |
|
150 | 150 | // Returns the tensor shape |
151 | | - const std::array<serial_size_t, 4>& shape() const { return shape_; } |
| 151 | + const std::array<size_t, 4>& shape() const { return shape_; } |
152 | 152 |
|
153 | 153 | // Returns the value of a specified index in the tensor. |
154 | 154 | // Checked version (throw exceptions for out-of-range error) |
155 | | - U& host_at(const serial_size_t d0, |
156 | | - const serial_size_t d1, |
157 | | - const serial_size_t d2, |
158 | | - const serial_size_t d3) { |
| 155 | + U& host_at(const size_t d0, |
| 156 | + const size_t d1, |
| 157 | + const size_t d2, |
| 158 | + const size_t d3) { |
159 | 159 | return *host_ptr(d0, d1, d2, d3); |
160 | 160 | } |
161 | 161 |
|
162 | | - U host_at(const serial_size_t d0, |
163 | | - const serial_size_t d1, |
164 | | - const serial_size_t d2, |
165 | | - const serial_size_t d3) const { |
| 162 | + U host_at(const size_t d0, |
| 163 | + const size_t d1, |
| 164 | + const size_t d2, |
| 165 | + const size_t d3) const { |
166 | 166 | return *host_ptr(d0, d1, d2, d3); |
167 | 167 | } |
168 | 168 |
|
169 | 169 | // Returns the pointer to a specified index in the tensor |
170 | 170 | // Checked version (throw exceptions for out-of-range error) |
171 | | - const U* host_ptr(const serial_size_t d0, |
172 | | - const serial_size_t d1, |
173 | | - const serial_size_t d2, |
174 | | - const serial_size_t d3) const { |
| 171 | + const U* host_ptr(const size_t d0, |
| 172 | + const size_t d1, |
| 173 | + const size_t d2, |
| 174 | + const size_t d3) const { |
175 | 175 | if (d0 >= shape_[0] || d1 >= shape_[1] || |
176 | 176 | d2 >= shape_[2] || d3 >= shape_[3]) { |
177 | 177 | throw nn_error("Access tensor out of range."); |
@@ -185,10 +185,10 @@ class Tensor { |
185 | 185 | ); |
186 | 186 | } |
187 | 187 |
|
188 | | - U* host_ptr(const serial_size_t d0, |
189 | | - const serial_size_t d1, |
190 | | - const serial_size_t d2, |
191 | | - const serial_size_t d3) { |
| 188 | + U* host_ptr(const size_t d0, |
| 189 | + const size_t d1, |
| 190 | + const size_t d2, |
| 191 | + const size_t d3) { |
192 | 192 | if (d0 >= shape_[0] || d1 >= shape_[1] || |
193 | 193 | d2 >= shape_[2] || d3 >= shape_[3]) { |
194 | 194 | throw nn_error("Access tensor out of range."); |
@@ -236,19 +236,18 @@ class Tensor { |
236 | 236 | std::fill(std::begin(host_data_), std::end(host_data_), value); |
237 | 237 | } |
238 | 238 |
|
239 | | - void reshape(const serial_size_t d0, |
240 | | - const serial_size_t d1, |
241 | | - const serial_size_t d2, |
242 | | - const serial_size_t d3) { |
| 239 | + void reshape(const size_t d0, |
| 240 | + const size_t d1, |
| 241 | + const size_t d2, |
| 242 | + const size_t d3) { |
243 | 243 | shape_[0] = d0; |
244 | 244 | shape_[1] = d1; |
245 | 245 | shape_[2] = d2; |
246 | 246 | shape_[3] = d3; |
247 | 247 | host_data_.resize(calcSize(), U(0)); |
248 | 248 | } |
249 | 249 |
|
250 | | - void reshape(const std::array<serial_size_t, 4> &sz) |
251 | | - { |
| 250 | + void reshape(const std::array<size_t, 4> &sz) { |
252 | 251 | shape_ = sz; |
253 | 252 | host_data_.resize(calcSize(), U(0)); |
254 | 253 | } |
@@ -295,7 +294,7 @@ class Tensor { |
295 | 294 | * shape_[2]: height |
296 | 295 | * shape_[3]: depth |
297 | 296 | */ |
298 | | - std::array<serial_size_t, 4> shape_; |
| 297 | + std::array<size_t, 4> shape_; |
299 | 298 |
|
300 | 299 | /* Pointer to the Tensor data in pure in the host device */ |
301 | 300 | std::vector<U, aligned_allocator<U, 64> > host_data_; |
|