source: src/ai/tensor.h @ e181d64

feature/cnnfeature/crepe
Last change on this file since e181d64 was 1fe822d, checked in by Paul Brossier <piem@piem.org>, 3 years ago

[ai] add first tensor draft

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2  Copyright (C) 2018 Paul Brossier <piem@aubio.org>
3
4  This file is part of aubio.
5
6  aubio is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10
11  aubio is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15
16  You should have received a copy of the GNU General Public License
17  along with aubio.  If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#ifndef AUBIO_TENSOR_H
22#define AUBIO_TENSOR_H
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28typedef struct {
29  uint_t n_dims;
30  uint_t dims[8];
31  smpl_t **data;
32  uint_t n_items;
33  uint_t items_per_row;
34} aubio_tensor_t;
35
36aubio_tensor_t *new_aubio_tensor(uint_t n_dims, uint_t *dims);
37
38void del_aubio_tensor(aubio_tensor_t *c);
39
40uint_t aubio_tensor_as_fvec(aubio_tensor_t *c, fvec_t *o);
41uint_t aubio_fvec_as_tensor(fvec_t *o, aubio_tensor_t *c);
42
43uint_t aubio_tensor_as_fmat(aubio_tensor_t *c, fmat_t *o);
44uint_t aubio_fmat_as_tensor(fmat_t *o, aubio_tensor_t *c);
45
46smpl_t aubio_tensor_max(aubio_tensor_t *t);
47
48#define AUBIO_ASSERT_EQUAL_SHAPE(t1, t2) { \
49    AUBIO_ASSERT(t1 && t2); \
50    AUBIO_ASSERT(t1->n_dims == t2->n_dims); \
51    uint_t nn; \
52    for (nn = 0; nn < t1->n_dims; nn++) \
53      AUBIO_ASSERT(t1->dims[nn] == t2->dims[nn]); \
54    }
55
56#ifdef __cplusplus
57}
58#endif
59
60#endif /* AUBIO_TENSOR_H */
Note: See TracBrowser for help on using the repository browser.