This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ### CMakeLists.txt for CUDA | |
| cmake_minimum_required(VERSION 2.8) | |
| find_package(CUDA QUIET REQUIRED) | |
| # Pass options to NVCC | |
| set( | |
| CUDA_NVCC_FLAGS | |
| ${CUDA_NVCC_FLAGS}; | |
| -O3 -gencode arch=compute_22,code=sm_22 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __global__ void reduce_kernel(float* d_in, int n, float* d_out) { | |
| extern __shared__ float shared_mem[]; | |
| int tid = threadIdx.x; | |
| int i = threadIdx.x + blockDim.x * blockIdx.x; | |
| if (i < len) { | |
| shared_mem[tid] = d_in[i]; | |
| } | |
| else { | |
| shared_mem[tid] = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import multiprocessing as mp | |
| class Job(object): | |
| '''Job present a data processing pipeline with mapper and reducer | |
| ''' | |
| def __init__(self, name, mapper, reducer, worker_n): | |
| '''initialize Job object with given mapper and reducer | |
| Parameters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| """RecordDb is an esay interface to save (image, label) data to `mx.record` | |
| """ | |
| import random | |
| import mxnet as mx | |
| class RecDb(object): | |
| """Interface to save (image, label) to `mx.record` | |
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import logging | |
| def get_logger(name=None): | |
| """return a logger | |
| """ | |
| logger = logging.getLogger(name) | |
| logger.setLevel(logging.INFO) | |
| sh = logging.StreamHandler() | |
| sh.setLevel(logging.INFO) |
OlderNewer