Skip to content

Instantly share code, notes, and snippets.

View culurciello's full-sized avatar

Eugenio Culurciello culurciello

View GitHub Profile
@culurciello
culurciello / gist:5189137
Last active November 8, 2016 14:29
test of torch numerical performance
#!/usr/bin/env torch
require 'nn'
require 'image'
require 'xlua'
require 'pl'
opt = lapp[[
-t,--threads (default 8) number of threads
-p,--type (default float) float or cuda
@culurciello
culurciello / mactest.c
Last active January 3, 2016 01:29
test of computer speed with dummy math/lin algebra code
/*
Test of C code speed
compile with: gcc -Ofast -fopenmp -mavx mactest.c
or gfortran -O3 -fopenmp mactest.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/time.h>
@culurciello
culurciello / gist:8410551
Last active January 3, 2016 04:39
apple accelerate matrix matrix multiply example
/*
Test of C code speed with Apple Accelerate Framework and openmp
https://developer.apple.com/library/mac/documentation/Accelerate/Reference/BLAS_Ref/Reference/reference.html#//apple_ref/c/func/cblas_sgemm
compile with:
gcc -Ofast -fopenmp -flax-vector-conversions -framework Accelerate acctest.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@culurciello
culurciello / testffi.lua
Last active August 29, 2015 13:57
torchFFI vs regular lua code: HUGE improvement
-- test of FFI vs regular lua code
-- EC march 21st 2014
torch.setdefaulttensortype('torch.FloatTensor')
require 'sys'
require 'image'
require 'torchffi'
local bit = require('bit')
local ffi = require('ffi')
-- E. Culurciello Oct 2014
-- video file loading in macos
-- a cheap ffmpeg hack / alternative:
require("image")
local lfs = require "lfs"
video = {}
function video:init(args)
--------------------------------------------------------------------------------
-- E. Culurciello, October 2014
-- socket test in node.js and Lua
--------------------------------------------------------------------------------
require 'image'
local async = require 'async'
-- tcp client:
async.tcp.connect({host='127.0.0.1', port=6969}, function(client)
// Example of sending to Lua code and receiving results:
// E. Culurciello, November 2014
// server and socket test:
// http://www.hacksparrow.com/tcp-socket-programming-in-node-js.html
var net = require('net');
var HOST = '127.0.0.1';
var PORT = 6969;
// Create a server instance, and chain the listen function to it
@culurciello
culurciello / precision-network.lua
Created March 5, 2015 15:47
precision test for Torch7 and new hardware
--[[ precision-test
Compare precision of hardware and software implementation
run with: qlua precision-network.lua
--]]
require 'nn'
require 'pl'
require 'image'
-- net cpu/gpu speed test
-- E. Culurciello, March 2015
require 'nn'
require('cunn')
torch.setdefaulttensortype('torch.FloatTensor')
net = torch.load('../../models/home-A1l/model.net')
net_gpu = torch.load('../../models/home-A1l/model.net')
net_gpu:cuda()
@culurciello
culurciello / gist:20c4acfc05e54dde1244
Last active August 29, 2015 14:21
pseudo-object segmentations on output of convnet
local mask = function (inputImage, mask, th)
local temp
mask = mask[1]
k = image.gaussian{size = 7, normalize = true}:float()
mask = image.convolve(mask, k, 'same'):repeatTensor(3,1,1)
temp = mask:gt(th):float():mul(.8):add(.2)
return inputImage:clone():cmul(temp)
end