Skip to content

mihaly-sisak/luau_torch7

 
 

Repository files navigation

Luau_Torch7

Luau-compatible fork of Torch7.

Some features needed to be removed, for the following reasons:

  • Luau does not support files to protect user filesystem
  • Luau does not have FFI library
  • Lua number max representable integer is 2^53, this can hold 32 bit pointers but can not hold 64 bit ones

Removed Torch7 features:

  • Whole modules
    • File
    • DiskFile
    • MemoryFile
    • PipeFile
    • CmdLine
    • FFInterface
    • Tester
    • TestSuite
  • Partial features
    • torch.isatty(), no tty in Luau
    • torch.TYPEStorage(size, ptr), allocating storage from Lua with a pointer + size
    • torch.TYPEStorage(filename [, shared [, size [, sharedMem]]]), allocating storage from memory mapped file
    • torch.class(), modifies global state
    • torch.setheaptracking(), modifies global state
    • torch.setdefaulttensortype(), modifies global state
    • Any other function modifying the global state

Modified Torch7 features:

  • torch.pointer() returns hash of the pointer, only good for comparing equality

Added Torch7 features:

  • Coherent noise optional library

Example

Use the LUAU_TORCH7_EXAMPLE CMake option to compile example.cpp, and pass example.lua as first argument to the exe.

Output with LUAU_TORCH7_NOISE enabled:

 1  2
 3  4
[torch.FloatTensor of size 2x2]

 1  1
 1  1
[torch.FloatTensor of size 2x2]

 2  3
 4  5
[torch.FloatTensor of size 2x2]

 1  1  1
 1  1  1
 1  1  1
[torch.FloatTensor of size 3x3]

 2  2  2
 2  2  2
 2  2  2
[torch.FloatTensor of size 3x3]

simplex2D:
    generated and filtered 5244100 values
    took 0.12464120599906892 seconds
    min = -0.999998927116394, max = 0.999998927116394
    num of indexes = 281666

node2D:
    generated and filtered 5244100 values
    took 0.2929048950027209 seconds
    min = -1, max = 1
    num of indexes = 378937

simplex3D:
    generated and filtered 5268024 values
    took 0.14669220199721167 seconds
    min = -0.9968256950378418, max = 0.9970061779022217
    num of indexes = 375681

node3D:
    generated and filtered 5268024 values
    took 0.5029356320010265 seconds
    min = -1, max = 1
    num of indexes = 367336

tracetest3
tracetest2
tracetest1
Runtime error: [string "example.lua"]:37: example error
[string "example.lua"]:37 function tracetest1
[string "example.lua"]:42 function tracetest2
[string "example.lua"]:47 function tracetest3
[string "example.lua"]:50

Tests

Massaged Tester and TestsSuite to work with Luau.

Run build_n_test.sh to execute luau_test.lua and example.lua.

  • longSize.lua : Tests DiskFile and MemoryFile, does not work.
  • test_aliasMultinomial.lua : Passes.
  • test_half.lua : Passes.
  • test_Multinomial.lua : Uses the FFInterface LongTensor:data() and LongTensor:apply(), does not work.
  • test_qr.lua : Passes.
  • test_sharedmem.lua : Tests torch.TYPEStorage(filename [, shared [, size [, sharedMem]]]), does not work.
  • test_Tester.lua : Passes.
  • test_timer.lua : Passes.
  • test_writeObject.lua : Tests DiskFile and MemoryFile, does not work.
  • test.lua : Passes, except a few cases testing the File, torch.class() or global state setting features.
  • timeSort.lua : Test measuring torch.sort speed, does not work.

Documentation

Torch is the main package in Torch7 where data structures for multi-dimensional tensors and mathematical operations over these are defined.

  • Tensor Library
    • Tensor defines the all powerful tensor object that provides multi-dimensional numerical arrays with type templating.
    • Mathematical operations that are defined for the tensor object types.
    • Storage defines a simple storage interface that controls the underlying storage for any tensor object.
  • Useful Utilities
    • Timer provides functionality for measuring time.
    • Random defines a random number generator package with various distributions.
    • Utility functions are provided for easy handling of torch tensor types and class inheritance.
    • Noise optional coherent noise library

About

Luau fork of Torch7

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C 86.5%
  • Lua 11.8%
  • CMake 1.4%
  • Other 0.3%