Changeset 50d7afe


Ignore:
Timestamp:
Jan 2, 2019, 10:47:51 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/cnn_org, feature/crepe_org
Children:
40520ea
Parents:
124166d
Message:

[tensor] add get_shape_string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ai/tensor.c

    r124166d r50d7afe  
    9696  return max;
    9797}
     98
     99const char_t *aubio_tensor_get_shape_string(aubio_tensor_t *t) {
     100  uint_t i;
     101  if (!t) return NULL;
     102  size_t offset = 2;
     103  static char_t shape_str[STRN_LENGTH];
     104  char_t shape_str_previous[STRN_LENGTH] = "(";
     105  for (i = 0; i < t->ndim; i++) {
     106    int len = snprintf(shape_str, STRN_LENGTH, "%s%d%s",
     107        shape_str_previous, t->shape[i], (i == t->ndim - 1) ? "" : ", ");
     108    strncpy(shape_str_previous, shape_str, len);
     109  }
     110  snprintf(shape_str, strnlen(shape_str, STRN_LENGTH - offset - 1) + offset,
     111      "%s)", shape_str_previous);
     112}
Note: See TracChangeset for help on using the changeset viewer.