Skip to content

Instantly share code, notes, and snippets.

View gglin001's full-sized avatar

Allen Guo gglin001

View GitHub Profile
from __future__ import annotations
import argparse
import logging
import re
# eg: `dense<"0xFFFF..."> : tensor<384xi32>`
# eg: `dense<[7031, 6266, 5765, ...]> : tensor<64xi32>`
RE_dense = re.compile(r"dense\<[\"\[][a-zA-Z0-9-,\ ]*[\"\]]\>")
@gglin001
gglin001 / cmake_split.py
Created January 31, 2024 07:58
cmake_split.py
import argparse
import os
parser = argparse.ArgumentParser()
parser.add_argument("raw", type=str, help="raw")
parser.add_argument("--inplace", "-i", action="store_false", help="inplace")
args = parser.parse_args()
# args = []
# cmd = "cmake --no-warn-unused-cli -DCMAKE_BUILD_TYPE:STRING=Debug ..."
@gglin001
gglin001 / gist:410066f34aa2b4e3bbf05a7837dfb560
Last active March 10, 2024 15:47
micromamba install linux64
# conda config --add channels conda-forge
# conda config --set channel_priority strict
curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba
mkdir -p $HOME/micromamba
mv ./bin $HOME/micromamba
$HOME/micromamba/bin/micromamba shell init --shell bash --root-prefix=$HOME/micromamba
micromamba config append channels conda-forge
micromamba create -n pyenv python=3.12
@gglin001
gglin001 / 0_qr_encode_file.py
Last active July 12, 2023 04:59
encode & decode onnx model to qr code
import argparse
import binascii
import tarfile
from io import BytesIO
import qrcode
parser = argparse.ArgumentParser("xx")
parser.add_argument("--input_file", type=str, required=True, help="input file")
@gglin001
gglin001 / AutoCCache.cmake
Created February 3, 2023 09:56 — forked from cgmb/AutoCCache.cmake
Script to enable ccache in CMake by default
option(AUTO_CCACHE "Use ccache to speed up rebuilds" ON)
find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM AND ${AUTO_CCACHE})
message(STATUS "Using ${CCACHE_PROGRAM} as compiler launcher")
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
# requires at least CMake 3.9 to be any use
set(CMAKE_CUDA_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
endif()
@gglin001
gglin001 / multiple_ssh_setting.md
Created October 31, 2022 06:14 — forked from jexchan/multiple_ssh_setting.md
Multiple SSH keys for different github accounts

Multiple SSH Keys settings for different github account

create different public key

create different ssh key according the article Mac Set-Up Git

$ ssh-keygen -t rsa -C "your_email@youremail.com"

Serialization: best practices

(In this document I pay attention mostly to data storage in scientific applications, not to web protocols.)

Traditional approaches

  • XML:
    • slow to parse
    • schemas (.xsd) are human-readable but hard to edit without special software
  • tooling for generating code for reading/writing is limited (mostly to Java)
@gglin001
gglin001 / README.md
Created September 27, 2022 03:05 — forked from michaelchughes/README.md
Fixes for GLIBC errors when installing tensorflow or pytorch on older Red Hat or CentOS cluster environments

Goal

Install working tensorflow or pytorch via standard conda environment workflow.

Basic Setup : Install pytorch in a fresh conda environment

The recommended conda-based install process works smoothly:

$ # Create a fresh environment
@gglin001
gglin001 / CMakeLists.txt
Last active August 4, 2022 13:39
ubuntu gcc from apt issue
cmake_minimum_required(VERSION 3.0)
project(project)
set(CMAKE_VERBOSE_MAKEFILE ON)
# a shared library
add_library(lib SHARED lib.cpp)
add_executable(main main.cpp)
@gglin001
gglin001 / symbols_cpp.md
Created July 31, 2022 15:48 — forked from ax3l/symbols_cpp.md
Symbol Visibility 101 by Boris Staletic @bstaletic

Visible Symbols in C++ Projects

Intro

This is a spontaneous and verbatime log of a conversion with Boris Staletic @bstaletic from March, 24th 2018 on the pybind11 gitter. Thank you so much, Boris!

To confuse future readers, we decided to write down the discussion and I added typos and unnecessarily long sentences.

The issue came up with linking a CMake (library) target into a pybind11 module (in openPMD-api).