Skip to content

Instantly share code, notes, and snippets.

View goldsborough's full-sized avatar
🔨
Fixing things

Peter Goldsborough goldsborough

🔨
Fixing things
View GitHub Profile
@goldsborough
goldsborough / any.cpp
Created May 10, 2018 17:58
Basic implementation of Any
class Any {
public:
template<typename T>
explicit Any(T&& value) : content_(new Holder<T>(std::forward<T>(value))) {}
Any(const Any& other) : content_(other.content_->clone()) {}
Any(Any&& other) { swap(other); }
Skipping /home/psag/pytorch/pytorch/torch/csrc/api/include/torch/optimizers.h. Compile command not found.
Skipping /home/psag/pytorch/pytorch/torch/csrc/api/include/torch/serialization.h. Compile command not found.
Skipping /home/psag/pytorch/pytorch/torch/csrc/api/include/torch/torch.h. Compile command not found.
Skipping /home/psag/pytorch/pytorch/torch/csrc/api/include/torch/detail.h. Compile command not found.
Skipping /home/psag/pytorch/pytorch/torch/csrc/api/include/torch/nn/module.h. Compile command not found.
Skipping /home/psag/pytorch/pytorch/torch/csrc/api/include/torch/nn/modules/conv.h. Compile command not found.
Skipping /home/psag/pytorch/pytorch/torch/csrc/api/include/torch/nn/modules/modules.h. Compile command not found.
Skipping /home/psag/pytorch/pytorch/torch/csrc/api/include/torch/nn/modules/functional.h. Compile command not found.
Skipping /home/psag/pytorch/pytorch/torch/csrc/api/include/torch/nn/modules/batchnorm.h. Compile command not found.
Skipping /home/psag/pytorch/pytorch/torch/c
AUTOGRAD_CONTAINER_CLASS(DefoggerModel) {
// Multi level LSTM model from starcraft_defogger.
public:
struct Parameters {
int map_embsize = 64;
int race_embsize = 8;
int dec_convsize = 3;
int dec_depth = 3;
int dec_embsize = 128;
int hid_dim = 256;
const int kRuns = 1000;
const int kWarmUp = 100000;
void benchmark() {
using clock = std::chrono::high_resolution_clock;
using duration = std::chrono::duration<double, std::micro>;
auto x = make_variable(CPU(kFloat).randn({10, 10}), true);
backward(x.sum());
@goldsborough
goldsborough / install-gcc.sh
Last active May 2, 2024 20:02
Instructions for installing GCC >= 4.9 for PyTorch Extensions
# Instructions for installing GCC 4.9 on various platforms.
# The commands show instructions for GCC 4.9, but any higher version will also work!
# Ubuntu (https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu/581497#581497)
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-4.9 g++-4.9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.9
diff --git a/torch/csrc/autograd/autograd.h b/torch/csrc/autograd/autograd.h
index f04b472e..7ff9a39f 100644
--- a/torch/csrc/autograd/autograd.h
+++ b/torch/csrc/autograd/autograd.h
@@ -2,12 +2,14 @@
#define THP_AUTOGRAD_H
PyObject * THPAutograd_initExtension(PyObject *_unused);
-bool THPAutograd_initFunctions(PyObject* module);
+void THPAutograd_initFunctions();
test_RNGState (test_torch.TestTorch) ... ok
test_RNGStateAliasing (test_torch.TestTorch) ... ok
test_Size (test_torch.TestTorch) ... ok
test_abs (test_torch.TestTorch) ... ok
test_accreal_type (test_torch.TestTorch) ... ok
test_acos (test_torch.TestTorch) ... ok
test_add (test_torch.TestTorch) ... ok
test_addbmm (test_torch.TestTorch) ... ok
test_addmm (test_torch.TestTorch) ... ok
test_addmv (test_torch.TestTorch) ... ok
@goldsborough
goldsborough / hex.rs
Created March 9, 2018 08:50
hex parser in rust
macro_rules! hex {
(0) => {48};
(9) => {57};
(A) => {65};
(F) => {70};
(a) => {97};
(z) => {102};
(0..9) => {48...57};
(A..F) => {65...70};
(a..f) => {97...102};
@goldsborough
goldsborough / rnn.py
Created February 24, 2018 09:12
RNN/LSTM/GRU in NumPy
import numpy as np
np.random.seed(42)
def sigmoid(z):
return 1 / (1 + np.exp(-z))
def d_sigmoid(z):
import argparse
import collections
import datetime
import math
import numpy as np
import os
import sys
import tensorflow as tf
import time
import warnings