From: Kai Li Date: Mon, 24 Mar 2014 01:47:00 +0000 (+0800) Subject: Separate WindowDataLayer::Forward_gpu into a cu file X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=af26a549cdef95a5d5cbb7365c15b74fc8667aa1;p=platform%2Fupstream%2Fcaffe.git Separate WindowDataLayer::Forward_gpu into a cu file --- diff --git a/src/caffe/layers/window_data_layer.cpp b/src/caffe/layers/window_data_layer.cpp index a288403..d447cba 100644 --- a/src/caffe/layers/window_data_layer.cpp +++ b/src/caffe/layers/window_data_layer.cpp @@ -418,24 +418,6 @@ Dtype WindowDataLayer::Forward_cpu(const vector*>& bottom, return Dtype(0.); } -template -Dtype WindowDataLayer::Forward_gpu(const vector*>& bottom, - vector*>* top) { - // First, join the thread - CHECK(!pthread_join(thread_, NULL)) << "Pthread joining failed."; - // Copy the data - CUDA_CHECK(cudaMemcpy((*top)[0]->mutable_gpu_data(), - prefetch_data_->cpu_data(), sizeof(Dtype) * prefetch_data_->count(), - cudaMemcpyHostToDevice)); - CUDA_CHECK(cudaMemcpy((*top)[1]->mutable_gpu_data(), - prefetch_label_->cpu_data(), sizeof(Dtype) * prefetch_label_->count(), - cudaMemcpyHostToDevice)); - // Start a new prefetch thread - CHECK(!pthread_create(&thread_, NULL, WindowDataLayerPrefetch, - reinterpret_cast(this))) << "Pthread execution failed."; - return Dtype(0.); -} - INSTANTIATE_CLASS(WindowDataLayer); } // namespace caffe diff --git a/src/caffe/layers/window_data_layer.cu b/src/caffe/layers/window_data_layer.cu new file mode 100644 index 0000000..bf33194 --- /dev/null +++ b/src/caffe/layers/window_data_layer.cu @@ -0,0 +1,53 @@ +// Copyright 2013 Ross Girshick +// +// Based on data_layer.cpp by Yangqing Jia. + +#include +#include + +#include +#include +#include +#include +#include // NOLINT(readability/streams) +#include + +#include "opencv2/core/core.hpp" +#include "opencv2/highgui/highgui.hpp" +#include "opencv2/imgproc/imgproc.hpp" + +#include "caffe/layer.hpp" +#include "caffe/util/io.hpp" +#include "caffe/vision_layers.hpp" + +using std::string; +using std::map; +using std::pair; + +// caffe.proto > LayerParameter +// 'source' field specifies the window_file +// 'cropsize' indicates the desired warped size + +namespace caffe { + +template +Dtype WindowDataLayer::Forward_gpu(const vector*>& bottom, + vector*>* top) { + // First, join the thread + CHECK(!pthread_join(thread_, NULL)) << "Pthread joining failed."; + // Copy the data + CUDA_CHECK(cudaMemcpy((*top)[0]->mutable_gpu_data(), + prefetch_data_->cpu_data(), sizeof(Dtype) * prefetch_data_->count(), + cudaMemcpyHostToDevice)); + CUDA_CHECK(cudaMemcpy((*top)[1]->mutable_gpu_data(), + prefetch_label_->cpu_data(), sizeof(Dtype) * prefetch_label_->count(), + cudaMemcpyHostToDevice)); + // Start a new prefetch thread + CHECK(!pthread_create(&thread_, NULL, WindowDataLayerPrefetch, + reinterpret_cast(this))) << "Pthread execution failed."; + return Dtype(0.); +} + +INSTANTIATE_CLASS(WindowDataLayer); + +} // namespace caffe