GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fool/convolution_filter.cpp at master · DaFuCoding/fool

Expand file tree

/

convolution_filter.cpp

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
66 lines (53 loc) · 2.15 KB
/

convolution_filter.cpp

Copy path

File metadata and controls

66 lines (53 loc) · 2.15 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#include "convolution_filter.hpp"
#include "block.hpp"
namespace fool{
template<typename Dtype>
void ConvolutionFilterCore(const Dtype* data, Dtype* outputData, const int inputChannel, const int startIdx,
const int outputIdx, const int kernelRow, const int kernelCol, const int channelStep,
const int inputColStep, const Dtype* weights, const int weightChannelStep){
for(int c = 0; c < inputChannel; ++c){
for(int i = 0; i < kernelRow; ++i){
for(int j = 0; j < kernelCol; ++j){
float inputValue = *(data + startIdx + c*channelStep + i*inputColStep + j);
float weightValue = *(weights + weightChannelStep + c*kernelCol*kernelRow + i*kernelCol + j);
*(outputData + outputIdx) = inputValue * weightValue;
}
}
}
}
template<typename Dtype>
void ConvolutionForward(const Block<Dtype>& inputs, Block<Dtype>& outputs, const Block<Dtype>& weightParam,
const int outputChannel, const int kernelSizeRow, const int kernelSizeCol,
const int stride=1, const int padSize=0){
int batchSize = inputs.batch;
// check batch size small than 1
assert(batchSize >= 1);
int inputRow = inputs.height;
int inputCol = inputs.width;
int inputChannel = inputs.channel;
int outputRow = (inputRow + 2*padSize - kernelSizeRow) / stride + 1;
int outputCol = (inputCol + 2*padSize - kernelSizeCol) / stride + 1;
Dtype* outputData = outputs.data;
const Dtype* weight = weightParam.data;
int inputStepLen = inputRow * inputCol;
int outputStepLen = outputRow * outputCol;
int inputBlockLen = inputStepLen * inputChannel;
int outputBlockLen = outputStepLen * outputChannel;
for(int b=0; b < batchSize; ++b){
for(int c = 0; c < outputChannel; ++c){
for(int i = 0; i < outputRow; i += stride){
for(int j = 0; j < outputCol; j += stride){
int startIdx = i * outputCol + j;
int outputIdx = c * outputStepLen + i * outputCol + j;
ConvolutionFilterCore(inputs.data, outputData, inputChannel, startIdx, outputIdx, kernelSizeRow, kernelSizeCol,
inputStepLen, inputCol, weight, c*kernelSizeCol*kernelSizeRow );
}
}
}
}
return;
}
template<typename Dtype>
void ConvolutionFilter<Dtype>::FilterInitize(){
}
} // namespace FOOL
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.