Skip to content

Instantly share code, notes, and snippets.

View llandsmeer's full-sized avatar
💡

Lennart Landsmeer llandsmeer

💡
View GitHub Profile
@llandsmeer
llandsmeer / mouse.py
Created June 9, 2025 11:20
Minimal JAX/MJX
import jax
import tqdm
from jax import numpy as jnp
from brax.io import mjcf
from brax.envs import PipelineEnv, State
from brax.io import html
from brax.generalized import pipeline
sys = mjcf.load('osc-mouse.xml')
@llandsmeer
llandsmeer / build.sh
Last active May 14, 2025 16:00
StreamHLS with JAX
set -ex
. ../env/bin/activate
python3 jax_test.py
iree-opt ./jax.stablehlo.mlir \
--iree-stablehlo-input-transformation-pipeline \
--convert-scf-to-cf \
> jax.linalg.mlir
@llandsmeer
llandsmeer / INSTALL.md
Created May 13, 2025 15:21
Stream HLS build and example

Build

git clone https://github.com/UCLA-VAST/Stream-HLS
cd Stream-HLS
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.11 python3.11-venv
python3.11 -m venv env
. env/bin/activate
@llandsmeer
llandsmeer / sdf_jax.py
Created May 7, 2025 11:27
Raymarch JAX
import jax
import jax.numpy as jnp
import matplotlib.pyplot as plt
def normalize(x):
return x / jnp.linalg.norm(x)
def vec(x, y, z):
return jnp.array([x, y, z], dtype='float32')
@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()):