FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
caffe/src/caffe/layers/conv_layer.cu at master · BVLC/caffe · GitHub
BVLC
caffe
Repository navigation
Code
Issues
899
(899)
Pull requests
277
(277)
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
caffe
/
src
/
caffe
/
layers
/
conv_layer.cu
Copy path
More file actions
More file actions
Latest commit
History
History
History
60 lines (54 loc) · 2.18 KB
Breadcrumbs
caffe
/
src
/
caffe
/
layers
/
conv_layer.cu
Copy path
File metadata and controls
60 lines (54 loc) · 2.18 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
#
include
<
vector
>
#
include
"
caffe/layers/conv_layer.hpp
"
namespace
caffe
{
template
<
typename
Dtype>
void
ConvolutionLayer<Dtype>::Forward_gpu(
const
vector<Blob<Dtype>*>& bottom,
const
vector<Blob<Dtype>*>& top) {
const
Dtype* weight =
this
->
blobs_
[
0
]->
gpu_data
();
for
(
int
i =
0
; i < bottom.
size
(); ++i) {
const
Dtype* bottom_data = bottom[i]->
gpu_data
();
Dtype* top_data = top[i]->
mutable_gpu_data
();
for
(
int
n =
0
; n <
this
->
num_
; ++n) {
this
->
forward_gpu_gemm
(bottom_data + n *
this
->
bottom_dim_
, weight,
top_data + n *
this
->
top_dim_
);
if
(
this
->
bias_term_
) {
const
Dtype* bias =
this
->
blobs_
[
1
]->
gpu_data
();
this
->
forward_gpu_bias
(top_data + n *
this
->
top_dim_
, bias);
}
}
}
}
template
<
typename
Dtype>
void
ConvolutionLayer<Dtype>::Backward_gpu(
const
vector<Blob<Dtype>*>& top,
const
vector<
bool
>& propagate_down,
const
vector<Blob<Dtype>*>& bottom) {
const
Dtype* weight =
this
->
blobs_
[
0
]->
gpu_data
();
Dtype* weight_diff =
this
->
blobs_
[
0
]->
mutable_gpu_diff
();
for
(
int
i =
0
; i < top.
size
(); ++i) {
const
Dtype* top_diff = top[i]->
gpu_diff
();
//
Bias gradient, if necessary.
if
(
this
->
bias_term_
&&
this
->
param_propagate_down_
[
1
]) {
Dtype* bias_diff =
this
->
blobs_
[
1
]->
mutable_gpu_diff
();
for
(
int
n =
0
; n <
this
->
num_
; ++n) {
this
->
backward_gpu_bias
(bias_diff, top_diff + n *
this
->
top_dim_
);
}
}
if
(
this
->
param_propagate_down_
[
0
] || propagate_down[i]) {
const
Dtype* bottom_data = bottom[i]->
gpu_data
();
Dtype* bottom_diff = bottom[i]->
mutable_gpu_diff
();
for
(
int
n =
0
; n <
this
->
num_
; ++n) {
//
gradient w.r.t. weight. Note that we will accumulate diffs.
if
(
this
->
param_propagate_down_
[
0
]) {
this
->
weight_gpu_gemm
(bottom_data + n *
this
->
bottom_dim_
,
top_diff + n *
this
->
top_dim_
, weight_diff);
}
//
gradient w.r.t. bottom data, if necessary.
if
(propagate_down[i]) {
this
->
backward_gpu_gemm
(top_diff + n *
this
->
top_dim_
, weight,
bottom_diff + n *
this
->
bottom_dim_
);
}
}
}
}
}
INSTANTIATE_LAYER_GPU_FUNCS
(ConvolutionLayer);
}
//
namespace caffe
Back
|
FazBrowse Home
|
New Git URL