Skip to content

Instantly share code, notes, and snippets.

"""
"""
from typing import Type, Tuple, Union
from functools import reduce
Scalar = Union[int, float]
ScalarType = Union[Type[int], Type[float]]
class Array:
import sys
import timeit
from functools import partial, reduce
from itertools import product
from typing import Optional, Union
import torch
from torch._inductor.compile_fx import compile_fx_inner, cudagraphify_impl, compile_fx
from torch._inductor.decomposition import decompositions
from torch.fx.experimental.proxy_tensor import make_fx
import math
import torch
import triton
import triton.language as tl
from typing import Optional, Tuple
def _has_triton():
if not torch.cuda.is_available():
import torch
import torch._dynamo as torchdynamo
torchdynamo.config.verbose = True
torchdynamo.config.suppress_errors = True
class TestCasePlaceholder:
def assertTrue(self, v):
assert v, "Expected True"
"""
Prior to adding the checks which error out when to_dense is called with hybrid (having dense dims) tensors
all of these examples triggered a segfault
The commented out lines trigger the error now, previously segfault
"""
import torch
dense = torch.randn(3, 4, dtype=torch.float32)
dense = dense * dense.relu().bool()
csr = dense.to_sparse_csr()
@amjames
amjames / g09_parsers.py
Created July 9, 2018 15:45
G09 fchk array parser
def _array_from_fchk(fchk_text, array_name):
# matches a line that looks like:
# {array_name} R N= {number of elements in array}
matcher = re.compile(r'\A(?P<title>{})\s+R\s+N=\s+(?P<nele>\d+)\Z'.format(array_name))
fchk_lines = fchk_text.split('\n')
start_line = 0
nline = 0
found_match = False
for i, line in enumerate(fchk_lines):
# see if the line matches the regex
@amjames
amjames / output.txt
Created April 19, 2018 02:05
Example of using std::vector(begin, begin+size) constructor.
Memory used after allocating lg_array: 800
Memory used after creating sm_vector: 840
sm_vector = [ 0, 1, 2, 3, 4,]
sm_vector (after modify) = [ 100, 101, 102, 103, 104,]
First 5 elements of the original lg_array = [ 0, 1, 2, 3, 4,]
size of allocation lg_array: 800
size of allocation sm_vector.data(): 40
@amjames
amjames / vt_locations_map.js
Created July 18, 2017 18:58
Google Maps javascript for MRPSS website
// I ran though this quick and expanded my useless comments with everything I could remember about this
// it was 2 years ago when I first wrote this.
// Some of it might be obvious to you, or just wrong, and I apologize but these ~200 lines are just about all of the js
// I have written in my life. Hope it helps!
google.maps.event.addDomListener(window, 'load', init);
var map;
var infowindow = null;
function init() {
//googlemaps api docs can explain what each option does
@amjames
amjames / Psi4SureIsNeat.ipynb
Created November 12, 2016 04:03
Psi4SureIsNeat.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.