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
// clang++ openmp.cpp -o openmp -fopenmp -O3 -std=c+11 | |
#include <cassert> | |
#include <stdlib.h> | |
#include <cmath> | |
#include <omp.h> | |
#include <iostream> | |
template<typename T> | |
struct Vector { |
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
#ifndef RTC_ARRAY_H | |
#define RTC_ARRAY_H | |
#include <vector> | |
#include <string> | |
#include <memory> | |
#include <sstream> | |
#include <iostream> | |
#define XINLINE __device__ __host__ |
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
/* | |
Comparing explicit BLAS parallelism using a thread pool | |
with vendor-implemented parallelism. | |
Program prints the runtime averaged over 100 runs of a matrix | |
multiply between two float matrices. | |
To run: | |
./gemm_parallel [<int> USE_EXPLICIT_PARALELLISM 0/1] [<int> LEADING_DIMENSION] |
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
def listify(x): | |
if isinstance(x, tuple): | |
return list(x) | |
return x | |
def awesome_scan(fn, elems, initializer=None, parallel_iterations=10, back_prop=True, | |
swap_memory=False, name=None): | |
"""scan on the list of tensors unpacked from `elems` on dimension 0. | |
This scan operator repeatedly applies the callable `fn` to a sequence | |
of elements from first to last. The elements are made of the tensors |
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
#include <vector> | |
#include <string> | |
#include <memory> | |
#include <sstream> | |
#include <iostream> | |
#define XINLINE __device__ __host__ | |
#define MAX_DIM 10 | |
#define INDENT_INCREMENT 2 |
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
/* | |
Reduction over all dimensions in mshadow. Requires changing the structs in | |
mshadow expression to store their input expressions by value instead of | |
reference. | |
Installation: | |
nvcc some_file.cu -std=c++11 -O3 -w -o some_file -I /usr/local/include | |
Usage: |
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
#ifndef DALI_MATH_MSHADOW_EIGEN_DOT_H | |
#define DALI_MATH_MSHADOW_EIGEN_DOT_H | |
#if MSHADOW_USE_EIGEN_DOT | |
#include <Eigen/Eigen> | |
#include <mshadow/tensor.h> | |
#include <cblas.h> | |
// Eigen Backend for Dot-Product in Mshadow | |
// Causes Adagrad to be slower. |
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
#!/bin/bash | |
# stop script on error and print it | |
set -e | |
# inform me of undefined variables | |
set -u | |
# handle cascading failures well | |
set -o pipefail | |
# install homebrew |
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 matplotlib.pyplot as plt | |
import theano, theano.tensor as T, numpy as np | |
import theano_lstm | |
import os | |
from collections import Counter | |
to_softmax = lambda x: T.nnet.softmax(x)[0] if x.ndim == 1 else T.nnet.softmax(x.T).T | |
class LatticeModel(object): | |
def __init__(self, | |
word_size, |
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 sqlite3 | |
import pickle | |
protocol = 0 | |
sqlite3.register_converter("pickle", pickle.loads) | |
sqlite3.register_adapter(list, pickle.dumps) | |
sqlite3.register_adapter(set, pickle.dumps) | |