| 226 | // NOTE(Liang Depeng): helper functions to process datas for specific channel over all samples. |
| 227 | template<typename T, typename DataProcessor> |
| 228 | static inline void ForEachFast(const T* data, const int64_t batch_size, const int64_t spatial_size, |
| 229 | const int64_t jump_step, const int64_t channel_idx, |
| 230 | DataProcessor data_processor) { |
| 231 | const int64_t start_offset = channel_idx * spatial_size; |
| 232 | const T* tmp_data = data + start_offset; |
| 233 | for (int64_t outer = 0; outer < batch_size; ++outer) { |
| 234 | for (int64_t i = 0; i < spatial_size; ++i) { data_processor(&tmp_data[i]); } |
| 235 | tmp_data += jump_step; |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | template<typename T, typename DataProcessor> |
| 240 | static inline void ForEachFast(const T* in_data1, const T* in_data2, const int64_t batch_size, |