Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
53630ed1
提交
53630ed1
authored
7月 29, 2014
作者:
Arjun Jain
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
changes after abergeron commented on the code
上级
fb660352
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
56 行增加
和
25 行删除
+56
-25
caffe_common.hpp
theano/sandbox/cuda/caffe_common.hpp
+24
-4
conv_gemm.cu
theano/sandbox/cuda/conv_gemm.cu
+31
-19
test_conv_gemm.py
theano/sandbox/cuda/tests/test_conv_gemm.py
+1
-2
没有找到文件。
theano/sandbox/cuda/caffe_common.hpp
浏览文件 @
53630ed1
// Copyright 2014 BVLC and contributors.
/*
Copyright (c) 2014, The Regents of the University of California (Regents)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CAFFE_COMMON_HPP_
#ifndef CAFFE_COMMON_HPP_
#define CAFFE_COMMON_HPP_
#define CAFFE_COMMON_HPP_
//#include <boost/shared_ptr.hpp>
#include <cublas_v2.h>
#include <cublas_v2.h>
#include <cuda.h>
#include <cuda.h>
#include <curand.h>
#include <driver_types.h> // cuda driver types
#include <driver_types.h> // cuda driver types
//#include <glog/logging.h>
// CUDA: grid stride looping
// CUDA: grid stride looping
#define CUDA_KERNEL_LOOP(i, n) \
#define CUDA_KERNEL_LOOP(i, n) \
...
...
theano/sandbox/cuda/conv_gemm.cu
浏览文件 @
53630ed1
// Copyright 2014 BVLC and contributors.
/*
Copyright (c) 2014, The Regents of the University of California (Regents)
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#undef _GLIBCXX_ATOMIC_BUILTINS
#undef _GLIBCXX_ATOMIC_BUILTINS
#include <Python.h>
#include <Python.h>
#include "cuda_ndarray.cuh"
#include "cuda_ndarray.cuh"
#include "caffe_common.hpp"
#include "caffe_common.hpp"
// Author: Arjun Jain
// Kernel for fast unfold+copy
// Kernel for fast unfold+copy
// (borrowed from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/conv_layer.cu)
// (borrowed from Caffe: https://github.com/BVLC/caffe/blob/master/src/caffe/layers/conv_layer.cu)
// Reference code: https://github.com/torch/cunn/blob/master/SpatialConvolutionMM.cu
__global__ void im2col_kernel(const int n, const float* data_im,
__global__ void im2col_kernel(const int n, const float* data_im,
const int height, const int width, const int ksize, const int pad,
const int height, const int width, const int ksize, const int pad,
const int stride, const int height_col, const int width_col,
const int stride, const int height_col, const int width_col,
...
@@ -51,18 +75,13 @@ void im2col(const float* data_im, const int channels,
...
@@ -51,18 +75,13 @@ void im2col(const float* data_im, const int channels,
// Author: Arjun Jain
CudaNdarray* validMM(const CudaNdarray *input,
CudaNdarray* validMM(const CudaNdarray *input,
CudaNdarray *weight,
CudaNdarray *weight,
CudaNdarray *output)
CudaNdarray *output)
{
{
// TODO: This needs to be done in the singleton!
cublasStatus_t status;
// Initialize CUBLAS
cublasHandle_t handle;
cublasStatus_t status = cublasCreate(&handle);
if (status != CUBLAS_STATUS_SUCCESS) {
std::cerr << "!!!! CUBLAS initialization error\n";
}
if (input->nd != 4)
if (input->nd != 4)
{
{
...
@@ -74,7 +93,6 @@ CudaNdarray* validMM(const CudaNdarray *input,
...
@@ -74,7 +93,6 @@ CudaNdarray* validMM(const CudaNdarray *input,
PyErr_SetString(PyExc_ValueError, "required weight of 4D");
PyErr_SetString(PyExc_ValueError, "required weight of 4D");
}
}
// Reference code: https://github.com/torch/cunn/blob/master/SpatialConvolutionMM.cu
// TODO: stride(dW, dH) and padding as function parameter
// TODO: stride(dW, dH) and padding as function parameter
int dH = 1;
int dH = 1;
int dW = 1;
int dW = 1;
...
@@ -146,19 +164,13 @@ CudaNdarray* validMM(const CudaNdarray *input,
...
@@ -146,19 +164,13 @@ CudaNdarray* validMM(const CudaNdarray *input,
output->devdata + elt * op_stride, m
output->devdata + elt * op_stride, m
);
);
if (status != CUBLAS_STATUS_SUCCESS) {
cudaError_t err = cudaGetLastError();
std::cerr << "!!!! CUBLAS initialization error\n";
if (err != cudaSuccess) {
printf("error in validMM: %s\n", cudaGetErrorString(err));
}
}
}
}
// TODO: How is columns and output deallocated?
Py_DECREF(columns);
// device_free(columns->devdata);
// TODO: I did not kill the cublas context. If it comes from
// the singleton, we dont need to kill it.
return output;
return output;
}
}
...
...
theano/sandbox/cuda/tests/test_conv_gemm.py
浏览文件 @
53630ed1
"""
"""
Tests for GPU convolution
Tests for
Caffe
GPU convolution
"""
"""
import
sys
import
sys
import
time
import
time
import
unittest
import
unittest
import
matplotlib.pyplot
as
plt
import
numpy
import
numpy
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论