You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#include "cpu.h"
#include "../layers/avgpoolLayer.h"
void cpuHOST::forward_layer(avgpoolLayer *layer, cortexSTATE state){ uint32_t Area = layer->m_nIn_Width * layer->m_nIn_Height; for (uint32_t b = 0; b < layer->m_nBatch; ++b){ for (uint32_t k = 0; k < layer->m_nIn_Channels; ++k){ uint32_t out_index = k + b*layer->m_nIn_Channels; layer->m_pOutput[out_index] = 0; for (uint32_t i = 0; i < Area; ++i){ uint32_t in_index = i + Area*out_index; layer->m_pOutput[out_index] += state.input[in_index]; }; layer->m_pOutput[out_index] /= Area; }; };};
void cpuHOST::backward_layer(avgpoolLayer *layer, cortexSTATE state){ uint32_t Area = layer->m_nIn_Width * layer->m_nIn_Height; for (uint32_t b = 0; b < layer->m_nBatch; ++b){ for (uint32_t k = 0; k < layer->m_nIn_Channels; ++k){ uint32_t out_index = k + b*layer->m_nIn_Channels; for (uint32_t i = 0; i < Area; ++i){ uint32_t in_index = i + Area*out_index; state.delta[in_index] += layer->m_pDelta[out_index]/Area; }; }; };};
|