Skip to content

Commit

Permalink
fixed double array torch ascii
Browse files Browse the repository at this point in the history
  • Loading branch information
lessthanoptimal committed May 12, 2016
1 parent 57a4ddc commit 0dd9cd9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,7 @@ private TorchStorage parseStorage( String name ) throws IOException {

case "torch.DoubleStorage":{
TorchDoubleStorage t = new TorchDoubleStorage(size);
for (int i = 0; i < size; i++) {
t.data[i] = readDouble();
}
readArrayDouble(size,t.data);
out = t;
}break;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,14 @@ public int readU8() throws IOException {

@Override
public void readArrayDouble(int size, double[] storage) throws IOException {
String line = readInnerString();
String words[] = line.split(" ");
if( words.length != size )
throw new IOException("Unexpected number of words "+size+" found "+words.length);
for (int i = 0; i < size; i++) {
storage[i] = readDouble();
storage[i] = Double.parseDouble(words[i]);
}
input.readByte();
// int foo = input.readByte();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import deepboof.io.torch7.ConvertTorchToBoofForward;
import deepboof.tensors.Tensor_F32;
import deepboof.tensors.Tensor_F64;
import deepboof.tensors.Tensor_U8;

import java.util.HashMap;
Expand Down Expand Up @@ -50,4 +51,8 @@ public Tensor_U8 getTensorU8(String key ) {
public Tensor_F32 getTensorF32(String key ) {
return (Tensor_F32)ConvertTorchToBoofForward.convert(map.get(key));
}

public Tensor_F64 getTensorF64(String key ) {
return (Tensor_F64)ConvertTorchToBoofForward.convert(map.get(key));
}
}

0 comments on commit 0dd9cd9

Please sign in to comment.