Skip to content

Instantly share code, notes, and snippets.

View sinkingsugar's full-sized avatar

Giovanni Petrantoni sinkingsugar

View GitHub Profile
@sinkingsugar
sinkingsugar / await.lua
Created October 15, 2015 06:22 — forked from ignacio/await.lua
await wrapper using coroutines (related to this gist: https://gist.github.com/creationix/5291866)
function await(continuation)
local coro = coroutine.running()
local result
local async
continuation(function(err, value)
if async == nil then
async = false
result = value
if err then error(err) end
return
@sinkingsugar
sinkingsugar / ATen-only.patch
Created October 2, 2018 11:28
Pytorch patch to build aten only
diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt
index 07f69d9f7..1eeb082c2 100644
--- a/caffe2/CMakeLists.txt
+++ b/caffe2/CMakeLists.txt
@@ -64,39 +64,41 @@ endif()
# ---[ Caffe2 build
# Note: the folders that are being commented out have not been properly
# addressed yet.
-add_subdirectory(proto)
-add_subdirectory(contrib)
@sinkingsugar
sinkingsugar / ad-manifesto.md
Created November 11, 2018 05:18 — forked from rxwei/ad-manifesto.md
First-Class Automatic Differentiation in Swift: A Manifesto

First-Class Automatic Differentiation in Swift: A Manifesto

This document is written for both the machine learning community and the Swift programming language design community, with a strong focus on language design.

Table of Contents

@sinkingsugar
sinkingsugar / xor.nim
Created November 15, 2018 07:03
iOS-xor
import strformat
import torch
import torch/[nn, optim]
let inputs = torch.tensor([
[0.0, 0.0],
[0.0, 1.0],
[1.0, 0.0],
[1.0, 1.0],
])
@sinkingsugar
sinkingsugar / gist:5a55308376423f2d8c69ea118f3186f6
Created December 11, 2018 19:06 — forked from chadhutchins/gist:1440602
Tarjan's strongly connected components algorithm in Javascript - followed pseudocode from http://en.wikipedia.org/wiki/Tarjan%E2%80%99s_strongly_connected_components_algorithm
window.onload = function() {
var v0 = new Vertex("0");
var v1 = new Vertex("1");
var v2 = new Vertex("2");
var v3 = new Vertex("3");
var v4 = new Vertex("4");
var v5 = new Vertex("5");
var v6 = new Vertex("6");
var v7 = new Vertex("7");
@sinkingsugar
sinkingsugar / obsplugin.nim
Last active May 3, 2020 14:18
Basic OBS Studio plugin, written in nim, supporting C++ (C fine too)
# nim cpp --app:lib .\obsplugin.nim
import nimline
cppincludes("obs-studio/libobs")
defineCppType(ObsData, "obs_data_t" , "obs-module.h")
defineCppType(ObsModule, "obs_module_t" , "obs-module.h")
defineCppType(ObsSource, "obs_source_t" , "obs-module.h")
defineCppType(ObsSourceInfo, "struct obs_source_info" , "obs-module.h")
@sinkingsugar
sinkingsugar / Dockerfile
Created February 20, 2019 08:51
Pytorch build
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
RUN apt-get update && apt-get install -y build-essential git cmake python3-pip libmpfr-dev libgmp-dev wget curl
RUN pip3 install pyyaml
RUN pip3 install typing
RUN cd && \
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
@sinkingsugar
sinkingsugar / halide.nim
Created July 2, 2019 05:52
Nim and Haldie
import nimline
import os
static:
let
halideDist = getenv("HALIDE_DIST")
assert halideDist != "" , "HALIDE_DIST environment variables not set!"
when defined windows:
@sinkingsugar
sinkingsugar / Swizzles.h
Created January 12, 2020 02:31 — forked from NocturnDragon/Swizzles.h
Swizzles in Clang, GCC, and Visual c++
#include <stdio.h>
// #define CLANG_EXTENSION
// Clang compile with -O3
#define VS_EXTENSION
// https://godbolt.org/z/sVWrF4
// Clang compile with -O3 -fms-compatibility
// VS2017 compile with /O3
@sinkingsugar
sinkingsugar / random.h
Created January 12, 2020 02:31 — forked from Leandros/random.h
C++ Pseudo Random Number Generators
/* Copyright (c) 2018 Arvid Gerstmann. */
/* This code is licensed under MIT license. */
#ifndef AG_RANDOM_H
#define AG_RANDOM_H
class splitmix
{
public:
using result_type = uint32_t;
static constexpr result_type (min)() { return 0; }