Skip to content

Instantly share code, notes, and snippets.

View syed-ahmed's full-sized avatar

Syed Tousif Ahmed syed-ahmed

View GitHub Profile
@syed-ahmed
syed-ahmed / distributions.ipynb
Created November 13, 2018 19:45
Distributions plot after patch
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@syed-ahmed
syed-ahmed / plot-stats.ipynb
Created November 13, 2018 21:11
@jcjohnson multinomial benchmark
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@syed-ahmed
syed-ahmed / gen-changes.patch
Last active March 1, 2019 20:53
CPU Generator code gen changes
diff --git a/build/aten/src/ATen/CPUBoolType.h b/build/aten/src/ATen/CPUBoolType.h
index e6773964f..f01df65c6 100644
--- a/build/aten/src/ATen/CPUBoolType.h
+++ b/build/aten/src/ATen/CPUBoolType.h
@@ -4,7 +4,7 @@
#include <ATen/CPUTypeDefault.h>
#include <ATen/Context.h>
-#include <ATen/CheckGenerator.h>
+#include <ATen/Utils.h>
============================= test session starts ==============================
platform linux -- Python 3.6.8, pytest-3.8.0, py-1.8.0, pluggy-0.9.0 -- /opt/conda/bin/python
cachedir: .pytest_cache
benchmark: 3.2.2 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /workspace/generator-refactor/pytorch/pyro, inifile: setup.cfg
plugins: xdist-1.27.0, forked-1.0.2, benchmark-3.2.2, nbval-0.9.1
collecting ... collected 1809 items
tests/distributions/test_categorical.py::TestCategorical::test_log_prob_sum PASSED
tests/distributions/test_categorical.py::TestCategorical::test_mean_and_var PASSED
#pragma once
// define constants like M_PI and C keywords for MSVC
#ifdef _MSC_VER
#define _USE_MATH_DEFINES
#include <math.h>
#endif
#include <stdint.h>
#include <cmath>
import torch
torch.manual_seed(1234)
# Cache the currnet rng state and get some random data at this point
# of the rng state
current_rng = torch.get_rng_state()
random_data_1 = torch.FloatTensor(1000).uniform_()
print(random_data_1.mean())
# save the rng state
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import os, argparse, json, random, time
import torch
def int_list(s):
return [int(x) for x in s.split(',')]
parser = argparse.ArgumentParser()
parser.add_argument('--S', type=int_list,
import torch
size = 128*512
nrep =100
import time
for i in range(10):
a=torch.Tensor(size).cuda().uniform_()
torch.cuda.synchronize()
start = time.time()
#dry run to alloc
--- out2.txt	2019-05-08 17:32:48.351580423 -0700
+++ out1.txt	2019-05-08 17:32:04.695579960 -0700
@@ -37,10 +37,10 @@
 +}
 diff --git a/build/aten/src/ATen/CPUType.cpp b/build/aten/src/ATen/CPUType.cpp
 new file mode 100644
-index 000000000..d27637938
+index 000000000..3027b13a6
 --- /dev/null