forked from anibali/torch-hdf5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into fix-nullable-annota…
…tion * origin/master: Added return code checking to header parsing. Throw error if the operation failed. Pass includePath to gcc so it can find include files that might not be on system path. Issue google-deepmind#105. Fix undefined behavior by not casting -1 to unsigned int directly Remove test for threads as it requries threads to be installed and hdf5 compiled with --enable-threadsafety Add torch serialization so hdf5files can be read from multiple threads Prevent H5Dget_space from being called twice
- Loading branch information
Showing
6 changed files
with
104 additions
and
9 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
--[[ | ||
Test torch serialization. | ||
]] | ||
require 'hdf5' | ||
|
||
local totem = require 'totem' | ||
local tester = totem.Tester() | ||
local myTests = {} | ||
local testUtils = hdf5._testUtils | ||
|
||
-- Lua 5.2 compatibility | ||
local unpack = unpack or table.unpack | ||
|
||
function myTests:testSerialization() | ||
testUtils.withTmpDir(function(tmpDir) | ||
local h5filename = path.join(tmpDir, "foo.h5") | ||
local h5file = hdf5.open(h5filename) | ||
local data = torch.zeros(7, 5) | ||
h5file:write("data", data) | ||
local memfile = torch.MemoryFile() | ||
memfile:binary() | ||
memfile:writeObject(h5file) | ||
local storage = memfile:storage() | ||
memfile:close() | ||
|
||
local stofile = torch.MemoryFile(storage) | ||
stofile:binary() | ||
local memh5file = stofile:readObject() | ||
stofile:close() | ||
local memdata = memh5file:read("data"):all() | ||
|
||
memh5file:close() | ||
|
||
tester:assert(data:eq(memdata):sum() == 7*5) | ||
end) | ||
end | ||
|
||
return tester:add(myTests):run() |