Skip to content

Instantly share code, notes, and snippets.

View dsuess's full-sized avatar
🤔
...

Daniel Suess dsuess

🤔
...
View GitHub Profile
@dsuess
dsuess / onnx_tensorrt.py
Last active March 28, 2019 23:55
An example of a failed import of a (trivial) ONNX model in TensorRT
import torch
from torch import nn
import tensorrt as trt
TRT_LOGGER = trt.Logger(trt.Logger.INFO)
class Model(nn.Module):
def forward(self, x):
y = (2 * x)[0:1]
import numpy as np
import torch
from torch import nn
import onnx_tensorrt.backend as backend
import onnx
class Model(nn.Module):
def forward(self, x):
y = (2 * x)[0:1]
@dsuess
dsuess / create_function.py
Last active October 24, 2022 09:35 — forked from dhagrow/create_function.py
Dynamic function creation in Python
"""
Python is a dynamic language, and it is relatively easy to dynamically create
and modify things such as classes and objects. Functions, however, are quite
challenging to create dynamically.
One area where we might want to do this is in an RPC library, where a function
defined on a server needs to be available remotely on a client.
The naive solution is to simply pass arguments to a generic function that
accepts `*args` and `**kwargs`. A lot of information is lost with this approach,
however, in particular the number of arguments taken. Used in an RPC
implementation, this also delays any error feedback until after the arguments
@dsuess
dsuess / setup.sh
Last active February 2, 2021 02:46
Lifecycle configuration to setup vim keybindings in SageMaker
source /home/ec2-user/anaconda3/bin/activate /home/ec2-user/anaconda3/envs/JupyterSystemEnv
jupyter labextension install jupyterlab_vim
pip install jupyter_contrib_nbextensions
sudo -H -u ec2-user bash -c "source /home/ec2-user/anaconda3/bin/activate /home/ec2-user/anaconda3/envs/JupyterSystemEnv && jupyter-contrib nbextension install --user && jupyter-nbextension enable select_keymap/main"