From 1578ec70d751231218c869d345404ea68be9e5e8 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Mon, 18 Jan 2016 23:40:14 +0000
Subject: [PATCH] idk

---
 src/blas.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/src/blas.c b/src/blas.c
index 3785937..8769df3 100644
--- a/src/blas.c
+++ b/src/blas.c
@@ -1,5 +1,32 @@
 #include "blas.h"
 #include "math.h"
+#include <assert.h>
+
+void shortcut_cpu(int batch, int w1, int h1, int c1, float *add, int w2, int h2, int c2, float *out)
+{
+    int stride = w1/w2;
+    int sample = w2/w1;
+    assert(stride == h1/h2);
+    assert(sample == h2/h1);
+    if(stride < 1) stride = 1;
+    if(sample < 1) sample = 1;
+    int minw = (w1 < w2) ? w1 : w2;
+    int minh = (h1 < h2) ? h1 : h2;
+    int minc = (c1 < c2) ? c1 : c2;
+
+    int i,j,k,b;
+    for(b = 0; b < batch; ++b){
+        for(k = 0; k < minc; ++k){
+            for(j = 0; j < minh; ++j){
+                for(i = 0; i < minw; ++i){
+                    int out_index = i*sample + w2*(j*sample + h2*(k + c2*b));
+                    int add_index = i*stride + w1*(j*stride + h1*(k + c1*b));
+                    out[out_index] += add[add_index];
+                }
+            }
+        }
+    }
+}
 
 void mean_cpu(float *x, int batch, int filters, int spatial, float *mean)
 {
@@ -76,6 +103,12 @@
     for(i = 0; i < N; ++i) X[i*INCX] *= ALPHA;
 }
 
+void fill_cpu(int N, float ALPHA, float *X, int INCX)
+{
+    int i;
+    for(i = 0; i < N; ++i) X[i*INCX] = ALPHA;
+}
+
 void copy_cpu(int N, float *X, int INCX, float *Y, int INCY)
 {
     int i;

--
Gitblit v1.10.0