Skip to content

Instantly share code, notes, and snippets.

View llandsmeer's full-sized avatar
💡

Lennart Landsmeer llandsmeer

💡
View GitHub Profile
@llandsmeer
llandsmeer / iojax.py
Last active January 30, 2025 22:32
iojax
import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
import functools
import typing
def main():
params = IOCellParams(g_CaL=1.2)
state0 = IOCellState.make(params)
@jax.jit
@llandsmeer
llandsmeer / counter.sh
Created January 7, 2025 11:37
NeuroML-DB stats
for model in paper_experiments/nml_standalones/*/
do
echo -n "$(basename "${model}")"
for fun in log exp sqrt sin cos tan sinh cosh tanh abs ceil factorial random
do
if rg \
-q \
-i \
-g '*.nml' \
'\b'"${fun}"'\b' \
@llandsmeer
llandsmeer / hist.txt
Created October 14, 2023 18:31
Onnx model zoo operator use
'Conv' #############################################################################################################################################################
'MaxPool' #################################################################################################################################################
'Relu' #############################################################################################################################################
'Reshape' ##################################################################################################################################
'Softmax' ##########################################################################################################
'Concat' ##################################################################################################
'Add' ########################
@llandsmeer
llandsmeer / jax_to_mlir.py
Created October 8, 2023 13:09
JAX to MLIR using IREE example
import jax
import iree.compiler as compiler
def YOUR_FUNCTION(x):
return x + 1
input_sample = [
jax.numpy.array([0.,])
]
@llandsmeer
llandsmeer / README.md
Created October 8, 2023 09:38
Make jax.lax.cond work in jax2tf
@llandsmeer
llandsmeer / hello_world.py
Created September 25, 2023 14:25
Minimal norse learning example - showing one possible (definitely not the most efficient) way of learning the XOR problem in norse. Created while following the norse workshop during HBPSC23
import torch
import numpy as np
import norse.torch as norse
import matplotlib.pyplot as plt
import tqdm.notebook as tqdm
_ = torch.manual_seed(0)
class MyModule(torch.nn.Module):
def __init__(self, p=norse.LIFParameters()):
@llandsmeer
llandsmeer / neo.cpp
Created March 25, 2023 12:24
Hardware efficient automatic thresholding for NEO-based neural spike detection (C version)
/*
* C implementation of
* Yang, Yuning, and Andrew J. Mason. "Hardware efficient automatic
* thresholding for NEO-based neural spike detection." IEEE Transactions
* on Biomedical Engineering 64.4 (2016): 826-833.
*
* Writted by Lennart P. L. Landsmeer
* NeurocomputingLab, Erasmus MC
* */
#include <stdint.h>
@llandsmeer
llandsmeer / Cell_type_0_code.gen.c
Created December 16, 2022 11:30
EDEN output for L5PC
// Generated code block BEGIN
#define M_PI 3.14159265358979323846
#include <math.h>
typedef float * __restrict__ __attribute__((align_value (32))) Table_F32;
typedef long long * __restrict__ __attribute__((align_value (32))) Table_I64;
typedef union { int i32; float f32; } TypePun_I32F32; typedef char static_assert[ sizeof(int) == sizeof(float) ];
static float EncodeI32ToF32( int i ){ TypePun_I32F32 cast; cast.i32 = i; return cast.f32;}
static int EncodeF32ToI32( float f ){ TypePun_I32F32 cast; cast.f32 = f; return cast.i32;}
static float stepf( float x ){ if( x < 0 ) return 0; else return 1; }
@llandsmeer
llandsmeer / plot_benchmark_runtimes.py
Created December 2, 2022 11:44
iotf single benchmark plotter
import collections
import pandas as pd
import matplotlib.pyplot as plt
logfile = '<path to benchmark output.dat>'
tables = collections.defaultdict(list)
def tryfloat(x):
# the argument can be a float or
@llandsmeer
llandsmeer / arbor_as_ode_solver_lorenz.py
Last active November 30, 2022 14:33
Arbor as an arbitrary ODE solver
import arbor
import re
import subprocess
import tempfile
import pathlib
import matplotlib.pyplot as plt
nmodl = '''
NEURON {
SUFFIX node