1 /* Copyright (c) 2022 Amazon 2 Written by Jan Buethe */ 3 /* 4 Redistribution and use in source and binary forms, with or without 5 modification, are permitted provided that the following conditions 6 are met: 7 8 - Redistributions of source code must retain the above copyright 9 notice, this list of conditions and the following disclaimer. 10 11 - Redistributions in binary form must reproduce the above copyright 12 notice, this list of conditions and the following disclaimer in the 13 documentation and/or other materials provided with the distribution. 14 15 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER 19 OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 21 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 22 PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 23 LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 24 NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 */ 27 28 #ifndef DRED_RDOVAE_DEC_H 29 #define DRED_RDOVAE_DEC_H 30 31 #include "dred_rdovae.h" 32 #include "dred_rdovae_dec_data.h" 33 #include "dred_rdovae_stats_data.h" 34 35 struct RDOVAEDecStruct { 36 int initialized; 37 float gru1_state[DEC_GRU1_STATE_SIZE]; 38 float gru2_state[DEC_GRU2_STATE_SIZE]; 39 float gru3_state[DEC_GRU3_STATE_SIZE]; 40 float gru4_state[DEC_GRU4_STATE_SIZE]; 41 float gru5_state[DEC_GRU5_STATE_SIZE]; 42 float conv1_state[DEC_CONV1_STATE_SIZE]; 43 float conv2_state[DEC_CONV2_STATE_SIZE]; 44 float conv3_state[DEC_CONV3_STATE_SIZE]; 45 float conv4_state[DEC_CONV4_STATE_SIZE]; 46 float conv5_state[DEC_CONV5_STATE_SIZE]; 47 }; 48 49 void dred_rdovae_dec_init_states(RDOVAEDecState *h, const RDOVAEDec *model, const float * initial_state, int arch); 50 void dred_rdovae_decode_qframe(RDOVAEDecState *h, const RDOVAEDec *model, float *qframe, const float * z, int arch); 51 void DRED_rdovae_decode_all(const RDOVAEDec *model, float *features, const float *state, const float *latents, int nb_latents, int arch); 52 53 #endif 54