Skip to content

Instantly share code, notes, and snippets.

cudaError_t Core(int peer_ = 0)
{
// --
// Alias variables
auto &data_slice = this -> enactor ->
problem -> data_slices[this -> gpu_num][0];
auto &enactor_slice = this -> enactor ->
enactor_slices[this -> gpu_num * this -> enactor -> num_gpus + peer_];
// raw CUDA implementation of
// ```python
// x = np.random.uniform((0, 1), (1000, 10))
// col_max = x.max(axis=0, keepdims=True)
// x = x - col_max
// x = exp(x)
// exp_col_sum = x.sum(axis=0, keepdims=True)
// x = log(x) - exp_col_sum
// ```
// CUDA CUB implementation of
// ```python
// x = np.random.uniform((0, 1), (1000, 10))
// x -= x.max(axis=0, keepdims=True) # subtract max element column-wise
// x = np.exp(x) # exponentiate all values
// x /= x.sum(axis=0, keepdims=True) # divide by column sums
// ```
__global__ void __transpose(double *d_xt, double *d_x, int num_rows, int num_cols) {
int offset = threadIdx.x + blockDim.x * blockIdx.x;
#!/usr/bin/env python
"""
snap_scan_statistics.py
"""
from __future__ import division, print_function
import sys
import snap
#!/bin/bash
# sdh-init.sh
# --
# Set current repo name (on github) and target repo name (on gitlab.sdh.cloud)
REPO_NAME="bhtsne"
REPO_URL="https://github.com/lvdmaaten/bhtsne"
TARGET_NAME="bhtsne"
#!/bin/bash
cleanup() {
echo "cleanup";
local pids=$(jobs -pr);
[ -n "$pids" ] && kill $pids;
};
trap "cleanup" INT QUIT TERM EXIT
# Put this at the beginning of a file to kill children
#!/usr/bin/env python
"""
pca_svd.py
"""
from sklearn.decomposition import TruncatedSVD, PCA
import numpy as np
X = np.random.normal(0, 1, (100, 10))
X -= X.mean(axis=0)
@bkj
bkj / aria.sh
Created June 20, 2018 17:19
aria.sh
#!/bin/bash
cat urls | shuf > tmp
cat tmp | paste - tmp | sed 's@\thttp://@\n\tout=dest/@' > aria-urls
cat aria-urls | aria2c -j8 --deferred-input --auto-file-renaming=false -i -
#!/usr/bin/env python
"""
quiet-logs.py
Supress annoying warning messages in `pyspark`
"""
def quiet_logs(sc):
logger = sc._jvm.org.apache.log4j
@bkj
bkj / rec-eval.py
Created June 15, 2018 20:06
rec-eval.py
#!/usr/bin/env python
"""
eval.py
"""
from __future__ import print_function, division
import sys
import argparse