本文整理汇总了C++中cuda_make_array函数的典型用法代码示例。如果您正苦于以下问题:C++ cuda_make_array函数的具体用法?C++ cuda_make_array怎么用?C++ cuda_make_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cuda_make_array函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: time_ongpu
void time_ongpu(int TA, int TB, int m, int k, int n)
{
int iter = 10;
float *a = random_matrix(m,k);
float *b = random_matrix(k,n);
int lda = (!TA)?k:m;
int ldb = (!TB)?n:k;
float *c = random_matrix(m,n);
float *a_cl = cuda_make_array(a, m*k);
float *b_cl = cuda_make_array(b, k*n);
float *c_cl = cuda_make_array(c, m*n);
int i;
clock_t start = clock(), end;
for(i = 0; i<iter; ++i){
gemm_ongpu(TA,TB,m,n,k,1,a_cl,lda,b_cl,ldb,1,c_cl,n);
cudaThreadSynchronize();
}
double flop = ((double)m)*n*(2.*k + 2.)*iter;
double gflop = flop/pow(10., 9);
end = clock();
double seconds = sec(end-start);
printf("Matrix Multiplication %dx%d * %dx%d, TA=%d, TB=%d: %lf s, %lf GFLOPS\n",m,k,k,n, TA, TB, seconds, gflop/seconds);
cuda_free(a_cl);
cuda_free(b_cl);
cuda_free(c_cl);
free(a);
free(b);
free(c);
}
开发者ID:hyperchris,项目名称:Yolo,代码行数:33,代码来源:gemm.c
示例2: make_shortcut_layer
layer make_shortcut_layer(int batch, int index, int w, int h, int c, int w2, int h2, int c2)
{
fprintf(stderr,"Shortcut Layer: %d\n", index);
layer l = {0};
l.type = SHORTCUT;
l.batch = batch;
l.w = w2;
l.h = h2;
l.c = c2;
l.out_w = w;
l.out_h = h;
l.out_c = c;
l.outputs = w*h*c;
l.inputs = l.outputs;
l.index = index;
l.delta = calloc(l.outputs*batch, sizeof(float));
l.output = calloc(l.outputs*batch, sizeof(float));;
l.forward = forward_shortcut_layer;
l.backward = backward_shortcut_layer;
#ifdef GPU
l.forward_gpu = forward_shortcut_layer_gpu;
l.backward_gpu = backward_shortcut_layer_gpu;
l.delta_gpu = cuda_make_array(l.delta, l.outputs*batch);
l.output_gpu = cuda_make_array(l.output, l.outputs*batch);
#endif
return l;
}
开发者ID:NomokoAG,项目名称:darknet,代码行数:31,代码来源:shortcut_layer.c
示例3: make_maxpool_layer
maxpool_layer make_maxpool_layer(int batch, int h, int w, int c, int size, int stride, int padding)
{
maxpool_layer l = {};
l.type = MAXPOOL;
l.batch = batch;
l.h = h;
l.w = w;
l.c = c;
l.pad = padding;
l.out_w = (w + 2*padding)/stride;
l.out_h = (h + 2*padding)/stride;
l.out_c = c;
l.outputs = l.out_h * l.out_w * l.out_c;
l.inputs = h*w*c;
l.size = size;
l.stride = stride;
int output_size = l.out_h * l.out_w * l.out_c * batch;
l.indexes = (int*)calloc(output_size, sizeof(int));
l.output = (float*)calloc(output_size, sizeof(float));
l.delta = (float*)calloc(output_size, sizeof(float));
l.forward = forward_maxpool_layer;
l.backward = backward_maxpool_layer;
#ifdef GPU
l.forward_gpu = forward_maxpool_layer_gpu;
l.backward_gpu = backward_maxpool_layer_gpu;
l.indexes_gpu = cuda_make_int_array(output_size);
l.output_gpu = cuda_make_array(l.output, output_size);
l.delta_gpu = cuda_make_array(l.delta, output_size);
#endif
fprintf(stderr, "max %d x %d / %d %4d x%4d x%4d -> %4d x%4d x%4d\n", size, size, stride, w, h, c, l.out_w, l.out_h, l.out_c);
return l;
}
开发者ID:vaiv,项目名称:OpenANPR,代码行数:33,代码来源:maxpool_layer.c
示例4: make_compact_layer
layer make_compact_layer(int batch, int splits, int method, int w, int h, int c)
{
fprintf(stderr,"Compact Layer: Split and merge channels in %d groups. %d %d %d\n", splits,w ,h ,c);
layer l = {0};
l.type = COMPACT;
l.batch = batch;
l.w = w;
l.h = h;
l.c = c;
l.out_w = w;
l.out_h = h;
if (method<10)
{
l.out_c = c/splits;
} else
{
l.out_c = c;
}
l.outputs = l.out_w * l.out_h * l.out_c;
l.inputs = w*h*c;
l.index = splits;
l.method = method;
l.delta = calloc(l.outputs*batch, sizeof(float));
l.output = calloc(l.outputs*batch, sizeof(float));;
l.indexes = calloc(l.outputs*batch, sizeof(int));
#ifdef GPU
l.delta_gpu = cuda_make_array(l.delta, l.outputs*batch);
l.output_gpu = cuda_make_array(l.output, l.outputs*batch);
l.indexes_gpu = cuda_make_int_array(l.outputs*batch);
#endif
return l;
}
开发者ID:JacoCronje,项目名称:darknet,代码行数:35,代码来源:compact_layer.c
示例5: make_cost_layer
cost_layer make_cost_layer(int batch, int inputs, COST_TYPE cost_type, float scale)
{
fprintf(stderr, "cost %4d\n", inputs);
cost_layer l = {0};
l.type = COST;
l.scale = scale;
l.batch = batch;
l.inputs = inputs;
l.outputs = inputs;
l.cost_type = cost_type;
l.delta = calloc(inputs*batch, sizeof(float));
l.output = calloc(inputs*batch, sizeof(float));
l.cost = calloc(1, sizeof(float));
l.forward = forward_cost_layer;
l.backward = backward_cost_layer;
#ifdef GPU
l.forward_gpu = forward_cost_layer_gpu;
l.backward_gpu = backward_cost_layer_gpu;
l.delta_gpu = cuda_make_array(l.output, inputs*batch);
l.output_gpu = cuda_make_array(l.delta, inputs*batch);
#endif
return l;
}
开发者ID:kunle12,项目名称:darknet,代码行数:26,代码来源:cost_layer.c
示例6: make_crop_layer
crop_layer make_crop_layer(int batch, int h, int w, int c, int crop_height, int crop_width, int flip, float angle, float saturation, float exposure)
{
fprintf(stderr, "Crop Layer: %d x %d -> %d x %d x %d image\n", h,w,crop_height,crop_width,c);
crop_layer l = {0};
l.type = CROP;
l.batch = batch;
l.h = h;
l.w = w;
l.c = c;
l.flip = flip;
l.angle = angle;
l.saturation = saturation;
l.exposure = exposure;
l.crop_width = crop_width;
l.crop_height = crop_height;
l.out_w = crop_width;
l.out_h = crop_height;
l.out_c = c;
l.inputs = l.w * l.h * l.c;
l.outputs = l.out_w * l.out_h * l.out_c;
l.output = calloc(crop_width*crop_height * c*batch, sizeof(float));
#ifdef GPU
l.output_gpu = cuda_make_array(l.output, crop_width*crop_height*c*batch);
l.rand_gpu = cuda_make_array(0, l.batch*8);
#endif
return l;
}
开发者ID:Nerei,项目名称:darknet,代码行数:27,代码来源:crop_layer.c
示例7: make_route_layer
route_layer make_route_layer(int batch, int n, int *input_layers, int *input_sizes)
{
fprintf(stderr,"Route Layer:");
route_layer l = {0};
l.type = ROUTE;
l.batch = batch;
l.n = n;
l.input_layers = input_layers;
l.input_sizes = input_sizes;
int i;
int outputs = 0;
for(i = 0; i < n; ++i){
fprintf(stderr," %d", input_layers[i]);
outputs += input_sizes[i];
}
fprintf(stderr, "\n");
l.outputs = outputs;
l.inputs = outputs;
l.delta = calloc(outputs*batch, sizeof(float));
l.output = calloc(outputs*batch, sizeof(float));;
#ifdef GPU
l.delta_gpu = cuda_make_array(0, outputs*batch);
l.output_gpu = cuda_make_array(0, outputs*batch);
#endif
return l;
}
开发者ID:Nerei,项目名称:darknet,代码行数:26,代码来源:route_layer.c
示例8: make_crop_layer
crop_layer make_crop_layer(int batch, int h, int w, int c, int crop_height,
int crop_width, int flip, real_t angle, real_t saturation,
real_t exposure) {
fprintf(stderr, "Crop Layer: %d x %d -> %d x %d x %d image\n", h, w,
crop_height, crop_width, c);
crop_layer l = { 0 };
l.type = CROP;
l.batch = batch;
l.h = h;
l.w = w;
l.c = c;
l.scale = (real_t) crop_height / h;
l.flip = flip;
l.angle = angle;
l.saturation = saturation;
l.exposure = exposure;
l.out_w = crop_width;
l.out_h = crop_height;
l.out_c = c;
l.inputs = l.w * l.h * l.c;
l.outputs = l.out_w * l.out_h * l.out_c;
l.output = calloc(l.outputs * batch, sizeof(real_t));
l.forward = forward_crop_layer;
l.backward = backward_crop_layer;
#ifdef GPU
l.forward_gpu = forward_crop_layer_gpu;
l.backward_gpu = backward_crop_layer_gpu;
l.output_gpu = cuda_make_array(l.output, l.outputs*batch);
l.rand_gpu = cuda_make_array(0, l.batch*8);
#endif
return l;
}
开发者ID:dagoliveira,项目名称:radiation-benchmarks,代码行数:33,代码来源:crop_layer.c
示例9: resize_reorg_old_layer
void resize_reorg_old_layer(layer *l, int w, int h)
{
int stride = l->stride;
int c = l->c;
l->h = h;
l->w = w;
if(l->reverse){
l->out_w = w*stride;
l->out_h = h*stride;
l->out_c = c/(stride*stride);
}else{
l->out_w = w/stride;
l->out_h = h/stride;
l->out_c = c*(stride*stride);
}
l->outputs = l->out_h * l->out_w * l->out_c;
l->inputs = l->outputs;
int output_size = l->outputs * l->batch;
l->output = realloc(l->output, output_size * sizeof(float));
l->delta = realloc(l->delta, output_size * sizeof(float));
#ifdef GPU
cuda_free(l->output_gpu);
cuda_free(l->delta_gpu);
l->output_gpu = cuda_make_array(l->output, output_size);
l->delta_gpu = cuda_make_array(l->delta, output_size);
#endif
}
开发者ID:daltskin,项目名称:darknet,代码行数:32,代码来源:reorg_old_layer.c
示例10: make_detection_layer
detection_layer make_detection_layer(int batch, int inputs, int n, int side, int classes, int coords, int rescore, const bool b_debug)
{
detection_layer l = {0};
l.type = DETECTION;
l.n = n;
l.batch = batch;
l.inputs = inputs;
l.classes = classes;
l.coords = coords;
l.rescore = rescore;
l.b_debug = b_debug;
l.side = side;
assert(side*side*((1 + l.coords)*l.n + l.classes) == inputs);
l.cost = calloc(1, sizeof(float));
l.outputs = l.inputs;
l.truths = l.side*l.side*(1+l.coords+l.classes);
l.output = calloc(batch*l.outputs, sizeof(float));
l.delta = calloc(batch*l.outputs, sizeof(float));
#ifdef GPU
l.output_gpu = cuda_make_array(l.output, batch*l.outputs);
l.delta_gpu = cuda_make_array(l.delta, batch*l.outputs);
#endif
fprintf(stderr, "Detection Layer\n");
srand(0);
return l;
}
开发者ID:cvjena,项目名称:darknet,代码行数:30,代码来源:detection_layer.c
示例11: resize_convolutional_layer
void resize_convolutional_layer(convolutional_layer *l, int w, int h)
{
l->w = w;
l->h = h;
int out_w = convolutional_out_width(*l);
int out_h = convolutional_out_height(*l);
l->out_w = out_w;
l->out_h = out_h;
l->outputs = l->out_h * l->out_w * l->out_c;
l->inputs = l->w * l->h * l->c;
l->col_image = realloc(l->col_image,
out_h*out_w*l->size*l->size*l->c*sizeof(float));
l->output = realloc(l->output,
l->batch*out_h * out_w * l->n*sizeof(float));
l->delta = realloc(l->delta,
l->batch*out_h * out_w * l->n*sizeof(float));
#ifdef GPU
cuda_free(l->col_image_gpu);
cuda_free(l->delta_gpu);
cuda_free(l->output_gpu);
l->col_image_gpu = cuda_make_array(l->col_image, out_h*out_w*l->size*l->size*l->c);
l->delta_gpu = cuda_make_array(l->delta, l->batch*out_h*out_w*l->n);
l->output_gpu = cuda_make_array(l->output, l->batch*out_h*out_w*l->n);
#endif
}
开发者ID:qianglan,项目名称:DirectConvOnTegra,代码行数:30,代码来源:convolutional_layer.c
示例12: make_avgpool_layer
avgpool_layer make_avgpool_layer(int batch, int w, int h, int c) {
fprintf(stderr, "avg %4d x%4d x%4d -> %4d\n", w, h,
c, c);
avgpool_layer l = { 0 };
l.type = AVGPOOL;
l.batch = batch;
l.h = h;
l.w = w;
l.c = c;
l.out_w = 1;
l.out_h = 1;
l.out_c = c;
l.outputs = l.out_c;
l.inputs = h * w * c;
int output_size = l.outputs * batch;
l.output = calloc(output_size, sizeof(real_t));
l.delta = calloc(output_size, sizeof(real_t));
l.forward = forward_avgpool_layer;
l.backward = backward_avgpool_layer;
#ifdef GPU
l.forward_gpu = forward_avgpool_layer_gpu;
l.backward_gpu = backward_avgpool_layer_gpu;
l.output_gpu = cuda_make_array(l.output, output_size);
l.delta_gpu = cuda_make_array(l.delta, output_size);
#endif
return l;
}
开发者ID:dagoliveira,项目名称:radiation-benchmarks,代码行数:27,代码来源:avgpool_layer.c
示例13: make_detection_layer
detection_layer make_detection_layer(int batch, int inputs, int classes, int coords, int joint, int rescore, int background, int objectness)
{
detection_layer l = {0};
l.type = DETECTION;
l.batch = batch;
l.inputs = inputs;
l.classes = classes;
l.coords = coords;
l.rescore = rescore;
l.objectness = objectness;
l.background = background;
l.joint = joint;
l.cost = calloc(1, sizeof(float));
l.does_cost=1;
int outputs = get_detection_layer_output_size(l);
l.outputs = outputs;
l.output = calloc(batch*outputs, sizeof(float));
l.delta = calloc(batch*outputs, sizeof(float));
#ifdef GPU
l.output_gpu = cuda_make_array(0, batch*outputs);
l.delta_gpu = cuda_make_array(0, batch*outputs);
#endif
fprintf(stderr, "Detection Layer\n");
srand(0);
return l;
}
开发者ID:volkov68,项目名称:darknet,代码行数:29,代码来源:detection_layer.c
示例14: make_region_layer
region_layer make_region_layer(int batch, int inputs, int n, int side, int classes, int coords, int rescore)
{
region_layer l = {0};
l.type = REGION;
l.n = n;
l.batch = batch;
l.inputs = inputs;
l.classes = classes;
l.coords = coords;
l.rescore = rescore;
l.side = side;
assert(side*side*l.coords*l.n == inputs);
l.cost = calloc(1, sizeof(float));
int outputs = l.n*5*side*side;
l.outputs = outputs;
l.output = calloc(batch*outputs, sizeof(float));
l.delta = calloc(batch*inputs, sizeof(float));
#ifdef GPU
l.output_gpu = cuda_make_array(l.output, batch*outputs);
l.delta_gpu = cuda_make_array(l.delta, batch*inputs);
#endif
fprintf(stderr, "Region Layer\n");
srand(0);
return l;
}
开发者ID:LongjunCode,项目名称:yolo-windows,代码行数:28,代码来源:region_layer.c
示例15: resize_maxpool_layer
void resize_maxpool_layer(maxpool_layer *l, int w, int h)
{
int stride = l->stride;
l->h = h;
l->w = w;
l->inputs = h*w*l->c;
l->out_w = (w-1)/stride + 1;
l->out_h = (h-1)/stride + 1;
l->outputs = l->out_w * l->out_h * l->c;
int output_size = l->outputs * l->batch;
l->indexes = realloc(l->indexes, output_size * sizeof(int));
l->output = realloc(l->output, output_size * sizeof(float));
l->delta = realloc(l->delta, output_size * sizeof(float));
#ifdef GPU
cuda_free((float *)l->indexes_gpu);
cuda_free(l->output_gpu);
cuda_free(l->delta_gpu);
l->indexes_gpu = cuda_make_int_array(output_size);
l->output_gpu = cuda_make_array(l->output, output_size);
l->delta_gpu = cuda_make_array(l->delta, output_size);
#endif
}
开发者ID:isuker,项目名称:darknet,代码行数:25,代码来源:maxpool_layer.c
示例16: make_maxpool_layer_show
maxpool_layer make_maxpool_layer_show(int batch, int h, int w, int c, int size, int stride, int show)
{
//fprintf(stderr, "Maxpool Layer: %d x %d x %d image, %d size, %d stride\n", h,w,c,size,stride);
maxpool_layer l = { 0 };
l.type = MAXPOOL;
l.batch = batch;
l.h = h;
l.w = w;
l.c = c;
l.out_w = (w - 1) / stride + 1;
l.out_h = (h - 1) / stride + 1;
l.out_c = c;
l.outputs = l.out_h * l.out_w * l.out_c;
l.inputs = h*w*c;
l.size = size;
l.stride = stride;
int output_size = l.out_h * l.out_w * l.out_c * batch;
l.indexes = calloc(output_size, sizeof(int));
l.output = calloc(output_size, sizeof(float));
l.delta = calloc(output_size, sizeof(float));
#ifdef GPU
l.indexes_gpu = cuda_make_int_array(output_size);
l.output_gpu = cuda_make_array(l.output, output_size);
l.delta_gpu = cuda_make_array(l.delta, output_size);
#endif
if (show){
fprintf(stderr, "Maxpool Layer: %d x %d x %d image, %d size, %d stride -> %d x %d x %d image\n", h, w, c, size, stride, l.out_h, l.out_w, l.out_c);
}
return l;
}
开发者ID:isuker,项目名称:darknet,代码行数:30,代码来源:maxpool_layer.c
示例17: resize_cost_layer
void resize_cost_layer(cost_layer *l, int inputs)
{
l->inputs = inputs;
l->outputs = inputs;
l->delta = realloc(l->delta, inputs*l->batch*sizeof(float));
l->output = realloc(l->output, inputs*l->batch*sizeof(float));
#ifdef GPU
cuda_free(l->delta_gpu);
cuda_free(l->output_gpu);
l->delta_gpu = cuda_make_array(l->delta, inputs*l->batch);
l->output_gpu = cuda_make_array(l->output, inputs*l->batch);
#endif
}
开发者ID:kunle12,项目名称:darknet,代码行数:13,代码来源:cost_layer.c
示例18: test_resize
void test_resize(char *filename)
{
image im = load_image(filename, 0,0, 3);
float mag = mag_array(im.data, im.w*im.h*im.c);
printf("L2 Norm: %f\n", mag);
image gray = grayscale_image(im);
image sat2 = copy_image(im);
saturate_image(sat2, 2);
image sat5 = copy_image(im);
saturate_image(sat5, .5);
image exp2 = copy_image(im);
exposure_image(exp2, 2);
image exp5 = copy_image(im);
exposure_image(exp5, .5);
#ifdef GPU
image r = resize_image(im, im.w, im.h);
image black = make_image(im.w*2 + 3, im.h*2 + 3, 9);
image black2 = make_image(im.w, im.h, 3);
float *r_gpu = cuda_make_array(r.data, r.w*r.h*r.c);
float *black_gpu = cuda_make_array(black.data, black.w*black.h*black.c);
float *black2_gpu = cuda_make_array(black2.data, black2.w*black2.h*black2.c);
shortcut_gpu(3, r.w, r.h, 1, r_gpu, black.w, black.h, 3, black_gpu);
//flip_image(r);
//shortcut_gpu(3, r.w, r.h, 1, r.data, black.w, black.h, 3, black.data);
shortcut_gpu(3, black.w, black.h, 3, black_gpu, black2.w, black2.h, 1, black2_gpu);
cuda_pull_array(black_gpu, black.data, black.w*black.h*black.c);
cuda_pull_array(black2_gpu, black2.data, black2.w*black2.h*black2.c);
show_image_layers(black, "Black");
show_image(black2, "Recreate");
#endif
show_image(im, "Original");
show_image(gray, "Gray");
show_image(sat2, "Saturation-2");
show_image(sat5, "Saturation-.5");
show_image(exp2, "Exposure-2");
show_image(exp5, "Exposure-.5");
#ifdef OPENCV
cvWaitKey(0);
#endif
}
开发者ID:jjmata,项目名称:cvjena-darknet,代码行数:48,代码来源:image.c
示例19: gemm_gpu
void gemm_gpu(int TA, int TB, int M, int N, int K, float ALPHA,
float *A, int lda,
float *B, int ldb,
float BETA,
float *C, int ldc)
{
float *A_gpu = cuda_make_array(A, (TA ? lda*K:lda*M));
float *B_gpu = cuda_make_array(B, (TB ? ldb*N : ldb*K));
float *C_gpu = cuda_make_array(C, ldc*M);
gemm_ongpu(TA, TB, M, N, K, ALPHA, A_gpu, lda, B_gpu, ldb, BETA, C_gpu, ldc);
cuda_pull_array(C_gpu, C, ldc*M);
cuda_free(A_gpu);
cuda_free(B_gpu);
cuda_free(C_gpu);
}
开发者ID:hyperchris,项目名称:Yolo,代码行数:17,代码来源:gemm.c
示例20: resize_dropout_layer
void resize_dropout_layer(dropout_layer *l, int inputs)
{
l->rand = realloc(l->rand, l->inputs*l->batch*sizeof(float));
#ifdef GPU
cuda_free(l->rand_gpu);
l->rand_gpu = cuda_make_array(l->rand, inputs*l->batch);
#endif
}
开发者ID:Benjamin-Vencill,项目名称:Darknet-Yolo,代码行数:9,代码来源:dropout_layer.c
注:本文中的cuda_make_array函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论