Skip to content

Instantly share code, notes, and snippets.

View praeclarum's full-sized avatar

Frank A. Krueger praeclarum

View GitHub Profile
@praeclarum
praeclarum / CSharpPredictor.fs
Created July 19, 2018 17:48
Predicts then next C# tokens given a history of previous tokens using CoreML on iOS with F#
// Given previous tokens, predict the next token (and runners up)
let predictNextToken (previousKinds : SyntaxKind[]) : Prediction[] =
if ios11 then
let model : MLModel = model.Value // Load the cached model
let mutable predictions : Prediction[] = [| |]
// RNNs require external memory
let mutable lstm_1_h : MLMultiArray = null
let mutable lstm_1_c : MLMultiArray = null
@praeclarum
praeclarum / CSharpFormatter.fs
Created April 12, 2018 20:07
Formats C# code using roslyn syntax and semantics
let getRefInfo (x : SyntaxNode) (ident : SyntaxToken) (isO : bool) =
let si = semantics.GetSymbolInfo (x)
if si.Symbol <> null then
Some (ident, si.Symbol, true, isO)
else None
let getDefInfo (x : SyntaxNode) (ident : SyntaxToken) (isO : bool) =
let s = semantics.GetDeclaredSymbol (x)
if s <> null then
Some (ident, s, false, isO)

iMac Pro PlaidML Training Perf

GPU vgg16 (batch size 8)

$ python plaidbench.py --train --batch-size 8 vgg16
/Users/fak/plaidml/lib/python2.7/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Running 1024 examples with vgg16, batch size 8
Loading CIFAR data
@praeclarum
praeclarum / ListDiff.cs
Created June 15, 2017 17:36
Implements generic list diffing
using System;
using System.Collections.Generic;
namespace Praeclarum
{
/// <summary>
/// The type of <see cref="ListDiffAction{S,D}"/>.
/// </summary>
public enum ListDiffActionType
{
@praeclarum
praeclarum / ObservableQuery.cs
Last active May 7, 2019 19:46
This class is a new collection that is given a function to retrieve its own data. It uses ListDiff to minimize updates.
using System;
using System.Collections.Specialized;
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using System.Linq;
using System.Diagnostics;
using System.Threading.Tasks;
namespace Praeclarum
@praeclarum
praeclarum / Matrix.fs
Created May 26, 2016 05:06
Basic matrix math in F#
module Drone.Control.Matrix
open System
type Matrix =
| MZero of int * int
| MEye of int * float
| MArray of float[,]
| MTranspose of Matrix
| MDiagonal of float[]
@praeclarum
praeclarum / Ukf.fs
Created May 26, 2016 05:04
Unscented Kalman Filter (nonlinear version of the classic Kalman filter) in F#
module Drone.Control.Ukf
open System
open Drone.Control.Matrix
type IDiscreteModel =
abstract Process : Matrix -> Matrix
abstract Observe : Matrix -> Matrix
abstract InitialState : Matrix
@praeclarum
praeclarum / Vibrantly Dark.json
Created March 4, 2016 18:18
A new dark theme for Xamarin Studio
{
"name":"Vibrantly Dark",
"version":"1.0",
"description":"A dark theme with vibrant highlights. Inspired by One Dark Vibrant from Atom.",
"originator":"Frank A. Krueger (@praeclarum)",
"colors":[
{"name": "Background(Read Only)", "color":"#2A2A2A" },
{"name": "Search result background", "color":"#005F60" },
{"name": "Search result background (highlighted)", "color":"#007F80" },
{"name": "Fold Square", "color":"#63677F", "secondcolor":"#2A2A2A" },
@praeclarum
praeclarum / NoMefRoslyn.cs
Created January 1, 2016 18:26
My attempt to get Roslyn working on iOS
using System;
using UIKit;
using Microsoft.CodeAnalysis;
using System.Linq;
using Microsoft.CodeAnalysis.Host;
using System.Collections.Generic;
namespace RR
{
public class TestVC : UITableViewController
@praeclarum
praeclarum / Parsing.fs
Last active November 26, 2020 22:29
Parser combinator in F# tuned to perform "well enough" on iOS (Xamarin)
module Parsing
/// Remember where we are in the code.
/// This is a struct to keep memory pressure down.
/// (Significant perf improvements on iOS.)
type ParseState =
struct
val Code : string
val Index : int
new (code : string, index : int) =