зеркало из https://github.com/microsoft/caffe.git
Separate ImagesLayer::Forward_gpu into a cu file
This commit is contained in:
Родитель
91483aef03
Коммит
3f33c202ce
|
@ -248,24 +248,6 @@ Dtype ImagesLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom,
|
|||
return Dtype(0.);
|
||||
}
|
||||
|
||||
template <typename Dtype>
|
||||
Dtype ImagesLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
|
||||
vector<Blob<Dtype>*>* 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, ImagesLayerPrefetch<Dtype>,
|
||||
reinterpret_cast<void*>(this))) << "Pthread execution failed.";
|
||||
return Dtype(0.);
|
||||
}
|
||||
|
||||
INSTANTIATE_CLASS(ImagesLayer);
|
||||
|
||||
} // namespace caffe
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
// Copyright 2013 Yangqing Jia
|
||||
|
||||
#include <stdint.h>
|
||||
#include <leveldb/db.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <iostream> // NOLINT(readability/streams)
|
||||
#include <fstream> // NOLINT(readability/streams)
|
||||
|
||||
#include "caffe/layer.hpp"
|
||||
#include "caffe/util/io.hpp"
|
||||
#include "caffe/vision_layers.hpp"
|
||||
|
||||
using std::string;
|
||||
using std::pair;
|
||||
|
||||
namespace caffe {
|
||||
|
||||
template <typename Dtype>
|
||||
Dtype ImagesLayer<Dtype>::Forward_gpu(const vector<Blob<Dtype>*>& bottom,
|
||||
vector<Blob<Dtype>*>* 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, ImagesLayerPrefetch<Dtype>,
|
||||
reinterpret_cast<void*>(this))) << "Pthread execution failed.";
|
||||
return Dtype(0.);
|
||||
}
|
||||
|
||||
INSTANTIATE_CLASS(ImagesLayer);
|
||||
|
||||
} // namespace caffe
|
Загрузка…
Ссылка в новой задаче