This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s = window.getSelection(); | |
oRange = s.getRangeAt(0); //get the text range | |
oRect = oRange.getBoundingClientRect(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cpu_count () = | |
try match Sys.os_type with | |
| "Win32" -> int_of_string (Sys.getenv "NUMBER_OF_PROCESSORS") | |
| _ -> | |
let i = Unix.open_process_in "getconf _NPROCESSORS_ONLN" in | |
let close () = ignore (Unix.close_process_in i) in | |
try Scanf.fscanf i "%d" (fun n -> close (); n) with e -> close (); raise e | |
with | |
| Not_found | Sys_error _ | Failure _ | Scanf.Scan_failure _ | |
| End_of_file | Unix.Unix_error (_, _, _) -> 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
shape = (10,1000,10000) | |
function f00() | |
t0 = time() | |
x = [] | |
t1 = time() | |
@printf "empty:\t\t%.8f\n" (t1 -t0) | |
end | |
function f01() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import time | |
import math | |
import numpy as npy | |
m, n, o = 10, 1000, 10000 | |
shape = [m,n,o] | |
def f00 () : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Owl | |
open Bigarray | |
let m, n, o = 10, 1000, 10000 | |
let shape = [|m;n;o|] | |
let test_op s c op = | |
let ttime = ref 0. in | |
for i = 1 to c do |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CXXFLAGS0 = -shared -fPIC -ansi -pedantic -W -Wall | |
CXXFLAGS1 = -shared -fPIC -ansi -pedantic -Wno-extern-c-compat -Wno-c++11-long-long | |
CXXFLAGS2 = -c -ansi -Wno-extern-c-compat -Wno-c++11-long-long | |
all: | |
g++ ${CXXFLAGS2} -I. eigen_dsmat.cpp -o eigen_dsmat.o | |
g++ ${CXXFLAGS2} -I. eigen_spmat.cpp -o eigen_spmat.o | |
#gcc -c ffi_eigen_generated_stub.c -I. -I`ocamlfind query ctypes` -I`ocamlc -where` -o eigen_stub.o | |
ld -r eigen_*.o -o libeigen.o | |
ocamlfind ocamlc -c -package ctypes ffi_eigen_generated.ml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* | |
* Eigen - an OCaml interface to C++ Eigen library | |
* Copyright (c) 2016 Liang Wang <[email protected]> | |
*) | |
module type MatSig = sig | |
type elt | |
type mat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(* Test neural network on MNIST *) | |
#require "bitstring";; | |
#require "bitstring.syntax";; | |
open Bitstring | |
type t = { magic : int; items : int } | |
let dataset = "/Users/liang/owl_dataset/t10k-images-idx3-ubyte" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Owl_algodiff_ad | |
type layer = { mutable w : t; mutable b : t; a : t -> t } | |
type network = { layers : layer array } | |
let run_layer x l = Maths.((x $@ l.w) + l.b) |> l.a | |
let run_network x nn = Array.fold_left run_layer x nn.layers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Owl | |
open Algodiff.AD | |
type layer = { mutable w : t; mutable b : t; a : t -> t } | |
type network = { layers : layer array } | |
let run_layer x l = Maths.((x $@ l.w) + l.b) |> l.a | |
let run_network x nn = Array.fold_left run_layer x nn.layers | |
let l0 = { |
OlderNewer