-
Notifications
You must be signed in to change notification settings - Fork 0
/
MWFusedConvReLULayer.cpp
69 lines (53 loc) · 2.67 KB
/
MWFusedConvReLULayer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* Copyright 2018 The MathWorks, Inc. */
#include "MWFusedConvReLULayer.hpp"
#include "MWFusedConvReLULayerImpl.hpp"
// utils
#include <stdio.h>
#include <cassert>
MWFusedConvReLULayer::MWFusedConvReLULayer()
{
}
MWFusedConvReLULayer::~MWFusedConvReLULayer()
{
}
void MWFusedConvReLULayer::createFusedConvReLULayer(MWTargetNetworkImpl* ntwk_impl,
MWTensor* m_in,
int m_r,
int m_s,
int m_c,
int m_k,
int m_StrideH,
int m_StrideW,
int m_PaddingH_T,
int m_PaddingH_B,
int m_PaddingW_L,
int m_PaddingW_R,
int m_DilationFactorH,
int m_DilationFactorW,
int m_g,
const char* m_weights_file,
const char* m_bias_file,
int outbufIdx)
{
setInputTensor(m_in);
int m_FilterHeight = m_r;
int m_FilterWidth = m_s;
int m_NumGroups = m_g;
int m_NumChannels = m_c;
int m_NumFilters = m_k;
int m_filterH_temp = ((m_FilterHeight-1)*m_DilationFactorH)+1;
int m_filterW_temp = ((m_FilterWidth-1)*m_DilationFactorW)+1;
int outputH = ((getInputTensor()->getHeight()- m_filterH_temp + m_PaddingH_B + m_PaddingH_T)/m_StrideH) + 1;
int outputW = ((getInputTensor()->getWidth()- m_filterW_temp + m_PaddingW_L + m_PaddingW_R)/m_StrideW) + 1;
// allocate output tensor
allocateOutputTensor(outputH, outputW, m_NumFilters*m_NumGroups , getInputTensor()->getBatchSize(), NULL);
m_impl = new MWFusedConvReLULayerImpl(this, ntwk_impl, m_FilterHeight, m_FilterWidth, m_NumGroups, m_NumChannels, m_NumFilters, m_StrideH, m_StrideW,
m_PaddingH_T, m_PaddingH_B, m_PaddingW_L, m_PaddingW_R, m_DilationFactorH, m_DilationFactorW, m_weights_file, m_bias_file, outbufIdx);
/*Setting the data pointer */
MWTensor *opTensor = getOutputTensor();
opTensor->setData(m_impl->getData());
}
void MWFusedConvReLULayer::postSetup()
{
m_impl->postSetup();
}