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.
29 lines
1002 B
29 lines
1002 B
#include "cpu.h"
|
|
#include "../layers/routeLayer.h"
|
|
|
|
|
|
void cpuHOST::forward_layer(routeLayer *layer, cortexSTATE state){
|
|
uint32_t offset = 0;
|
|
for (uint32_t i = 0; i < layer->m_nN; ++i){
|
|
uint32_t index = layer->m_pInputLayers[i];
|
|
uint32_t input_size = layer->m_pInputSizes[i];
|
|
float *input = state.net->getLayer(index)->m_pOutput;
|
|
for (uint32_t j = 0; j < layer->m_nBatch; ++j){
|
|
makeCopy(input_size, input + j*input_size, 1, layer->m_pOutput + offset + j*layer->m_nOutput, 1);
|
|
};
|
|
offset += input_size;
|
|
};
|
|
};
|
|
|
|
void cpuHOST::backward_layer(routeLayer *layer, cortexSTATE state){
|
|
uint32_t offset = 0;
|
|
for (uint32_t i = 0; i < layer->m_nN; ++i){
|
|
uint32_t index = layer->m_pInputLayers[i];
|
|
uint32_t input_size = layer->m_pInputSizes[i];
|
|
float *delta = state.net->getLayer(index)->m_pDelta;
|
|
for (uint32_t j = 0; j < layer->m_nBatch; ++j){
|
|
calcAxpy(input_size, 1, layer->m_pDelta + offset + j*layer->m_nOutput, 1, delta + j*input_size, 1);
|
|
};
|
|
offset += input_size;
|
|
};
|
|
};
|