are you me?    id passwd

status  

 sleepy

picture

 

 thinking

calender

연락이오면 - 일상

대구성모여성병원
대구 달서구 월배로 204
053 640 1000
http://www.smwomen.co.kr

written time : 2017-02-13 10:01:03.0

Cublas 할때 GRU 시작 부분 - 컴퓨터

/**
* vec *= mat
* 3 times
* ex) ei_vec *= weight.transpose();
*/

cublasSgemv(handle, CUBLAS_OP_T, //cublasHandle_t handle, cublasOperation_t trans,
SIZE, SIZE, //int m, int n,
&one, //const float *alpha,
cu_reset_in_mat, SIZE, //const float *A(m x n), int lda,
cu_reset, 1, //const float *x, int incx,
&one, //const float *beta,
cu_reset, 1); //float *y, int incy)
cublasSgemv(handle, CUBLAS_OP_T, //cublasHandle_t handle, cublasOperation_t trans,
SIZE, SIZE, //int m, int n,
&one, //const float *alpha,
cu_update_in_mat, SIZE, //const float *A(m x n), int lda,
cu_update, 1, //const float *x, int incx,
&one, //const float *beta,
cu_update, 1); //float *y, int incy)
cublasSgemv(handle, CUBLAS_OP_T, //cublasHandle_t handle, cublasOperation_t trans,
SIZE, SIZE, //int m, int n,
&one, //const float *alpha,
cu_quasihidden_in_mat, SIZE, //const float *A(m x n), int lda,
cu_quasihidden, 1, //const float *x, int incx,
&one, //const float *beta,
cu_quasihidden, 1); //float *y, int incy)

written time : 2017-02-09 22:02:14.0

Binary, int 변환 - 컴퓨터

//할 때마다 헷갈리는 index 들
//기억할 건 단순히 binary 는 좌측부터 0 이고 int는 우측부터 0이다.
//for 문 방향 어디든 상관없음;; 어짜피 겹치는 곳이 있을 수가 없음;
#include <stdio.h>

inline int my_string_length(const char* c) { int i = 0; for (i = 0; c[i] != '\0'; i++); return i; }

void itob(int a){
    for (int i = sizeof(a) * 8 - 1; i >=0 ; i--) {
        if (a >> i & 1) printf("1");
        else printf("0");
    }
    printf("
");
}

int btoi(const char* binary) {
    int a = 0;
    int len = my_string_length(binary);
    if (len == 0)return 0;
    if (len == 32 && binary[0] == '1') {
        for (int i = len - 1; i >= 0; i--) {
            if (binary[i] == '0')
                a = a + (1 << (31-i));
        }
        a = -1 * a - 1;
    }
    else {
        for (int i = len - 1; i >= 0; i--)
            if (binary[i] == '1')
                a = a + (1 << (len - 1 -i));
    }
    return a;
}

unsigned int btou(const char* binary) {
    unsigned int a = 0;
    int len = my_string_length(binary);
    if (len == 0)return 0;
    for (int i = len - 1; i >= 0; i--)
        if (binary[i] == '1')
            a = a + (1u << (len - 1-i));
    return a;
}

int main() {
    //int to binary
    itob(-2147483648);
    //binary to int
    const char* binary = "101";
    printf("%d
",btoi(binary));
    printf("%u
", btou(binary));
}

written time : 2017-02-06 22:53:14.0
...  50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 |  ...