Changeset 1666945


Ignore:
Timestamp:
Dec 29, 2021, 5:52:03 PM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/crepe
Children:
6f53da8
Parents:
636bc43
git-author:
Paul Brossier <piem@piem.org> (01/29/19 03:58:40)
git-committer:
Paul Brossier <piem@piem.org> (12/29/21 17:52:03)
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

    r636bc43 r1666945  
    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.