- Timestamp:
- Dec 29, 2021, 5:51:48 PM (3 years ago)
- Branches:
- feature/cnn, feature/crepe
- Children:
- 6d1566e
- Parents:
- 1f13e29
- git-author:
- Paul Brossier <piem@piem.org> (01/07/19 23:26:09)
- git-committer:
- Paul Brossier <piem@piem.org> (12/29/21 17:51:48)
- Location:
- src/ai
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ai/tensor.c
r1f13e29 ra33c395 204 204 AUBIO_MSG("\n"); 205 205 } 206 207 void aubio_tensor_matmul(aubio_tensor_t *a, aubio_tensor_t *b, 208 aubio_tensor_t *c) 209 { 210 AUBIO_ASSERT (a->shape[0] == c->shape[0]); 211 AUBIO_ASSERT (a->shape[1] == b->shape[0]); 212 AUBIO_ASSERT (b->shape[1] == c->shape[1]); 213 #if !defined(HAVE_BLAS) 214 uint_t i, j, k; 215 for (i = 0; i < c->shape[0]; i++) { 216 for (j = 0; j < c->shape[1]; j++) { 217 smpl_t sum = 0.; 218 for (k = 0; k < a->shape[1]; k++) { 219 sum += a->buffer[i * a->shape[1] + k] 220 * b->buffer[k * b->shape[1] + j]; 221 } 222 c->buffer[i * c->shape[1] + j] = sum; 223 } 224 } 225 #else 226 cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, a->shape[0], 227 b->shape[1], b->shape[0], 1.F, a->buffer, a->shape[1], b->buffer, 228 b->shape[1], 0.F, c->buffer, b->shape[1]); 229 #endif 230 } -
src/ai/tensor.h
r1f13e29 ra33c395 149 149 const char_t *aubio_tensor_get_shape_string(aubio_tensor_t *t); 150 150 151 void aubio_tensor_matmul(aubio_tensor_t *a, aubio_tensor_t *b, 152 aubio_tensor_t *c); 153 151 154 #ifdef __cplusplus 152 155 }
Note: See TracChangeset
for help on using the changeset viewer.