Skip to content

Instantly share code, notes, and snippets.

@chsasank
chsasank / .bashrc
Created February 12, 2024 10:55
Infinite bash history
# Eternal bash history.
# ---------------------
# Undocumented feature which sets the size to "unlimited".
# http://stackoverflow.com/questions/9457233/unlimited-bash-history
export HISTFILESIZE=
export HISTSIZE=
export HISTTIMEFORMAT="[%F %T] "
# Change the file location because certain bash sessions truncate .bash_history file upon close.
# http://superuser.com/questions/575479/bash-history-truncated-to-500-lines-on-each-login
export HISTFILE=~/.bash_eternal_history
@chsasank
chsasank / joint_matrix.cpp
Last active February 6, 2024 13:17
joint matrix gemm
//==============================================================
// Copyright © 2022 Intel Corporation
//
// SPDX-License-Identifier: MIT
// =============================================================
#include <iostream>
#include <sycl/sycl.hpp>
#include <chrono>
@chsasank
chsasank / .tmux.conf
Created January 12, 2024 00:33
Tmux conf
set -g mouse on
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
@chsasank
chsasank / benchmark.py
Last active February 13, 2024 13:47
Measure Bandwidth and FLOPs with PyTorch
import torch
import time
import numpy as np
from torch import mps, cuda
num_trails = 10
def flops_benchmark(device):
test_range = 2 ** np.arange(8, 13, 0.25)
@chsasank
chsasank / Benchmarks.md
Last active August 17, 2021 15:28
PyTorch Benchmarks on my systems

M1 Macbook Air

MacBook Air (M1, 2020)

Native (brew)

$ /opt/homebrew/bin/python3 -c 'import platform; print(platform.platform())'
macOS-11.4-arm64-arm-64bit
@chsasank
chsasank / install_node_m1.md
Last active June 11, 2021 11:30
Install NVM and node in MBA M1 without building
  1. Install rosetta2
  2. Install NVM using instructions here curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
  3. Add the stuff from the above command to zshrc to initialize nvm
  4. Go to x86 shell by arch -x86_64 zsh
  5. Install lts node using nvm in the intel shell: nvm install --lts
  6. Enjoy node in all shells (x86 or arm)
@chsasank
chsasank / ipynb_to_gallery.py
Last active February 21, 2024 14:29
Convert jupyter notebook to sphinx gallery notebook styled examples.
@chsasank
chsasank / elastic_transform.py
Last active October 14, 2023 01:55 — forked from fmder/elastic_transform.py
Elastic transformation of an image in Python
import numpy as np
from scipy.ndimage.interpolation import map_coordinates
from scipy.ndimage.filters import gaussian_filter
def elastic_transform(image, alpha, sigma, random_state=None):
"""Elastic deformation of images as described in [Simard2003]_.
.. [Simard2003] Simard, Steinkraus and Platt, "Best Practices for
Convolutional Neural Networks applied to Visual Document Analysis", in
@chsasank
chsasank / elastic.lua
Last active September 6, 2021 08:31
Elastic transformation/deformation of an image in Torch
require 'image'
function ElasticTransform(img, alpha, sigma)
--[[
Parameters
----------
img: Tensor of size KxHxW
Image on which elastic transformation have to be applied
alpha: number
Intensity of the transformation
@chsasank
chsasank / homography.py
Created April 20, 2016 06:34
Homogprahies useful for data augmentation. Quite fast.
import numpy as np
from skimage import io
from skimage import transform
import matplotlib.pyplot as plt
import math
import time
I = io.imread('random_img.jpg')
# Homography