Changeset bf3ce2c


Ignore:
Timestamp:
Jan 29, 2019, 3:58:40 AM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/crepe_org
Children:
befee7a
Parents:
e18c30e
Message:

[file_hdf5] check if tensor exists before loading, double precision support, improve debug output

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/io/file_hdf5.c

    re18c30e rbf3ce2c  
    3030#include <hdf5_hl.h>
    3131
     32#if !HAVE_AUBIO_DOUBLE
     33#define aubio_H5LTread_dataset_smpl H5LTread_dataset_float
     34#else
     35#define aubio_H5LTread_dataset_smpl H5LTread_dataset_double
     36#endif
     37
    3238struct _aubio_file_hdf5_t {
    3339  const char_t *path;
     
    5258
    5359uint_t aubio_file_hdf5_load_dataset_into_tensor (aubio_file_hdf5_t *f,
    54     const char_t *key, aubio_tensor_t *tensor) {
     60    const char_t *key, aubio_tensor_t *tensor)
     61{
    5562  uint_t i;
    5663  AUBIO_ASSERT(f && key && tensor);
    57   // check file is open
    58   if (!f->fid)
     64  // check arguments
     65  if (!f->fid || !key || !tensor)
    5966    return AUBIO_FAIL;
    6067  // find key in file
     
    7683  AUBIO_ASSERT(ndim == (sint_t)tensor->ndim);
    7784  for (i = 0; i < (uint_t)ndim; i++) {
    78     //AUBIO_DBG("file_hdf5: found dim %d : %d %d (%s in %s)\n", i, dims[i],
    79     //    tensor->shape[i], key, f->path);
    8085    AUBIO_ASSERT(shape[i] == tensor->shape[i]);
    8186  }
     
    8893  // read data from hdf5 file into tensor buffer
    8994  smpl_t *buffer = tensor->buffer;
    90   herr_t err = H5LTread_dataset_float(f->fid, key, buffer);
     95  herr_t err = aubio_H5LTread_dataset_smpl(f->fid, key, buffer);
    9196
    9297  if (err < 0) {
    9398    return AUBIO_FAIL;
    9499  }
     100
     101  //AUBIO_DBG("file_hdf5: loaded : shape %s from key %s\n",
     102  //    aubio_tensor_get_shape_string(tensor), key);
    95103
    96104  H5Dclose(data_id);
Note: See TracChangeset for help on using the changeset viewer.