Skip to content

Instantly share code, notes, and snippets.

View apaszke's full-sized avatar

Adam Paszke apaszke

View GitHub Profile
// Compile with:
// g++ -c -fpic -o hack.o hack.cpp && g++ -shared -o libhack.so hack.o
// Then load with the Python
// import ctypes; ctypes.CDLL('libhack.so')
#include <stdio.h>
#include <dlfcn.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/mman.h>
json = require 'cjson'
function buildNcduLayer(name, module)
local result = nil
if torch.isTensor(module) then
if module:numel() ~= 0 then
local strt = {name..': [' .. torch.typename(module) .. ' of size '}
for i=1,module:nDimension() do
table.insert(strt, module:size(i))
if i ~= module:nDimension() then