#include #include #include "caffe/layer.hpp" #include "caffe/vision_layers.hpp" namespace caffe { template __global__ void ThresholdForward(const int n, const Dtype threshold, const Dtype* in, Dtype* out) { CUDA_KERNEL_LOOP(index, n) { out[index] = in[index] > threshold ? 1 : 0; } } template void ThresholdLayer::Forward_gpu(const vector*>& bottom, const vector*>& top) { const Dtype* bottom_data = bottom[0]->gpu_data(); Dtype* top_data = top[0]->mutable_gpu_data(); const int count = bottom[0]->count(); // NOLINT_NEXT_LINE(whitespace/operators) ThresholdForward<<>>( count, threshold_, bottom_data, top_data); CUDA_POST_KERNEL_CHECK; } INSTANTIATE_LAYER_GPU_FORWARD(ThresholdLayer); } // namespace caffe