-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip C port of core encoder, test_rade_enc.c builds (not tested), atte…
…mpt at fixing Issue #7, patch to export libopus selected nnet.h funcs
- Loading branch information
Showing
7 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
30a31,32 | ||
> #define RADE_EXPORT __attribute__((visibility("default"))) | ||
> | ||
88,93c90,95 | ||
< void compute_generic_dense(const LinearLayer *layer, float *output, const float *input, int activation, int arch); | ||
< void compute_generic_gru(const LinearLayer *input_weights, const LinearLayer *recurrent_weights, float *state, const float *in, int arch); | ||
< void compute_generic_conv1d(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, int activation, int arch); | ||
< void compute_generic_conv1d_dilation(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, int dilation, int activation, int arch); | ||
< void compute_glu(const LinearLayer *layer, float *output, const float *input, int arch); | ||
< void compute_gated_activation(const LinearLayer *layer, float *output, const float *input, int activation, int arch); | ||
--- | ||
> void RADE_EXPORT compute_generic_dense(const LinearLayer *layer, float *output, const float *input, int activation, int arch); | ||
> void RADE_EXPORT compute_generic_gru(const LinearLayer *input_weights, const LinearLayer *recurrent_weights, float *state, const float *in, int arch); | ||
> void RADE_EXPORT compute_generic_conv1d(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, int activation, int arch); | ||
> void RADE_EXPORT compute_generic_conv1d_dilation(const LinearLayer *layer, float *output, float *mem, const float *input, int input_size, int dilation, int activation, int arch); | ||
> void RADE_EXPORT compute_glu(const LinearLayer *layer, float *output, const float *input, int arch); | ||
> void RADE_EXPORT compute_gated_activation(const LinearLayer *layer, float *output, const float *input, int activation, int arch); | ||
108c110 | ||
< int linear_init(LinearLayer *layer, const WeightArray *arrays, | ||
--- | ||
> int RADE_EXPORT linear_init(LinearLayer *layer, const WeightArray *arrays, | ||
119c121 | ||
< int conv2d_init(Conv2dLayer *layer, const WeightArray *arrays, | ||
--- | ||
> int RADE_EXPORT conv2d_init(Conv2dLayer *layer, const WeightArray *arrays, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include <assert.h> | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include "config.h" | ||
#endif | ||
#include "rade_core.h" | ||
#include "rade_enc.h" | ||
#include "rade_enc_data.h" | ||
|
||
int opus_select_arch(void); | ||
|
||
int main(void) | ||
{ | ||
RADEEnc enc_model; | ||
RADEEncState enc_state; | ||
|
||
if (init_radeenc(&enc_model, rdovaeenc_arrays) != 0) { | ||
fprintf(stderr, "Error initialising encoder model\n"); | ||
exit(1); | ||
} | ||
rade_init_encoder(&enc_state); | ||
|
||
int n_features_in = enc_model.enc_dense1.nb_inputs; | ||
assert(enc_model.enc_zdense.nb_outputs == RADE_LATENT_DIM); | ||
fprintf(stderr, "n_features_in: %d n_z_out: %d", n_features_in, enc_model.enc_zdense.nb_outputs); | ||
float features[n_features_in]; | ||
float z[RADE_LATENT_DIM]; | ||
int arch = opus_select_arch(); | ||
|
||
while((size_t)n_features_in == fread(features, sizeof(float), n_features_in, stdin)) { | ||
rade_core_encoder(&enc_state, &enc_model, z, features, arch); | ||
fwrite(z, sizeof(float), RADE_LATENT_DIM, stdout); | ||
fflush(stdout); | ||
} | ||
|
||
return 0; | ||
} |