Changeset c61cf97


Ignore:
Timestamp:
Dec 29, 2021, 5:51:45 PM (2 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/cnn, feature/crepe
Children:
d3d72b7
Parents:
7c6c8625
git-author:
Paul Brossier <piem@piem.org> (01/02/19 22:47:51)
git-committer:
Paul Brossier <piem@piem.org> (12/29/21 17:51:45)
Message:

[tensor] add get_shape_string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ai/tensor.c

    r7c6c8625 rc61cf97  
    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.