Skip to content

Instantly share code, notes, and snippets.

View cloudhan's full-sized avatar

cloudhan

  • 05:01 (UTC +08:00)
View GitHub Profile
from __future__ import annotations
from contextlib import contextmanager
from typing import NamedTuple, Callable, Optional, Any
import numpy as np
Array = Any
class Node(NamedTuple):
vjp: Optional[Callable]
parents: List[Node]
@bgolus
bgolus / WorldNormalFromDepthTexture.shader
Last active June 7, 2024 02:13
Different methods for getting World Normal from Depth Texture, without any external script dependencies.
Shader "WorldNormalFromDepthTexture"
{
Properties {
[KeywordEnum(3 Tap, 4 Tap, Improved, Accurate)] _ReconstructionMethod ("Normal Reconstruction Method", Float) = 0
}
SubShader
{
Tags { "RenderType"="Transparent" "Queue"="Transparent" }
LOD 100
@nadavrot
nadavrot / Matrix.md
Last active June 23, 2024 10:25
Efficient matrix multiplication

High-Performance Matrix Multiplication

This is a short post that explains how to write a high-performance matrix multiplication program on modern processors. In this tutorial I will use a single core of the Skylake-client CPU with AVX2, but the principles in this post also apply to other processors with different instruction sets (such as AVX512).

Intro

Matrix multiplication is a mathematical operation that defines the product of

@marta-sd
marta-sd / tf_merge.py
Last active February 10, 2022 10:08
Merge two models in TensorFlow
import tensorflow as tf
# 1. Create and save two graphs
# c = a*b
g1 = tf.Graph()
with g1.as_default():
a = tf.placeholder(tf.float32, name='a')
b = tf.Variable(initial_value=tf.truncated_normal((1,)), name='b')
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active June 29, 2024 16:03
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

@cloudhan
cloudhan / profile.ps1
Last active May 1, 2023 16:15
PowerShell Profile Script.
# Set-ExecutionPolicy Bypass -Scope CurrentUser # to further speedup powershell startup
$PROFILE_DIR = Split-Path -Path $PROFILE.CurrentUserAllHosts -Parent
$OLD = $PROFILE
$PROFILE = Join-Path $PROFILE_DIR "profile.ps1"
$PROFILE | Add-Member -NotePropertyName AllUsersAllHosts -NotePropertyValue $OLD.AllUsersAllHosts
$PROFILE | Add-Member -NotePropertyName AllUsersCurrentHost -NotePropertyValue $OLD.AllUsersCurrentHost
$PROFILE | Add-Member -NotePropertyName CurrentUserAllHosts -NotePropertyValue $PROFILE.ToString()
$PROFILE | Add-Member -NotePropertyName CurrentUserCurrentHost -NotePropertyValue $PROFILE.ToString()
Clear-Variable OLD
@dherman
dherman / ssa-cps-anf.txt
Created November 20, 2012 03:10
links on SSA, CPS, and A-normal form
Original paper on A-normal form:
http://redlinernotes.com/docs/Classics/The%20Essence%20of%20Compiling%20with%20Continuations.pdf
A high-level intro to ANF:
http://matt.might.net/articles/a-normalization/
One of the earlier attempts to relate SSA and CPS: