stanford-ppl / spatial-lang

Spatial: "Specify Parameterized Accelerators Through Inordinately Abstract Language"
MIT License
100 stars 12 forks source link

API for reading binary data #111

Open shadjis opened 7 years ago

shadjis commented 7 years ago

It would be nice to have a function similar to numpy.fromfile, e.g.

ReadTensor(file_path, datatype, dims)

Where the file is in binary format, e.g. 4 byte float, 1 byte uint8, etc.

I can make a separate issue but it would also be nice to have a DecodeJPEG function which takes a file path e.g. something equivalent to the following Scala

  import javax.imageio.ImageIO
  val photo1 = ImageIO.read(new File("photo.jpg"))
  printf("Photo size is %d x %d\n, photo1.getWidth, photo1.getHeight)
dkoeplin commented 7 years ago

These seem like good additions to the existing file read support - working on them now.

Reading arbitrary data from binary file is a bit annoying, but I'll definitely have something for numeric types soon.

dkoeplin commented 7 years ago

Binary file reading is now added and confirmed working in Scala, but no support yet in C