From 9f013975bd3e05b801a5c855d99078eae361624e Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Sun, 19 Apr 2020 13:34:16 -0700 Subject: [PATCH 01/15] adding FastGRNN C reference implementation and test case for low rank model --- c_reference/Makefile | 22 +++++ c_reference/config.mk | 6 ++ c_reference/include/classifier.h | 16 ++++ c_reference/include/fastgrnn.h | 130 +++++++++++++++++++++++++++ c_reference/include/utils.h | 127 ++++++++++++++++++++++++++ c_reference/tests/test_fastgrnn_lr.c | 79 ++++++++++++++++ 6 files changed, 380 insertions(+) create mode 100644 c_reference/Makefile create mode 100644 c_reference/config.mk create mode 100644 c_reference/include/classifier.h create mode 100644 c_reference/include/fastgrnn.h create mode 100644 c_reference/include/utils.h create mode 100644 c_reference/tests/test_fastgrnn_lr.c diff --git a/c_reference/Makefile b/c_reference/Makefile new file mode 100644 index 000000000..1b602e0b4 --- /dev/null +++ b/c_reference/Makefile @@ -0,0 +1,22 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. + +include config.mk + +INCLUDE_DIR=include +TEST_DIR=tests + +IFLAGS = -I $(INCLUDE_DIR) + +all: test_fastgrnn_lr + +test_fastgrnn_lr: $(TEST_DIR)/test_fastgrnn_lr.c + $(CC) -o $(TEST_DIR)/$@ $(IFLAGS) $(CFLAGS) $^ -lm + +.PHONY: clean cleanest + +clean: + rm -f *.o *.gch + +cleanest: clean + rm *~ \ No newline at end of file diff --git a/c_reference/config.mk b/c_reference/config.mk new file mode 100644 index 000000000..bbfb1fd59 --- /dev/null +++ b/c_reference/config.mk @@ -0,0 +1,6 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. + +LDFLAGS= -lm -ldl +CC=gcc +CFLAGS= -g -fPIC -O3 -Wall \ No newline at end of file diff --git a/c_reference/include/classifier.h b/c_reference/include/classifier.h new file mode 100644 index 000000000..13f2a9f59 --- /dev/null +++ b/c_reference/include/classifier.h @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#ifndef __CLASSIFIER_H__ +#define __CLASSIFIER_H__ + +#include "utils.h" + +void FC(const float *const FCweights, const float *const FCbias, + const float *const input, const unsigned inputLen, + float* const classScores, const unsigned numClasses) { + matVec(FCweights, input, numClasses, inputLen, 0.0f, 1.0f, classScores); + v_add(1.0f, FCbias, 1.0f, classScores, numClasses, classScores); +} + +#endif \ No newline at end of file diff --git a/c_reference/include/fastgrnn.h b/c_reference/include/fastgrnn.h new file mode 100644 index 000000000..2763d4a1e --- /dev/null +++ b/c_reference/include/fastgrnn.h @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#ifndef __RNN_H__ +#define __RNN_H__ + +#include "utils.h" + +#define ERR_PRECOMP_NOT_INIT -1 +#define ERR_TEMPLRW_NOT_INIT -2 +#define ERR_TEMPLRU_NOT_INIT -3 +#define ERR_NORMFEATURES_NOT_INIT -4 +/** + * @brief Multi-step updates of a FastGRNN cell with low rank W, U(W=W1*W2; U=U1*U2) + * @param[in] W1 pointer to first low-rank component of W + * @param[in] W2 pointer to second low-rank component of W + * @param[in] wRank rank of W matrix + * @param[in] U1 pointer to first low-rank component of U + * @param[in] U2 pointer to second low-rank component of U + * @param[in] wRank rank of U matrix + * @param[in] Bg pointer to bias for sigmoid + * @param[in] Bh pointer to bias for tanh + * @param[in] zeta first weight parameter for update from input from next step + * @param[in] nu second weight parameter for update from input from next step + * @param[in] steps number of steps of FastGRNN cell + * @param[in,out] hiddenState pointer to initial hidden state and output hidden state + * @param[in] hiddenDims dimension of hidden state of the FastGRNN cell + * @param[in] input pointer to concatenated input vectors for all steps, size inputDims*steps + * @param[in] inputDims dimension of input vector for each step + * @param[in] mean pointer to mean of input vector for normalization, size inputDims + * @param[in] stdDev pointer to standard dev of input for normalization, size inputDims*steps + * @param[in,out] preComp pointer to buffer space, must be initalized to atleast hiddenDims size + * @param[in,out] tempLRW pointer to buffer space, must be initalized to atleast wRank size + * @param[in,out] tempLRU pointer to buffer space, must be initalized to atleast uRank size + * @param[in,out] normFeatures pointer to buffer space, must be initalized to atleast inputDims size + * @return The function returns 0 on success + * ERR_PRECOMP_NOT_INIT if preComp not allocated + * ERR_TEMPLRW_NOT_INIT if tempLRW not allocated + * ERR_TEMPLRU_NOT_INIT if tempLRU not allocated + * ERR_NORMFEAT_NOT_INIT if normFeatures not allocated +*/ +int FastGRNN_LR(const float* const W1, const float* const W2, const int wRank, + const float* const U1, const float* const U2, const int uRank, + const float* const Bg, const float* const Bh, + const float zeta, const float nu, const unsigned steps, + float* const hiddenState, const unsigned hiddenDims, + const float* const input, const int inputDims, + const float* const mean, const float* const stdDev, + float* preComp, float* tempLRW, float* tempLRU, float* normFeatures) { + + if (preComp == 0) return ERR_PRECOMP_NOT_INIT; + if (tempLRW == 0) return ERR_TEMPLRW_NOT_INIT; + if (tempLRU == 0) return ERR_TEMPLRU_NOT_INIT; + if (normFeatures == 0) return ERR_NORMFEATURES_NOT_INIT; + + // #steps iterations of the RNN cell starting from hiddenState + for (unsigned t = 0; t < steps; t++) { + // Normalize the features + v_add(1.0f, input + t * inputDims, -1.0f, mean + t * inputDims, inputDims, normFeatures); + v_div(stdDev + t * inputDims, normFeatures, inputDims, normFeatures); + + // Process the new input and previous hidden state + matVec(W1, normFeatures, wRank, inputDims, 0.0f, 1.0f, tempLRW); + matVec(W2, tempLRW, hiddenDims, wRank, 0.0f, 1.0f, preComp); + matVec(U1, hiddenState, uRank, hiddenDims, 0.0f, 1.0f, tempLRU); + matVec(U2, tempLRU, hiddenDims, uRank, 1.0f, 1.0f, preComp); + + // Apply the gate to generate the new hidden state + for (int i = 0; i < hiddenDims; i++) { + float gate = sigmoid(preComp[i] + Bg[i]); + float update = tanh(preComp[i] + Bh[i]); + hiddenState[i] = gate * hiddenState[i] + (zeta * (1.0 - gate) + nu) * update; + } + } + return 0; +} + + +/** + * @brief Multi-step updates of a FastGRNN cell + * @param[in] W pointer to W + * @param[in] U pointer to U + * @param[in] Bg pointer to bias for sigmoid + * @param[in] Bh pointer to bias for tanh + * @param[in] zeta first weight parameter for update from input from next step + * @param[in] nu second weight parameter for update from input from next step + * @param[in] steps number of steps of FastGRNN cell + * @param[in,out] hiddenState pointer to initial hidden state and output hidden state + * @param[in] hiddenDims dimension of hidden state of the FastGRNN cell + * @param[in] input pointer to concatenated input vectors for all steps, size inputDims*steps + * @param[in] inputDims dimension of input vector for each step + * @param[in] mean pointer to mean of input vector for normalization, size inputDims + * @param[in] stdDev pointer to standard dev of input for normalization, size inputDims*steps + * @param[in,out] preComp pointer to buffer space, must be initalized to atleast hiddenDims size + * @param[in,out] normFeatures pointer to buffer space, must be initalized to atleast inputDims size + * @return The function returns 0 on success + * ERR_PRECOMP_NOT_INIT if preComp not allocated + * ERR_NORMFEAT_NOT_INIT if normFeatures not allocated +*/ +int FastGRNN(const float* const W, const float* const U, + const float* const Bg, const float* const Bh, + const float zeta, const float nu, const unsigned steps, + float* const hiddenState, const unsigned hiddenDims, + const float* const input, const int inputDims, + const float* const mean, const float* const stdDev, + float* preComp, float* normFeatures) { + + if (preComp == 0) return ERR_PRECOMP_NOT_INIT; + if (normFeatures == 0) return ERR_NORMFEATURES_NOT_INIT; + + for (unsigned t = 0; t < steps; t++) { + // Normalize the features + v_add(1.0f, input + t * inputDims, -1.0f, mean + t * inputDims, inputDims, normFeatures); + v_div(stdDev + t * inputDims, normFeatures, inputDims, normFeatures); + + // Process the new input and previous hidden state + matVec(W, normFeatures, hiddenDims, inputDims, 0.0f, 1.0f, preComp); + matVec(U, hiddenState, hiddenDims, hiddenDims, 1.0f, 1.0f, preComp); + + // Apply the gate to generate the new hidden state + for (int i = 0; i < hiddenDims; i++) { + float gate = sigmoid(preComp[i] + Bg[i]); + float update = tanh(preComp[i] + Bh[i]); + hiddenState[i] = gate * hiddenState[i] + (zeta * (1.0 - gate) + nu) * update; + } + } + return 0; +} + +#endif \ No newline at end of file diff --git a/c_reference/include/utils.h b/c_reference/include/utils.h new file mode 100644 index 000000000..1999d068e --- /dev/null +++ b/c_reference/include/utils.h @@ -0,0 +1,127 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#ifndef __UTILS_H__ +#define __UTILS_H__ + +#include +#include + +inline float min(const float a, const float b) { + return (a < b) ? a : b; +} + +inline float max(const float a, const float b) { + return (a > b) ? a : b; +} + +inline float relu(const float x) { + if (x < 0.0) return 0.0; + else return x; +} + +inline float sigmoid(const float x) { + return 1.0f / (1.0f + expf(-1.0f * x)); +} + +inline float tanhyperbolic(const float x) { + float ex = expf(x); + float enx = expf(-1.0f * x); + return (ex - enx) / (ex + enx); +} + +inline float quantTanh(const float x) { + return max(min(x, 1.0f), -1.0f); +} + +inline float quantSigmoid(const float x) { + return max(min((x + 1.0f) / 2.0f, 1.0f), 0.0f); +} + +void v_relu(const float* const vec, const unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) ret[i] = relu(vec[i]); +} + +void v_sigmoid(const float* const vec, const unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) ret[i] = sigmoid(vec[i]); +} + +void v_tanh(const float* const vec, const unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) ret[i] = tanhyperbolic(vec[i]); +} + +void v_quantSigmoid(const float* const vec, const unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) ret[i] = sigmoid(vec[i]); +} + +void v_quantTanh(const float* const vec, const unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) ret[i] = tanh(vec[i]); +} + +/* Scaled matrix-vector multiplication: ret = alpha * ret + beta * mat * vec + alpha and beta are scalars + ret is of size nrows, vec is of size ncols + mat is of size nrows * ncols, stored in row major */ +void matVec(const float* const mat, const float* const vec, + const unsigned nrows, const unsigned ncols, + const float alpha, const float beta, + float* const ret) { + + for (unsigned row = 0; row < nrows; row++) { + float sum = 0.0f; + float* mat_offset = (float*)mat + row * ncols; + for (unsigned col = 0; col < ncols; col++) { + sum += *mat_offset++ * vec[col]; + } + ret[row] = alpha * ret[row] + beta * sum; + } +} + +// scaled vector addition: ret = scalar1 * vec1 + scalar2 * vector2 +void v_add(const float scalar1, const float* const vec1, + const float scalar2, const float* const vec2, + const unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) + ret[i] = scalar1 * vec1[i] + scalar2 * vec2[i]; +} + +// point-wise vector division ret = vec2 / vec1 +void v_mult(const float* const vec1, const float* const vec2, + const unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) + ret[i] = vec1[i] * vec2[i]; +} + +// point-wise vector division ret = vec2 / vec1 +void v_div(const float* const vec1, const float* const vec2, + const unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) + ret[i] = vec2[i] / vec1[i]; +} + +// Return index with max value, if tied, return first tied index. +unsigned argmax(const float* const vec, const unsigned len) { + unsigned maxId = 0; + float maxScore = FLT_MIN; + for (unsigned i = 0; i < len; i++) { + if (vec[i] > maxScore) { + maxScore = vec[i]; + maxId = i; + } + } + return maxId; +} + +// ret[i] = exp(input[i]) / \sum_i exp(input[i]) +void softmax(const float* const input, const unsigned len, float* const ret) { + float m = input[argmax(input, len)]; + float sum = 0.0f; + for (unsigned i = 0; i < len; i++) + sum += expf(input[i] - m); + + float offset = m + logf(sum); + for (unsigned i = 0; i < len; i++) + ret[i] = expf(input[i] - offset); +} + +#endif \ No newline at end of file diff --git a/c_reference/tests/test_fastgrnn_lr.c b/c_reference/tests/test_fastgrnn_lr.c new file mode 100644 index 000000000..b407859f6 --- /dev/null +++ b/c_reference/tests/test_fastgrnn_lr.c @@ -0,0 +1,79 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#include +#include + +#include "fastgrnn.h" +#include "classifier.h" + +// A low-rank FastGRNN model to classify digits expressed as 16x16 pixels +// Trained on USPS data + +#define inputDims 16 // Each input vector is a row +#define timeSteps 16 // Each column is a time step. +#define numClasses 10 // 10 digits + +#define hiddenDims 32 +#define wRank 5 +#define uRank 5 + + +static const float zeta = 0.8710977; +static const float nu = 0.077582605; + +static const float mean[inputDims*timeSteps] = { -0.9919499212727939, -0.9725694919764011, -0.9309642959813387, -0.853716200521184, -0.7349504700315451, -0.5802354099574815, -0.39248257687560045, -0.2269891389384171, -0.2174700892881636, -0.3516331625291455, -0.5171603246468245, -0.6708125888081178, -0.7990983028391132, -0.8932807097791728, -0.9539613342476979, -0.9857407134823684, -0.982065124537093, -0.9396279381429109, -0.8481889680427892, -0.6871382765052781, -0.46854966931833575, -0.23665195432725242, -0.010466119873817016, 0.16903683075024034, 0.16696242696475144, 0.000575173501577279, -0.19530754532985956, -0.4051392961185021, -0.6211168477575091, -0.7968383502948817, -0.9104805820875028, -0.9707068291043692, -0.972355607872715, -0.9089240443011889, -0.7740880982032617, -0.5530052536003301, -0.3013481248114096, -0.10879414689343007, 0.02414649869702375, 0.12112666931833796, 0.09386644177753416, -0.026313687560005544, -0.13068748580441636, -0.2786945901796741, -0.5084887787683436, -0.7343963726512096, -0.8844299572075165, -0.962161552736246, -0.9642070229049474, -0.8840199842271269, -0.7208337917981055, -0.48003281689754523, -0.2592399288163491, -0.15972010135783873, -0.13488242545604182, -0.11083945041832412, -0.14293412796598523, -0.19081482046358608, -0.18728045165272306, -0.25101744602935144, -0.4563265265395706, -0.7004354450692639, -0.8731881069812105, -0.9611915881223407, -0.9567694833356168, -0.8617201112330247, -0.683815164037853, -0.4513802841859834, -0.2767222655328479, -0.24271835893567434, -0.27267054121519685, -0.27519317062131443, -0.28616588533808773, -0.2777844744205183, -0.22406378836922136, -0.2557428004388969, -0.44326194554930604, -0.6840314127005878, -0.8646587673844441, -0.9602941933891046, -0.9477821902345276, -0.8393201226169212, -0.6594944069400636, -0.44880140515704203, -0.3044652061445627, -0.2859914052941979, -0.316657265121382, -0.3067866066383211, -0.28780289836785117, -0.2623772171169936, -0.22743563598957653, -0.28094515306542406, -0.46172105499931243, -0.6816232979015237, -0.853368788643532, -0.9539364379371749, -0.9359569141407178, -0.8178023395967626, -0.6458083161431897, -0.46078189713345175, -0.3343425966259763, -0.3040399067343306, -0.3020369240159101, -0.2565737191057453, -0.2143900148127831, -0.20347084844328667, -0.21882569194897866, -0.31159891482649676, -0.4869429131806326, -0.6789936108901359, -0.8352845457413198, -0.9403150890138469, -0.9219565331230252, -0.7991542114936192, -0.6391470298998767, -0.480406617885063, -0.3772339624194202, -0.3432734622136863, -0.3076273417912494, -0.22275086654779863, -0.1591171466191192, -0.15866637937182784, -0.21225642422164245, -0.3290358596900291, -0.4917353549581671, -0.6600453933616788, -0.8079168403511172, -0.9216502385132305, -0.9072759818954866, -0.7804653297215689, -0.6322083482375515, -0.5027187801398963, -0.4339113278013999, -0.41547600946372387, -0.3618670742010695, -0.24068855520504717, -0.1473811658208747, -0.14548218365107626, -0.21954138403511242, -0.33686426539569414, -0.473740655054176, -0.6233680076807026, -0.7741535508160722, -0.9028491551227509, -0.8929522782882959, -0.756864783705938, -0.6146212389246978, -0.513367757646413, -0.48232288945274865, -0.48646097517487225, -0.42513441489507686, -0.27327081648607815, -0.15083051817309004, -0.15585458030448487, -0.24761655191331758, -0.3462121758332204, -0.44668136702784256, -0.5835845624742833, -0.746094467699902, -0.8914101106844001, -0.8821387661500428, -0.7320792965299654, -0.5845565805787934, -0.4976560571938005, -0.4952595445069262, -0.5208868074338231, -0.4561778712110802, -0.2812537535317511, -0.14685717116993566, -0.17610946427101884, -0.277720601563572, -0.3429429920449862, -0.41290968659991617, -0.553466350569195, -0.7356155199561067, -0.8925808374708505, -0.884290182965297, -0.7233545645316107, -0.555796021533396, -0.45550774763406854, -0.4571342345357299, -0.49459585763269837, -0.4290731143876021, -0.24324041955835948, -0.12013004718145653, -0.17548549403374053, -0.26795098175833226, -0.30909644794952573, -0.38439246646550385, -0.5516582737621708, -0.7513137768481636, -0.905721511452472, -0.9041776875600014, -0.7504212261692499, -0.5617998211493601, -0.4151893102455081, -0.3705037724591977, -0.38054928884926614, -0.30209018968591367, -0.11544845686462707, -0.020367994925250304, -0.10257074612536023, -0.1971577605266772, -0.26616795720751535, -0.398158987244547, -0.6004331385269481, -0.7961418553010544, -0.927132169249758, -0.9355877185571251, -0.8164877640927145, -0.636413944314908, -0.4417967572349474, -0.30123951707584623, -0.21375640858592782, -0.07664012673158706, 0.11518739075572665, 0.16615884350569157, 0.02465076409271711, -0.14109523247839745, -0.3035931360581551, -0.5030459921821414, -0.7066635047318597, -0.8603180109724315, -0.9508067177341882, -0.9675336151419524, -0.9003715298312993, -0.7766258472088848, -0.5970459330681649, -0.3958499355369634, -0.19905987738307548, 0.02545309765464275, 0.23516244191468944, 0.23560784803182028, 0.00534759127691674, -0.2629597399533658, -0.4955072450966976, -0.6918777547661497, -0.8361089925936072, -0.9240889329310108, -0.972631745576734, -0.9893073183376733, -0.9649322459196252, -0.9132032637498255, -0.8204827562748569, -0.6831469591276887, -0.506931868330818, -0.2965040820189278, -0.11981037566863263, -0.13915219805239362, -0.3596030020573289, -0.5987721205595955, -0.7692781906459996, -0.8760536623234108, -0.9370363911671895, -0.9704590652859655, -0.9892901006720557 }; +static const float stdDev[inputDims * timeSteps] = { 0.05066656593826383, 0.11768215831858285, 0.19527142979975337, 0.2833393066737951, 0.37268899940299066, 0.43424831734200253, 0.4509077884558764, 0.4523467450088637, 0.4435444516292877, 0.453474411938222, 0.4511610370141509, 0.4090808907117051, 0.340842016175768, 0.2515266389290965, 0.1535781715584388, 0.06980490524925699, 0.08765943105043687, 0.19636324018365733, 0.32429032997742996, 0.4567512820282358, 0.5626439446484282, 0.6032659791055035, 0.5639062519215206, 0.5308776133306021, 0.5223175793565092, 0.5540930619255867, 0.6009820087794636, 0.5835468006853077, 0.5110815844557693, 0.39510080274123266, 0.25620023445987633, 0.1226867565488554, 0.11282186786555957, 0.2443736268637558, 0.3927773337244816, 0.5300792876318842, 0.611455535763247, 0.6137703781184999, 0.5486362827625642, 0.558238252221451, 0.5640102654180597, 0.5458372730410752, 0.6033813665182791, 0.6179035980472674, 0.5636690595511944, 0.4471630564471609, 0.2991307396396185, 0.14513349372261522, 0.13165609358200855, 0.27850705968930484, 0.43720035704012494, 0.5696589694535166, 0.6305106802282854, 0.6130665659135671, 0.5708937380167166, 0.6267080783818001, 0.6140579359769878, 0.5502386047872234, 0.6051362682299342, 0.635397491562088, 0.5917012576621496, 0.4694826022296184, 0.3049891980667035, 0.1417658489946166, 0.14660482167334782, 0.3108270739064537, 0.4796721806586266, 0.6021156740335395, 0.6438981023490464, 0.6149730879531347, 0.5786341846733203, 0.6260900111005044, 0.6088319125295019, 0.5527066903416282, 0.6139823813708458, 0.6469383840051754, 0.6087765126529255, 0.4896843988025161, 0.3130099011675707, 0.13746176784318512, 0.1651363517565353, 0.3525996924710074, 0.5214554460712036, 0.6228931000316578, 0.6466288953590107, 0.617026839758864, 0.5735516128512261, 0.6164884033345998, 0.6226536777808414, 0.579468571253997, 0.6226313291006089, 0.6420111615955644, 0.6028682944062023, 0.5012722033813212, 0.3390059533601551, 0.15299465137681406, 0.19251594791512783, 0.396952702268763, 0.552159431496869, 0.6320421473488981, 0.6443326365880183, 0.6170472505372365, 0.5834546203509037, 0.6456206774803475, 0.6632037104438387, 0.6136658430782906, 0.6282883980800487, 0.6266066841912776, 0.5877284692447173, 0.5083732571738568, 0.37672585693697697, 0.19071297464730821, 0.22738939517708093, 0.43216309636726685, 0.5672536909906605, 0.631729474977315, 0.639288052909488, 0.6083883492195362, 0.5889647486063578, 0.6632192879286241, 0.666693521410897, 0.6141086834297501, 0.6235523636944053, 0.6110232070097491, 0.5810599302729026, 0.5248683372032933, 0.416871751902074, 0.23245043001693613, 0.25787896223721457, 0.45642840103735277, 0.5706055474263793, 0.6215019791294262, 0.6240378390525279, 0.585872663503391, 0.5811279830268054, 0.6602994727745124, 0.6489034985750345, 0.603285958818, 0.6104761926038955, 0.6019458376723148, 0.593072552824263, 0.5541512721442687, 0.45442464044327674, 0.26421446020604794, 0.2750748340184962, 0.4759504899089418, 0.5801160408912686, 0.6171973056405151, 0.6084475754936072, 0.5662766326533075, 0.5725163997626637, 0.6523704000367663, 0.6439544061328982, 0.6038993966379462, 0.5936445165640896, 0.5988208807738072, 0.6134438430981234, 0.5822474624078565, 0.4781320392750622, 0.2744472002370629, 0.27978594406798046, 0.49000304569115505, 0.596927771017493, 0.6295636513656973, 0.6130992222136632, 0.5685432540366993, 0.5722666927638678, 0.6490460968540127, 0.6510618224925118, 0.5951965161993366, 0.579054281068931, 0.6133129715581599, 0.6399127837494875, 0.601009829227199, 0.4759842934093174, 0.25926034572427836, 0.2659329405966657, 0.48229673831219794, 0.6058557018009367, 0.6475577504899299, 0.6318593264440545, 0.5793441705514869, 0.5626352996175501, 0.6396798454937799, 0.6395304006230473, 0.5643649762025762, 0.5814789782426448, 0.6437155669568893, 0.6622897081277597, 0.5981077340856256, 0.4440137907748311, 0.22855334793658635, 0.23058280104056256, 0.4391108535116708, 0.5858018231169397, 0.6568158083074834, 0.660992447300762, 0.6050293531558012, 0.551566388582632, 0.6078442167019985, 0.5874351599908308, 0.5329056322660973, 0.6156086282390514, 0.6757254453683215, 0.658579754018323, 0.5568677508414656, 0.3855427765572426, 0.19247519514628053, 0.18151505693157194, 0.36316373873982777, 0.5198136719231422, 0.6273283747062883, 0.6745273153652143, 0.6455002272347471, 0.5585396598417464, 0.5410453171458859, 0.5096064443341672, 0.5429252747140453, 0.6545502373132852, 0.6698239302774162, 0.5980652613996279, 0.4668007421210614, 0.3114873386910331, 0.15654842294915372, 0.12168436193114814, 0.2528519135349363, 0.3889022669431662, 0.51681799362489, 0.6152354929585003, 0.6480000627279904, 0.5868680464219567, 0.5207594899432356, 0.5133934769539377, 0.5830576463663892, 0.6286429551523846, 0.5707288552482176, 0.4582805109955963, 0.3362912300487512, 0.224029788596469, 0.1134877995573401, 0.05688552112923371, 0.1253359275691928, 0.20678860013345332, 0.30178570214200107, 0.39857085075127774, 0.4710686511232531, 0.4809255781447563, 0.4517230712365873, 0.44968948316492025, 0.4579322493794554, 0.4218312472593008, 0.3369818647335357, 0.2510674309664235, 0.18299863726222423, 0.1220244940300115, 0.059526488182894154 }; + +static const float W1[inputDims * wRank] = { 0.04437631741166115, 0.13164237141609192, 0.13089998066425323, -0.005882591009140015, 0.04586317017674446, 0.21047545969486237, 0.9706279635429382, -0.5048243999481201, -0.7511760592460632, 0.07774244248867035, 0.40391597151756287, -0.016807876527309418, 0.08794082701206207, 0.09336663037538528, 0.08842388540506363, -0.10721755772829056, -0.16265031695365906, -0.506087601184845, -0.2623403072357178, -0.41705453395843506, -0.3362988531589508, 0.20567356050014496, 0.09920496493577957, 0.399951696395874, -0.10302149504423141, -0.2829299569129944, -0.21695533394813538, -0.11943338066339493, -0.17138315737247467, -0.08943527936935425, 0.09248100966215134, -0.11688404530286789, -0.2544580101966858, 0.2178615778684616, -0.245102658867836, -0.2574276626110077, 0.022898254916071892, -0.4134445786476135, 0.028750110417604446, -0.047812022268772125, 0.4697933793067932, 0.4765063524246216, 0.35218697786331177, 0.29210469126701355, 0.1622641533613205, -0.1555808037519455, 0.04628629982471466, -0.031492870301008224, -0.23739324510097504, -0.0762714371085167, -0.16486185789108276, -0.2018968164920807, -0.5137050151824951, 0.14758920669555664, -0.5882534980773926, -0.7306461334228516, -0.7919453978538513, 0.07507729530334473, 0.1977670043706894, 0.21115902066230774, -0.12351129949092865, -0.07091476023197174, 0.06400024145841599, 0.021400034427642822, 0.10578139871358871, 0.17063069343566895, 0.3912162184715271, -0.02506481111049652, 0.09003248065710068, 0.42354777455329895, -0.37391015887260437, 0.14988373219966888, 0.2816886901855469, -0.35063880681991577, -0.05643891915678978, -0.15927889943122864, -0.47207891941070557, -0.5888171195983887, -0.18981651961803436, -0.41033101081848145 }; +static const float W2[wRank * hiddenDims] = { 0.2863377332687378, -1.2143335342407227, 0.610011875629425, 0.1656205952167511, -0.8666146397590637, -0.5734943747520447, 0.7413628101348877, 0.1714680939912796, 0.9024200439453125, 0.32295238971710205, -0.3873929977416992, -0.2707236707210541, 0.5344352126121521, -0.8188126683235168, 0.35341984033584595, -0.6474847197532654, 1.4979887008666992, -0.4152466952800751, 0.2156294882297516, 0.20376665890216827, 0.18564093112945557, -0.25238993763923645, 0.3459400534629822, 0.7960702776908875, -1.1047370433807373, 0.5615563988685608, -0.3268606960773468, 0.09511122852563858, 0.21674132347106934, -0.7735028862953186, -0.1510464996099472, -0.414810448884964, -0.41682058572769165, 0.5789415836334229, 0.5722947716712952, 0.4911503493785858, 0.9235195517539978, -0.22825153172016144, -0.17003802955150604, 1.5115245580673218, -0.3358864486217499, 0.5848679542541504, -0.0174887552857399, -0.325115442276001, 0.8525659441947937, 0.07604137063026428, -0.11137218028306961, -1.094437599182129, -0.21889141201972961, 0.6240004897117615, 0.6826394200325012, 0.3434017598628998, -0.1567269265651703, 0.2540211081504822, 0.177201509475708, -0.11570670455694199, 0.04361787065863609, 0.070060133934021, 0.40478208661079407, -0.16697058081626892, -0.27620503306388855, -0.12831233441829681, 0.11825147271156311, -0.13083836436271667, -0.4768890142440796, 0.9436963796615601, -0.8370056748390198, -0.3582906424999237, 0.2789956331253052, -0.7134209275245667, -0.03986117243766785, -0.32654106616973877, 0.6198241114616394, 0.4585057497024536, -0.6961711049079895, 0.5115857720375061, -0.22929508984088898, -0.44659942388534546, 0.3906383514404297, -0.29806071519851685, -0.4874197542667389, 0.22447143495082855, 0.902230978012085, -0.5234335660934448, -0.07662484794855118, 0.6974019408226013, 0.18268021941184998, 0.1972568929195404, -0.7540782690048218, 0.16145218908786774, -0.13156381249427795, 0.588074266910553, -1.0683441162109375, 0.30249473452568054, 0.8400665521621704, 0.47553586959838867, -0.4598252773284912, -0.2067403942346573, -0.8708492517471313, -0.283275842666626, -0.23203222453594208, -0.18401674926280975, -0.5495933294296265, 1.218782901763916, 0.239736407995224, 0.18521395325660706, -0.1917710155248642, -0.5461402535438538, 0.14571575820446014, 0.004668646026402712, -0.19929653406143188, 0.12697455286979675, -0.3280128836631775, -0.5886898636817932, 0.22302460670471191, -0.4971023499965668, -0.41075021028518677, 0.33907508850097656, 0.407676100730896, -0.27239513397216797, -0.45195865631103516, 0.14889605343341827, 0.3355768918991089, -0.5228666663169861, -0.12074578553438187, -0.5339986681938171, -0.06062544137239456, 1.006304144859314, -0.36918461322784424, 0.37021008133888245, 0.5438523292541504, -0.7772119641304016, -0.045975420624017715, -0.7924363613128662, 0.512947678565979, -0.003562948200851679, -0.009431581944227219, -0.4735417664051056, 0.13429303467273712, -0.11795001477003098, -0.07338037341833115, -0.15307340025901794, 0.07787186652421951, 0.174309641122818, -0.08390356600284576, 0.4766653776168823, -0.12070371210575104, -0.37375226616859436, -0.4071563184261322, 0.056958504021167755, 0.06188056617975235, 0.12964613735675812, -0.34358277916908264, 0.7809591889381409, 0.22712215781211853, -0.4458172023296356, 0.13437648117542267, 0.12954799830913544, 1.001265287399292, 0.18989679217338562 }; + +static const float U1[hiddenDims * wRank] = { 0.26560232043266296, 0.23243790864944458, 0.7191420197486877, -0.20894131064414978, 0.49118855595588684, 0.6319213509559631, 0.34289464354515076, 0.01801704801619053, -0.0745602548122406, -1.0685001611709595, -0.26240262389183044, 0.4905305802822113, 0.1572536826133728, -0.23067831993103027, -0.5052195191383362, 0.7681716680526733, 0.9279878735542297, -0.5277288556098938, -0.08344665914773941, 0.6202220916748047, -0.5001773238182068, -0.5095654726028442, -0.3295743465423584, 0.5233407616615295, -0.5727354288101196, -0.8839725852012634, -0.010022483766078949, -0.09335310012102127, -0.39809176325798035, -0.1842958629131317, 0.24937759339809418, -0.10589130222797394, 0.08205743134021759, 0.31646987795829773, -0.29515960812568665, 0.5459985733032227, 0.1268385350704193, 0.04255566745996475, 0.33306896686553955, -0.16022534668445587, -0.29528936743736267, -0.25233426690101624, -0.2937506437301636, 0.4037521183490753, 0.23886920511722565, 0.06710945069789886, 0.08734912425279617, 0.5572593808174133, -1.314361333847046, 0.03353128582239151, 0.2606905698776245, 0.6152605414390564, -0.3894504904747009, -0.32302090525627136, 0.36168500781059265, 0.6218935251235962, -0.38376080989837646, 0.09247376024723053, 1.026206612586975, 1.1414283514022827, -0.10093820095062256, 0.9370135068893433, 1.9249975681304932, -0.5042387247085571, 0.18620948493480682, -0.3022148311138153, 0.03854614496231079, 0.37739163637161255, -0.3281741440296173, -0.34284695982933044, 0.5523097515106201, 0.03876172751188278, -0.1751827448606491, -0.0030013038776814938, 0.05078490078449249, -0.29853954911231995, -0.6525045037269592, -0.05094808712601662, -0.20980416238307953, 0.03934936225414276, 0.7077404856681824, -0.5978014469146729, -0.03315050154924393, -0.9729236960411072, -0.8541942834854126, -0.23380915820598602, -0.8171064853668213, 0.08188191801309586, 0.3533187210559845, -0.3635164201259613, -0.8342750072479248, 0.726115882396698, 0.2952367961406708, -0.4665921926498413, 0.7437827587127686, 0.45183295011520386, 0.5798006057739258, 0.2457144558429718, 0.4404001533985138, 0.12141070514917374, 0.3805271089076996, -0.23846925795078278, 0.7316015958786011, -0.3569253087043762, 0.15102985501289368, -0.39612525701522827, 0.28232714533805847, -0.6851686239242554, 0.6952816247940063, 0.452238529920578, 0.08832887560129166, 1.4521069526672363, 0.36747226119041443, 0.31619787216186523, 0.19886334240436554, 0.23799069225788116, -0.5594980716705322, -0.3654753267765045, -0.19946272671222687, -0.10181467235088348, -0.12737073004245758, 0.7593855857849121, -0.9848454594612122, 0.6157532930374146, 0.2603704035282135, 0.999906063079834, -0.4353993237018585, -0.4969525635242462, -0.714335024356842, 0.04920447617769241, 0.151398703455925, -0.40162163972854614, -0.27132919430732727, 0.7902809977531433, -0.10028137266635895, 1.0021592378616333, -0.30421894788742065, 0.3746432662010193, 0.5291203856468201, -0.3812990188598633, 0.7990191578865051, 0.508926272392273, -0.1624583899974823, -0.1668565720319748, 0.2089664191007614, -0.13996511697769165, 0.3811531960964203, 0.2811248302459717, 0.6223021149635315, -0.7457583546638489, -0.33088400959968567, 1.0035068988800049, -0.35653096437454224, -0.4059991240501404, -0.1819305270910263, -0.4383915662765503, 0.7609431743621826, -0.7965887784957886, 0.5413278937339783, -0.3607611358165741 }; +static const float U2[wRank * hiddenDims] = { -1.1701158285140991, -0.1588035672903061, -1.1778416633605957, 0.11378461867570877, 0.1573396474123001, 0.13804543018341064, -0.28284865617752075, 0.8901959657669067, -0.5648555755615234, -0.6038640737533569, -0.4130585789680481, 0.7159488797187805, -1.263935923576355, 0.22861142456531525, 0.39220884442329407, 0.6647656559944153, 0.28182974457740784, 0.6640202403068542, 0.20066450536251068, -0.7047211527824402, 0.42111220955848694, -0.5956082344055176, -0.1325611025094986, 0.5465019941329956, -0.42245036363601685, -0.6001131534576416, -0.2538827061653137, -0.24035486578941345, -0.46974751353263855, 0.9539428949356079, 0.4083715081214905, 0.1597665399312973, 0.31555771827697754, -0.1176120713353157, -0.3248029053211212, 0.5774492025375366, 0.06316787749528885, 0.13469642400741577, 0.7753828167915344, -0.19036400318145752, 0.558892548084259, 0.2966901361942291, -0.2756923735141754, 0.0863649770617485, 0.5044283270835876, 0.5554067492485046, 1.2062954902648926, -0.06426048278808594, 0.251096248626709, 0.7044650316238403, 0.7219952940940857, 0.2331368625164032, 0.6588672995567322, -0.021296916529536247, -0.5537024140357971, 0.1907256543636322, -0.08542638272047043, -0.9375039339065552, -0.11962691694498062, -0.34279578924179077, -0.1679597795009613, 0.8744648694992065, 0.4903189241886139, -0.002235307591035962, 0.49500423669815063, -0.20796941220760345, -0.4931069314479828, 0.19794103503227234, 0.23972071707248688, 0.07782389968633652, -1.5402740240097046, 0.4908592104911804, 0.37148523330688477, 0.9664593935012817, -1.0712075233459473, -0.47738638520240784, 0.3663298785686493, 0.01408083550632, -0.5519229173660278, -0.5287301540374756, 0.2269572615623474, 0.05943543091416359, -0.813250720500946, 0.3974776566028595, 0.6844959855079651, 0.009752316400408745, -0.22982186079025269, -0.18944667279720306, -0.33985260128974915, 0.20089533925056458, 0.24146895110607147, -0.3968782126903534, -0.6829974055290222, 0.2860521376132965, 0.06187593191862106, -0.0817679762840271, 1.0080456733703613, 1.087625503540039, 0.8712841868400574, 1.0755778551101685, -0.474960595369339, -0.723259687423706, -0.9868606925010681, 0.8535012602806091, -0.5053154230117798, -0.30608052015304565, -0.7238053679466248, -0.04056096449494362, -0.37457355856895447, 0.14730329811573029, -0.1650729775428772, 0.4555414319038391, -0.0914393812417984, -0.027970634400844574, 0.48361921310424805, 0.09482058882713318, -0.6751720309257507, 0.7193213105201721, -0.3357415199279785, 0.033068787306547165, -0.6387664079666138, -0.08479925990104675, -0.19875706732273102, -0.9184507727622986, 0.700031578540802, 0.19395720958709717, 0.05879056081175804, -0.3861687183380127, 0.15968921780586243, -0.22974976897239685, 0.21669058501720428, 0.07636229693889618, 0.30239996314048767, -0.22337456047534943, 0.14845764636993408, -0.3706870675086975, -0.9184858798980713, 0.28799909353256226, -0.6701984405517578, -0.1726493388414383, -0.061379268765449524, -0.5134955048561096, 0.6964709758758545, -0.006153882015496492, -0.009776073507964611, 0.16820202767848969, 0.4359828531742096, 0.5606184601783752, -0.7106017470359802, 0.10443971306085587, 0.3130362927913666, -1.2240679264068604, 0.08121868968009949, 0.1808670610189438, -0.30179110169410706, 0.26126185059547424, 0.42505496740341187, -0.369361937046051, -0.02273283340036869, 0.059929925948381424 }; + +static const float Bg[hiddenDims] = { 4.59620475769043, 0.1966695934534073, 1.9611409902572632, 3.5603864192962646, 4.187475204467773, 4.361924648284912, 0.3600460886955261, 1.3823245763778687, -0.677017092704773, 4.105582237243652, 5.264251232147217, -0.5598424077033997, 5.148655414581299, 2.0772266387939453, 4.553979873657227, 5.08613920211792, 4.782368183135986, 0.7364211678504944, 5.434220314025879, 3.580031394958496, 3.1102733612060547, -0.7808840870857239, 0.7291825413703918, 4.574047565460205, 3.3059921264648438, 0.3563838303089142, 2.718221664428711, 3.580395460128784, 3.4779181480407715, 2.5830607414245605, 2.9951508045196533, 0.9241535663604736 }; +static const float Bh[hiddenDims] = { 0.4606550931930542, 0.790073573589325, -0.017053354531526566, 0.9936599731445312, 1.7931172847747803, 1.5456229448318481, 1.1712238788604736, 0.25801223516464233, 0.31747567653656006, 0.19287768006324768, 2.0994107723236084, 1.0495734214782715, 1.4762489795684814, 1.309980034828186, 0.3596293032169342, 1.5582088232040405, 0.40993940830230713, 1.8783470392227173, 1.493168830871582, -0.24529218673706055, 1.1273030042648315, 0.2839592695236206, 1.9818940162658691, 1.6705248355865479, 0.6683108806610107, 1.1119632720947266, 1.71348237991333, 2.004892110824585, 2.6525025367736816, 1.5513267517089844, 1.5202845335006714, -0.5777350068092346 }; + +static const float FC_weights[hiddenDims * numClasses] = { -0.24747183918952942, -0.055960506200790405, 1.3475773334503174, -0.2660730183124542, 0.08773329854011536, 2.71574068069458, -1.4928890466690063, 1.5905754566192627, 1.4361884593963623, 1.3066115379333496, -0.41571110486984253, 0.9617563486099243, 0.40012961626052856, 0.8696961998939514, -1.6383168697357178, 0.7999024391174316, -0.16858834028244019, -1.0727401971817017, 0.7396827340126038, 0.3806271553039551, -0.8257421255111694, 0.1623869240283966, -0.39433446526527405, -3.482332468032837, -0.08032357692718506, 0.994373083114624, 0.9860239028930664, -5.6317973136901855, -3.062581777572632, -3.2377049922943115, -1.088222861289978, 0.7581420540809631, -0.1045861691236496, 1.0123625993728638, 2.7781565189361572, 4.226351737976074, -0.4395594894886017, -1.9928295612335205, -0.03426577150821686, 0.2318461388349533, -3.200232982635498, 0.7830891013145447, -2.003850221633911, -1.0072307586669922, -0.09394438564777374, -0.402126282453537, 2.8108479976654053, 0.027125360444188118, 1.893704891204834, -0.03775143623352051, 0.6053617596626282, 0.3430182933807373, -3.2976200580596924, -1.1353939771652222, 0.024645693600177765, 0.3784751296043396, 1.4342879056930542, -0.7492150664329529, -1.0270135402679443, 2.5554628372192383, 0.6594746112823486, 0.7780766487121582, 0.8985974788665771, -0.0034258293453603983, 0.21751202642917633, -2.3399763107299805, 1.1613740921020508, -1.447609305381775, -1.3636846542358398, 1.7248963117599487, -0.3620492219924927, -2.375091075897217, -1.3364042043685913, 1.359509825706482, -2.648242235183716, 1.4566280841827393, 0.6185098886489868, 0.9421749711036682, -1.8496538400650024, -1.3294904232025146, -0.565808892250061, -1.6445082426071167, 1.2565573453903198, 2.4306249618530273, -1.6949048042297363, 2.2069883346557617, 1.103385329246521, -0.9351933598518372, -0.824954628944397, -0.7599087953567505, -0.6911792755126953, 2.7740914821624756, 1.6341619491577148, 1.849193811416626, 1.146787166595459, -1.4661681652069092, 2.0738017559051514, -1.9961793422698975, -1.1605796813964844, 0.9941896200180054, 0.3308192789554596, 2.13922119140625, -0.17217597365379333, -0.9082329869270325, 0.7720779180526733, -1.0596287250518799, 1.586103081703186, -2.9859485626220703, 1.55707585811615, 1.1488341093063354, -3.2394535541534424, 1.169393539428711, -0.13278652727603912, 1.6355780363082886, -0.1245696097612381, 1.808440923690796, -1.1002291440963745, -0.3053940534591675, 1.6078038215637207, 3.8395557403564453, 0.019826073199510574, -0.3926658034324646, -1.9981871843338013, -0.6696834564208984, 0.08870892226696014, 1.6605280637741089, 0.5209671854972839, -2.3854024410247803, 1.5786619186401367, 1.8952832221984863, -1.304535150527954, 0.2743481695652008, 2.8763298988342285, -0.6256309747695923, 3.8730015754699707, -0.32314497232437134, -0.6618545651435852, -3.0481762886047363, -2.8654234409332275, -0.8415182828903198, -1.3170037269592285, 1.3599309921264648, 1.2142889499664307, 0.07019823044538498, -0.5422642827033997, 0.23863810300827026, 3.584157943725586, 0.7111842036247253, 0.9668632745742798, 1.3011258840560913, -0.003976037260144949, 1.7265373468399048, -0.48193755745887756, 0.463483989238739, -0.3804154098033905, 2.4481565952301025, -1.081111192703247, 1.9583369493484497, -3.963627338409424, 0.729573667049408, -0.4898405373096466, -0.5738614201545715, -1.7461729049682617, -1.8392359018325806, -0.4148902893066406, -1.158633828163147, -1.6964939832687378, 0.5787208080291748, 1.4248132705688477, -0.4257330894470215, 3.0490269660949707, -1.1780657768249512, 1.0951701402664185, 0.8462642431259155, 0.9555350542068481, 2.9707250595092773, -1.3199042081832886, 1.8216924667358398, -0.6233108639717102, 1.5412005186080933, 0.334654837846756, 0.2763754725456238, 1.3666235208511353, 1.851394534111023, -1.7485069036483765, 1.0322270393371582, -1.8656693696975708, -1.1901252269744873, 1.0325310230255127, -0.8999790549278259, 0.22713708877563477, -3.3022899627685547, -2.718987464904785, 0.6280394792556763, 0.7579594254493713, -2.2618398666381836, -1.1550352573394775, 1.0463181734085083, -0.2427310198545456, -0.1560579091310501, -0.19294323027133942, 0.3897946774959564, -1.5712190866470337, 1.0458306074142456, -0.7470991015434265, 1.2837566137313843, 2.3155717849731445, 2.0378687381744385, 0.7463016510009766, 1.3255469799041748, -1.7185251712799072, -0.1644330620765686, 2.248473882675171, -0.05582746863365173, -0.39194202423095703, -1.050262212753296, 1.1556638479232788, 0.03496933728456497, 1.5286030769348145, 0.01176676619797945, -1.1746597290039062, -0.038728803396224976, -0.3821633458137512, 0.9377774596214294, -0.3956509530544281, 1.074571967124939, -1.6802961826324463, -0.3645908534526825, -1.4564014673233032, 0.6331769227981567, 2.4816489219665527, 0.32858720421791077, 1.5533283948898315, 1.6947213411331177, 0.3252701461315155, 3.2225258350372314, 1.1926754713058472, 0.3901558518409729, -0.8612796664237976, -4.8346662521362305, -1.9908527135849, 0.7937301993370056, -1.5082682371139526, 0.4805694818496704, -1.419480323791504, 0.157501682639122, 2.0960652828216553, 0.005156002938747406, -2.6489176750183105, 1.263648271560669, -1.3384476900100708, 1.4031224250793457, 0.4655438959598541, 1.8326048851013184, 3.110736131668091, 0.26125067472457886, 2.7024500370025635, -0.9119302034378052, -0.6820136308670044, 3.8541572093963623, -1.3096107244491577, 1.7389343976974487, 2.067892551422119, 1.1543680429458618, 0.03984083607792854, 0.6176361441612244, -0.8746475577354431, 0.40996477007865906, -2.3278424739837646, 0.5317244529724121, -1.1554235219955444, 0.8648607730865479, 0.5743665099143982, 0.9955512881278992, 0.8316799998283386, -1.9429028034210205, 0.6146461367607117, -4.532263278961182, -0.8694373965263367, -0.31155335903167725, -0.030860910192131996, 1.173535704612732, 0.8387981057167053, -1.3379566669464111, 1.902561902999878, 2.197434663772583, 1.3871995210647583, -1.6537810564041138, -2.7861647605895996, -0.005632062442600727, -2.181979179382324, 2.3240818977355957, 0.914097785949707, 0.10216601192951202, 2.52095103263855, 0.6039048433303833, -1.1367847919464111, -2.309983015060425, 2.7826766967773438, -0.6315389275550842, -3.811366319656372, 2.09122633934021, -0.6774390339851379, -0.9190919995307922, 0.9899649620056152, 1.0903472900390625, -0.7736498713493347, -1.3925520181655884, 0.6861974596977234, 3.141139268875122, 0.7085739970207214, 0.35131436586380005, 1.6807632446289062, 1.0083352327346802, -0.38794782757759094, -1.839680790901184, -0.7718075513839722, 0.41827693581581116, 1.8001973628997803, 1.2126221656799316 }; +static const float FCbias[numClasses] = { 0.7145490646362305, 0.2392704039812088, 0.7243489027023315, -0.3943518102169037, -0.7943000793457031, 0.18482555449008942, 0.29146698117256165, -0.04441819712519646, 1.5886560678482056, -0.8504140377044678 }; + +// Here are 10 example with labels to check code correctness +#define numExamples 10 +static const float input[numExamples * inputDims * timeSteps] = { +-9.999989999999999712e-01, -9.999280000000000390e-01, -9.978850000000000220e-01, -9.737289999999999557e-01, -8.557719999999999771e-01, -5.974159999999999471e-01, -2.892540000000000111e-01, 1.891000000000000103e-03, 1.991960000000000119e-01, 2.921619999999999773e-01, 5.840999999999999664e-02, -3.988849999999999896e-01, -7.828040000000000553e-01, -9.586670000000000469e-01, -9.971060000000000478e-01, -9.999299999999999855e-01, -9.999660000000000215e-01, -9.984709999999999974e-01, -9.743000000000000549e-01, -8.181580000000000519e-01, -3.776260000000000172e-01, 1.784530000000000005e-01, 4.618349999999999955e-01, 4.866269999999999762e-01, 4.564190000000000191e-01, 4.585899999999999976e-01, 4.410350000000000104e-01, 2.776770000000000072e-01, -2.715719999999999801e-01, -7.943890000000000118e-01, -9.763939999999999841e-01, -9.989860000000000406e-01, -9.994060000000000166e-01, -9.843779999999999752e-01, -8.419809999999999794e-01, -3.601309999999999789e-01, 2.763050000000000228e-01, 5.122529999999999584e-01, 3.171390000000000042e-01, -5.488300000000000123e-02, -3.208799999999999986e-01, -3.823739999999999917e-01, -1.500219999999999887e-01, 3.192159999999999997e-01, 2.445279999999999954e-01, -4.316969999999999974e-01, -8.891390000000000127e-01, -9.936409999999999965e-01, -9.952950000000000408e-01, -9.140859999999999541e-01, -4.970399999999999818e-01, 2.440730000000000122e-01, 4.769090000000000273e-01, 3.452399999999999913e-02, -4.699980000000000269e-01, -7.523990000000000400e-01, -8.733349999999999724e-01, -8.564300000000000246e-01, -5.707010000000000138e-01, 7.110299999999999954e-02, 5.098099999999999854e-01, 3.845200000000000007e-02, -7.229849999999999888e-01, -9.823070000000000412e-01, -9.843929999999999625e-01, -7.619580000000000242e-01, -5.724800000000000028e-02, 4.982750000000000234e-01, 1.289379999999999971e-01, -5.653420000000000112e-01, -9.008960000000000301e-01, -9.768630000000000368e-01, -9.654559999999999809e-01, -7.698230000000000350e-01, -2.443150000000000044e-01, 3.408079999999999998e-01, 6.986529999999999685e-01, 2.799619999999999886e-01, -6.274570000000000425e-01, -9.747249999999999526e-01, -9.740199999999999969e-01, -6.315579999999999528e-01, 2.490229999999999944e-01, 4.868640000000000190e-01, -2.849450000000000038e-01, -8.529759999999999565e-01, -9.786280000000000534e-01, -9.680050000000000043e-01, -8.506489999999999885e-01, -3.887789999999999857e-01, 3.913400000000000212e-01, 7.540489999999999693e-01, 6.519970000000000487e-01, 6.102400000000000185e-02, -7.050119999999999720e-01, -9.787219999999999809e-01, -9.727649999999999908e-01, -6.046329999999999760e-01, 3.010070000000000245e-01, 4.125269999999999770e-01, -4.544940000000000091e-01, -8.776140000000000052e-01, -8.431469999999999798e-01, -6.940309999999999535e-01, -3.879340000000000011e-01, 1.740309999999999913e-01, 7.366949999999999887e-01, 7.265779999999999461e-01, 1.642170000000000019e-01, -4.996470000000000078e-01, -8.923109999999999653e-01, -9.926230000000000331e-01, -9.797400000000000553e-01, -6.899070000000000480e-01, 9.411700000000000621e-02, 3.872579999999999911e-01, -1.671759999999999913e-01, -4.210010000000000141e-01, -2.404840000000000033e-01, 5.989099999999999979e-02, 4.223910000000000164e-01, 7.399440000000000461e-01, 8.160749999999999948e-01, 3.639479999999999937e-01, -4.222170000000000090e-01, -8.689219999999999722e-01, -9.837040000000000228e-01, -9.991529999999999578e-01, -9.896549999999999514e-01, -8.313369999999999926e-01, -2.835340000000000082e-01, 3.112550000000000039e-01, 4.447369999999999934e-01, 4.600369999999999737e-01, 5.187220000000000164e-01, 5.491030000000000078e-01, 6.715740000000000043e-01, 8.727289999999999770e-01, 6.886210000000000386e-01, -8.334999999999999354e-02, -7.613389999999999880e-01, -9.757749999999999480e-01, -9.987230000000000274e-01, -9.999609999999999888e-01, -9.974539999999999518e-01, -9.540859999999999896e-01, -7.398449999999999749e-01, -2.981320000000000081e-01, 1.168259999999999993e-01, 2.966269999999999740e-01, 2.590549999999999797e-01, 1.147709999999999980e-01, 3.006869999999999821e-01, 7.234869999999999912e-01, 4.759129999999999749e-01, -4.180459999999999732e-01, -9.063860000000000250e-01, -9.947169999999999623e-01, -9.999120000000000230e-01, -9.999989999999999712e-01, -9.998259999999999925e-01, -9.956909999999999927e-01, -9.592690000000000383e-01, -8.423429999999999529e-01, -6.910760000000000236e-01, -6.172760000000000469e-01, -6.201600000000000446e-01, -4.761870000000000269e-01, 1.655320000000000125e-01, 6.454130000000000145e-01, 2.260870000000000102e-01, -6.278190000000000159e-01, -9.656599999999999628e-01, -9.988850000000000229e-01, -9.999900000000000455e-01, -1.000000000000000000e+00, -9.999970000000000248e-01, -9.998519999999999630e-01, -9.978810000000000180e-01, -9.905059999999999976e-01, -9.802600000000000202e-01, -9.741710000000000091e-01, -9.412179999999999991e-01, -5.735930000000000195e-01, 3.320199999999999818e-01, 6.261999999999999789e-01, -3.573099999999999887e-02, -7.612609999999999655e-01, -9.845939999999999692e-01, -9.997819999999999485e-01, -9.999989999999999712e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999989999999999712e-01, -9.999770000000000048e-01, -9.998920000000000030e-01, -9.997390000000000443e-01, -9.965319999999999734e-01, -9.296180000000000554e-01, -4.550699999999999745e-01, 4.870189999999999797e-01, 5.592399999999999594e-01, -3.041880000000000139e-01, -8.719719999999999693e-01, -9.928409999999999735e-01, -9.999190000000000023e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999329999999999607e-01, -9.939230000000000009e-01, -8.872520000000000406e-01, -3.392859999999999765e-01, 5.403149999999999897e-01, 4.513349999999999862e-01, -4.945749999999999869e-01, -9.424919999999999964e-01, -9.976519999999999833e-01, -9.999759999999999760e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999259999999999815e-01, -9.933429999999999760e-01, -8.806059999999999999e-01, -3.493580000000000019e-01, 4.458260000000000001e-01, 3.244429999999999814e-01, -5.840009999999999923e-01, -9.678870000000000529e-01, -9.992910000000000403e-01, -9.999949999999999672e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999679999999999680e-01, -9.970299999999999718e-01, -9.415249999999999453e-01, -6.157479999999999620e-01, -2.896299999999999916e-02, -4.975899999999999768e-02, -6.953970000000000429e-01, -9.771060000000000301e-01, -9.995380000000000376e-01, -9.999970000000000248e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, +-1.000000000000000000e+00, -9.999970000000000248e-01, -9.998139999999999805e-01, -9.966190000000000326e-01, -9.780339999999999590e-01, -9.545759999999999801e-01, -9.752389999999999670e-01, -9.954779999999999740e-01, -9.997519999999999740e-01, -9.999970000000000248e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999980000000000535e-01, -9.998369999999999758e-01, -9.954880000000000395e-01, -9.504259999999999931e-01, -7.896699999999999831e-01, -6.470510000000000428e-01, -8.003550000000000386e-01, -9.586339999999999861e-01, -9.975939999999999808e-01, -9.999730000000000008e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999430000000000263e-01, -9.972550000000000026e-01, -9.556320000000000370e-01, -7.292520000000000113e-01, -2.420829999999999926e-01, -2.454399999999999984e-02, -5.075699999999999656e-01, -9.040599999999999747e-01, -9.945370000000000044e-01, -9.999390000000000223e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.992020000000000346e-01, -9.800210000000000310e-01, -8.063310000000000199e-01, -2.593779999999999974e-01, 3.189710000000000045e-01, 1.385699999999999987e-01, -5.933460000000000401e-01, -9.467590000000000172e-01, -9.975420000000000398e-01, -9.999730000000000008e-01, -9.999810000000000088e-01, -9.999059999999999615e-01, -9.997890000000000388e-01, -9.997160000000000490e-01, -9.997420000000000195e-01, -9.998690000000000078e-01, -9.933290000000000175e-01, -9.030359999999999498e-01, -4.857190000000000119e-01, 2.202580000000000093e-01, 3.925609999999999933e-01, -2.135680000000000078e-01, -8.084810000000000052e-01, -9.859269999999999978e-01, -9.996680000000000010e-01, -9.998460000000000125e-01, -9.982060000000000377e-01, -9.917500000000000204e-01, -9.816620000000000346e-01, -9.754720000000000057e-01, -9.776810000000000223e-01, -9.885800000000000143e-01, -9.579349999999999810e-01, -6.812009999999999454e-01, -1.472900000000000077e-02, 4.044590000000000130e-01, 1.744000000000000107e-03, -6.527589999999999781e-01, -9.469760000000000399e-01, -9.971389999999999976e-01, -9.990179999999999616e-01, -9.935869999999999980e-01, -9.621610000000000440e-01, -8.605129999999999724e-01, -7.114340000000000108e-01, -6.217570000000000041e-01, -6.545539999999999692e-01, -8.180990000000000206e-01, -8.326540000000000052e-01, -2.617280000000000162e-01, 3.754509999999999792e-01, 2.040089999999999959e-01, -4.992320000000000091e-01, -9.049289999999999834e-01, -9.926559999999999828e-01, -9.970080000000000053e-01, -9.778109999999999857e-01, -9.049239999999999506e-01, -7.120379999999999487e-01, -3.425619999999999776e-01, 6.654699999999999505e-02, 2.899360000000000270e-01, 2.038639999999999897e-01, -2.888930000000000109e-01, -6.016200000000000436e-01, 2.237599999999999867e-01, 4.728720000000000145e-01, -2.020810000000000106e-01, -8.067750000000000199e-01, -9.818890000000000118e-01, -9.959559999999999524e-01, -9.594920000000000115e-01, -8.015440000000000342e-01, -4.776880000000000015e-01, -5.933299999999999685e-02, 3.293409999999999949e-01, 4.718570000000000264e-01, 5.348239999999999661e-01, 6.105019999999999891e-01, 1.929130000000000011e-01, -3.182189999999999741e-01, 4.499960000000000071e-01, 2.788849999999999940e-01, -5.529119999999999591e-01, -9.429680000000000284e-01, -9.955770000000000453e-01, -9.679489999999999483e-01, -7.739960000000000173e-01, -2.748309999999999920e-01, 2.607160000000000033e-01, 4.484049999999999980e-01, 2.828910000000000036e-01, -7.138799999999999313e-02, -6.642099999999999393e-02, 4.065540000000000265e-01, 2.446029999999999871e-01, 3.899699999999999694e-02, 5.033360000000000056e-01, -4.535299999999999748e-02, -7.580999999999999961e-01, -9.829919999999999769e-01, -9.917150000000000132e-01, -8.703159999999999785e-01, -3.756889999999999952e-01, 3.230350000000000166e-01, 4.952420000000000155e-01, 9.888500000000000068e-02, -3.883220000000000005e-01, -4.875369999999999981e-01, -8.031599999999999850e-02, 3.734810000000000074e-01, -2.383000000000000049e-02, 2.615910000000000180e-01, 5.028839999999999977e-01, -2.584890000000000243e-01, -8.368999999999999773e-01, -9.704739999999999478e-01, -9.594789999999999708e-01, -6.982570000000000165e-01, 6.056000000000000272e-02, 5.625900000000000345e-01, 2.014019999999999977e-01, -3.725189999999999890e-01, -4.919939999999999869e-01, -1.114050000000000040e-01, 3.437359999999999860e-01, 2.275850000000000095e-01, -4.526970000000000161e-01, 1.003830000000000000e-01, 4.796369999999999800e-01, -4.047699999999999909e-02, -5.253360000000000252e-01, -6.631690000000000085e-01, -6.518180000000000085e-01, -3.370239999999999903e-01, 4.402659999999999907e-01, 7.036090000000000400e-01, 2.616310000000000024e-01, -4.629099999999999882e-02, 1.247849999999999931e-01, 3.785680000000000156e-01, 2.745529999999999915e-01, -3.034560000000000035e-01, -8.094130000000000491e-01, -3.392160000000000175e-01, 2.911190000000000166e-01, 4.478119999999999878e-01, 2.841810000000000169e-01, 1.725970000000000004e-01, 1.636219999999999897e-01, 3.333510000000000084e-01, 7.324669999999999792e-01, 8.364880000000000093e-01, 6.596779999999999866e-01, 4.947179999999999911e-01, 3.596230000000000260e-01, 6.418400000000000494e-02, -3.763210000000000166e-01, -7.848289999999999988e-01, -9.641279999999999850e-01, -7.788399999999999768e-01, -3.283260000000000067e-01, 1.826979999999999993e-01, 4.072209999999999996e-01, 4.398770000000000180e-01, 4.419750000000000068e-01, 4.685380000000000100e-01, 5.024669999999999970e-01, 4.371590000000000198e-01, 3.300500000000000100e-01, 8.870500000000000607e-02, -2.866989999999999816e-01, -6.432419999999999805e-01, -8.643650000000000500e-01, -9.685209999999999653e-01, -9.969440000000000524e-01, -9.666979999999999462e-01, -8.456479999999999553e-01, -6.185110000000000330e-01, -4.195189999999999753e-01, -3.446670000000000011e-01, -3.342269999999999963e-01, -3.463689999999999825e-01, -4.145019999999999816e-01, -5.345849999999999769e-01, -6.055599999999999872e-01, -7.047379999999999756e-01, -8.486580000000000235e-01, -9.541119999999999601e-01, -9.905789999999999873e-01, -9.983819999999999917e-01, -9.998939999999999495e-01, -9.982809999999999739e-01, -9.897010000000000529e-01, -9.606010000000000382e-01, -9.117140000000000244e-01, -8.874419999999999531e-01, -8.837279999999999580e-01, -8.886560000000000015e-01, -9.140369999999999884e-01, -9.559229999999999672e-01, -9.734709999999999752e-01, -9.812159999999999771e-01, -9.910759999999999570e-01, -9.978909999999999725e-01, -9.997979999999999645e-01, -9.999810000000000088e-01, -9.999989999999999712e-01, +-9.981079999999999952e-01, -9.638900000000000245e-01, -7.673659999999999926e-01, -2.878439999999999888e-01, 2.341890000000000083e-01, 4.676179999999999781e-01, 5.042510000000000048e-01, 5.016939999999999733e-01, 4.801219999999999932e-01, 3.454900000000000193e-01, -6.736999999999999933e-03, -4.381289999999999907e-01, -7.494800000000000351e-01, -9.366400000000000281e-01, -9.944420000000000481e-01, -9.998240000000000460e-01, -9.919229999999999992e-01, -8.630259999999999598e-01, -3.455880000000000063e-01, 4.015329999999999733e-01, 7.366509999999999447e-01, 6.913629999999999498e-01, 5.819159999999999888e-01, 5.270550000000000512e-01, 5.444989999999999553e-01, 5.688980000000000148e-01, 5.186180000000000234e-01, 3.642090000000000050e-01, -1.064640000000000031e-01, -6.902979999999999672e-01, -9.535810000000000120e-01, -9.976319999999999633e-01, -9.868759999999999755e-01, -7.869169999999999776e-01, -1.141999999999999960e-01, 5.454299999999999704e-01, 4.628650000000000264e-01, 1.139000000000000038e-03, -3.319489999999999941e-01, -4.679980000000000251e-01, -4.026799999999999824e-01, -2.014759999999999884e-01, 1.090420000000000000e-01, 5.561369999999999925e-01, 4.693010000000000237e-01, -2.451190000000000035e-01, -8.299600000000000311e-01, -9.896859999999999546e-01, -9.922189999999999621e-01, -8.700480000000000436e-01, -4.169459999999999833e-01, 1.373399999999999968e-02, -2.686060000000000114e-01, -6.914200000000000346e-01, -8.835169999999999968e-01, -9.425860000000000349e-01, -9.128619999999999512e-01, -7.964980000000000393e-01, -4.124470000000000081e-01, 3.843889999999999807e-01, 7.012939999999999729e-01, 1.581490000000000118e-01, -6.815440000000000387e-01, -9.794960000000000333e-01, -9.982649999999999579e-01, -9.697109999999999896e-01, -8.481670000000000043e-01, -7.238719999999999599e-01, -8.331269999999999509e-01, -9.562640000000000029e-01, -9.904990000000000183e-01, -9.886059999999999848e-01, -9.499870000000000259e-01, -7.771839999999999860e-01, -2.510830000000000006e-01, 5.462240000000000428e-01, 7.753590000000000204e-01, 2.161720000000000030e-01, -6.596440000000000081e-01, -9.779849999999999932e-01, -9.998960000000000070e-01, -9.981590000000000185e-01, -9.904249999999999998e-01, -9.819870000000000543e-01, -9.862069999999999448e-01, -9.836279999999999468e-01, -9.545780000000000376e-01, -8.613840000000000385e-01, -6.529260000000000064e-01, -2.222439999999999971e-01, 3.960919999999999996e-01, 7.985600000000000476e-01, 6.370780000000000332e-01, -1.015319999999999973e-01, -7.826849999999999641e-01, -9.865279999999999605e-01, -9.999989999999999712e-01, -9.999749999999999472e-01, -9.995570000000000288e-01, -9.922720000000000429e-01, -9.375529999999999697e-01, -7.899850000000000483e-01, -5.878679999999999461e-01, -2.961349999999999816e-01, 1.050139999999999962e-01, 5.383170000000000455e-01, 7.839110000000000245e-01, 6.556429999999999758e-01, 1.581349999999999978e-01, -5.542070000000000052e-01, -9.249490000000000212e-01, -9.959500000000000020e-01, -1.000000000000000000e+00, -9.999719999999999720e-01, -9.974939999999999918e-01, -9.525150000000000006e-01, -7.039530000000000509e-01, -1.841490000000000071e-01, 2.693470000000000031e-01, 5.657489999999999464e-01, 7.621790000000000509e-01, 8.794899999999999940e-01, 7.069879999999999498e-01, 8.978600000000000469e-02, -5.292769999999999975e-01, -8.836690000000000378e-01, -9.877160000000000384e-01, -9.995009999999999728e-01, -1.000000000000000000e+00, -9.999419999999999975e-01, -9.948249999999999593e-01, -9.076969999999999761e-01, -4.979180000000000272e-01, 2.081250000000000044e-01, 6.160609999999999697e-01, 6.964740000000000375e-01, 6.877750000000000252e-01, 6.993089999999999584e-01, 5.238779999999999548e-01, -9.077899999999999858e-02, -6.546239999999999837e-01, -9.253200000000000314e-01, -9.932659999999999823e-01, -9.997629999999999573e-01, -9.999989999999999712e-01, -9.999609999999999888e-01, -9.978470000000000395e-01, -9.592690000000000383e-01, -7.384619999999999518e-01, -2.760850000000000248e-01, 2.470400000000000026e-02, -2.028900000000000148e-02, -1.128060000000000035e-01, -1.263700000000000066e-02, 2.434250000000000025e-01, 2.889909999999999979e-01, -1.155059999999999976e-01, -6.710180000000000033e-01, -9.444360000000000532e-01, -9.969860000000000388e-01, -9.999029999999999863e-01, -9.986140000000000017e-01, -9.962689999999999602e-01, -9.933499999999999552e-01, -9.518590000000000106e-01, -8.313700000000000534e-01, -7.355030000000000179e-01, -7.579700000000000326e-01, -7.949979999999999825e-01, -7.193739999999999579e-01, -3.583839999999999804e-01, 2.627740000000000076e-01, 4.156500000000000195e-01, -1.765680000000000027e-01, -7.989979999999999860e-01, -9.874110000000000387e-01, -9.980970000000000120e-01, -9.744159999999999489e-01, -9.319570000000000354e-01, -9.535059999999999647e-01, -9.797080000000000233e-01, -9.788189999999999946e-01, -9.721640000000000281e-01, -9.703990000000000116e-01, -9.638210000000000388e-01, -9.095929999999999849e-01, -5.962709999999999955e-01, 1.384900000000000020e-01, 6.472449999999999593e-01, 2.482080000000000120e-01, -6.367789999999999839e-01, -9.742520000000000069e-01, -9.878000000000000114e-01, -8.519309999999999938e-01, -5.778370000000000450e-01, -6.101900000000000102e-01, -7.677709999999999813e-01, -8.192359999999999642e-01, -8.127459999999999685e-01, -7.648099999999999898e-01, -6.593409999999999549e-01, -4.941920000000000202e-01, -1.190080000000000027e-01, 5.140879999999999894e-01, 7.980770000000000364e-01, 3.512669999999999959e-01, -5.896099999999999675e-01, -9.677379999999999871e-01, -9.724479999999999791e-01, -6.663019999999999499e-01, 2.621899999999999925e-02, 1.771210000000000007e-01, -6.968799999999999994e-02, -1.701680000000000137e-01, -1.531969999999999998e-01, -4.003899999999999820e-02, 2.042660000000000031e-01, 4.641270000000000118e-01, 6.479850000000000332e-01, 7.893719999999999626e-01, 6.452259999999999662e-01, 6.800799999999999901e-02, -6.987100000000000533e-01, -9.783699999999999619e-01, -9.786059999999999759e-01, -7.037609999999999699e-01, 2.787399999999999947e-02, 5.020740000000000203e-01, 5.929429999999999978e-01, 6.279829999999999579e-01, 6.403919999999999613e-01, 6.377840000000000176e-01, 6.714040000000000008e-01, 7.021939999999999849e-01, 6.126629999999999576e-01, 3.825479999999999992e-01, -2.902499999999999872e-02, -5.488520000000000065e-01, -8.998169999999999780e-01, -9.938010000000000455e-01, -9.937319999999999487e-01, -8.988930000000000531e-01, -5.493149999999999977e-01, -6.138500000000000206e-02, 2.785079999999999778e-01, 4.566049999999999831e-01, 4.704360000000000208e-01, 3.507660000000000222e-01, 1.918739999999999890e-01, 3.332899999999999752e-02, -2.258090000000000097e-01, -5.235830000000000206e-01, -7.471060000000000478e-01, -9.176849999999999730e-01, -9.883260000000000378e-01, -9.994210000000000038e-01, +-1.000000000000000000e+00, -1.000000000000000000e+00, -9.999900000000000455e-01, -9.997899999999999565e-01, -9.976829999999999865e-01, -9.927460000000000173e-01, -9.923980000000000024e-01, -9.975640000000000063e-01, -9.998390000000000333e-01, -9.999980000000000535e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999980000000000535e-01, -9.999479999999999480e-01, -9.991339999999999666e-01, -9.915479999999999849e-01, -9.504340000000000011e-01, -8.729780000000000317e-01, -8.726829999999999865e-01, -9.596080000000000165e-01, -9.973319999999999963e-01, -9.999689999999999968e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.998740000000000405e-01, -9.976500000000000368e-01, -9.794129999999999781e-01, -8.824499999999999567e-01, -6.233319999999999972e-01, -3.459149999999999725e-01, -4.198180000000000245e-01, -8.212300000000000155e-01, -9.882600000000000273e-01, -9.998639999999999750e-01, -9.999970000000000248e-01, -9.999730000000000008e-01, -9.999160000000000270e-01, -9.998829999999999663e-01, -9.999019999999999575e-01, -9.999649999999999928e-01, -9.966380000000000239e-01, -9.629490000000000549e-01, -8.102000000000000313e-01, -4.236550000000000038e-01, 1.173639999999999961e-01, 3.936600000000000099e-01, 8.208300000000000318e-02, -6.777579999999999716e-01, -9.789740000000000109e-01, -9.997219999999999995e-01, -9.996610000000000218e-01, -9.974730000000000540e-01, -9.925089999999999746e-01, -9.897150000000000114e-01, -9.913049999999999917e-01, -9.967979999999999619e-01, -9.608630000000000226e-01, -7.701940000000000452e-01, -2.874499999999999833e-01, 2.824639999999999929e-01, 4.915649999999999742e-01, 3.047590000000000021e-01, -1.226239999999999969e-01, -7.465789999999999926e-01, -9.831800000000000539e-01, -9.972940000000000138e-01, -9.873950000000000227e-01, -9.462559999999999860e-01, -8.683750000000000080e-01, -8.267210000000000392e-01, -8.517630000000000479e-01, -9.393399999999999528e-01, -7.812019999999999520e-01, -2.706709999999999949e-01, 3.276169999999999916e-01, 4.458889999999999798e-01, 3.754400000000000098e-02, -4.666629999999999945e-01, -7.371459999999999679e-01, -9.261909999999999865e-01, -9.828120000000000189e-01, -9.472450000000000037e-01, -8.349210000000000242e-01, -5.957379999999999898e-01, -3.172900000000000165e-01, -1.978489999999999971e-01, -2.860289999999999777e-01, -6.242510000000000003e-01, -3.651150000000000229e-01, 3.176059999999999994e-01, 4.418730000000000158e-01, -7.831799999999999873e-02, -6.257380000000000164e-01, -9.049700000000000522e-01, -9.774699999999999500e-01, -9.697099999999999609e-01, -8.517839999999999856e-01, -5.919299999999999562e-01, -2.501749999999999807e-01, 1.785750000000000115e-01, 4.523530000000000051e-01, 5.131930000000000103e-01, 4.744280000000000164e-01, -9.254999999999999338e-03, 1.024469999999999964e-01, 5.279740000000000544e-01, 4.572299999999999975e-02, -6.280670000000000419e-01, -9.299460000000000504e-01, -9.924039999999999528e-01, -9.917610000000000037e-01, -8.720919999999999783e-01, -4.215949999999999975e-01, 1.810410000000000075e-01, 4.653200000000000114e-01, 4.655859999999999999e-01, 3.404690000000000216e-01, 3.477899999999999880e-01, 6.438030000000000141e-01, 3.223219999999999974e-01, 3.874630000000000019e-01, 4.806699999999999862e-01, -3.624470000000000192e-01, -8.839390000000000303e-01, -9.910729999999999817e-01, -9.992980000000000196e-01, -9.813770000000000548e-01, -7.102209999999999912e-01, 6.699800000000000200e-02, 5.831619999999999582e-01, 3.546889999999999765e-01, -1.637659999999999949e-01, -3.961439999999999961e-01, -6.468300000000000438e-02, 5.020489999999999675e-01, 1.715389999999999970e-01, 4.478389999999999871e-01, 4.489029999999999965e-01, -4.588510000000000089e-01, -9.120479999999999698e-01, -9.785580000000000389e-01, -9.832009999999999916e-01, -9.630049999999999999e-01, -6.288479999999999626e-01, 2.212280000000000080e-01, 4.346530000000000116e-01, -2.164010000000000100e-01, -6.838199999999999834e-01, -5.579009999999999803e-01, 8.209900000000000531e-02, 4.127810000000000090e-01, -1.943020000000000025e-01, 3.531460000000000155e-01, 5.549539999999999473e-01, -8.643800000000000094e-02, -5.576809999999999823e-01, -7.063540000000000374e-01, -7.371919999999999584e-01, -7.603729999999999656e-01, -5.268469999999999542e-01, 6.800900000000000001e-02, 1.054960000000000064e-01, -3.759379999999999944e-01, -4.755820000000000047e-01, -9.471799999999999664e-02, 3.599820000000000242e-01, 1.593489999999999907e-01, -5.666539999999999910e-01, -4.232799999999999757e-02, 5.357260000000000355e-01, 5.419399999999999773e-01, 2.748499999999999832e-01, 7.790500000000000203e-02, 1.149400000000000074e-02, -8.034099999999999575e-02, -5.118999999999999939e-02, 1.194650000000000017e-01, 1.582610000000000128e-01, 1.542389999999999872e-01, 2.814320000000000155e-01, 3.595550000000000135e-01, 1.167360000000000064e-01, -4.186070000000000069e-01, -8.536270000000000246e-01, -5.914359999999999618e-01, 3.788000000000000134e-03, 4.162959999999999994e-01, 5.051090000000000302e-01, 4.775039999999999840e-01, 4.356450000000000045e-01, 4.223770000000000024e-01, 4.078030000000000266e-01, 4.383630000000000027e-01, 4.332909999999999817e-01, 4.064949999999999952e-01, 3.214739999999999820e-01, -1.074499999999999934e-02, -5.162700000000000067e-01, -8.534640000000000004e-01, -9.753950000000000120e-01, -9.159960000000000324e-01, -6.974339999999999984e-01, -4.367389999999999883e-01, -2.475509999999999933e-01, -1.656199999999999894e-01, -2.064199999999999924e-01, -1.434920000000000084e-01, -1.471600000000000130e-01, -9.934400000000000175e-02, -1.565469999999999917e-01, -3.238219999999999987e-01, -4.862779999999999880e-01, -7.060650000000000537e-01, -9.053480000000000416e-01, -9.841450000000000475e-01, -9.983840000000000492e-01, -9.943009999999999904e-01, -9.679830000000000378e-01, -9.113649999999999807e-01, -8.473500000000000476e-01, -8.134740000000000304e-01, -8.295970000000000288e-01, -8.026010000000000089e-01, -8.036219999999999475e-01, -7.840160000000000462e-01, -8.079730000000000523e-01, -8.760839999999999739e-01, -9.281700000000000506e-01, -9.713899999999999757e-01, -9.939529999999999754e-01, -9.993319999999999981e-01, -9.999620000000000175e-01, -9.998810000000000198e-01, -9.987549999999999484e-01, -9.954100000000000170e-01, -9.911440000000000250e-01, -9.888080000000000203e-01, -9.899280000000000301e-01, -9.880499999999999838e-01, -9.881189999999999696e-01, -9.867569999999999952e-01, -9.884209999999999940e-01, -9.931280000000000108e-01, -9.965509999999999646e-01, -9.989909999999999624e-01, -9.998890000000000278e-01, -9.999930000000000208e-01, -1.000000000000000000e+00, +-1.000000000000000000e+00, -1.000000000000000000e+00, -9.999970000000000248e-01, -9.998409999999999798e-01, -9.972020000000000328e-01, -9.761370000000000324e-01, -8.540100000000000469e-01, -5.194410000000000416e-01, -9.588299999999999601e-02, 5.394600000000000090e-02, -3.946649999999999880e-01, -8.580910000000000482e-01, -9.913399999999999990e-01, -9.999010000000000398e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999959999999999960e-01, -9.998029999999999973e-01, -9.955720000000000125e-01, -9.563770000000000326e-01, -8.009880000000000333e-01, -4.063089999999999757e-01, 1.930870000000000086e-01, 4.775909999999999878e-01, 2.283389999999999864e-01, -4.042339999999999822e-01, -8.695000000000000506e-01, -9.921790000000000331e-01, -9.999109999999999943e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999959999999999960e-01, -9.997949999999999893e-01, -9.951539999999999830e-01, -9.475839999999999819e-01, -7.313960000000000461e-01, -2.586049999999999738e-01, 2.826190000000000091e-01, 5.578870000000000218e-01, 2.574009999999999909e-01, -3.556400000000000117e-01, -7.837669999999999915e-01, -9.596980000000000510e-01, -9.976880000000000193e-01, -9.999740000000000295e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.998029999999999973e-01, -9.950269999999999948e-01, -9.456780000000000186e-01, -7.133869999999999933e-01, -1.758919999999999928e-01, 4.002870000000000039e-01, 5.516839999999999522e-01, 2.288699999999999901e-01, -3.980299999999999949e-01, -8.303070000000000173e-01, -9.707980000000000498e-01, -9.966979999999999729e-01, -9.998430000000000373e-01, -9.999980000000000535e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.963419999999999499e-01, -9.478680000000000438e-01, -7.083500000000000352e-01, -1.572820000000000051e-01, 4.290510000000000157e-01, 5.155260000000000398e-01, 6.981600000000000306e-02, -4.716119999999999757e-01, -8.436669999999999447e-01, -9.765909999999999869e-01, -9.980860000000000287e-01, -9.999090000000000478e-01, -9.999980000000000535e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.713260000000000227e-01, -7.660850000000000160e-01, -1.856089999999999962e-01, 4.482920000000000238e-01, 5.260949999999999793e-01, 2.863999999999999792e-03, -5.922889999999999544e-01, -8.902970000000000050e-01, -9.805460000000000287e-01, -9.983429999999999804e-01, -9.999000000000000110e-01, -9.998700000000000365e-01, -9.997589999999999533e-01, -9.997169999999999668e-01, -9.997629999999999573e-01, -9.998970000000000358e-01, -8.755249999999999977e-01, -3.933650000000000202e-01, 3.601650000000000129e-01, 6.137660000000000338e-01, 8.204000000000000181e-02, -5.906979999999999453e-01, -9.166630000000000056e-01, -9.905439999999999801e-01, -9.989900000000000446e-01, -9.994070000000000453e-01, -9.966559999999999864e-01, -9.886810000000000320e-01, -9.790980000000000238e-01, -9.755669999999999620e-01, -9.795270000000000366e-01, -9.910170000000000368e-01, -6.575600000000000334e-01, 9.662300000000000055e-02, 6.376030000000000308e-01, 3.687719999999999887e-01, -4.316249999999999809e-01, -8.899660000000000348e-01, -9.902090000000000058e-01, -9.987610000000000099e-01, -9.951100000000000501e-01, -9.809210000000000429e-01, -9.321350000000000469e-01, -8.127020000000000355e-01, -6.737999999999999545e-01, -6.229449999999999710e-01, -6.806999999999999718e-01, -8.523399999999999865e-01, -3.262869999999999937e-01, 4.729999999999999760e-01, 5.660979999999999901e-01, -1.339730000000000087e-01, -7.745830000000000215e-01, -9.773110000000000408e-01, -9.955810000000000493e-01, -9.773089999999999833e-01, -9.120479999999999698e-01, -7.668819999999999526e-01, -5.267960000000000420e-01, -1.733270000000000088e-01, 1.724400000000000099e-01, 2.967650000000000010e-01, 1.516760000000000053e-01, -3.596590000000000065e-01, 5.601699999999999735e-02, 6.344410000000000327e-01, 3.005999999999999783e-01, -5.434689999999999799e-01, -9.375909999999999522e-01, -9.913619999999999655e-01, -9.450479999999999992e-01, -7.700010000000000465e-01, -4.640000000000000235e-01, -8.389199999999999435e-02, 2.959379999999999789e-01, 5.346060000000000256e-01, 6.073769999999999447e-01, 6.735499999999999821e-01, 6.957999999999999741e-01, 1.982770000000000088e-01, 3.538259999999999739e-01, 6.584079999999999933e-01, 1.139699999999999915e-02, -7.391389999999999905e-01, -9.788540000000000019e-01, -9.481439999999999868e-01, -6.979670000000000041e-01, -1.587540000000000062e-01, 3.584089999999999776e-01, 5.570760000000000156e-01, 5.161059999999999537e-01, 3.482509999999999772e-01, 1.696610000000000062e-01, 3.687059999999999782e-01, 6.665529999999999511e-01, 2.324150000000000105e-01, 4.524119999999999808e-01, 6.011649999999999494e-01, -2.301529999999999965e-01, -8.344289999999999763e-01, -9.682290000000000063e-01, -8.032150000000000123e-01, -2.007839999999999903e-01, 4.742379999999999929e-01, 6.425290000000000168e-01, 3.184589999999999921e-01, -1.645089999999999886e-01, -3.864900000000000002e-01, -1.637810000000000099e-01, 3.560400000000000231e-01, 4.626020000000000132e-01, -1.633650000000000102e-01, 4.320220000000000171e-01, 6.335269999999999513e-01, -8.046399999999999386e-02, -6.243269999999999653e-01, -7.814569999999999572e-01, -5.411890000000000311e-01, 2.733700000000000019e-01, 7.055979999999999475e-01, 3.551219999999999932e-01, -2.566030000000000255e-01, -5.033760000000000456e-01, -2.989240000000000230e-01, 2.182860000000000078e-01, 4.306719999999999993e-01, 1.294900000000000044e-02, -6.267369999999999886e-01, 2.077380000000000060e-01, 6.903080000000000327e-01, 4.742879999999999874e-01, 9.430900000000000394e-02, -1.230279999999999985e-01, -6.237000000000000356e-03, 6.192269999999999719e-01, 8.019880000000000342e-01, 3.798270000000000257e-01, -3.532400000000000123e-02, 5.718299999999999772e-02, 3.409960000000000213e-01, 3.857320000000000193e-01, -6.424000000000000023e-03, -5.768240000000000034e-01, -9.070580000000000309e-01, -3.005939999999999723e-01, 3.440150000000000152e-01, 5.949210000000000331e-01, 6.079649999999999777e-01, 6.151590000000000114e-01, 6.641709999999999559e-01, 8.488449999999999607e-01, 8.884469999999999867e-01, 7.228529999999999678e-01, 5.132970000000000033e-01, 4.251650000000000151e-01, 2.606859999999999733e-01, -1.879570000000000130e-01, -6.466709999999999958e-01, -9.105130000000000168e-01, -9.894249999999999989e-01, -7.856840000000000490e-01, -4.267690000000000095e-01, -9.207600000000000506e-02, 1.683649999999999869e-01, 3.832749999999999768e-01, 4.562720000000000109e-01, 4.728749999999999898e-01, 4.704800000000000093e-01, 3.851760000000000184e-01, 1.245170000000000027e-01, -1.989710000000000090e-01, -5.082919999999999661e-01, -7.861470000000000402e-01, -9.440340000000000398e-01, -9.920400000000000329e-01, -9.994549999999999823e-01, +-1.000000000000000000e+00, -1.000000000000000000e+00, -9.999700000000000255e-01, -9.985479999999999912e-01, -9.684730000000000283e-01, -7.095500000000000140e-01, -7.298100000000000420e-02, 2.636479999999999935e-01, -8.694799999999999751e-02, -6.486779999999999768e-01, -9.054919999999999636e-01, -9.745530000000000026e-01, -9.953760000000000385e-01, -9.995920000000000361e-01, -9.999820000000000375e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999930000000000208e-01, -9.994330000000000158e-01, -9.859480000000000466e-01, -8.564169999999999838e-01, -3.488120000000000109e-01, 4.450819999999999776e-01, 7.302790000000000115e-01, 3.767759999999999998e-01, -1.120089999999999975e-01, -4.609159999999999924e-01, -7.383049999999999891e-01, -9.254360000000000364e-01, -9.894359999999999822e-01, -9.991649999999999698e-01, -9.999689999999999968e-01, -9.999980000000000535e-01, -9.998089999999999478e-01, -9.932750000000000190e-01, -9.099019999999999886e-01, -5.238410000000000011e-01, 2.129359999999999864e-01, 7.360839999999999606e-01, 6.251659999999999995e-01, 1.902629999999999877e-01, 2.588070000000000093e-01, 3.203710000000000169e-01, -6.539200000000000568e-02, -5.842690000000000383e-01, -8.951419999999999932e-01, -9.873549999999999827e-01, -9.994129999999999958e-01, -9.999700000000000255e-01, -9.975319999999999743e-01, -9.516400000000000414e-01, -6.654290000000000482e-01, 2.285600000000000132e-02, 6.596670000000000034e-01, 7.272629999999999928e-01, 1.874570000000000125e-01, -3.814190000000000080e-01, -1.379759999999999875e-01, 4.412170000000000258e-01, 5.373649999999999816e-01, 6.529600000000000681e-02, -5.923599999999999977e-01, -9.274139999999999606e-01, -9.952830000000000288e-01, -9.997390000000000443e-01, -9.880280000000000173e-01, -8.309379999999999544e-01, -2.529270000000000129e-01, 5.170519999999999561e-01, 7.708080000000000487e-01, 3.588080000000000158e-01, -3.904560000000000253e-01, -8.147429999999999950e-01, -6.801779999999999493e-01, -9.802700000000000302e-02, 5.083699999999999886e-01, 5.347920000000000451e-01, -1.111489999999999978e-01, -7.485380000000000367e-01, -9.711610000000000520e-01, -9.977819999999999467e-01, -9.514049999999999452e-01, -6.170069999999999721e-01, 1.752450000000000119e-01, 7.180379999999999541e-01, 5.057279999999999553e-01, -2.236350000000000005e-01, -7.903769999999999962e-01, -9.685580000000000300e-01, -9.324799999999999756e-01, -6.316540000000000488e-01, 5.454500000000000320e-02, 6.317930000000000490e-01, 4.015859999999999985e-01, -3.959010000000000029e-01, -8.859709999999999530e-01, -9.904509999999999703e-01, -8.418130000000000335e-01, -2.555899999999999839e-01, 5.434069999999999734e-01, 6.721690000000000165e-01, 2.506200000000000094e-02, -6.758809999999999540e-01, -9.531760000000000232e-01, -9.967300000000000049e-01, -9.902400000000000091e-01, -8.706620000000000470e-01, -3.365389999999999771e-01, 5.112510000000000110e-01, 6.475149999999999517e-01, -6.151000000000000217e-02, -7.717070000000000318e-01, -9.742169999999999996e-01, -6.715419999999999723e-01, 1.570809999999999984e-01, 7.162570000000000325e-01, 4.360299999999999732e-01, -3.933849999999999847e-01, -8.853269999999999751e-01, -9.921130000000000226e-01, -9.997859999999999525e-01, -9.981820000000000137e-01, -9.523580000000000378e-01, -5.448739999999999695e-01, 3.806959999999999789e-01, 6.650479999999999725e-01, 1.734099999999999878e-02, -7.413950000000000262e-01, -9.188760000000000261e-01, -4.498010000000000064e-01, 4.522220000000000129e-01, 6.866550000000000153e-01, 4.376399999999999735e-02, -6.968539999999999734e-01, -9.667459999999999942e-01, -9.986279999999999601e-01, -9.999829999999999552e-01, -9.996110000000000273e-01, -9.750269999999999770e-01, -6.358049999999999535e-01, 2.580509999999999748e-01, 6.488390000000000546e-01, 8.176600000000000534e-02, -7.138229999999999853e-01, -7.927210000000000090e-01, -1.103390000000000065e-01, 6.605910000000000393e-01, 6.028210000000000512e-01, -2.746720000000000272e-01, -8.598909999999999609e-01, -9.912079999999999780e-01, -9.998430000000000373e-01, -9.999869999999999592e-01, -9.996909999999999963e-01, -9.799069999999999725e-01, -6.927130000000000232e-01, 1.256400000000000017e-01, 5.979959999999999720e-01, 8.597399999999999487e-02, -7.105939999999999479e-01, -7.064259999999999984e-01, 1.054950000000000054e-01, 7.535380000000000411e-01, 5.387579999999999592e-01, -4.254820000000000269e-01, -9.195990000000000553e-01, -9.951640000000000486e-01, -9.995300000000000296e-01, -9.986800000000000122e-01, -9.946559999999999846e-01, -9.627580000000000027e-01, -6.583670000000000355e-01, 1.511440000000000006e-01, 6.272489999999999455e-01, 1.430579999999999907e-01, -6.872709999999999653e-01, -7.405019999999999936e-01, 1.638200000000000073e-02, 6.954150000000000054e-01, 5.443839999999999790e-01, -3.204330000000000234e-01, -8.316620000000000124e-01, -9.548499999999999766e-01, -9.713199999999999612e-01, -9.583390000000000519e-01, -9.073579999999999979e-01, -7.744699999999999918e-01, -3.537950000000000261e-01, 3.734680000000000222e-01, 6.627880000000000438e-01, 8.875099999999999656e-02, -7.108790000000000386e-01, -8.519499999999999851e-01, -3.016800000000000037e-01, 4.682490000000000263e-01, 6.738340000000000440e-01, 2.025000000000000133e-01, -3.146959999999999757e-01, -5.416260000000000518e-01, -5.828710000000000280e-01, -5.470059999999999922e-01, -4.093439999999999857e-01, -1.299970000000000014e-01, 3.460340000000000082e-01, 7.377150000000000096e-01, 6.421050000000000368e-01, -8.693700000000000039e-02, -7.796950000000000269e-01, -9.553939999999999655e-01, -6.889079999999999648e-01, -5.955699999999999883e-02, 5.008770000000000167e-01, 6.413990000000000524e-01, 5.226169999999999982e-01, 4.169370000000000021e-01, 3.959889999999999799e-01, 4.210149999999999726e-01, 5.101980000000000404e-01, 6.598159999999999581e-01, 8.094240000000000324e-01, 7.524340000000000472e-01, 2.860440000000000205e-01, -4.554860000000000020e-01, -8.949829999999999730e-01, -9.942800000000000527e-01, -9.287480000000000180e-01, -6.642569999999999864e-01, -1.777910000000000046e-01, 3.138790000000000191e-01, 6.192600000000000326e-01, 7.436599999999999877e-01, 8.396230000000000082e-01, 8.436489999999999823e-01, 7.704239999999999977e-01, 7.148430000000000062e-01, 5.697179999999999467e-01, 2.059999999999999887e-01, -4.113990000000000147e-01, -8.371979999999999977e-01, -9.765909999999999869e-01, -9.997120000000000450e-01, -9.937369999999999814e-01, -9.450960000000000472e-01, -7.861749999999999572e-01, -4.838660000000000183e-01, -9.814100000000000601e-02, 1.764900000000000080e-01, 4.212069999999999981e-01, 4.166460000000000163e-01, 1.843950000000000033e-01, -1.423600000000000039e-02, -2.918330000000000091e-01, -5.729509999999999881e-01, -8.581590000000000051e-01, -9.798499999999999988e-01, -9.982680000000000442e-01, +-1.000000000000000000e+00, -9.999980000000000535e-01, -9.998139999999999805e-01, -9.925359999999999738e-01, -8.940909999999999691e-01, -4.773229999999999973e-01, 7.837299999999999822e-02, -2.449600000000000041e-02, -5.304339999999999611e-01, -8.222869999999999902e-01, -9.443089999999999540e-01, -9.900820000000000176e-01, -9.991039999999999921e-01, -9.999599999999999600e-01, -9.999989999999999712e-01, -1.000000000000000000e+00, -9.999989999999999712e-01, -9.999209999999999487e-01, -9.970879999999999743e-01, -9.539220000000000477e-01, -6.749039999999999484e-01, 2.440799999999999914e-02, 6.375389999999999668e-01, 6.045890000000000430e-01, 1.954990000000000061e-01, -2.315859999999999863e-01, -6.225300000000000278e-01, -8.890040000000000164e-01, -9.831069999999999531e-01, -9.986030000000000184e-01, -9.999470000000000303e-01, -9.999989999999999712e-01, -9.999670000000000503e-01, -9.985070000000000334e-01, -9.733380000000000365e-01, -7.904740000000000100e-01, -2.296970000000000123e-01, 5.007270000000000332e-01, 7.893470000000000208e-01, 6.764310000000000045e-01, 6.254210000000000047e-01, 5.193130000000000246e-01, 9.871000000000000607e-02, -4.840130000000000265e-01, -8.628029999999999866e-01, -9.823089999999999877e-01, -9.991550000000000153e-01, -9.999909999999999632e-01, -9.995140000000000136e-01, -9.864530000000000243e-01, -8.540200000000000014e-01, -3.697320000000000051e-01, 3.609789999999999943e-01, 7.299579999999999957e-01, 4.676939999999999986e-01, 2.896699999999999969e-02, 1.992079999999999962e-01, 6.063770000000000548e-01, 6.520869999999999722e-01, 1.776270000000000071e-01, -5.431559999999999722e-01, -9.210429999999999451e-01, -9.956519999999999815e-01, -9.999489999999999768e-01, -9.972550000000000026e-01, -9.427750000000000297e-01, -5.819339999999999513e-01, 2.171210000000000084e-01, 7.395429999999999504e-01, 5.820640000000000258e-01, -1.385540000000000105e-01, -6.551219999999999821e-01, -5.308079999999999465e-01, 7.768799999999999317e-02, 6.599009999999999598e-01, 5.923059999999999992e-01, -1.487650000000000083e-01, -7.986429999999999918e-01, -9.865949999999999998e-01, -9.997719999999999940e-01, -9.942560000000000286e-01, -8.931240000000000290e-01, -3.671090000000000186e-01, 5.377359999999999918e-01, 7.717049999999999743e-01, 2.126260000000000094e-01, -5.910050000000000026e-01, -9.317360000000000086e-01, -8.866779999999999662e-01, -4.425180000000000224e-01, 3.633730000000000016e-01, 7.284389999999999477e-01, 2.550979999999999914e-01, -6.115880000000000205e-01, -9.621210000000000040e-01, -9.986800000000000122e-01, -9.941130000000000244e-01, -8.897749999999999826e-01, -3.422189999999999954e-01, 5.533219999999999805e-01, 5.569579999999999531e-01, -2.412910000000000055e-01, -8.341979999999999951e-01, -9.874340000000000339e-01, -9.702479999999999993e-01, -6.777969999999999828e-01, 1.231720000000000037e-01, 7.482469999999999954e-01, 5.237349999999999506e-01, -4.056219999999999826e-01, -9.091900000000000537e-01, -9.953739999999999810e-01, -9.923830000000000151e-01, -8.648740000000000316e-01, -2.866909999999999736e-01, 4.854879999999999751e-01, 2.437360000000000082e-01, -5.753580000000000361e-01, -9.452439999999999731e-01, -9.972239999999999993e-01, -9.815709999999999713e-01, -7.158569999999999656e-01, 8.152700000000000224e-02, 7.605910000000000171e-01, 6.399540000000000228e-01, -2.302500000000000102e-01, -8.447040000000000104e-01, -9.909829999999999472e-01, -9.922349999999999781e-01, -8.628120000000000234e-01, -2.872990000000000266e-01, 4.018320000000000225e-01, 1.114399999999999939e-02, -7.286730000000000151e-01, -9.796249999999999680e-01, -9.993020000000000236e-01, -9.810149999999999704e-01, -7.045179999999999776e-01, 1.104289999999999994e-01, 7.753470000000000084e-01, 6.681749999999999634e-01, -1.690859999999999863e-01, -8.199429999999999774e-01, -9.892670000000000075e-01, -9.911680000000000490e-01, -8.474909999999999943e-01, -2.533290000000000264e-01, 3.676780000000000048e-01, -1.115479999999999944e-01, -7.871040000000000258e-01, -9.867580000000000240e-01, -9.991970000000000018e-01, -9.749550000000000161e-01, -6.755799999999999583e-01, 1.568440000000000112e-01, 7.843010000000000259e-01, 6.055660000000000487e-01, -2.993210000000000037e-01, -8.717549999999999466e-01, -9.928470000000000351e-01, -9.906660000000000466e-01, -8.402319999999999789e-01, -2.331409999999999871e-01, 4.125599999999999823e-01, -1.752799999999999844e-02, -7.432729999999999615e-01, -9.789419999999999789e-01, -9.917010000000000547e-01, -9.341699999999999449e-01, -5.293080000000000007e-01, 3.628489999999999771e-01, 8.212639999999999940e-01, 4.679499999999999771e-01, -4.755849999999999800e-01, -9.323690000000000033e-01, -9.969189999999999996e-01, -9.900349999999999984e-01, -8.311169999999999947e-01, -2.054519999999999957e-01, 5.107140000000000013e-01, 2.353959999999999941e-01, -5.444080000000000030e-01, -8.748679999999999790e-01, -8.854769999999999586e-01, -7.087369999999999504e-01, -1.629510000000000125e-01, 6.195720000000000116e-01, 7.866450000000000387e-01, 1.993709999999999927e-01, -6.487720000000000153e-01, -9.697390000000000176e-01, -9.991189999999999793e-01, -9.901830000000000354e-01, -8.338470000000000049e-01, -2.155320000000000014e-01, 5.825979999999999492e-01, 6.006089999999999485e-01, 1.747699999999999948e-02, -3.331770000000000009e-01, -3.360819999999999919e-01, -4.672899999999999970e-02, 4.609790000000000276e-01, 8.152279999999999527e-01, 5.974289999999999878e-01, -1.809149999999999925e-01, -8.114949999999999664e-01, -9.878190000000000026e-01, -9.998099999999999765e-01, -9.942419999999999591e-01, -8.975959999999999495e-01, -4.476160000000000139e-01, 3.046940000000000204e-01, 6.771179999999999977e-01, 6.706069999999999531e-01, 6.023739999999999650e-01, 6.100400000000000267e-01, 7.172859999999999792e-01, 8.486350000000000282e-01, 7.364209999999999923e-01, 1.584270000000000123e-01, -5.897019999999999484e-01, -9.368720000000000381e-01, -9.967129999999999601e-01, -9.999620000000000175e-01, -9.985579999999999457e-01, -9.715660000000000407e-01, -8.064430000000000209e-01, -3.960159999999999791e-01, 1.218680000000000041e-01, 5.926740000000000341e-01, 8.422770000000000534e-01, 9.226590000000000069e-01, 8.967230000000000478e-01, 7.183009999999999673e-01, 2.757919999999999816e-01, -4.282380000000000075e-01, -8.740379999999999816e-01, -9.886939999999999618e-01, -9.996030000000000193e-01, -9.999959999999999960e-01, -9.999010000000000398e-01, -9.973560000000000203e-01, -9.720790000000000264e-01, -8.678230000000000111e-01, -5.962370000000000170e-01, -1.255239999999999967e-01, 2.974260000000000237e-01, 4.797640000000000238e-01, 4.036319999999999908e-01, 4.627699999999999869e-02, -4.244359999999999800e-01, -8.270539999999999559e-01, -9.783929999999999572e-01, -9.988679999999999781e-01, -9.999770000000000048e-01, -1.000000000000000000e+00, +-1.000000000000000000e+00, -9.999989999999999712e-01, -9.998979999999999535e-01, -9.944140000000000201e-01, -9.193130000000000468e-01, -6.860070000000000334e-01, -4.917940000000000089e-01, -3.503020000000000023e-01, 5.921099999999999974e-02, 1.041100000000000012e-02, -4.839160000000000128e-01, -8.739860000000000406e-01, -9.888510000000000355e-01, -9.996270000000000433e-01, -9.999959999999999960e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999890000000000168e-01, -9.989209999999999479e-01, -9.708790000000000475e-01, -7.120830000000000215e-01, -5.896799999999999958e-02, 2.788370000000000015e-01, 7.422800000000000231e-02, 2.170539999999999969e-01, 4.936670000000000225e-01, 1.743669999999999942e-01, -5.529650000000000398e-01, -9.273970000000000269e-01, -9.955920000000000325e-01, -9.999109999999999943e-01, -9.999989999999999712e-01, -9.999989999999999712e-01, -9.998639999999999750e-01, -9.929289999999999505e-01, -8.873969999999999914e-01, -3.837180000000000035e-01, 4.593340000000000201e-01, 6.476070000000000437e-01, 5.968099999999999794e-02, -2.045540000000000136e-01, 3.382370000000000099e-01, 5.421019999999999728e-01, -7.517999999999999683e-02, -7.425929999999999476e-01, -9.724319999999999631e-01, -9.988899999999999446e-01, -9.999890000000000168e-01, -9.999829999999999552e-01, -9.985589999999999744e-01, -9.653420000000000334e-01, -6.835120000000000084e-01, 7.296999999999999320e-02, 7.352800000000000447e-01, 6.593320000000000292e-01, -1.075160000000000005e-01, -5.812030000000000252e-01, -1.241799999999999987e-01, 5.603409999999999780e-01, 3.941029999999999811e-01, -3.945359999999999978e-01, -8.849430000000000351e-01, -9.934150000000000480e-01, -9.999230000000000063e-01, -9.998529999999999918e-01, -9.921189999999999731e-01, -8.760040000000000049e-01, -3.526960000000000095e-01, 4.954569999999999808e-01, 8.206560000000000521e-01, 4.228160000000000251e-01, -4.029300000000000104e-01, -8.264219999999999899e-01, -5.024589999999999890e-01, 3.795370000000000132e-01, 6.594100000000000517e-01, 6.471000000000000363e-02, -7.140229999999999633e-01, -9.801929999999999810e-01, -9.996559999999999890e-01, -9.991109999999999713e-01, -9.726329999999999698e-01, -6.991920000000000357e-01, 7.147799999999999987e-02, 7.417110000000000092e-01, 6.971089999999999787e-01, -2.765499999999999903e-02, -7.216620000000000257e-01, -9.461610000000000298e-01, -6.977419999999999733e-01, 1.079790000000000055e-01, 7.042580000000000506e-01, 3.939199999999999924e-01, -5.345969999999999889e-01, -9.493460000000000232e-01, -9.980139999999999567e-01, -9.957629999999999537e-01, -9.166959999999999553e-01, -4.514699999999999824e-01, 4.460480000000000000e-01, 8.430950000000000388e-01, 4.896769999999999734e-01, -3.904730000000000145e-01, -8.926150000000000473e-01, -9.827700000000000324e-01, -8.242930000000000534e-01, -1.833059999999999967e-01, 6.349240000000000439e-01, 5.812230000000000452e-01, -3.014800000000000257e-01, -8.706319999999999615e-01, -9.927470000000000461e-01, -9.885939999999999728e-01, -8.106670000000000265e-01, -1.524520000000000042e-01, 6.625929999999999875e-01, 7.996069999999999567e-01, 1.978060000000000096e-01, -6.366000000000000547e-01, -9.631600000000000161e-01, -9.948550000000000448e-01, -9.212740000000000373e-01, -4.343170000000000086e-01, 5.095549999999999802e-01, 6.914609999999999923e-01, -2.108399999999999858e-02, -7.582799999999999541e-01, -9.849799999999999667e-01, -9.827770000000000117e-01, -7.265380000000000171e-01, 5.796500000000000263e-02, 7.543349999999999778e-01, 6.803670000000000551e-01, -1.354859999999999953e-01, -8.042759999999999909e-01, -9.873790000000000067e-01, -9.986850000000000449e-01, -9.615270000000000206e-01, -5.593430000000000346e-01, 3.986819999999999808e-01, 7.479099999999999637e-01, 1.971640000000000059e-01, -6.678389999999999604e-01, -9.786970000000000391e-01, -9.795869999999999855e-01, -6.806029999999999580e-01, 1.699160000000000115e-01, 7.961190000000000211e-01, 6.149459999999999926e-01, -3.028509999999999813e-01, -8.749329999999999607e-01, -9.930590000000000250e-01, -9.978409999999999780e-01, -9.470990000000000242e-01, -5.160759999999999792e-01, 4.365749999999999909e-01, 7.617500000000000382e-01, 2.052339999999999998e-01, -6.648009999999999753e-01, -9.784859999999999669e-01, -9.777339999999999920e-01, -6.539460000000000273e-01, 2.347100000000000020e-01, 8.212880000000000180e-01, 5.999799999999999578e-01, -3.419710000000000250e-01, -8.907570000000000210e-01, -9.939010000000000344e-01, -9.924910000000000121e-01, -8.728749999999999565e-01, -3.136999999999999789e-01, 5.720750000000000002e-01, 7.423499999999999543e-01, 8.060100000000000597e-02, -7.168269999999999920e-01, -9.821020000000000305e-01, -9.822340000000000515e-01, -7.188029999999999697e-01, 7.561400000000000066e-02, 7.555460000000000509e-01, 6.344039999999999679e-01, -2.402120000000000088e-01, -8.342319999999999736e-01, -9.729430000000000023e-01, -9.649689999999999657e-01, -7.440740000000000132e-01, -3.490999999999999659e-02, 7.089339999999999531e-01, 7.138219999999999565e-01, -3.453400000000000220e-02, -7.641489999999999672e-01, -9.853859999999999841e-01, -9.900849999999999929e-01, -8.333890000000000464e-01, -2.259980000000000044e-01, 5.814550000000000551e-01, 6.986729999999999885e-01, 7.609200000000000685e-02, -4.862159999999999815e-01, -6.968649999999999567e-01, -6.816229999999999789e-01, -3.557219999999999827e-01, 3.541409999999999836e-01, 8.164270000000000138e-01, 5.921450000000000324e-01, -2.471839999999999871e-01, -8.440029999999999477e-01, -9.908439999999999470e-01, -9.966939999999999689e-01, -9.353010000000000490e-01, -5.730450000000000266e-01, 1.876780000000000115e-01, 6.799629999999999841e-01, 6.312750000000000306e-01, 3.480630000000000113e-01, 1.113859999999999989e-01, 1.238449999999999968e-01, 4.182930000000000259e-01, 7.676140000000000185e-01, 7.827220000000000288e-01, 2.443929999999999991e-01, -5.659359999999999946e-01, -9.386719999999999509e-01, -9.969970000000000221e-01, -9.994570000000000398e-01, -9.856169999999999654e-01, -8.540470000000000006e-01, -4.098820000000000241e-01, 2.222330000000000139e-01, 6.433590000000000142e-01, 7.773949999999999472e-01, 7.554790000000000116e-01, 7.672029999999999683e-01, 8.476040000000000241e-01, 8.226999999999999869e-01, 4.388409999999999811e-01, -3.040990000000000082e-01, -8.371469999999999745e-01, -9.860959999999999726e-01, -9.995600000000000041e-01, -9.999620000000000175e-01, -9.983619999999999717e-01, -9.748299999999999743e-01, -8.476059999999999706e-01, -5.138850000000000362e-01, -3.221000000000000252e-02, 3.553390000000000160e-01, 4.962779999999999969e-01, 5.169599999999999751e-01, 4.933790000000000120e-01, 2.992960000000000065e-01, -2.084910000000000097e-01, -7.450219999999999620e-01, -9.641739999999999755e-01, -9.980599999999999472e-01, -9.999660000000000215e-01, +-1.000000000000000000e+00, -1.000000000000000000e+00, -9.999980000000000535e-01, -9.999109999999999943e-01, -9.980109999999999815e-01, -9.765080000000000426e-01, -8.321119999999999628e-01, -4.132810000000000095e-01, 6.191599999999999882e-02, -1.512100000000000076e-02, -6.786839999999999540e-01, -9.739520000000000399e-01, -9.993630000000000013e-01, -9.999949999999999672e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999989999999999712e-01, -9.999200000000000310e-01, -9.976660000000000528e-01, -9.714749999999999774e-01, -8.316789999999999461e-01, -3.994249999999999745e-01, 2.811170000000000058e-01, 6.095589999999999620e-01, 2.228839999999999988e-01, -6.159989999999999633e-01, -9.645930000000000337e-01, -9.988700000000000356e-01, -9.999900000000000455e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999839999999999840e-01, -9.986399999999999721e-01, -9.732469999999999732e-01, -8.119279999999999831e-01, -3.630160000000000053e-01, 2.552240000000000064e-01, 6.330850000000000088e-01, 4.155610000000000137e-01, -2.360230000000000106e-01, -8.038279999999999870e-01, -9.836110000000000131e-01, -9.995220000000000216e-01, -9.999959999999999960e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999989999999999712e-01, -9.997880000000000100e-01, -9.900719999999999521e-01, -8.583929999999999616e-01, -3.676309999999999856e-01, 3.254110000000000058e-01, 6.478009999999999602e-01, 3.721610000000000196e-01, -2.761199999999999766e-01, -7.610130000000000505e-01, -9.566799999999999748e-01, -9.972640000000000393e-01, -9.999489999999999768e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999719999999999720e-01, -9.976890000000000480e-01, -9.496909999999999519e-01, -5.970659999999999856e-01, 2.117870000000000030e-01, 6.937159999999999993e-01, 4.559150000000000147e-01, -2.400990000000000069e-01, -7.768019999999999925e-01, -9.638409999999999478e-01, -9.964420000000000499e-01, -9.997920000000000140e-01, -9.999639999999999640e-01, -9.999909999999999632e-01, -9.999989999999999712e-01, -1.000000000000000000e+00, -9.997380000000000155e-01, -9.879609999999999781e-01, -8.284719999999999862e-01, -2.235929999999999862e-01, 5.583439999999999515e-01, 5.977459999999999996e-01, -8.387600000000000611e-02, -7.176749999999999519e-01, -9.565979999999999484e-01, -9.950820000000000221e-01, -9.955049999999999732e-01, -9.950639999999999485e-01, -9.968050000000000521e-01, -9.990919999999999801e-01, -9.999249999999999527e-01, -9.999980000000000535e-01, -9.979550000000000365e-01, -9.527039999999999953e-01, -6.027689999999999992e-01, 2.202070000000000138e-01, 6.620519999999999738e-01, 2.264660000000000006e-01, -5.507570000000000521e-01, -9.225320000000000187e-01, -9.813669999999999893e-01, -9.569060000000000343e-01, -9.130939999999999612e-01, -9.041209999999999525e-01, -9.337459999999999649e-01, -9.776709999999999567e-01, -9.970539999999999958e-01, -9.998559999999999670e-01, -9.910269999999999913e-01, -8.507390000000000230e-01, -2.701600000000000112e-01, 5.434059999999999446e-01, 5.735689999999999955e-01, -2.125509999999999899e-01, -8.019079999999999542e-01, -9.169399999999999773e-01, -8.156670000000000309e-01, -6.133600000000000163e-01, -4.196719999999999895e-01, -3.841660000000000075e-01, -5.232970000000000121e-01, -7.941409999999999858e-01, -9.593110000000000248e-01, -9.970970000000000111e-01, -9.751560000000000228e-01, -6.797109999999999541e-01, 1.385709999999999997e-01, 6.864390000000000214e-01, 3.392689999999999872e-01, -4.874479999999999924e-01, -7.319799999999999640e-01, -5.256499999999999506e-01, -1.906569999999999931e-01, 2.180199999999999916e-01, 5.021109999999999740e-01, 5.525290000000000479e-01, 3.290899999999999936e-01, -2.649619999999999753e-01, -7.999849999999999461e-01, -9.789830000000000476e-01, -9.499689999999999523e-01, -5.240080000000000293e-01, 4.249629999999999797e-01, 6.786429999999999962e-01, 5.608099999999999891e-02, -4.465129999999999932e-01, -1.784429999999999905e-01, 3.072540000000000271e-01, 5.773639999999999883e-01, 6.720899999999999652e-01, 6.760460000000000358e-01, 7.491590000000000193e-01, 7.680249999999999577e-01, 2.811879999999999935e-01, -5.698039999999999772e-01, -9.474129999999999496e-01, -9.247640000000000304e-01, -4.326670000000000238e-01, 5.239409999999999901e-01, 6.149069999999999814e-01, -3.413000000000000062e-02, -2.844800000000000106e-02, 4.832830000000000181e-01, 6.992829999999999879e-01, 5.437600000000000211e-01, 2.362779999999999880e-01, 4.252500000000000030e-02, 3.525619999999999865e-01, 7.246479999999999588e-01, 3.671969999999999956e-01, -5.475229999999999819e-01, -9.509640000000000315e-01, -9.198260000000000325e-01, -4.177669999999999995e-01, 5.320120000000000404e-01, 6.585560000000000302e-01, 2.681580000000000075e-01, 5.121499999999999941e-01, 7.009710000000000107e-01, 3.509410000000000029e-01, -1.824060000000000126e-01, -4.668559999999999932e-01, -2.773129999999999762e-01, 3.425960000000000116e-01, 5.676470000000000127e-01, 1.403800000000000013e-02, -7.189929999999999932e-01, -9.769529999999999603e-01, -9.501509999999999678e-01, -5.308570000000000233e-01, 4.065779999999999950e-01, 7.959519999999999929e-01, 7.434330000000000105e-01, 7.922390000000000265e-01, 4.766489999999999894e-01, -2.232079999999999897e-01, -5.542200000000000459e-01, -3.670470000000000121e-01, 1.485849999999999949e-01, 5.058120000000000394e-01, 1.747799999999999909e-01, -5.121040000000000036e-01, -9.069129999999999692e-01, -9.943699999999999761e-01, -9.798670000000000435e-01, -7.352990000000000359e-01, -1.590199999999999947e-02, 6.495440000000000103e-01, 9.004729999999999679e-01, 8.427259999999999751e-01, 3.889090000000000047e-01, -1.341759999999999897e-01, -8.256299999999999750e-02, 3.315020000000000189e-01, 5.622800000000000020e-01, 2.571829999999999949e-01, -4.197859999999999925e-01, -8.626650000000000151e-01, -9.851600000000000357e-01, -9.993689999999999518e-01, -9.950010000000000243e-01, -9.153569999999999762e-01, -5.521939999999999626e-01, 1.199319999999999969e-01, 6.734639999999999516e-01, 8.663650000000000517e-01, 7.553119999999999834e-01, 5.964960000000000262e-01, 5.805789999999999562e-01, 5.701289999999999969e-01, 2.733269999999999866e-01, -3.548580000000000068e-01, -8.276090000000000391e-01, -9.784059999999999979e-01, -9.987350000000000394e-01, -9.999679999999999680e-01, -9.994309999999999583e-01, -9.875019999999999909e-01, -8.936009999999999787e-01, -5.549920000000000408e-01, 1.387399999999999918e-02, 4.146819999999999951e-01, 5.082729999999999748e-01, 4.627740000000000187e-01, 2.876859999999999973e-01, -5.380399999999999766e-02, -4.912639999999999785e-01, -8.338780000000000081e-01, -9.722640000000000171e-01, -9.980350000000000055e-01, -9.999430000000000263e-01, -9.999989999999999712e-01, +-1.000000000000000000e+00, -9.999959999999999960e-01, -9.996310000000000473e-01, -9.895479999999999832e-01, -8.874069999999999458e-01, -5.554470000000000240e-01, -1.209969999999999934e-01, 1.245330000000000048e-01, 9.912500000000000477e-02, -9.508199999999999985e-02, -4.457300000000000151e-01, -7.774109999999999632e-01, -9.535529999999999839e-01, -9.968029999999999946e-01, -9.999320000000000430e-01, -9.999989999999999712e-01, -9.999989999999999712e-01, -9.999080000000000190e-01, -9.954229999999999468e-01, -9.263820000000000388e-01, -5.735820000000000363e-01, 6.419700000000000406e-02, 3.456580000000000208e-01, 2.055079999999999962e-01, 1.974700000000000066e-02, 3.107000000000000040e-02, 8.932999999999999968e-03, -3.228949999999999876e-01, -7.930129999999999679e-01, -9.787099999999999689e-01, -9.992029999999999523e-01, -9.999919999999999920e-01, -9.999890000000000168e-01, -9.989069999999999894e-01, -9.722990000000000244e-01, -7.390849999999999920e-01, -1.042740000000000056e-01, 3.342359999999999776e-01, -1.014100000000000071e-02, -5.011839999999999629e-01, -6.861249999999999849e-01, -6.023859999999999770e-01, -2.539390000000000258e-01, 7.340000000000000170e-03, -5.360639999999999850e-01, -9.279899999999999816e-01, -9.963539999999999619e-01, -9.999599999999999600e-01, -9.999289999999999567e-01, -9.938409999999999744e-01, -8.910719999999999752e-01, -4.204680000000000084e-01, 2.440489999999999882e-01, 1.276470000000000105e-01, -5.459789999999999921e-01, -9.083539999999999948e-01, -9.746449999999999836e-01, -9.250709999999999766e-01, -5.068550000000000555e-01, 1.227619999999999961e-01, -3.371129999999999960e-01, -8.668350000000000222e-01, -9.923429999999999751e-01, -9.999120000000000230e-01, -9.997709999999999653e-01, -9.827839999999999909e-01, -7.364389999999999548e-01, -3.639099999999999974e-02, 2.855779999999999985e-01, -3.016949999999999910e-01, -8.421330000000000204e-01, -9.867240000000000455e-01, -9.945920000000000316e-01, -9.481870000000000021e-01, -5.469279999999999697e-01, 1.521359999999999935e-01, -1.868329999999999991e-01, -8.003930000000000211e-01, -9.872440000000000104e-01, -9.998209999999999598e-01, -9.996169999999999778e-01, -9.736749999999999572e-01, -6.188660000000000272e-01, 1.831619999999999915e-01, 1.459189999999999932e-01, -5.948510000000000186e-01, -9.401920000000000277e-01, -9.738120000000000109e-01, -9.237769999999999593e-01, -7.546420000000000350e-01, -3.003569999999999851e-01, 3.133679999999999799e-01, 6.803900000000000226e-02, -6.910880000000000356e-01, -9.789090000000000291e-01, -9.996749999999999803e-01, -9.996680000000000010e-01, -9.746489999999999876e-01, -6.252220000000000555e-01, 1.648399999999999865e-01, 1.457479999999999887e-01, -4.983520000000000172e-01, -7.479339999999999877e-01, -6.952329999999999899e-01, -4.888680000000000248e-01, -9.849700000000000122e-02, 3.467500000000000027e-01, 4.453320000000000056e-01, -1.102709999999999940e-01, -7.708500000000000352e-01, -9.851339999999999542e-01, -9.997960000000000180e-01, -9.998120000000000340e-01, -9.841699999999999893e-01, -7.538399999999999546e-01, -1.127029999999999976e-01, 2.311529999999999974e-01, 4.328000000000000250e-03, -1.028030000000000055e-01, 1.871799999999999853e-02, 2.894169999999999798e-01, 6.092760000000000398e-01, 6.553400000000000336e-01, 1.334609999999999963e-01, -5.782640000000000002e-01, -9.283700000000000285e-01, -9.960729999999999862e-01, -9.999540000000000095e-01, -9.999479999999999480e-01, -9.954410000000000203e-01, -9.213390000000000191e-01, -6.063699999999999646e-01, -1.318699999999999872e-01, 9.272800000000000487e-02, 1.544679999999999942e-01, 2.092430000000000123e-01, 3.988920000000000243e-01, 6.904000000000000137e-01, 4.292009999999999992e-01, -3.758059999999999734e-01, -8.747880000000000100e-01, -9.900430000000000064e-01, -9.996939999999999715e-01, -9.999970000000000248e-01, -9.999959999999999960e-01, -9.995859999999999745e-01, -9.905049999999999688e-01, -9.211979999999999613e-01, -7.565330000000000110e-01, -6.303330000000000322e-01, -5.666109999999999758e-01, -3.800100000000000144e-01, 1.551700000000000024e-01, 4.869299999999999740e-01, -4.089999999999999886e-02, -7.291159999999999863e-01, -9.720569999999999489e-01, -9.988939999999999486e-01, -9.999869999999999592e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999869999999999592e-01, -9.995840000000000281e-01, -9.954250000000000043e-01, -9.841750000000000220e-01, -9.692950000000000177e-01, -8.891219999999999679e-01, -4.781320000000000014e-01, 2.457809999999999995e-01, 2.590979999999999950e-01, -4.726859999999999951e-01, -9.108519999999999950e-01, -9.947009999999999463e-01, -9.999050000000000438e-01, -9.999989999999999712e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999959999999999960e-01, -9.999430000000000263e-01, -9.992320000000000091e-01, -9.798390000000000155e-01, -7.648350000000000426e-01, -1.181730000000000003e-01, 3.464090000000000225e-01, -1.123030000000000000e-01, -7.580249999999999488e-01, -9.777379999999999960e-01, -9.992469999999999963e-01, -9.999930000000000208e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999730000000000008e-01, -9.974509999999999765e-01, -9.430300000000000349e-01, -5.511559999999999793e-01, 2.066419999999999924e-01, 1.977410000000000001e-01, -5.178369999999999918e-01, -9.222249999999999615e-01, -9.955880000000000285e-01, -9.999280000000000390e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999299999999999855e-01, -9.937310000000000310e-01, -8.853539999999999743e-01, -3.587739999999999818e-01, 3.026260000000000061e-01, -9.434099999999999431e-02, -7.619230000000000169e-01, -9.803380000000000427e-01, -9.994349999999999623e-01, -9.999949999999999672e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999010000000000398e-01, -9.912339999999999485e-01, -8.499409999999999465e-01, -2.860480000000000245e-01, 2.147119999999999862e-01, -3.605459999999999776e-01, -8.809749999999999526e-01, -9.931990000000000540e-01, -9.999099999999999655e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999299999999999855e-01, -9.938409999999999744e-01, -8.944029999999999481e-01, -4.974450000000000260e-01, -1.725480000000000069e-01, -6.308340000000000058e-01, -9.508029999999999538e-01, -9.977610000000000090e-01, -9.999759999999999760e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, +}; + +static const unsigned labels[numExamples] = { 9, 6, 3, 6, 6, 0, 0, 0, 6, 9 }; + +int main() { + float hiddenState[hiddenDims] = { 0.0 }; + float preComp[hiddenDims] = { 0.0 }; + float tempLRW[wRank] = { 0.0 }; + float tempLRU[uRank] = { 0.0 }; + float classScores[numClasses] = { 0.0 }; + float normalizedFeats[inputDims] = { 0.0 }; + + for (unsigned n = 0; n < numExamples; ++n) { + + memset(hiddenState, 0, sizeof(float) * hiddenDims); + FastGRNN_LR(W1, W2, wRank, U1, U2, uRank, Bg, Bh, + zeta, nu, timeSteps, hiddenState, hiddenDims, + input + n * inputDims * timeSteps, inputDims, mean, stdDev, + preComp, tempLRW, tempLRU, normalizedFeats); + FC(FC_weights, FCbias, hiddenState, hiddenDims, classScores, numClasses); + unsigned predicted_class = argmax(classScores, numClasses); + + printf("Example: %d Predicted class: %d Actual class: %d\n", + n, predicted_class, labels[n]); + // printVec(classScores, numClasses); + } +} \ No newline at end of file From d5f05e6e259be92b63290cbee8cdb65a1086572c Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Sun, 19 Apr 2020 13:37:03 -0700 Subject: [PATCH 02/15] adding FastGRNN C reference implementation and test case for low rank model --- c_reference/Makefile | 2 +- c_reference/include/classifier.h | 2 +- c_reference/include/fastgrnn.h | 2 +- c_reference/include/utils.h | 2 +- c_reference/tests/test_fastgrnn_lr.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/c_reference/Makefile b/c_reference/Makefile index 1b602e0b4..29788045f 100644 --- a/c_reference/Makefile +++ b/c_reference/Makefile @@ -19,4 +19,4 @@ clean: rm -f *.o *.gch cleanest: clean - rm *~ \ No newline at end of file + rm *~ diff --git a/c_reference/include/classifier.h b/c_reference/include/classifier.h index 13f2a9f59..126d6a06c 100644 --- a/c_reference/include/classifier.h +++ b/c_reference/include/classifier.h @@ -13,4 +13,4 @@ void FC(const float *const FCweights, const float *const FCbias, v_add(1.0f, FCbias, 1.0f, classScores, numClasses, classScores); } -#endif \ No newline at end of file +#endif diff --git a/c_reference/include/fastgrnn.h b/c_reference/include/fastgrnn.h index 2763d4a1e..ba5cc73fe 100644 --- a/c_reference/include/fastgrnn.h +++ b/c_reference/include/fastgrnn.h @@ -127,4 +127,4 @@ int FastGRNN(const float* const W, const float* const U, return 0; } -#endif \ No newline at end of file +#endif diff --git a/c_reference/include/utils.h b/c_reference/include/utils.h index 1999d068e..f803ab3cf 100644 --- a/c_reference/include/utils.h +++ b/c_reference/include/utils.h @@ -124,4 +124,4 @@ void softmax(const float* const input, const unsigned len, float* const ret) { ret[i] = expf(input[i] - offset); } -#endif \ No newline at end of file +#endif diff --git a/c_reference/tests/test_fastgrnn_lr.c b/c_reference/tests/test_fastgrnn_lr.c index b407859f6..07aa775f4 100644 --- a/c_reference/tests/test_fastgrnn_lr.c +++ b/c_reference/tests/test_fastgrnn_lr.c @@ -76,4 +76,4 @@ int main() { n, predicted_class, labels[n]); // printVec(classScores, numClasses); } -} \ No newline at end of file +} From a4f0481bd5b3d2e05c6e6119832b33a666fe39a4 Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Sun, 19 Apr 2020 13:37:40 -0700 Subject: [PATCH 03/15] adding FastGRNN C reference implementation and test case for low rank model --- c_reference/config.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c_reference/config.mk b/c_reference/config.mk index bbfb1fd59..e4009244b 100644 --- a/c_reference/config.mk +++ b/c_reference/config.mk @@ -3,4 +3,4 @@ LDFLAGS= -lm -ldl CC=gcc -CFLAGS= -g -fPIC -O3 -Wall \ No newline at end of file +CFLAGS= -g -fPIC -O3 -Wall From 4a699945caaf4c3be2f54c3a6c9f246d941e85a7 Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Sun, 19 Apr 2020 22:38:53 -0700 Subject: [PATCH 04/15] changed header file format, and test files --- c_reference/include/fastgrnn.h | 197 +++++++++++++++++---------- c_reference/tests/test_fastgrnn_lr.c | 89 +++++++----- 2 files changed, 180 insertions(+), 106 deletions(-) diff --git a/c_reference/include/fastgrnn.h b/c_reference/include/fastgrnn.h index ba5cc73fe..91224b7af 100644 --- a/c_reference/include/fastgrnn.h +++ b/c_reference/include/fastgrnn.h @@ -1,8 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT license. -#ifndef __RNN_H__ -#define __RNN_H__ +#ifndef __FASTGRNN_H__ +#define __FASRGRNN_H__ #include "utils.h" @@ -10,118 +10,173 @@ #define ERR_TEMPLRW_NOT_INIT -2 #define ERR_TEMPLRU_NOT_INIT -3 #define ERR_NORMFEATURES_NOT_INIT -4 + +/** + * @brief Model paramters for low-rank FastGRNN + * @var mean pointer to mean of input vector for normalization, size inputDims + * @var stdDev pointer to standard dev of input for normalization, size inputDims*steps + * @var W1 pointer to first low-rank component of W + * @var W2 pointer to second low-rank component of W + * @var wRank rank of W matrix + * @var U1 pointer to first low-rank component of U + * @var U2 pointer to second low-rank component of U + * @var uRank rank of U matrix + * @var Bg pointer to bias for sigmoid + * @var Bh pointer to bias for tanh + * @var zeta first weight parameter for update from input from next step + * @var nu second weight parameter for update from input from next step + */ +typedef struct FastGRNN_LR_Params { + float* mean; + float* stdDev; + float* W1; + float* W2; + unsigned wRank; + float* U1; + float* U2; + unsigned uRank; + float* Bg; + float* Bh; + float zeta; + float nu; +} FastGRNN_LR_Params; + +/** +* @brief Buffers required for computation of low-rank FastGRNN +* @var preComp pointer to buffer space, must be initalized to atleast hiddenDims size +* @var tempLRW pointer to buffer space, must be initalized to atleast wRank size +* @var tempLRU pointer to buffer space, must be initalized to atleast uRank size +* @var normFeatures pointer to buffer space, must be initalized to atleast inputDims size +*/ +typedef struct FastGRNN_LR_Buffers { + float* preComp; + float* tempLRW; + float* tempLRU; + float* normFeatures; +} FastGRNN_LR_Buffers; + /** * @brief Multi-step updates of a FastGRNN cell with low rank W, U(W=W1*W2; U=U1*U2) - * @param[in] W1 pointer to first low-rank component of W - * @param[in] W2 pointer to second low-rank component of W - * @param[in] wRank rank of W matrix - * @param[in] U1 pointer to first low-rank component of U - * @param[in] U2 pointer to second low-rank component of U - * @param[in] wRank rank of U matrix - * @param[in] Bg pointer to bias for sigmoid - * @param[in] Bh pointer to bias for tanh - * @param[in] zeta first weight parameter for update from input from next step - * @param[in] nu second weight parameter for update from input from next step - * @param[in] steps number of steps of FastGRNN cell * @param[in,out] hiddenState pointer to initial hidden state and output hidden state * @param[in] hiddenDims dimension of hidden state of the FastGRNN cell - * @param[in] input pointer to concatenated input vectors for all steps, size inputDims*steps + * @param[in] input pointer to concatenated input vectors for all steps, size inputDims*steps * @param[in] inputDims dimension of input vector for each step - * @param[in] mean pointer to mean of input vector for normalization, size inputDims - * @param[in] stdDev pointer to standard dev of input for normalization, size inputDims*steps - * @param[in,out] preComp pointer to buffer space, must be initalized to atleast hiddenDims size - * @param[in,out] tempLRW pointer to buffer space, must be initalized to atleast wRank size - * @param[in,out] tempLRU pointer to buffer space, must be initalized to atleast uRank size - * @param[in,out] normFeatures pointer to buffer space, must be initalized to atleast inputDims size + * @param[in] steps number of steps of FastGRNN cell + * @param[in] params pointer to model parameter + * @param[in] buffers pointer to buffer spaces * @return The function returns 0 on success * ERR_PRECOMP_NOT_INIT if preComp not allocated * ERR_TEMPLRW_NOT_INIT if tempLRW not allocated * ERR_TEMPLRU_NOT_INIT if tempLRU not allocated * ERR_NORMFEAT_NOT_INIT if normFeatures not allocated */ -int FastGRNN_LR(const float* const W1, const float* const W2, const int wRank, - const float* const U1, const float* const U2, const int uRank, - const float* const Bg, const float* const Bh, - const float zeta, const float nu, const unsigned steps, - float* const hiddenState, const unsigned hiddenDims, - const float* const input, const int inputDims, - const float* const mean, const float* const stdDev, - float* preComp, float* tempLRW, float* tempLRU, float* normFeatures) { - - if (preComp == 0) return ERR_PRECOMP_NOT_INIT; - if (tempLRW == 0) return ERR_TEMPLRW_NOT_INIT; - if (tempLRU == 0) return ERR_TEMPLRU_NOT_INIT; - if (normFeatures == 0) return ERR_NORMFEATURES_NOT_INIT; +int fastgrnn_lr (float* const hiddenState, const unsigned hiddenDims, + const float* const input, const int inputDims, const unsigned steps, + const FastGRNN_LR_Params* params, FastGRNN_LR_Buffers * buffers) { + + if (buffers->preComp == 0) return ERR_PRECOMP_NOT_INIT; + if (buffers->tempLRW == 0) return ERR_TEMPLRW_NOT_INIT; + if (buffers->tempLRU == 0) return ERR_TEMPLRU_NOT_INIT; + if (buffers->normFeatures == 0) return ERR_NORMFEATURES_NOT_INIT; // #steps iterations of the RNN cell starting from hiddenState for (unsigned t = 0; t < steps; t++) { // Normalize the features - v_add(1.0f, input + t * inputDims, -1.0f, mean + t * inputDims, inputDims, normFeatures); - v_div(stdDev + t * inputDims, normFeatures, inputDims, normFeatures); + v_add(1.0f, input + t * inputDims, -1.0f, params->mean + t * inputDims, + inputDims, buffers->normFeatures); + v_div(params->stdDev + t * inputDims, buffers->normFeatures, inputDims, + buffers->normFeatures); // Process the new input and previous hidden state - matVec(W1, normFeatures, wRank, inputDims, 0.0f, 1.0f, tempLRW); - matVec(W2, tempLRW, hiddenDims, wRank, 0.0f, 1.0f, preComp); - matVec(U1, hiddenState, uRank, hiddenDims, 0.0f, 1.0f, tempLRU); - matVec(U2, tempLRU, hiddenDims, uRank, 1.0f, 1.0f, preComp); + matVec(params->W1, buffers->normFeatures, params->wRank, inputDims, + 0.0f, 1.0f, buffers->tempLRW); + matVec(params->W2, buffers->tempLRW, hiddenDims, params->wRank, + 0.0f, 1.0f, buffers->preComp); + matVec(params->U1, hiddenState, params->uRank, hiddenDims, + 0.0f, 1.0f, buffers->tempLRU); + matVec(params->U2, buffers->tempLRU, hiddenDims, params->uRank, + 1.0f, 1.0f, buffers->preComp); // Apply the gate to generate the new hidden state - for (int i = 0; i < hiddenDims; i++) { - float gate = sigmoid(preComp[i] + Bg[i]); - float update = tanh(preComp[i] + Bh[i]); - hiddenState[i] = gate * hiddenState[i] + (zeta * (1.0 - gate) + nu) * update; + for (unsigned i = 0; i < hiddenDims; i++) { + float gate = sigmoid(buffers->preComp[i] + params->Bg[i]); + float update = tanh(buffers->preComp[i] + params->Bh[i]); + hiddenState[i] = gate * hiddenState[i] + (params->zeta * (1.0 - gate) + params->nu) * update; } } return 0; } +/** + * @brief Model paramters for low-rank FastGRNN + * @var mean pointer to mean of input vector for normalization, size inputDims + * @var stdDev pointer to standard dev of input for normalization, size inputDims*steps + * @var W pointer to W matrix + * @var U pointer U matrix + * @var Bg pointer to bias for sigmoid + * @var Bh pointer to bias for tanh + * @var zeta first weight parameter for update from input from next step + * @var nu second weight parameter for update from input from next step + */ +typedef struct FastGRNN_Params { + float* mean; + float* stdDev; + float* W; + float* U; + float* Bg; + float* Bh; + float zeta; + float nu; +} FastGRNN_Params; + +/** +* @brief Buffers required for computation of FastGRNN +* @var preComp pointer to buffer space, must be initalized to atleast hiddenDims size +* @var normFeatures pointer to buffer space, must be initalized to atleast inputDims size +*/ +typedef struct FastGRNN_Buffers { + float* preComp; + float* normFeatures; +} FastGRNN_Buffers; /** * @brief Multi-step updates of a FastGRNN cell - * @param[in] W pointer to W - * @param[in] U pointer to U - * @param[in] Bg pointer to bias for sigmoid - * @param[in] Bh pointer to bias for tanh - * @param[in] zeta first weight parameter for update from input from next step - * @param[in] nu second weight parameter for update from input from next step - * @param[in] steps number of steps of FastGRNN cell * @param[in,out] hiddenState pointer to initial hidden state and output hidden state * @param[in] hiddenDims dimension of hidden state of the FastGRNN cell * @param[in] input pointer to concatenated input vectors for all steps, size inputDims*steps * @param[in] inputDims dimension of input vector for each step - * @param[in] mean pointer to mean of input vector for normalization, size inputDims - * @param[in] stdDev pointer to standard dev of input for normalization, size inputDims*steps - * @param[in,out] preComp pointer to buffer space, must be initalized to atleast hiddenDims size - * @param[in,out] normFeatures pointer to buffer space, must be initalized to atleast inputDims size + * @param[in] steps number of steps of FastGRNN cell + * @param[in] params pointer to model parameter + * @param[in] buffers pointer to buffer spaces * @return The function returns 0 on success * ERR_PRECOMP_NOT_INIT if preComp not allocated * ERR_NORMFEAT_NOT_INIT if normFeatures not allocated */ -int FastGRNN(const float* const W, const float* const U, - const float* const Bg, const float* const Bh, - const float zeta, const float nu, const unsigned steps, - float* const hiddenState, const unsigned hiddenDims, - const float* const input, const int inputDims, - const float* const mean, const float* const stdDev, - float* preComp, float* normFeatures) { +int fatgrnn(float* const hiddenState, const unsigned hiddenDims, + const float* const input, const int inputDims, const unsigned steps, + const FastGRNN_Params* params, FastGRNN_Buffers* buffers) { - if (preComp == 0) return ERR_PRECOMP_NOT_INIT; - if (normFeatures == 0) return ERR_NORMFEATURES_NOT_INIT; + if (buffers->preComp == 0) return ERR_PRECOMP_NOT_INIT; + if (buffers->normFeatures == 0) return ERR_NORMFEATURES_NOT_INIT; for (unsigned t = 0; t < steps; t++) { // Normalize the features - v_add(1.0f, input + t * inputDims, -1.0f, mean + t * inputDims, inputDims, normFeatures); - v_div(stdDev + t * inputDims, normFeatures, inputDims, normFeatures); + v_add(1.0f, input + t * inputDims, -1.0f, params->mean + t * inputDims, + inputDims, buffers->normFeatures); + v_div(params->stdDev + t * inputDims, buffers->normFeatures, inputDims, + buffers->normFeatures); // Process the new input and previous hidden state - matVec(W, normFeatures, hiddenDims, inputDims, 0.0f, 1.0f, preComp); - matVec(U, hiddenState, hiddenDims, hiddenDims, 1.0f, 1.0f, preComp); + matVec(params->W, buffers->normFeatures, hiddenDims, inputDims, + 0.0f, 1.0f, buffers->preComp); + matVec(params->U, hiddenState, hiddenDims, hiddenDims, + 1.0f, 1.0f, buffers->preComp); // Apply the gate to generate the new hidden state - for (int i = 0; i < hiddenDims; i++) { - float gate = sigmoid(preComp[i] + Bg[i]); - float update = tanh(preComp[i] + Bh[i]); - hiddenState[i] = gate * hiddenState[i] + (zeta * (1.0 - gate) + nu) * update; + for (unsigned i = 0; i < hiddenDims; i++) { + float gate = sigmoid(buffers->preComp[i] + params->Bg[i]); + float update = tanh(buffers->preComp[i] + params->Bh[i]); + hiddenState[i] = gate * hiddenState[i] + (params->zeta * (1.0 - gate) + params->nu) * update; } } return 0; diff --git a/c_reference/tests/test_fastgrnn_lr.c b/c_reference/tests/test_fastgrnn_lr.c index 07aa775f4..813489637 100644 --- a/c_reference/tests/test_fastgrnn_lr.c +++ b/c_reference/tests/test_fastgrnn_lr.c @@ -10,36 +10,36 @@ // A low-rank FastGRNN model to classify digits expressed as 16x16 pixels // Trained on USPS data -#define inputDims 16 // Each input vector is a row -#define timeSteps 16 // Each column is a time step. -#define numClasses 10 // 10 digits +#define INPUT_DIMS 16 // Each input vector is a row +#define TIME_STEPS 16 // Each column is a time step. +#define NUM_CLASSES 10 // 10 digits +#define HIDDEN_DIMS 32 -#define hiddenDims 32 -#define wRank 5 -#define uRank 5 +#define USPS_wRank 5 +#define USPS_uRank 5 -static const float zeta = 0.8710977; -static const float nu = 0.077582605; +static float USPS_mean[INPUT_DIMS*TIME_STEPS] = { -0.9919499212727939, -0.9725694919764011, -0.9309642959813387, -0.853716200521184, -0.7349504700315451, -0.5802354099574815, -0.39248257687560045, -0.2269891389384171, -0.2174700892881636, -0.3516331625291455, -0.5171603246468245, -0.6708125888081178, -0.7990983028391132, -0.8932807097791728, -0.9539613342476979, -0.9857407134823684, -0.982065124537093, -0.9396279381429109, -0.8481889680427892, -0.6871382765052781, -0.46854966931833575, -0.23665195432725242, -0.010466119873817016, 0.16903683075024034, 0.16696242696475144, 0.000575173501577279, -0.19530754532985956, -0.4051392961185021, -0.6211168477575091, -0.7968383502948817, -0.9104805820875028, -0.9707068291043692, -0.972355607872715, -0.9089240443011889, -0.7740880982032617, -0.5530052536003301, -0.3013481248114096, -0.10879414689343007, 0.02414649869702375, 0.12112666931833796, 0.09386644177753416, -0.026313687560005544, -0.13068748580441636, -0.2786945901796741, -0.5084887787683436, -0.7343963726512096, -0.8844299572075165, -0.962161552736246, -0.9642070229049474, -0.8840199842271269, -0.7208337917981055, -0.48003281689754523, -0.2592399288163491, -0.15972010135783873, -0.13488242545604182, -0.11083945041832412, -0.14293412796598523, -0.19081482046358608, -0.18728045165272306, -0.25101744602935144, -0.4563265265395706, -0.7004354450692639, -0.8731881069812105, -0.9611915881223407, -0.9567694833356168, -0.8617201112330247, -0.683815164037853, -0.4513802841859834, -0.2767222655328479, -0.24271835893567434, -0.27267054121519685, -0.27519317062131443, -0.28616588533808773, -0.2777844744205183, -0.22406378836922136, -0.2557428004388969, -0.44326194554930604, -0.6840314127005878, -0.8646587673844441, -0.9602941933891046, -0.9477821902345276, -0.8393201226169212, -0.6594944069400636, -0.44880140515704203, -0.3044652061445627, -0.2859914052941979, -0.316657265121382, -0.3067866066383211, -0.28780289836785117, -0.2623772171169936, -0.22743563598957653, -0.28094515306542406, -0.46172105499931243, -0.6816232979015237, -0.853368788643532, -0.9539364379371749, -0.9359569141407178, -0.8178023395967626, -0.6458083161431897, -0.46078189713345175, -0.3343425966259763, -0.3040399067343306, -0.3020369240159101, -0.2565737191057453, -0.2143900148127831, -0.20347084844328667, -0.21882569194897866, -0.31159891482649676, -0.4869429131806326, -0.6789936108901359, -0.8352845457413198, -0.9403150890138469, -0.9219565331230252, -0.7991542114936192, -0.6391470298998767, -0.480406617885063, -0.3772339624194202, -0.3432734622136863, -0.3076273417912494, -0.22275086654779863, -0.1591171466191192, -0.15866637937182784, -0.21225642422164245, -0.3290358596900291, -0.4917353549581671, -0.6600453933616788, -0.8079168403511172, -0.9216502385132305, -0.9072759818954866, -0.7804653297215689, -0.6322083482375515, -0.5027187801398963, -0.4339113278013999, -0.41547600946372387, -0.3618670742010695, -0.24068855520504717, -0.1473811658208747, -0.14548218365107626, -0.21954138403511242, -0.33686426539569414, -0.473740655054176, -0.6233680076807026, -0.7741535508160722, -0.9028491551227509, -0.8929522782882959, -0.756864783705938, -0.6146212389246978, -0.513367757646413, -0.48232288945274865, -0.48646097517487225, -0.42513441489507686, -0.27327081648607815, -0.15083051817309004, -0.15585458030448487, -0.24761655191331758, -0.3462121758332204, -0.44668136702784256, -0.5835845624742833, -0.746094467699902, -0.8914101106844001, -0.8821387661500428, -0.7320792965299654, -0.5845565805787934, -0.4976560571938005, -0.4952595445069262, -0.5208868074338231, -0.4561778712110802, -0.2812537535317511, -0.14685717116993566, -0.17610946427101884, -0.277720601563572, -0.3429429920449862, -0.41290968659991617, -0.553466350569195, -0.7356155199561067, -0.8925808374708505, -0.884290182965297, -0.7233545645316107, -0.555796021533396, -0.45550774763406854, -0.4571342345357299, -0.49459585763269837, -0.4290731143876021, -0.24324041955835948, -0.12013004718145653, -0.17548549403374053, -0.26795098175833226, -0.30909644794952573, -0.38439246646550385, -0.5516582737621708, -0.7513137768481636, -0.905721511452472, -0.9041776875600014, -0.7504212261692499, -0.5617998211493601, -0.4151893102455081, -0.3705037724591977, -0.38054928884926614, -0.30209018968591367, -0.11544845686462707, -0.020367994925250304, -0.10257074612536023, -0.1971577605266772, -0.26616795720751535, -0.398158987244547, -0.6004331385269481, -0.7961418553010544, -0.927132169249758, -0.9355877185571251, -0.8164877640927145, -0.636413944314908, -0.4417967572349474, -0.30123951707584623, -0.21375640858592782, -0.07664012673158706, 0.11518739075572665, 0.16615884350569157, 0.02465076409271711, -0.14109523247839745, -0.3035931360581551, -0.5030459921821414, -0.7066635047318597, -0.8603180109724315, -0.9508067177341882, -0.9675336151419524, -0.9003715298312993, -0.7766258472088848, -0.5970459330681649, -0.3958499355369634, -0.19905987738307548, 0.02545309765464275, 0.23516244191468944, 0.23560784803182028, 0.00534759127691674, -0.2629597399533658, -0.4955072450966976, -0.6918777547661497, -0.8361089925936072, -0.9240889329310108, -0.972631745576734, -0.9893073183376733, -0.9649322459196252, -0.9132032637498255, -0.8204827562748569, -0.6831469591276887, -0.506931868330818, -0.2965040820189278, -0.11981037566863263, -0.13915219805239362, -0.3596030020573289, -0.5987721205595955, -0.7692781906459996, -0.8760536623234108, -0.9370363911671895, -0.9704590652859655, -0.9892901006720557 }; +static float USPS_stdDev[INPUT_DIMS * TIME_STEPS] = { 0.05066656593826383, 0.11768215831858285, 0.19527142979975337, 0.2833393066737951, 0.37268899940299066, 0.43424831734200253, 0.4509077884558764, 0.4523467450088637, 0.4435444516292877, 0.453474411938222, 0.4511610370141509, 0.4090808907117051, 0.340842016175768, 0.2515266389290965, 0.1535781715584388, 0.06980490524925699, 0.08765943105043687, 0.19636324018365733, 0.32429032997742996, 0.4567512820282358, 0.5626439446484282, 0.6032659791055035, 0.5639062519215206, 0.5308776133306021, 0.5223175793565092, 0.5540930619255867, 0.6009820087794636, 0.5835468006853077, 0.5110815844557693, 0.39510080274123266, 0.25620023445987633, 0.1226867565488554, 0.11282186786555957, 0.2443736268637558, 0.3927773337244816, 0.5300792876318842, 0.611455535763247, 0.6137703781184999, 0.5486362827625642, 0.558238252221451, 0.5640102654180597, 0.5458372730410752, 0.6033813665182791, 0.6179035980472674, 0.5636690595511944, 0.4471630564471609, 0.2991307396396185, 0.14513349372261522, 0.13165609358200855, 0.27850705968930484, 0.43720035704012494, 0.5696589694535166, 0.6305106802282854, 0.6130665659135671, 0.5708937380167166, 0.6267080783818001, 0.6140579359769878, 0.5502386047872234, 0.6051362682299342, 0.635397491562088, 0.5917012576621496, 0.4694826022296184, 0.3049891980667035, 0.1417658489946166, 0.14660482167334782, 0.3108270739064537, 0.4796721806586266, 0.6021156740335395, 0.6438981023490464, 0.6149730879531347, 0.5786341846733203, 0.6260900111005044, 0.6088319125295019, 0.5527066903416282, 0.6139823813708458, 0.6469383840051754, 0.6087765126529255, 0.4896843988025161, 0.3130099011675707, 0.13746176784318512, 0.1651363517565353, 0.3525996924710074, 0.5214554460712036, 0.6228931000316578, 0.6466288953590107, 0.617026839758864, 0.5735516128512261, 0.6164884033345998, 0.6226536777808414, 0.579468571253997, 0.6226313291006089, 0.6420111615955644, 0.6028682944062023, 0.5012722033813212, 0.3390059533601551, 0.15299465137681406, 0.19251594791512783, 0.396952702268763, 0.552159431496869, 0.6320421473488981, 0.6443326365880183, 0.6170472505372365, 0.5834546203509037, 0.6456206774803475, 0.6632037104438387, 0.6136658430782906, 0.6282883980800487, 0.6266066841912776, 0.5877284692447173, 0.5083732571738568, 0.37672585693697697, 0.19071297464730821, 0.22738939517708093, 0.43216309636726685, 0.5672536909906605, 0.631729474977315, 0.639288052909488, 0.6083883492195362, 0.5889647486063578, 0.6632192879286241, 0.666693521410897, 0.6141086834297501, 0.6235523636944053, 0.6110232070097491, 0.5810599302729026, 0.5248683372032933, 0.416871751902074, 0.23245043001693613, 0.25787896223721457, 0.45642840103735277, 0.5706055474263793, 0.6215019791294262, 0.6240378390525279, 0.585872663503391, 0.5811279830268054, 0.6602994727745124, 0.6489034985750345, 0.603285958818, 0.6104761926038955, 0.6019458376723148, 0.593072552824263, 0.5541512721442687, 0.45442464044327674, 0.26421446020604794, 0.2750748340184962, 0.4759504899089418, 0.5801160408912686, 0.6171973056405151, 0.6084475754936072, 0.5662766326533075, 0.5725163997626637, 0.6523704000367663, 0.6439544061328982, 0.6038993966379462, 0.5936445165640896, 0.5988208807738072, 0.6134438430981234, 0.5822474624078565, 0.4781320392750622, 0.2744472002370629, 0.27978594406798046, 0.49000304569115505, 0.596927771017493, 0.6295636513656973, 0.6130992222136632, 0.5685432540366993, 0.5722666927638678, 0.6490460968540127, 0.6510618224925118, 0.5951965161993366, 0.579054281068931, 0.6133129715581599, 0.6399127837494875, 0.601009829227199, 0.4759842934093174, 0.25926034572427836, 0.2659329405966657, 0.48229673831219794, 0.6058557018009367, 0.6475577504899299, 0.6318593264440545, 0.5793441705514869, 0.5626352996175501, 0.6396798454937799, 0.6395304006230473, 0.5643649762025762, 0.5814789782426448, 0.6437155669568893, 0.6622897081277597, 0.5981077340856256, 0.4440137907748311, 0.22855334793658635, 0.23058280104056256, 0.4391108535116708, 0.5858018231169397, 0.6568158083074834, 0.660992447300762, 0.6050293531558012, 0.551566388582632, 0.6078442167019985, 0.5874351599908308, 0.5329056322660973, 0.6156086282390514, 0.6757254453683215, 0.658579754018323, 0.5568677508414656, 0.3855427765572426, 0.19247519514628053, 0.18151505693157194, 0.36316373873982777, 0.5198136719231422, 0.6273283747062883, 0.6745273153652143, 0.6455002272347471, 0.5585396598417464, 0.5410453171458859, 0.5096064443341672, 0.5429252747140453, 0.6545502373132852, 0.6698239302774162, 0.5980652613996279, 0.4668007421210614, 0.3114873386910331, 0.15654842294915372, 0.12168436193114814, 0.2528519135349363, 0.3889022669431662, 0.51681799362489, 0.6152354929585003, 0.6480000627279904, 0.5868680464219567, 0.5207594899432356, 0.5133934769539377, 0.5830576463663892, 0.6286429551523846, 0.5707288552482176, 0.4582805109955963, 0.3362912300487512, 0.224029788596469, 0.1134877995573401, 0.05688552112923371, 0.1253359275691928, 0.20678860013345332, 0.30178570214200107, 0.39857085075127774, 0.4710686511232531, 0.4809255781447563, 0.4517230712365873, 0.44968948316492025, 0.4579322493794554, 0.4218312472593008, 0.3369818647335357, 0.2510674309664235, 0.18299863726222423, 0.1220244940300115, 0.059526488182894154 }; -static const float mean[inputDims*timeSteps] = { -0.9919499212727939, -0.9725694919764011, -0.9309642959813387, -0.853716200521184, -0.7349504700315451, -0.5802354099574815, -0.39248257687560045, -0.2269891389384171, -0.2174700892881636, -0.3516331625291455, -0.5171603246468245, -0.6708125888081178, -0.7990983028391132, -0.8932807097791728, -0.9539613342476979, -0.9857407134823684, -0.982065124537093, -0.9396279381429109, -0.8481889680427892, -0.6871382765052781, -0.46854966931833575, -0.23665195432725242, -0.010466119873817016, 0.16903683075024034, 0.16696242696475144, 0.000575173501577279, -0.19530754532985956, -0.4051392961185021, -0.6211168477575091, -0.7968383502948817, -0.9104805820875028, -0.9707068291043692, -0.972355607872715, -0.9089240443011889, -0.7740880982032617, -0.5530052536003301, -0.3013481248114096, -0.10879414689343007, 0.02414649869702375, 0.12112666931833796, 0.09386644177753416, -0.026313687560005544, -0.13068748580441636, -0.2786945901796741, -0.5084887787683436, -0.7343963726512096, -0.8844299572075165, -0.962161552736246, -0.9642070229049474, -0.8840199842271269, -0.7208337917981055, -0.48003281689754523, -0.2592399288163491, -0.15972010135783873, -0.13488242545604182, -0.11083945041832412, -0.14293412796598523, -0.19081482046358608, -0.18728045165272306, -0.25101744602935144, -0.4563265265395706, -0.7004354450692639, -0.8731881069812105, -0.9611915881223407, -0.9567694833356168, -0.8617201112330247, -0.683815164037853, -0.4513802841859834, -0.2767222655328479, -0.24271835893567434, -0.27267054121519685, -0.27519317062131443, -0.28616588533808773, -0.2777844744205183, -0.22406378836922136, -0.2557428004388969, -0.44326194554930604, -0.6840314127005878, -0.8646587673844441, -0.9602941933891046, -0.9477821902345276, -0.8393201226169212, -0.6594944069400636, -0.44880140515704203, -0.3044652061445627, -0.2859914052941979, -0.316657265121382, -0.3067866066383211, -0.28780289836785117, -0.2623772171169936, -0.22743563598957653, -0.28094515306542406, -0.46172105499931243, -0.6816232979015237, -0.853368788643532, -0.9539364379371749, -0.9359569141407178, -0.8178023395967626, -0.6458083161431897, -0.46078189713345175, -0.3343425966259763, -0.3040399067343306, -0.3020369240159101, -0.2565737191057453, -0.2143900148127831, -0.20347084844328667, -0.21882569194897866, -0.31159891482649676, -0.4869429131806326, -0.6789936108901359, -0.8352845457413198, -0.9403150890138469, -0.9219565331230252, -0.7991542114936192, -0.6391470298998767, -0.480406617885063, -0.3772339624194202, -0.3432734622136863, -0.3076273417912494, -0.22275086654779863, -0.1591171466191192, -0.15866637937182784, -0.21225642422164245, -0.3290358596900291, -0.4917353549581671, -0.6600453933616788, -0.8079168403511172, -0.9216502385132305, -0.9072759818954866, -0.7804653297215689, -0.6322083482375515, -0.5027187801398963, -0.4339113278013999, -0.41547600946372387, -0.3618670742010695, -0.24068855520504717, -0.1473811658208747, -0.14548218365107626, -0.21954138403511242, -0.33686426539569414, -0.473740655054176, -0.6233680076807026, -0.7741535508160722, -0.9028491551227509, -0.8929522782882959, -0.756864783705938, -0.6146212389246978, -0.513367757646413, -0.48232288945274865, -0.48646097517487225, -0.42513441489507686, -0.27327081648607815, -0.15083051817309004, -0.15585458030448487, -0.24761655191331758, -0.3462121758332204, -0.44668136702784256, -0.5835845624742833, -0.746094467699902, -0.8914101106844001, -0.8821387661500428, -0.7320792965299654, -0.5845565805787934, -0.4976560571938005, -0.4952595445069262, -0.5208868074338231, -0.4561778712110802, -0.2812537535317511, -0.14685717116993566, -0.17610946427101884, -0.277720601563572, -0.3429429920449862, -0.41290968659991617, -0.553466350569195, -0.7356155199561067, -0.8925808374708505, -0.884290182965297, -0.7233545645316107, -0.555796021533396, -0.45550774763406854, -0.4571342345357299, -0.49459585763269837, -0.4290731143876021, -0.24324041955835948, -0.12013004718145653, -0.17548549403374053, -0.26795098175833226, -0.30909644794952573, -0.38439246646550385, -0.5516582737621708, -0.7513137768481636, -0.905721511452472, -0.9041776875600014, -0.7504212261692499, -0.5617998211493601, -0.4151893102455081, -0.3705037724591977, -0.38054928884926614, -0.30209018968591367, -0.11544845686462707, -0.020367994925250304, -0.10257074612536023, -0.1971577605266772, -0.26616795720751535, -0.398158987244547, -0.6004331385269481, -0.7961418553010544, -0.927132169249758, -0.9355877185571251, -0.8164877640927145, -0.636413944314908, -0.4417967572349474, -0.30123951707584623, -0.21375640858592782, -0.07664012673158706, 0.11518739075572665, 0.16615884350569157, 0.02465076409271711, -0.14109523247839745, -0.3035931360581551, -0.5030459921821414, -0.7066635047318597, -0.8603180109724315, -0.9508067177341882, -0.9675336151419524, -0.9003715298312993, -0.7766258472088848, -0.5970459330681649, -0.3958499355369634, -0.19905987738307548, 0.02545309765464275, 0.23516244191468944, 0.23560784803182028, 0.00534759127691674, -0.2629597399533658, -0.4955072450966976, -0.6918777547661497, -0.8361089925936072, -0.9240889329310108, -0.972631745576734, -0.9893073183376733, -0.9649322459196252, -0.9132032637498255, -0.8204827562748569, -0.6831469591276887, -0.506931868330818, -0.2965040820189278, -0.11981037566863263, -0.13915219805239362, -0.3596030020573289, -0.5987721205595955, -0.7692781906459996, -0.8760536623234108, -0.9370363911671895, -0.9704590652859655, -0.9892901006720557 }; -static const float stdDev[inputDims * timeSteps] = { 0.05066656593826383, 0.11768215831858285, 0.19527142979975337, 0.2833393066737951, 0.37268899940299066, 0.43424831734200253, 0.4509077884558764, 0.4523467450088637, 0.4435444516292877, 0.453474411938222, 0.4511610370141509, 0.4090808907117051, 0.340842016175768, 0.2515266389290965, 0.1535781715584388, 0.06980490524925699, 0.08765943105043687, 0.19636324018365733, 0.32429032997742996, 0.4567512820282358, 0.5626439446484282, 0.6032659791055035, 0.5639062519215206, 0.5308776133306021, 0.5223175793565092, 0.5540930619255867, 0.6009820087794636, 0.5835468006853077, 0.5110815844557693, 0.39510080274123266, 0.25620023445987633, 0.1226867565488554, 0.11282186786555957, 0.2443736268637558, 0.3927773337244816, 0.5300792876318842, 0.611455535763247, 0.6137703781184999, 0.5486362827625642, 0.558238252221451, 0.5640102654180597, 0.5458372730410752, 0.6033813665182791, 0.6179035980472674, 0.5636690595511944, 0.4471630564471609, 0.2991307396396185, 0.14513349372261522, 0.13165609358200855, 0.27850705968930484, 0.43720035704012494, 0.5696589694535166, 0.6305106802282854, 0.6130665659135671, 0.5708937380167166, 0.6267080783818001, 0.6140579359769878, 0.5502386047872234, 0.6051362682299342, 0.635397491562088, 0.5917012576621496, 0.4694826022296184, 0.3049891980667035, 0.1417658489946166, 0.14660482167334782, 0.3108270739064537, 0.4796721806586266, 0.6021156740335395, 0.6438981023490464, 0.6149730879531347, 0.5786341846733203, 0.6260900111005044, 0.6088319125295019, 0.5527066903416282, 0.6139823813708458, 0.6469383840051754, 0.6087765126529255, 0.4896843988025161, 0.3130099011675707, 0.13746176784318512, 0.1651363517565353, 0.3525996924710074, 0.5214554460712036, 0.6228931000316578, 0.6466288953590107, 0.617026839758864, 0.5735516128512261, 0.6164884033345998, 0.6226536777808414, 0.579468571253997, 0.6226313291006089, 0.6420111615955644, 0.6028682944062023, 0.5012722033813212, 0.3390059533601551, 0.15299465137681406, 0.19251594791512783, 0.396952702268763, 0.552159431496869, 0.6320421473488981, 0.6443326365880183, 0.6170472505372365, 0.5834546203509037, 0.6456206774803475, 0.6632037104438387, 0.6136658430782906, 0.6282883980800487, 0.6266066841912776, 0.5877284692447173, 0.5083732571738568, 0.37672585693697697, 0.19071297464730821, 0.22738939517708093, 0.43216309636726685, 0.5672536909906605, 0.631729474977315, 0.639288052909488, 0.6083883492195362, 0.5889647486063578, 0.6632192879286241, 0.666693521410897, 0.6141086834297501, 0.6235523636944053, 0.6110232070097491, 0.5810599302729026, 0.5248683372032933, 0.416871751902074, 0.23245043001693613, 0.25787896223721457, 0.45642840103735277, 0.5706055474263793, 0.6215019791294262, 0.6240378390525279, 0.585872663503391, 0.5811279830268054, 0.6602994727745124, 0.6489034985750345, 0.603285958818, 0.6104761926038955, 0.6019458376723148, 0.593072552824263, 0.5541512721442687, 0.45442464044327674, 0.26421446020604794, 0.2750748340184962, 0.4759504899089418, 0.5801160408912686, 0.6171973056405151, 0.6084475754936072, 0.5662766326533075, 0.5725163997626637, 0.6523704000367663, 0.6439544061328982, 0.6038993966379462, 0.5936445165640896, 0.5988208807738072, 0.6134438430981234, 0.5822474624078565, 0.4781320392750622, 0.2744472002370629, 0.27978594406798046, 0.49000304569115505, 0.596927771017493, 0.6295636513656973, 0.6130992222136632, 0.5685432540366993, 0.5722666927638678, 0.6490460968540127, 0.6510618224925118, 0.5951965161993366, 0.579054281068931, 0.6133129715581599, 0.6399127837494875, 0.601009829227199, 0.4759842934093174, 0.25926034572427836, 0.2659329405966657, 0.48229673831219794, 0.6058557018009367, 0.6475577504899299, 0.6318593264440545, 0.5793441705514869, 0.5626352996175501, 0.6396798454937799, 0.6395304006230473, 0.5643649762025762, 0.5814789782426448, 0.6437155669568893, 0.6622897081277597, 0.5981077340856256, 0.4440137907748311, 0.22855334793658635, 0.23058280104056256, 0.4391108535116708, 0.5858018231169397, 0.6568158083074834, 0.660992447300762, 0.6050293531558012, 0.551566388582632, 0.6078442167019985, 0.5874351599908308, 0.5329056322660973, 0.6156086282390514, 0.6757254453683215, 0.658579754018323, 0.5568677508414656, 0.3855427765572426, 0.19247519514628053, 0.18151505693157194, 0.36316373873982777, 0.5198136719231422, 0.6273283747062883, 0.6745273153652143, 0.6455002272347471, 0.5585396598417464, 0.5410453171458859, 0.5096064443341672, 0.5429252747140453, 0.6545502373132852, 0.6698239302774162, 0.5980652613996279, 0.4668007421210614, 0.3114873386910331, 0.15654842294915372, 0.12168436193114814, 0.2528519135349363, 0.3889022669431662, 0.51681799362489, 0.6152354929585003, 0.6480000627279904, 0.5868680464219567, 0.5207594899432356, 0.5133934769539377, 0.5830576463663892, 0.6286429551523846, 0.5707288552482176, 0.4582805109955963, 0.3362912300487512, 0.224029788596469, 0.1134877995573401, 0.05688552112923371, 0.1253359275691928, 0.20678860013345332, 0.30178570214200107, 0.39857085075127774, 0.4710686511232531, 0.4809255781447563, 0.4517230712365873, 0.44968948316492025, 0.4579322493794554, 0.4218312472593008, 0.3369818647335357, 0.2510674309664235, 0.18299863726222423, 0.1220244940300115, 0.059526488182894154 }; +static float USPS_W1[INPUT_DIMS * USPS_wRank] = { 0.04437631741166115, 0.13164237141609192, 0.13089998066425323, -0.005882591009140015, 0.04586317017674446, 0.21047545969486237, 0.9706279635429382, -0.5048243999481201, -0.7511760592460632, 0.07774244248867035, 0.40391597151756287, -0.016807876527309418, 0.08794082701206207, 0.09336663037538528, 0.08842388540506363, -0.10721755772829056, -0.16265031695365906, -0.506087601184845, -0.2623403072357178, -0.41705453395843506, -0.3362988531589508, 0.20567356050014496, 0.09920496493577957, 0.399951696395874, -0.10302149504423141, -0.2829299569129944, -0.21695533394813538, -0.11943338066339493, -0.17138315737247467, -0.08943527936935425, 0.09248100966215134, -0.11688404530286789, -0.2544580101966858, 0.2178615778684616, -0.245102658867836, -0.2574276626110077, 0.022898254916071892, -0.4134445786476135, 0.028750110417604446, -0.047812022268772125, 0.4697933793067932, 0.4765063524246216, 0.35218697786331177, 0.29210469126701355, 0.1622641533613205, -0.1555808037519455, 0.04628629982471466, -0.031492870301008224, -0.23739324510097504, -0.0762714371085167, -0.16486185789108276, -0.2018968164920807, -0.5137050151824951, 0.14758920669555664, -0.5882534980773926, -0.7306461334228516, -0.7919453978538513, 0.07507729530334473, 0.1977670043706894, 0.21115902066230774, -0.12351129949092865, -0.07091476023197174, 0.06400024145841599, 0.021400034427642822, 0.10578139871358871, 0.17063069343566895, 0.3912162184715271, -0.02506481111049652, 0.09003248065710068, 0.42354777455329895, -0.37391015887260437, 0.14988373219966888, 0.2816886901855469, -0.35063880681991577, -0.05643891915678978, -0.15927889943122864, -0.47207891941070557, -0.5888171195983887, -0.18981651961803436, -0.41033101081848145 }; +static float USPS_W2[USPS_wRank * HIDDEN_DIMS] = { 0.2863377332687378, -1.2143335342407227, 0.610011875629425, 0.1656205952167511, -0.8666146397590637, -0.5734943747520447, 0.7413628101348877, 0.1714680939912796, 0.9024200439453125, 0.32295238971710205, -0.3873929977416992, -0.2707236707210541, 0.5344352126121521, -0.8188126683235168, 0.35341984033584595, -0.6474847197532654, 1.4979887008666992, -0.4152466952800751, 0.2156294882297516, 0.20376665890216827, 0.18564093112945557, -0.25238993763923645, 0.3459400534629822, 0.7960702776908875, -1.1047370433807373, 0.5615563988685608, -0.3268606960773468, 0.09511122852563858, 0.21674132347106934, -0.7735028862953186, -0.1510464996099472, -0.414810448884964, -0.41682058572769165, 0.5789415836334229, 0.5722947716712952, 0.4911503493785858, 0.9235195517539978, -0.22825153172016144, -0.17003802955150604, 1.5115245580673218, -0.3358864486217499, 0.5848679542541504, -0.0174887552857399, -0.325115442276001, 0.8525659441947937, 0.07604137063026428, -0.11137218028306961, -1.094437599182129, -0.21889141201972961, 0.6240004897117615, 0.6826394200325012, 0.3434017598628998, -0.1567269265651703, 0.2540211081504822, 0.177201509475708, -0.11570670455694199, 0.04361787065863609, 0.070060133934021, 0.40478208661079407, -0.16697058081626892, -0.27620503306388855, -0.12831233441829681, 0.11825147271156311, -0.13083836436271667, -0.4768890142440796, 0.9436963796615601, -0.8370056748390198, -0.3582906424999237, 0.2789956331253052, -0.7134209275245667, -0.03986117243766785, -0.32654106616973877, 0.6198241114616394, 0.4585057497024536, -0.6961711049079895, 0.5115857720375061, -0.22929508984088898, -0.44659942388534546, 0.3906383514404297, -0.29806071519851685, -0.4874197542667389, 0.22447143495082855, 0.902230978012085, -0.5234335660934448, -0.07662484794855118, 0.6974019408226013, 0.18268021941184998, 0.1972568929195404, -0.7540782690048218, 0.16145218908786774, -0.13156381249427795, 0.588074266910553, -1.0683441162109375, 0.30249473452568054, 0.8400665521621704, 0.47553586959838867, -0.4598252773284912, -0.2067403942346573, -0.8708492517471313, -0.283275842666626, -0.23203222453594208, -0.18401674926280975, -0.5495933294296265, 1.218782901763916, 0.239736407995224, 0.18521395325660706, -0.1917710155248642, -0.5461402535438538, 0.14571575820446014, 0.004668646026402712, -0.19929653406143188, 0.12697455286979675, -0.3280128836631775, -0.5886898636817932, 0.22302460670471191, -0.4971023499965668, -0.41075021028518677, 0.33907508850097656, 0.407676100730896, -0.27239513397216797, -0.45195865631103516, 0.14889605343341827, 0.3355768918991089, -0.5228666663169861, -0.12074578553438187, -0.5339986681938171, -0.06062544137239456, 1.006304144859314, -0.36918461322784424, 0.37021008133888245, 0.5438523292541504, -0.7772119641304016, -0.045975420624017715, -0.7924363613128662, 0.512947678565979, -0.003562948200851679, -0.009431581944227219, -0.4735417664051056, 0.13429303467273712, -0.11795001477003098, -0.07338037341833115, -0.15307340025901794, 0.07787186652421951, 0.174309641122818, -0.08390356600284576, 0.4766653776168823, -0.12070371210575104, -0.37375226616859436, -0.4071563184261322, 0.056958504021167755, 0.06188056617975235, 0.12964613735675812, -0.34358277916908264, 0.7809591889381409, 0.22712215781211853, -0.4458172023296356, 0.13437648117542267, 0.12954799830913544, 1.001265287399292, 0.18989679217338562 }; -static const float W1[inputDims * wRank] = { 0.04437631741166115, 0.13164237141609192, 0.13089998066425323, -0.005882591009140015, 0.04586317017674446, 0.21047545969486237, 0.9706279635429382, -0.5048243999481201, -0.7511760592460632, 0.07774244248867035, 0.40391597151756287, -0.016807876527309418, 0.08794082701206207, 0.09336663037538528, 0.08842388540506363, -0.10721755772829056, -0.16265031695365906, -0.506087601184845, -0.2623403072357178, -0.41705453395843506, -0.3362988531589508, 0.20567356050014496, 0.09920496493577957, 0.399951696395874, -0.10302149504423141, -0.2829299569129944, -0.21695533394813538, -0.11943338066339493, -0.17138315737247467, -0.08943527936935425, 0.09248100966215134, -0.11688404530286789, -0.2544580101966858, 0.2178615778684616, -0.245102658867836, -0.2574276626110077, 0.022898254916071892, -0.4134445786476135, 0.028750110417604446, -0.047812022268772125, 0.4697933793067932, 0.4765063524246216, 0.35218697786331177, 0.29210469126701355, 0.1622641533613205, -0.1555808037519455, 0.04628629982471466, -0.031492870301008224, -0.23739324510097504, -0.0762714371085167, -0.16486185789108276, -0.2018968164920807, -0.5137050151824951, 0.14758920669555664, -0.5882534980773926, -0.7306461334228516, -0.7919453978538513, 0.07507729530334473, 0.1977670043706894, 0.21115902066230774, -0.12351129949092865, -0.07091476023197174, 0.06400024145841599, 0.021400034427642822, 0.10578139871358871, 0.17063069343566895, 0.3912162184715271, -0.02506481111049652, 0.09003248065710068, 0.42354777455329895, -0.37391015887260437, 0.14988373219966888, 0.2816886901855469, -0.35063880681991577, -0.05643891915678978, -0.15927889943122864, -0.47207891941070557, -0.5888171195983887, -0.18981651961803436, -0.41033101081848145 }; -static const float W2[wRank * hiddenDims] = { 0.2863377332687378, -1.2143335342407227, 0.610011875629425, 0.1656205952167511, -0.8666146397590637, -0.5734943747520447, 0.7413628101348877, 0.1714680939912796, 0.9024200439453125, 0.32295238971710205, -0.3873929977416992, -0.2707236707210541, 0.5344352126121521, -0.8188126683235168, 0.35341984033584595, -0.6474847197532654, 1.4979887008666992, -0.4152466952800751, 0.2156294882297516, 0.20376665890216827, 0.18564093112945557, -0.25238993763923645, 0.3459400534629822, 0.7960702776908875, -1.1047370433807373, 0.5615563988685608, -0.3268606960773468, 0.09511122852563858, 0.21674132347106934, -0.7735028862953186, -0.1510464996099472, -0.414810448884964, -0.41682058572769165, 0.5789415836334229, 0.5722947716712952, 0.4911503493785858, 0.9235195517539978, -0.22825153172016144, -0.17003802955150604, 1.5115245580673218, -0.3358864486217499, 0.5848679542541504, -0.0174887552857399, -0.325115442276001, 0.8525659441947937, 0.07604137063026428, -0.11137218028306961, -1.094437599182129, -0.21889141201972961, 0.6240004897117615, 0.6826394200325012, 0.3434017598628998, -0.1567269265651703, 0.2540211081504822, 0.177201509475708, -0.11570670455694199, 0.04361787065863609, 0.070060133934021, 0.40478208661079407, -0.16697058081626892, -0.27620503306388855, -0.12831233441829681, 0.11825147271156311, -0.13083836436271667, -0.4768890142440796, 0.9436963796615601, -0.8370056748390198, -0.3582906424999237, 0.2789956331253052, -0.7134209275245667, -0.03986117243766785, -0.32654106616973877, 0.6198241114616394, 0.4585057497024536, -0.6961711049079895, 0.5115857720375061, -0.22929508984088898, -0.44659942388534546, 0.3906383514404297, -0.29806071519851685, -0.4874197542667389, 0.22447143495082855, 0.902230978012085, -0.5234335660934448, -0.07662484794855118, 0.6974019408226013, 0.18268021941184998, 0.1972568929195404, -0.7540782690048218, 0.16145218908786774, -0.13156381249427795, 0.588074266910553, -1.0683441162109375, 0.30249473452568054, 0.8400665521621704, 0.47553586959838867, -0.4598252773284912, -0.2067403942346573, -0.8708492517471313, -0.283275842666626, -0.23203222453594208, -0.18401674926280975, -0.5495933294296265, 1.218782901763916, 0.239736407995224, 0.18521395325660706, -0.1917710155248642, -0.5461402535438538, 0.14571575820446014, 0.004668646026402712, -0.19929653406143188, 0.12697455286979675, -0.3280128836631775, -0.5886898636817932, 0.22302460670471191, -0.4971023499965668, -0.41075021028518677, 0.33907508850097656, 0.407676100730896, -0.27239513397216797, -0.45195865631103516, 0.14889605343341827, 0.3355768918991089, -0.5228666663169861, -0.12074578553438187, -0.5339986681938171, -0.06062544137239456, 1.006304144859314, -0.36918461322784424, 0.37021008133888245, 0.5438523292541504, -0.7772119641304016, -0.045975420624017715, -0.7924363613128662, 0.512947678565979, -0.003562948200851679, -0.009431581944227219, -0.4735417664051056, 0.13429303467273712, -0.11795001477003098, -0.07338037341833115, -0.15307340025901794, 0.07787186652421951, 0.174309641122818, -0.08390356600284576, 0.4766653776168823, -0.12070371210575104, -0.37375226616859436, -0.4071563184261322, 0.056958504021167755, 0.06188056617975235, 0.12964613735675812, -0.34358277916908264, 0.7809591889381409, 0.22712215781211853, -0.4458172023296356, 0.13437648117542267, 0.12954799830913544, 1.001265287399292, 0.18989679217338562 }; +static float USPS_U1[HIDDEN_DIMS * USPS_uRank] = { 0.26560232043266296, 0.23243790864944458, 0.7191420197486877, -0.20894131064414978, 0.49118855595588684, 0.6319213509559631, 0.34289464354515076, 0.01801704801619053, -0.0745602548122406, -1.0685001611709595, -0.26240262389183044, 0.4905305802822113, 0.1572536826133728, -0.23067831993103027, -0.5052195191383362, 0.7681716680526733, 0.9279878735542297, -0.5277288556098938, -0.08344665914773941, 0.6202220916748047, -0.5001773238182068, -0.5095654726028442, -0.3295743465423584, 0.5233407616615295, -0.5727354288101196, -0.8839725852012634, -0.010022483766078949, -0.09335310012102127, -0.39809176325798035, -0.1842958629131317, 0.24937759339809418, -0.10589130222797394, 0.08205743134021759, 0.31646987795829773, -0.29515960812568665, 0.5459985733032227, 0.1268385350704193, 0.04255566745996475, 0.33306896686553955, -0.16022534668445587, -0.29528936743736267, -0.25233426690101624, -0.2937506437301636, 0.4037521183490753, 0.23886920511722565, 0.06710945069789886, 0.08734912425279617, 0.5572593808174133, -1.314361333847046, 0.03353128582239151, 0.2606905698776245, 0.6152605414390564, -0.3894504904747009, -0.32302090525627136, 0.36168500781059265, 0.6218935251235962, -0.38376080989837646, 0.09247376024723053, 1.026206612586975, 1.1414283514022827, -0.10093820095062256, 0.9370135068893433, 1.9249975681304932, -0.5042387247085571, 0.18620948493480682, -0.3022148311138153, 0.03854614496231079, 0.37739163637161255, -0.3281741440296173, -0.34284695982933044, 0.5523097515106201, 0.03876172751188278, -0.1751827448606491, -0.0030013038776814938, 0.05078490078449249, -0.29853954911231995, -0.6525045037269592, -0.05094808712601662, -0.20980416238307953, 0.03934936225414276, 0.7077404856681824, -0.5978014469146729, -0.03315050154924393, -0.9729236960411072, -0.8541942834854126, -0.23380915820598602, -0.8171064853668213, 0.08188191801309586, 0.3533187210559845, -0.3635164201259613, -0.8342750072479248, 0.726115882396698, 0.2952367961406708, -0.4665921926498413, 0.7437827587127686, 0.45183295011520386, 0.5798006057739258, 0.2457144558429718, 0.4404001533985138, 0.12141070514917374, 0.3805271089076996, -0.23846925795078278, 0.7316015958786011, -0.3569253087043762, 0.15102985501289368, -0.39612525701522827, 0.28232714533805847, -0.6851686239242554, 0.6952816247940063, 0.452238529920578, 0.08832887560129166, 1.4521069526672363, 0.36747226119041443, 0.31619787216186523, 0.19886334240436554, 0.23799069225788116, -0.5594980716705322, -0.3654753267765045, -0.19946272671222687, -0.10181467235088348, -0.12737073004245758, 0.7593855857849121, -0.9848454594612122, 0.6157532930374146, 0.2603704035282135, 0.999906063079834, -0.4353993237018585, -0.4969525635242462, -0.714335024356842, 0.04920447617769241, 0.151398703455925, -0.40162163972854614, -0.27132919430732727, 0.7902809977531433, -0.10028137266635895, 1.0021592378616333, -0.30421894788742065, 0.3746432662010193, 0.5291203856468201, -0.3812990188598633, 0.7990191578865051, 0.508926272392273, -0.1624583899974823, -0.1668565720319748, 0.2089664191007614, -0.13996511697769165, 0.3811531960964203, 0.2811248302459717, 0.6223021149635315, -0.7457583546638489, -0.33088400959968567, 1.0035068988800049, -0.35653096437454224, -0.4059991240501404, -0.1819305270910263, -0.4383915662765503, 0.7609431743621826, -0.7965887784957886, 0.5413278937339783, -0.3607611358165741 }; +static float USPS_U2[USPS_uRank * HIDDEN_DIMS] = { -1.1701158285140991, -0.1588035672903061, -1.1778416633605957, 0.11378461867570877, 0.1573396474123001, 0.13804543018341064, -0.28284865617752075, 0.8901959657669067, -0.5648555755615234, -0.6038640737533569, -0.4130585789680481, 0.7159488797187805, -1.263935923576355, 0.22861142456531525, 0.39220884442329407, 0.6647656559944153, 0.28182974457740784, 0.6640202403068542, 0.20066450536251068, -0.7047211527824402, 0.42111220955848694, -0.5956082344055176, -0.1325611025094986, 0.5465019941329956, -0.42245036363601685, -0.6001131534576416, -0.2538827061653137, -0.24035486578941345, -0.46974751353263855, 0.9539428949356079, 0.4083715081214905, 0.1597665399312973, 0.31555771827697754, -0.1176120713353157, -0.3248029053211212, 0.5774492025375366, 0.06316787749528885, 0.13469642400741577, 0.7753828167915344, -0.19036400318145752, 0.558892548084259, 0.2966901361942291, -0.2756923735141754, 0.0863649770617485, 0.5044283270835876, 0.5554067492485046, 1.2062954902648926, -0.06426048278808594, 0.251096248626709, 0.7044650316238403, 0.7219952940940857, 0.2331368625164032, 0.6588672995567322, -0.021296916529536247, -0.5537024140357971, 0.1907256543636322, -0.08542638272047043, -0.9375039339065552, -0.11962691694498062, -0.34279578924179077, -0.1679597795009613, 0.8744648694992065, 0.4903189241886139, -0.002235307591035962, 0.49500423669815063, -0.20796941220760345, -0.4931069314479828, 0.19794103503227234, 0.23972071707248688, 0.07782389968633652, -1.5402740240097046, 0.4908592104911804, 0.37148523330688477, 0.9664593935012817, -1.0712075233459473, -0.47738638520240784, 0.3663298785686493, 0.01408083550632, -0.5519229173660278, -0.5287301540374756, 0.2269572615623474, 0.05943543091416359, -0.813250720500946, 0.3974776566028595, 0.6844959855079651, 0.009752316400408745, -0.22982186079025269, -0.18944667279720306, -0.33985260128974915, 0.20089533925056458, 0.24146895110607147, -0.3968782126903534, -0.6829974055290222, 0.2860521376132965, 0.06187593191862106, -0.0817679762840271, 1.0080456733703613, 1.087625503540039, 0.8712841868400574, 1.0755778551101685, -0.474960595369339, -0.723259687423706, -0.9868606925010681, 0.8535012602806091, -0.5053154230117798, -0.30608052015304565, -0.7238053679466248, -0.04056096449494362, -0.37457355856895447, 0.14730329811573029, -0.1650729775428772, 0.4555414319038391, -0.0914393812417984, -0.027970634400844574, 0.48361921310424805, 0.09482058882713318, -0.6751720309257507, 0.7193213105201721, -0.3357415199279785, 0.033068787306547165, -0.6387664079666138, -0.08479925990104675, -0.19875706732273102, -0.9184507727622986, 0.700031578540802, 0.19395720958709717, 0.05879056081175804, -0.3861687183380127, 0.15968921780586243, -0.22974976897239685, 0.21669058501720428, 0.07636229693889618, 0.30239996314048767, -0.22337456047534943, 0.14845764636993408, -0.3706870675086975, -0.9184858798980713, 0.28799909353256226, -0.6701984405517578, -0.1726493388414383, -0.061379268765449524, -0.5134955048561096, 0.6964709758758545, -0.006153882015496492, -0.009776073507964611, 0.16820202767848969, 0.4359828531742096, 0.5606184601783752, -0.7106017470359802, 0.10443971306085587, 0.3130362927913666, -1.2240679264068604, 0.08121868968009949, 0.1808670610189438, -0.30179110169410706, 0.26126185059547424, 0.42505496740341187, -0.369361937046051, -0.02273283340036869, 0.059929925948381424 }; -static const float U1[hiddenDims * wRank] = { 0.26560232043266296, 0.23243790864944458, 0.7191420197486877, -0.20894131064414978, 0.49118855595588684, 0.6319213509559631, 0.34289464354515076, 0.01801704801619053, -0.0745602548122406, -1.0685001611709595, -0.26240262389183044, 0.4905305802822113, 0.1572536826133728, -0.23067831993103027, -0.5052195191383362, 0.7681716680526733, 0.9279878735542297, -0.5277288556098938, -0.08344665914773941, 0.6202220916748047, -0.5001773238182068, -0.5095654726028442, -0.3295743465423584, 0.5233407616615295, -0.5727354288101196, -0.8839725852012634, -0.010022483766078949, -0.09335310012102127, -0.39809176325798035, -0.1842958629131317, 0.24937759339809418, -0.10589130222797394, 0.08205743134021759, 0.31646987795829773, -0.29515960812568665, 0.5459985733032227, 0.1268385350704193, 0.04255566745996475, 0.33306896686553955, -0.16022534668445587, -0.29528936743736267, -0.25233426690101624, -0.2937506437301636, 0.4037521183490753, 0.23886920511722565, 0.06710945069789886, 0.08734912425279617, 0.5572593808174133, -1.314361333847046, 0.03353128582239151, 0.2606905698776245, 0.6152605414390564, -0.3894504904747009, -0.32302090525627136, 0.36168500781059265, 0.6218935251235962, -0.38376080989837646, 0.09247376024723053, 1.026206612586975, 1.1414283514022827, -0.10093820095062256, 0.9370135068893433, 1.9249975681304932, -0.5042387247085571, 0.18620948493480682, -0.3022148311138153, 0.03854614496231079, 0.37739163637161255, -0.3281741440296173, -0.34284695982933044, 0.5523097515106201, 0.03876172751188278, -0.1751827448606491, -0.0030013038776814938, 0.05078490078449249, -0.29853954911231995, -0.6525045037269592, -0.05094808712601662, -0.20980416238307953, 0.03934936225414276, 0.7077404856681824, -0.5978014469146729, -0.03315050154924393, -0.9729236960411072, -0.8541942834854126, -0.23380915820598602, -0.8171064853668213, 0.08188191801309586, 0.3533187210559845, -0.3635164201259613, -0.8342750072479248, 0.726115882396698, 0.2952367961406708, -0.4665921926498413, 0.7437827587127686, 0.45183295011520386, 0.5798006057739258, 0.2457144558429718, 0.4404001533985138, 0.12141070514917374, 0.3805271089076996, -0.23846925795078278, 0.7316015958786011, -0.3569253087043762, 0.15102985501289368, -0.39612525701522827, 0.28232714533805847, -0.6851686239242554, 0.6952816247940063, 0.452238529920578, 0.08832887560129166, 1.4521069526672363, 0.36747226119041443, 0.31619787216186523, 0.19886334240436554, 0.23799069225788116, -0.5594980716705322, -0.3654753267765045, -0.19946272671222687, -0.10181467235088348, -0.12737073004245758, 0.7593855857849121, -0.9848454594612122, 0.6157532930374146, 0.2603704035282135, 0.999906063079834, -0.4353993237018585, -0.4969525635242462, -0.714335024356842, 0.04920447617769241, 0.151398703455925, -0.40162163972854614, -0.27132919430732727, 0.7902809977531433, -0.10028137266635895, 1.0021592378616333, -0.30421894788742065, 0.3746432662010193, 0.5291203856468201, -0.3812990188598633, 0.7990191578865051, 0.508926272392273, -0.1624583899974823, -0.1668565720319748, 0.2089664191007614, -0.13996511697769165, 0.3811531960964203, 0.2811248302459717, 0.6223021149635315, -0.7457583546638489, -0.33088400959968567, 1.0035068988800049, -0.35653096437454224, -0.4059991240501404, -0.1819305270910263, -0.4383915662765503, 0.7609431743621826, -0.7965887784957886, 0.5413278937339783, -0.3607611358165741 }; -static const float U2[wRank * hiddenDims] = { -1.1701158285140991, -0.1588035672903061, -1.1778416633605957, 0.11378461867570877, 0.1573396474123001, 0.13804543018341064, -0.28284865617752075, 0.8901959657669067, -0.5648555755615234, -0.6038640737533569, -0.4130585789680481, 0.7159488797187805, -1.263935923576355, 0.22861142456531525, 0.39220884442329407, 0.6647656559944153, 0.28182974457740784, 0.6640202403068542, 0.20066450536251068, -0.7047211527824402, 0.42111220955848694, -0.5956082344055176, -0.1325611025094986, 0.5465019941329956, -0.42245036363601685, -0.6001131534576416, -0.2538827061653137, -0.24035486578941345, -0.46974751353263855, 0.9539428949356079, 0.4083715081214905, 0.1597665399312973, 0.31555771827697754, -0.1176120713353157, -0.3248029053211212, 0.5774492025375366, 0.06316787749528885, 0.13469642400741577, 0.7753828167915344, -0.19036400318145752, 0.558892548084259, 0.2966901361942291, -0.2756923735141754, 0.0863649770617485, 0.5044283270835876, 0.5554067492485046, 1.2062954902648926, -0.06426048278808594, 0.251096248626709, 0.7044650316238403, 0.7219952940940857, 0.2331368625164032, 0.6588672995567322, -0.021296916529536247, -0.5537024140357971, 0.1907256543636322, -0.08542638272047043, -0.9375039339065552, -0.11962691694498062, -0.34279578924179077, -0.1679597795009613, 0.8744648694992065, 0.4903189241886139, -0.002235307591035962, 0.49500423669815063, -0.20796941220760345, -0.4931069314479828, 0.19794103503227234, 0.23972071707248688, 0.07782389968633652, -1.5402740240097046, 0.4908592104911804, 0.37148523330688477, 0.9664593935012817, -1.0712075233459473, -0.47738638520240784, 0.3663298785686493, 0.01408083550632, -0.5519229173660278, -0.5287301540374756, 0.2269572615623474, 0.05943543091416359, -0.813250720500946, 0.3974776566028595, 0.6844959855079651, 0.009752316400408745, -0.22982186079025269, -0.18944667279720306, -0.33985260128974915, 0.20089533925056458, 0.24146895110607147, -0.3968782126903534, -0.6829974055290222, 0.2860521376132965, 0.06187593191862106, -0.0817679762840271, 1.0080456733703613, 1.087625503540039, 0.8712841868400574, 1.0755778551101685, -0.474960595369339, -0.723259687423706, -0.9868606925010681, 0.8535012602806091, -0.5053154230117798, -0.30608052015304565, -0.7238053679466248, -0.04056096449494362, -0.37457355856895447, 0.14730329811573029, -0.1650729775428772, 0.4555414319038391, -0.0914393812417984, -0.027970634400844574, 0.48361921310424805, 0.09482058882713318, -0.6751720309257507, 0.7193213105201721, -0.3357415199279785, 0.033068787306547165, -0.6387664079666138, -0.08479925990104675, -0.19875706732273102, -0.9184507727622986, 0.700031578540802, 0.19395720958709717, 0.05879056081175804, -0.3861687183380127, 0.15968921780586243, -0.22974976897239685, 0.21669058501720428, 0.07636229693889618, 0.30239996314048767, -0.22337456047534943, 0.14845764636993408, -0.3706870675086975, -0.9184858798980713, 0.28799909353256226, -0.6701984405517578, -0.1726493388414383, -0.061379268765449524, -0.5134955048561096, 0.6964709758758545, -0.006153882015496492, -0.009776073507964611, 0.16820202767848969, 0.4359828531742096, 0.5606184601783752, -0.7106017470359802, 0.10443971306085587, 0.3130362927913666, -1.2240679264068604, 0.08121868968009949, 0.1808670610189438, -0.30179110169410706, 0.26126185059547424, 0.42505496740341187, -0.369361937046051, -0.02273283340036869, 0.059929925948381424 }; +static float USPS_Bg[HIDDEN_DIMS] = { 4.59620475769043, 0.1966695934534073, 1.9611409902572632, 3.5603864192962646, 4.187475204467773, 4.361924648284912, 0.3600460886955261, 1.3823245763778687, -0.677017092704773, 4.105582237243652, 5.264251232147217, -0.5598424077033997, 5.148655414581299, 2.0772266387939453, 4.553979873657227, 5.08613920211792, 4.782368183135986, 0.7364211678504944, 5.434220314025879, 3.580031394958496, 3.1102733612060547, -0.7808840870857239, 0.7291825413703918, 4.574047565460205, 3.3059921264648438, 0.3563838303089142, 2.718221664428711, 3.580395460128784, 3.4779181480407715, 2.5830607414245605, 2.9951508045196533, 0.9241535663604736 }; +static float USPS_Bh[HIDDEN_DIMS] = { 0.4606550931930542, 0.790073573589325, -0.017053354531526566, 0.9936599731445312, 1.7931172847747803, 1.5456229448318481, 1.1712238788604736, 0.25801223516464233, 0.31747567653656006, 0.19287768006324768, 2.0994107723236084, 1.0495734214782715, 1.4762489795684814, 1.309980034828186, 0.3596293032169342, 1.5582088232040405, 0.40993940830230713, 1.8783470392227173, 1.493168830871582, -0.24529218673706055, 1.1273030042648315, 0.2839592695236206, 1.9818940162658691, 1.6705248355865479, 0.6683108806610107, 1.1119632720947266, 1.71348237991333, 2.004892110824585, 2.6525025367736816, 1.5513267517089844, 1.5202845335006714, -0.5777350068092346 }; -static const float Bg[hiddenDims] = { 4.59620475769043, 0.1966695934534073, 1.9611409902572632, 3.5603864192962646, 4.187475204467773, 4.361924648284912, 0.3600460886955261, 1.3823245763778687, -0.677017092704773, 4.105582237243652, 5.264251232147217, -0.5598424077033997, 5.148655414581299, 2.0772266387939453, 4.553979873657227, 5.08613920211792, 4.782368183135986, 0.7364211678504944, 5.434220314025879, 3.580031394958496, 3.1102733612060547, -0.7808840870857239, 0.7291825413703918, 4.574047565460205, 3.3059921264648438, 0.3563838303089142, 2.718221664428711, 3.580395460128784, 3.4779181480407715, 2.5830607414245605, 2.9951508045196533, 0.9241535663604736 }; -static const float Bh[hiddenDims] = { 0.4606550931930542, 0.790073573589325, -0.017053354531526566, 0.9936599731445312, 1.7931172847747803, 1.5456229448318481, 1.1712238788604736, 0.25801223516464233, 0.31747567653656006, 0.19287768006324768, 2.0994107723236084, 1.0495734214782715, 1.4762489795684814, 1.309980034828186, 0.3596293032169342, 1.5582088232040405, 0.40993940830230713, 1.8783470392227173, 1.493168830871582, -0.24529218673706055, 1.1273030042648315, 0.2839592695236206, 1.9818940162658691, 1.6705248355865479, 0.6683108806610107, 1.1119632720947266, 1.71348237991333, 2.004892110824585, 2.6525025367736816, 1.5513267517089844, 1.5202845335006714, -0.5777350068092346 }; +static float USPS_zeta = 0.8710977; +static float USPS_nu = 0.077582605; -static const float FC_weights[hiddenDims * numClasses] = { -0.24747183918952942, -0.055960506200790405, 1.3475773334503174, -0.2660730183124542, 0.08773329854011536, 2.71574068069458, -1.4928890466690063, 1.5905754566192627, 1.4361884593963623, 1.3066115379333496, -0.41571110486984253, 0.9617563486099243, 0.40012961626052856, 0.8696961998939514, -1.6383168697357178, 0.7999024391174316, -0.16858834028244019, -1.0727401971817017, 0.7396827340126038, 0.3806271553039551, -0.8257421255111694, 0.1623869240283966, -0.39433446526527405, -3.482332468032837, -0.08032357692718506, 0.994373083114624, 0.9860239028930664, -5.6317973136901855, -3.062581777572632, -3.2377049922943115, -1.088222861289978, 0.7581420540809631, -0.1045861691236496, 1.0123625993728638, 2.7781565189361572, 4.226351737976074, -0.4395594894886017, -1.9928295612335205, -0.03426577150821686, 0.2318461388349533, -3.200232982635498, 0.7830891013145447, -2.003850221633911, -1.0072307586669922, -0.09394438564777374, -0.402126282453537, 2.8108479976654053, 0.027125360444188118, 1.893704891204834, -0.03775143623352051, 0.6053617596626282, 0.3430182933807373, -3.2976200580596924, -1.1353939771652222, 0.024645693600177765, 0.3784751296043396, 1.4342879056930542, -0.7492150664329529, -1.0270135402679443, 2.5554628372192383, 0.6594746112823486, 0.7780766487121582, 0.8985974788665771, -0.0034258293453603983, 0.21751202642917633, -2.3399763107299805, 1.1613740921020508, -1.447609305381775, -1.3636846542358398, 1.7248963117599487, -0.3620492219924927, -2.375091075897217, -1.3364042043685913, 1.359509825706482, -2.648242235183716, 1.4566280841827393, 0.6185098886489868, 0.9421749711036682, -1.8496538400650024, -1.3294904232025146, -0.565808892250061, -1.6445082426071167, 1.2565573453903198, 2.4306249618530273, -1.6949048042297363, 2.2069883346557617, 1.103385329246521, -0.9351933598518372, -0.824954628944397, -0.7599087953567505, -0.6911792755126953, 2.7740914821624756, 1.6341619491577148, 1.849193811416626, 1.146787166595459, -1.4661681652069092, 2.0738017559051514, -1.9961793422698975, -1.1605796813964844, 0.9941896200180054, 0.3308192789554596, 2.13922119140625, -0.17217597365379333, -0.9082329869270325, 0.7720779180526733, -1.0596287250518799, 1.586103081703186, -2.9859485626220703, 1.55707585811615, 1.1488341093063354, -3.2394535541534424, 1.169393539428711, -0.13278652727603912, 1.6355780363082886, -0.1245696097612381, 1.808440923690796, -1.1002291440963745, -0.3053940534591675, 1.6078038215637207, 3.8395557403564453, 0.019826073199510574, -0.3926658034324646, -1.9981871843338013, -0.6696834564208984, 0.08870892226696014, 1.6605280637741089, 0.5209671854972839, -2.3854024410247803, 1.5786619186401367, 1.8952832221984863, -1.304535150527954, 0.2743481695652008, 2.8763298988342285, -0.6256309747695923, 3.8730015754699707, -0.32314497232437134, -0.6618545651435852, -3.0481762886047363, -2.8654234409332275, -0.8415182828903198, -1.3170037269592285, 1.3599309921264648, 1.2142889499664307, 0.07019823044538498, -0.5422642827033997, 0.23863810300827026, 3.584157943725586, 0.7111842036247253, 0.9668632745742798, 1.3011258840560913, -0.003976037260144949, 1.7265373468399048, -0.48193755745887756, 0.463483989238739, -0.3804154098033905, 2.4481565952301025, -1.081111192703247, 1.9583369493484497, -3.963627338409424, 0.729573667049408, -0.4898405373096466, -0.5738614201545715, -1.7461729049682617, -1.8392359018325806, -0.4148902893066406, -1.158633828163147, -1.6964939832687378, 0.5787208080291748, 1.4248132705688477, -0.4257330894470215, 3.0490269660949707, -1.1780657768249512, 1.0951701402664185, 0.8462642431259155, 0.9555350542068481, 2.9707250595092773, -1.3199042081832886, 1.8216924667358398, -0.6233108639717102, 1.5412005186080933, 0.334654837846756, 0.2763754725456238, 1.3666235208511353, 1.851394534111023, -1.7485069036483765, 1.0322270393371582, -1.8656693696975708, -1.1901252269744873, 1.0325310230255127, -0.8999790549278259, 0.22713708877563477, -3.3022899627685547, -2.718987464904785, 0.6280394792556763, 0.7579594254493713, -2.2618398666381836, -1.1550352573394775, 1.0463181734085083, -0.2427310198545456, -0.1560579091310501, -0.19294323027133942, 0.3897946774959564, -1.5712190866470337, 1.0458306074142456, -0.7470991015434265, 1.2837566137313843, 2.3155717849731445, 2.0378687381744385, 0.7463016510009766, 1.3255469799041748, -1.7185251712799072, -0.1644330620765686, 2.248473882675171, -0.05582746863365173, -0.39194202423095703, -1.050262212753296, 1.1556638479232788, 0.03496933728456497, 1.5286030769348145, 0.01176676619797945, -1.1746597290039062, -0.038728803396224976, -0.3821633458137512, 0.9377774596214294, -0.3956509530544281, 1.074571967124939, -1.6802961826324463, -0.3645908534526825, -1.4564014673233032, 0.6331769227981567, 2.4816489219665527, 0.32858720421791077, 1.5533283948898315, 1.6947213411331177, 0.3252701461315155, 3.2225258350372314, 1.1926754713058472, 0.3901558518409729, -0.8612796664237976, -4.8346662521362305, -1.9908527135849, 0.7937301993370056, -1.5082682371139526, 0.4805694818496704, -1.419480323791504, 0.157501682639122, 2.0960652828216553, 0.005156002938747406, -2.6489176750183105, 1.263648271560669, -1.3384476900100708, 1.4031224250793457, 0.4655438959598541, 1.8326048851013184, 3.110736131668091, 0.26125067472457886, 2.7024500370025635, -0.9119302034378052, -0.6820136308670044, 3.8541572093963623, -1.3096107244491577, 1.7389343976974487, 2.067892551422119, 1.1543680429458618, 0.03984083607792854, 0.6176361441612244, -0.8746475577354431, 0.40996477007865906, -2.3278424739837646, 0.5317244529724121, -1.1554235219955444, 0.8648607730865479, 0.5743665099143982, 0.9955512881278992, 0.8316799998283386, -1.9429028034210205, 0.6146461367607117, -4.532263278961182, -0.8694373965263367, -0.31155335903167725, -0.030860910192131996, 1.173535704612732, 0.8387981057167053, -1.3379566669464111, 1.902561902999878, 2.197434663772583, 1.3871995210647583, -1.6537810564041138, -2.7861647605895996, -0.005632062442600727, -2.181979179382324, 2.3240818977355957, 0.914097785949707, 0.10216601192951202, 2.52095103263855, 0.6039048433303833, -1.1367847919464111, -2.309983015060425, 2.7826766967773438, -0.6315389275550842, -3.811366319656372, 2.09122633934021, -0.6774390339851379, -0.9190919995307922, 0.9899649620056152, 1.0903472900390625, -0.7736498713493347, -1.3925520181655884, 0.6861974596977234, 3.141139268875122, 0.7085739970207214, 0.35131436586380005, 1.6807632446289062, 1.0083352327346802, -0.38794782757759094, -1.839680790901184, -0.7718075513839722, 0.41827693581581116, 1.8001973628997803, 1.2126221656799316 }; -static const float FCbias[numClasses] = { 0.7145490646362305, 0.2392704039812088, 0.7243489027023315, -0.3943518102169037, -0.7943000793457031, 0.18482555449008942, 0.29146698117256165, -0.04441819712519646, 1.5886560678482056, -0.8504140377044678 }; +static float FC_weights[HIDDEN_DIMS * NUM_CLASSES] = { -0.24747183918952942, -0.055960506200790405, 1.3475773334503174, -0.2660730183124542, 0.08773329854011536, 2.71574068069458, -1.4928890466690063, 1.5905754566192627, 1.4361884593963623, 1.3066115379333496, -0.41571110486984253, 0.9617563486099243, 0.40012961626052856, 0.8696961998939514, -1.6383168697357178, 0.7999024391174316, -0.16858834028244019, -1.0727401971817017, 0.7396827340126038, 0.3806271553039551, -0.8257421255111694, 0.1623869240283966, -0.39433446526527405, -3.482332468032837, -0.08032357692718506, 0.994373083114624, 0.9860239028930664, -5.6317973136901855, -3.062581777572632, -3.2377049922943115, -1.088222861289978, 0.7581420540809631, -0.1045861691236496, 1.0123625993728638, 2.7781565189361572, 4.226351737976074, -0.4395594894886017, -1.9928295612335205, -0.03426577150821686, 0.2318461388349533, -3.200232982635498, 0.7830891013145447, -2.003850221633911, -1.0072307586669922, -0.09394438564777374, -0.402126282453537, 2.8108479976654053, 0.027125360444188118, 1.893704891204834, -0.03775143623352051, 0.6053617596626282, 0.3430182933807373, -3.2976200580596924, -1.1353939771652222, 0.024645693600177765, 0.3784751296043396, 1.4342879056930542, -0.7492150664329529, -1.0270135402679443, 2.5554628372192383, 0.6594746112823486, 0.7780766487121582, 0.8985974788665771, -0.0034258293453603983, 0.21751202642917633, -2.3399763107299805, 1.1613740921020508, -1.447609305381775, -1.3636846542358398, 1.7248963117599487, -0.3620492219924927, -2.375091075897217, -1.3364042043685913, 1.359509825706482, -2.648242235183716, 1.4566280841827393, 0.6185098886489868, 0.9421749711036682, -1.8496538400650024, -1.3294904232025146, -0.565808892250061, -1.6445082426071167, 1.2565573453903198, 2.4306249618530273, -1.6949048042297363, 2.2069883346557617, 1.103385329246521, -0.9351933598518372, -0.824954628944397, -0.7599087953567505, -0.6911792755126953, 2.7740914821624756, 1.6341619491577148, 1.849193811416626, 1.146787166595459, -1.4661681652069092, 2.0738017559051514, -1.9961793422698975, -1.1605796813964844, 0.9941896200180054, 0.3308192789554596, 2.13922119140625, -0.17217597365379333, -0.9082329869270325, 0.7720779180526733, -1.0596287250518799, 1.586103081703186, -2.9859485626220703, 1.55707585811615, 1.1488341093063354, -3.2394535541534424, 1.169393539428711, -0.13278652727603912, 1.6355780363082886, -0.1245696097612381, 1.808440923690796, -1.1002291440963745, -0.3053940534591675, 1.6078038215637207, 3.8395557403564453, 0.019826073199510574, -0.3926658034324646, -1.9981871843338013, -0.6696834564208984, 0.08870892226696014, 1.6605280637741089, 0.5209671854972839, -2.3854024410247803, 1.5786619186401367, 1.8952832221984863, -1.304535150527954, 0.2743481695652008, 2.8763298988342285, -0.6256309747695923, 3.8730015754699707, -0.32314497232437134, -0.6618545651435852, -3.0481762886047363, -2.8654234409332275, -0.8415182828903198, -1.3170037269592285, 1.3599309921264648, 1.2142889499664307, 0.07019823044538498, -0.5422642827033997, 0.23863810300827026, 3.584157943725586, 0.7111842036247253, 0.9668632745742798, 1.3011258840560913, -0.003976037260144949, 1.7265373468399048, -0.48193755745887756, 0.463483989238739, -0.3804154098033905, 2.4481565952301025, -1.081111192703247, 1.9583369493484497, -3.963627338409424, 0.729573667049408, -0.4898405373096466, -0.5738614201545715, -1.7461729049682617, -1.8392359018325806, -0.4148902893066406, -1.158633828163147, -1.6964939832687378, 0.5787208080291748, 1.4248132705688477, -0.4257330894470215, 3.0490269660949707, -1.1780657768249512, 1.0951701402664185, 0.8462642431259155, 0.9555350542068481, 2.9707250595092773, -1.3199042081832886, 1.8216924667358398, -0.6233108639717102, 1.5412005186080933, 0.334654837846756, 0.2763754725456238, 1.3666235208511353, 1.851394534111023, -1.7485069036483765, 1.0322270393371582, -1.8656693696975708, -1.1901252269744873, 1.0325310230255127, -0.8999790549278259, 0.22713708877563477, -3.3022899627685547, -2.718987464904785, 0.6280394792556763, 0.7579594254493713, -2.2618398666381836, -1.1550352573394775, 1.0463181734085083, -0.2427310198545456, -0.1560579091310501, -0.19294323027133942, 0.3897946774959564, -1.5712190866470337, 1.0458306074142456, -0.7470991015434265, 1.2837566137313843, 2.3155717849731445, 2.0378687381744385, 0.7463016510009766, 1.3255469799041748, -1.7185251712799072, -0.1644330620765686, 2.248473882675171, -0.05582746863365173, -0.39194202423095703, -1.050262212753296, 1.1556638479232788, 0.03496933728456497, 1.5286030769348145, 0.01176676619797945, -1.1746597290039062, -0.038728803396224976, -0.3821633458137512, 0.9377774596214294, -0.3956509530544281, 1.074571967124939, -1.6802961826324463, -0.3645908534526825, -1.4564014673233032, 0.6331769227981567, 2.4816489219665527, 0.32858720421791077, 1.5533283948898315, 1.6947213411331177, 0.3252701461315155, 3.2225258350372314, 1.1926754713058472, 0.3901558518409729, -0.8612796664237976, -4.8346662521362305, -1.9908527135849, 0.7937301993370056, -1.5082682371139526, 0.4805694818496704, -1.419480323791504, 0.157501682639122, 2.0960652828216553, 0.005156002938747406, -2.6489176750183105, 1.263648271560669, -1.3384476900100708, 1.4031224250793457, 0.4655438959598541, 1.8326048851013184, 3.110736131668091, 0.26125067472457886, 2.7024500370025635, -0.9119302034378052, -0.6820136308670044, 3.8541572093963623, -1.3096107244491577, 1.7389343976974487, 2.067892551422119, 1.1543680429458618, 0.03984083607792854, 0.6176361441612244, -0.8746475577354431, 0.40996477007865906, -2.3278424739837646, 0.5317244529724121, -1.1554235219955444, 0.8648607730865479, 0.5743665099143982, 0.9955512881278992, 0.8316799998283386, -1.9429028034210205, 0.6146461367607117, -4.532263278961182, -0.8694373965263367, -0.31155335903167725, -0.030860910192131996, 1.173535704612732, 0.8387981057167053, -1.3379566669464111, 1.902561902999878, 2.197434663772583, 1.3871995210647583, -1.6537810564041138, -2.7861647605895996, -0.005632062442600727, -2.181979179382324, 2.3240818977355957, 0.914097785949707, 0.10216601192951202, 2.52095103263855, 0.6039048433303833, -1.1367847919464111, -2.309983015060425, 2.7826766967773438, -0.6315389275550842, -3.811366319656372, 2.09122633934021, -0.6774390339851379, -0.9190919995307922, 0.9899649620056152, 1.0903472900390625, -0.7736498713493347, -1.3925520181655884, 0.6861974596977234, 3.141139268875122, 0.7085739970207214, 0.35131436586380005, 1.6807632446289062, 1.0083352327346802, -0.38794782757759094, -1.839680790901184, -0.7718075513839722, 0.41827693581581116, 1.8001973628997803, 1.2126221656799316 }; +static float FCbias[NUM_CLASSES] = { 0.7145490646362305, 0.2392704039812088, 0.7243489027023315, -0.3943518102169037, -0.7943000793457031, 0.18482555449008942, 0.29146698117256165, -0.04441819712519646, 1.5886560678482056, -0.8504140377044678 }; // Here are 10 example with labels to check code correctness #define numExamples 10 -static const float input[numExamples * inputDims * timeSteps] = { +static float input[numExamples * INPUT_DIMS * TIME_STEPS] = { -9.999989999999999712e-01, -9.999280000000000390e-01, -9.978850000000000220e-01, -9.737289999999999557e-01, -8.557719999999999771e-01, -5.974159999999999471e-01, -2.892540000000000111e-01, 1.891000000000000103e-03, 1.991960000000000119e-01, 2.921619999999999773e-01, 5.840999999999999664e-02, -3.988849999999999896e-01, -7.828040000000000553e-01, -9.586670000000000469e-01, -9.971060000000000478e-01, -9.999299999999999855e-01, -9.999660000000000215e-01, -9.984709999999999974e-01, -9.743000000000000549e-01, -8.181580000000000519e-01, -3.776260000000000172e-01, 1.784530000000000005e-01, 4.618349999999999955e-01, 4.866269999999999762e-01, 4.564190000000000191e-01, 4.585899999999999976e-01, 4.410350000000000104e-01, 2.776770000000000072e-01, -2.715719999999999801e-01, -7.943890000000000118e-01, -9.763939999999999841e-01, -9.989860000000000406e-01, -9.994060000000000166e-01, -9.843779999999999752e-01, -8.419809999999999794e-01, -3.601309999999999789e-01, 2.763050000000000228e-01, 5.122529999999999584e-01, 3.171390000000000042e-01, -5.488300000000000123e-02, -3.208799999999999986e-01, -3.823739999999999917e-01, -1.500219999999999887e-01, 3.192159999999999997e-01, 2.445279999999999954e-01, -4.316969999999999974e-01, -8.891390000000000127e-01, -9.936409999999999965e-01, -9.952950000000000408e-01, -9.140859999999999541e-01, -4.970399999999999818e-01, 2.440730000000000122e-01, 4.769090000000000273e-01, 3.452399999999999913e-02, -4.699980000000000269e-01, -7.523990000000000400e-01, -8.733349999999999724e-01, -8.564300000000000246e-01, -5.707010000000000138e-01, 7.110299999999999954e-02, 5.098099999999999854e-01, 3.845200000000000007e-02, -7.229849999999999888e-01, -9.823070000000000412e-01, -9.843929999999999625e-01, -7.619580000000000242e-01, -5.724800000000000028e-02, 4.982750000000000234e-01, 1.289379999999999971e-01, -5.653420000000000112e-01, -9.008960000000000301e-01, -9.768630000000000368e-01, -9.654559999999999809e-01, -7.698230000000000350e-01, -2.443150000000000044e-01, 3.408079999999999998e-01, 6.986529999999999685e-01, 2.799619999999999886e-01, -6.274570000000000425e-01, -9.747249999999999526e-01, -9.740199999999999969e-01, -6.315579999999999528e-01, 2.490229999999999944e-01, 4.868640000000000190e-01, -2.849450000000000038e-01, -8.529759999999999565e-01, -9.786280000000000534e-01, -9.680050000000000043e-01, -8.506489999999999885e-01, -3.887789999999999857e-01, 3.913400000000000212e-01, 7.540489999999999693e-01, 6.519970000000000487e-01, 6.102400000000000185e-02, -7.050119999999999720e-01, -9.787219999999999809e-01, -9.727649999999999908e-01, -6.046329999999999760e-01, 3.010070000000000245e-01, 4.125269999999999770e-01, -4.544940000000000091e-01, -8.776140000000000052e-01, -8.431469999999999798e-01, -6.940309999999999535e-01, -3.879340000000000011e-01, 1.740309999999999913e-01, 7.366949999999999887e-01, 7.265779999999999461e-01, 1.642170000000000019e-01, -4.996470000000000078e-01, -8.923109999999999653e-01, -9.926230000000000331e-01, -9.797400000000000553e-01, -6.899070000000000480e-01, 9.411700000000000621e-02, 3.872579999999999911e-01, -1.671759999999999913e-01, -4.210010000000000141e-01, -2.404840000000000033e-01, 5.989099999999999979e-02, 4.223910000000000164e-01, 7.399440000000000461e-01, 8.160749999999999948e-01, 3.639479999999999937e-01, -4.222170000000000090e-01, -8.689219999999999722e-01, -9.837040000000000228e-01, -9.991529999999999578e-01, -9.896549999999999514e-01, -8.313369999999999926e-01, -2.835340000000000082e-01, 3.112550000000000039e-01, 4.447369999999999934e-01, 4.600369999999999737e-01, 5.187220000000000164e-01, 5.491030000000000078e-01, 6.715740000000000043e-01, 8.727289999999999770e-01, 6.886210000000000386e-01, -8.334999999999999354e-02, -7.613389999999999880e-01, -9.757749999999999480e-01, -9.987230000000000274e-01, -9.999609999999999888e-01, -9.974539999999999518e-01, -9.540859999999999896e-01, -7.398449999999999749e-01, -2.981320000000000081e-01, 1.168259999999999993e-01, 2.966269999999999740e-01, 2.590549999999999797e-01, 1.147709999999999980e-01, 3.006869999999999821e-01, 7.234869999999999912e-01, 4.759129999999999749e-01, -4.180459999999999732e-01, -9.063860000000000250e-01, -9.947169999999999623e-01, -9.999120000000000230e-01, -9.999989999999999712e-01, -9.998259999999999925e-01, -9.956909999999999927e-01, -9.592690000000000383e-01, -8.423429999999999529e-01, -6.910760000000000236e-01, -6.172760000000000469e-01, -6.201600000000000446e-01, -4.761870000000000269e-01, 1.655320000000000125e-01, 6.454130000000000145e-01, 2.260870000000000102e-01, -6.278190000000000159e-01, -9.656599999999999628e-01, -9.988850000000000229e-01, -9.999900000000000455e-01, -1.000000000000000000e+00, -9.999970000000000248e-01, -9.998519999999999630e-01, -9.978810000000000180e-01, -9.905059999999999976e-01, -9.802600000000000202e-01, -9.741710000000000091e-01, -9.412179999999999991e-01, -5.735930000000000195e-01, 3.320199999999999818e-01, 6.261999999999999789e-01, -3.573099999999999887e-02, -7.612609999999999655e-01, -9.845939999999999692e-01, -9.997819999999999485e-01, -9.999989999999999712e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999989999999999712e-01, -9.999770000000000048e-01, -9.998920000000000030e-01, -9.997390000000000443e-01, -9.965319999999999734e-01, -9.296180000000000554e-01, -4.550699999999999745e-01, 4.870189999999999797e-01, 5.592399999999999594e-01, -3.041880000000000139e-01, -8.719719999999999693e-01, -9.928409999999999735e-01, -9.999190000000000023e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999329999999999607e-01, -9.939230000000000009e-01, -8.872520000000000406e-01, -3.392859999999999765e-01, 5.403149999999999897e-01, 4.513349999999999862e-01, -4.945749999999999869e-01, -9.424919999999999964e-01, -9.976519999999999833e-01, -9.999759999999999760e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999259999999999815e-01, -9.933429999999999760e-01, -8.806059999999999999e-01, -3.493580000000000019e-01, 4.458260000000000001e-01, 3.244429999999999814e-01, -5.840009999999999923e-01, -9.678870000000000529e-01, -9.992910000000000403e-01, -9.999949999999999672e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999679999999999680e-01, -9.970299999999999718e-01, -9.415249999999999453e-01, -6.157479999999999620e-01, -2.896299999999999916e-02, -4.975899999999999768e-02, -6.953970000000000429e-01, -9.771060000000000301e-01, -9.995380000000000376e-01, -9.999970000000000248e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999970000000000248e-01, -9.998139999999999805e-01, -9.966190000000000326e-01, -9.780339999999999590e-01, -9.545759999999999801e-01, -9.752389999999999670e-01, -9.954779999999999740e-01, -9.997519999999999740e-01, -9.999970000000000248e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999980000000000535e-01, -9.998369999999999758e-01, -9.954880000000000395e-01, -9.504259999999999931e-01, -7.896699999999999831e-01, -6.470510000000000428e-01, -8.003550000000000386e-01, -9.586339999999999861e-01, -9.975939999999999808e-01, -9.999730000000000008e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999430000000000263e-01, -9.972550000000000026e-01, -9.556320000000000370e-01, -7.292520000000000113e-01, -2.420829999999999926e-01, -2.454399999999999984e-02, -5.075699999999999656e-01, -9.040599999999999747e-01, -9.945370000000000044e-01, -9.999390000000000223e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.992020000000000346e-01, -9.800210000000000310e-01, -8.063310000000000199e-01, -2.593779999999999974e-01, 3.189710000000000045e-01, 1.385699999999999987e-01, -5.933460000000000401e-01, -9.467590000000000172e-01, -9.975420000000000398e-01, -9.999730000000000008e-01, -9.999810000000000088e-01, -9.999059999999999615e-01, -9.997890000000000388e-01, -9.997160000000000490e-01, -9.997420000000000195e-01, -9.998690000000000078e-01, -9.933290000000000175e-01, -9.030359999999999498e-01, -4.857190000000000119e-01, 2.202580000000000093e-01, 3.925609999999999933e-01, -2.135680000000000078e-01, -8.084810000000000052e-01, -9.859269999999999978e-01, -9.996680000000000010e-01, -9.998460000000000125e-01, -9.982060000000000377e-01, -9.917500000000000204e-01, -9.816620000000000346e-01, -9.754720000000000057e-01, -9.776810000000000223e-01, -9.885800000000000143e-01, -9.579349999999999810e-01, -6.812009999999999454e-01, -1.472900000000000077e-02, 4.044590000000000130e-01, 1.744000000000000107e-03, -6.527589999999999781e-01, -9.469760000000000399e-01, -9.971389999999999976e-01, -9.990179999999999616e-01, -9.935869999999999980e-01, -9.621610000000000440e-01, -8.605129999999999724e-01, -7.114340000000000108e-01, -6.217570000000000041e-01, -6.545539999999999692e-01, -8.180990000000000206e-01, -8.326540000000000052e-01, -2.617280000000000162e-01, 3.754509999999999792e-01, 2.040089999999999959e-01, -4.992320000000000091e-01, -9.049289999999999834e-01, -9.926559999999999828e-01, -9.970080000000000053e-01, -9.778109999999999857e-01, -9.049239999999999506e-01, -7.120379999999999487e-01, -3.425619999999999776e-01, 6.654699999999999505e-02, 2.899360000000000270e-01, 2.038639999999999897e-01, -2.888930000000000109e-01, -6.016200000000000436e-01, 2.237599999999999867e-01, 4.728720000000000145e-01, -2.020810000000000106e-01, -8.067750000000000199e-01, -9.818890000000000118e-01, -9.959559999999999524e-01, -9.594920000000000115e-01, -8.015440000000000342e-01, -4.776880000000000015e-01, -5.933299999999999685e-02, 3.293409999999999949e-01, 4.718570000000000264e-01, 5.348239999999999661e-01, 6.105019999999999891e-01, 1.929130000000000011e-01, -3.182189999999999741e-01, 4.499960000000000071e-01, 2.788849999999999940e-01, -5.529119999999999591e-01, -9.429680000000000284e-01, -9.955770000000000453e-01, -9.679489999999999483e-01, -7.739960000000000173e-01, -2.748309999999999920e-01, 2.607160000000000033e-01, 4.484049999999999980e-01, 2.828910000000000036e-01, -7.138799999999999313e-02, -6.642099999999999393e-02, 4.065540000000000265e-01, 2.446029999999999871e-01, 3.899699999999999694e-02, 5.033360000000000056e-01, -4.535299999999999748e-02, -7.580999999999999961e-01, -9.829919999999999769e-01, -9.917150000000000132e-01, -8.703159999999999785e-01, -3.756889999999999952e-01, 3.230350000000000166e-01, 4.952420000000000155e-01, 9.888500000000000068e-02, -3.883220000000000005e-01, -4.875369999999999981e-01, -8.031599999999999850e-02, 3.734810000000000074e-01, -2.383000000000000049e-02, 2.615910000000000180e-01, 5.028839999999999977e-01, -2.584890000000000243e-01, -8.368999999999999773e-01, -9.704739999999999478e-01, -9.594789999999999708e-01, -6.982570000000000165e-01, 6.056000000000000272e-02, 5.625900000000000345e-01, 2.014019999999999977e-01, -3.725189999999999890e-01, -4.919939999999999869e-01, -1.114050000000000040e-01, 3.437359999999999860e-01, 2.275850000000000095e-01, -4.526970000000000161e-01, 1.003830000000000000e-01, 4.796369999999999800e-01, -4.047699999999999909e-02, -5.253360000000000252e-01, -6.631690000000000085e-01, -6.518180000000000085e-01, -3.370239999999999903e-01, 4.402659999999999907e-01, 7.036090000000000400e-01, 2.616310000000000024e-01, -4.629099999999999882e-02, 1.247849999999999931e-01, 3.785680000000000156e-01, 2.745529999999999915e-01, -3.034560000000000035e-01, -8.094130000000000491e-01, -3.392160000000000175e-01, 2.911190000000000166e-01, 4.478119999999999878e-01, 2.841810000000000169e-01, 1.725970000000000004e-01, 1.636219999999999897e-01, 3.333510000000000084e-01, 7.324669999999999792e-01, 8.364880000000000093e-01, 6.596779999999999866e-01, 4.947179999999999911e-01, 3.596230000000000260e-01, 6.418400000000000494e-02, -3.763210000000000166e-01, -7.848289999999999988e-01, -9.641279999999999850e-01, -7.788399999999999768e-01, -3.283260000000000067e-01, 1.826979999999999993e-01, 4.072209999999999996e-01, 4.398770000000000180e-01, 4.419750000000000068e-01, 4.685380000000000100e-01, 5.024669999999999970e-01, 4.371590000000000198e-01, 3.300500000000000100e-01, 8.870500000000000607e-02, -2.866989999999999816e-01, -6.432419999999999805e-01, -8.643650000000000500e-01, -9.685209999999999653e-01, -9.969440000000000524e-01, -9.666979999999999462e-01, -8.456479999999999553e-01, -6.185110000000000330e-01, -4.195189999999999753e-01, -3.446670000000000011e-01, -3.342269999999999963e-01, -3.463689999999999825e-01, -4.145019999999999816e-01, -5.345849999999999769e-01, -6.055599999999999872e-01, -7.047379999999999756e-01, -8.486580000000000235e-01, -9.541119999999999601e-01, -9.905789999999999873e-01, -9.983819999999999917e-01, -9.998939999999999495e-01, -9.982809999999999739e-01, -9.897010000000000529e-01, -9.606010000000000382e-01, -9.117140000000000244e-01, -8.874419999999999531e-01, -8.837279999999999580e-01, -8.886560000000000015e-01, -9.140369999999999884e-01, -9.559229999999999672e-01, -9.734709999999999752e-01, -9.812159999999999771e-01, -9.910759999999999570e-01, -9.978909999999999725e-01, -9.997979999999999645e-01, -9.999810000000000088e-01, -9.999989999999999712e-01, -9.981079999999999952e-01, -9.638900000000000245e-01, -7.673659999999999926e-01, -2.878439999999999888e-01, 2.341890000000000083e-01, 4.676179999999999781e-01, 5.042510000000000048e-01, 5.016939999999999733e-01, 4.801219999999999932e-01, 3.454900000000000193e-01, -6.736999999999999933e-03, -4.381289999999999907e-01, -7.494800000000000351e-01, -9.366400000000000281e-01, -9.944420000000000481e-01, -9.998240000000000460e-01, -9.919229999999999992e-01, -8.630259999999999598e-01, -3.455880000000000063e-01, 4.015329999999999733e-01, 7.366509999999999447e-01, 6.913629999999999498e-01, 5.819159999999999888e-01, 5.270550000000000512e-01, 5.444989999999999553e-01, 5.688980000000000148e-01, 5.186180000000000234e-01, 3.642090000000000050e-01, -1.064640000000000031e-01, -6.902979999999999672e-01, -9.535810000000000120e-01, -9.976319999999999633e-01, -9.868759999999999755e-01, -7.869169999999999776e-01, -1.141999999999999960e-01, 5.454299999999999704e-01, 4.628650000000000264e-01, 1.139000000000000038e-03, -3.319489999999999941e-01, -4.679980000000000251e-01, -4.026799999999999824e-01, -2.014759999999999884e-01, 1.090420000000000000e-01, 5.561369999999999925e-01, 4.693010000000000237e-01, -2.451190000000000035e-01, -8.299600000000000311e-01, -9.896859999999999546e-01, -9.922189999999999621e-01, -8.700480000000000436e-01, -4.169459999999999833e-01, 1.373399999999999968e-02, -2.686060000000000114e-01, -6.914200000000000346e-01, -8.835169999999999968e-01, -9.425860000000000349e-01, -9.128619999999999512e-01, -7.964980000000000393e-01, -4.124470000000000081e-01, 3.843889999999999807e-01, 7.012939999999999729e-01, 1.581490000000000118e-01, -6.815440000000000387e-01, -9.794960000000000333e-01, -9.982649999999999579e-01, -9.697109999999999896e-01, -8.481670000000000043e-01, -7.238719999999999599e-01, -8.331269999999999509e-01, -9.562640000000000029e-01, -9.904990000000000183e-01, -9.886059999999999848e-01, -9.499870000000000259e-01, -7.771839999999999860e-01, -2.510830000000000006e-01, 5.462240000000000428e-01, 7.753590000000000204e-01, 2.161720000000000030e-01, -6.596440000000000081e-01, -9.779849999999999932e-01, -9.998960000000000070e-01, -9.981590000000000185e-01, -9.904249999999999998e-01, -9.819870000000000543e-01, -9.862069999999999448e-01, -9.836279999999999468e-01, -9.545780000000000376e-01, -8.613840000000000385e-01, -6.529260000000000064e-01, -2.222439999999999971e-01, 3.960919999999999996e-01, 7.985600000000000476e-01, 6.370780000000000332e-01, -1.015319999999999973e-01, -7.826849999999999641e-01, -9.865279999999999605e-01, -9.999989999999999712e-01, -9.999749999999999472e-01, -9.995570000000000288e-01, -9.922720000000000429e-01, -9.375529999999999697e-01, -7.899850000000000483e-01, -5.878679999999999461e-01, -2.961349999999999816e-01, 1.050139999999999962e-01, 5.383170000000000455e-01, 7.839110000000000245e-01, 6.556429999999999758e-01, 1.581349999999999978e-01, -5.542070000000000052e-01, -9.249490000000000212e-01, -9.959500000000000020e-01, -1.000000000000000000e+00, -9.999719999999999720e-01, -9.974939999999999918e-01, -9.525150000000000006e-01, -7.039530000000000509e-01, -1.841490000000000071e-01, 2.693470000000000031e-01, 5.657489999999999464e-01, 7.621790000000000509e-01, 8.794899999999999940e-01, 7.069879999999999498e-01, 8.978600000000000469e-02, -5.292769999999999975e-01, -8.836690000000000378e-01, -9.877160000000000384e-01, -9.995009999999999728e-01, -1.000000000000000000e+00, -9.999419999999999975e-01, -9.948249999999999593e-01, -9.076969999999999761e-01, -4.979180000000000272e-01, 2.081250000000000044e-01, 6.160609999999999697e-01, 6.964740000000000375e-01, 6.877750000000000252e-01, 6.993089999999999584e-01, 5.238779999999999548e-01, -9.077899999999999858e-02, -6.546239999999999837e-01, -9.253200000000000314e-01, -9.932659999999999823e-01, -9.997629999999999573e-01, -9.999989999999999712e-01, -9.999609999999999888e-01, -9.978470000000000395e-01, -9.592690000000000383e-01, -7.384619999999999518e-01, -2.760850000000000248e-01, 2.470400000000000026e-02, -2.028900000000000148e-02, -1.128060000000000035e-01, -1.263700000000000066e-02, 2.434250000000000025e-01, 2.889909999999999979e-01, -1.155059999999999976e-01, -6.710180000000000033e-01, -9.444360000000000532e-01, -9.969860000000000388e-01, -9.999029999999999863e-01, -9.986140000000000017e-01, -9.962689999999999602e-01, -9.933499999999999552e-01, -9.518590000000000106e-01, -8.313700000000000534e-01, -7.355030000000000179e-01, -7.579700000000000326e-01, -7.949979999999999825e-01, -7.193739999999999579e-01, -3.583839999999999804e-01, 2.627740000000000076e-01, 4.156500000000000195e-01, -1.765680000000000027e-01, -7.989979999999999860e-01, -9.874110000000000387e-01, -9.980970000000000120e-01, -9.744159999999999489e-01, -9.319570000000000354e-01, -9.535059999999999647e-01, -9.797080000000000233e-01, -9.788189999999999946e-01, -9.721640000000000281e-01, -9.703990000000000116e-01, -9.638210000000000388e-01, -9.095929999999999849e-01, -5.962709999999999955e-01, 1.384900000000000020e-01, 6.472449999999999593e-01, 2.482080000000000120e-01, -6.367789999999999839e-01, -9.742520000000000069e-01, -9.878000000000000114e-01, -8.519309999999999938e-01, -5.778370000000000450e-01, -6.101900000000000102e-01, -7.677709999999999813e-01, -8.192359999999999642e-01, -8.127459999999999685e-01, -7.648099999999999898e-01, -6.593409999999999549e-01, -4.941920000000000202e-01, -1.190080000000000027e-01, 5.140879999999999894e-01, 7.980770000000000364e-01, 3.512669999999999959e-01, -5.896099999999999675e-01, -9.677379999999999871e-01, -9.724479999999999791e-01, -6.663019999999999499e-01, 2.621899999999999925e-02, 1.771210000000000007e-01, -6.968799999999999994e-02, -1.701680000000000137e-01, -1.531969999999999998e-01, -4.003899999999999820e-02, 2.042660000000000031e-01, 4.641270000000000118e-01, 6.479850000000000332e-01, 7.893719999999999626e-01, 6.452259999999999662e-01, 6.800799999999999901e-02, -6.987100000000000533e-01, -9.783699999999999619e-01, -9.786059999999999759e-01, -7.037609999999999699e-01, 2.787399999999999947e-02, 5.020740000000000203e-01, 5.929429999999999978e-01, 6.279829999999999579e-01, 6.403919999999999613e-01, 6.377840000000000176e-01, 6.714040000000000008e-01, 7.021939999999999849e-01, 6.126629999999999576e-01, 3.825479999999999992e-01, -2.902499999999999872e-02, -5.488520000000000065e-01, -8.998169999999999780e-01, -9.938010000000000455e-01, -9.937319999999999487e-01, -8.988930000000000531e-01, -5.493149999999999977e-01, -6.138500000000000206e-02, 2.785079999999999778e-01, 4.566049999999999831e-01, 4.704360000000000208e-01, 3.507660000000000222e-01, 1.918739999999999890e-01, 3.332899999999999752e-02, -2.258090000000000097e-01, -5.235830000000000206e-01, -7.471060000000000478e-01, -9.176849999999999730e-01, -9.883260000000000378e-01, -9.994210000000000038e-01, @@ -52,28 +52,47 @@ static const float input[numExamples * inputDims * timeSteps] = { -1.000000000000000000e+00, -9.999959999999999960e-01, -9.996310000000000473e-01, -9.895479999999999832e-01, -8.874069999999999458e-01, -5.554470000000000240e-01, -1.209969999999999934e-01, 1.245330000000000048e-01, 9.912500000000000477e-02, -9.508199999999999985e-02, -4.457300000000000151e-01, -7.774109999999999632e-01, -9.535529999999999839e-01, -9.968029999999999946e-01, -9.999320000000000430e-01, -9.999989999999999712e-01, -9.999989999999999712e-01, -9.999080000000000190e-01, -9.954229999999999468e-01, -9.263820000000000388e-01, -5.735820000000000363e-01, 6.419700000000000406e-02, 3.456580000000000208e-01, 2.055079999999999962e-01, 1.974700000000000066e-02, 3.107000000000000040e-02, 8.932999999999999968e-03, -3.228949999999999876e-01, -7.930129999999999679e-01, -9.787099999999999689e-01, -9.992029999999999523e-01, -9.999919999999999920e-01, -9.999890000000000168e-01, -9.989069999999999894e-01, -9.722990000000000244e-01, -7.390849999999999920e-01, -1.042740000000000056e-01, 3.342359999999999776e-01, -1.014100000000000071e-02, -5.011839999999999629e-01, -6.861249999999999849e-01, -6.023859999999999770e-01, -2.539390000000000258e-01, 7.340000000000000170e-03, -5.360639999999999850e-01, -9.279899999999999816e-01, -9.963539999999999619e-01, -9.999599999999999600e-01, -9.999289999999999567e-01, -9.938409999999999744e-01, -8.910719999999999752e-01, -4.204680000000000084e-01, 2.440489999999999882e-01, 1.276470000000000105e-01, -5.459789999999999921e-01, -9.083539999999999948e-01, -9.746449999999999836e-01, -9.250709999999999766e-01, -5.068550000000000555e-01, 1.227619999999999961e-01, -3.371129999999999960e-01, -8.668350000000000222e-01, -9.923429999999999751e-01, -9.999120000000000230e-01, -9.997709999999999653e-01, -9.827839999999999909e-01, -7.364389999999999548e-01, -3.639099999999999974e-02, 2.855779999999999985e-01, -3.016949999999999910e-01, -8.421330000000000204e-01, -9.867240000000000455e-01, -9.945920000000000316e-01, -9.481870000000000021e-01, -5.469279999999999697e-01, 1.521359999999999935e-01, -1.868329999999999991e-01, -8.003930000000000211e-01, -9.872440000000000104e-01, -9.998209999999999598e-01, -9.996169999999999778e-01, -9.736749999999999572e-01, -6.188660000000000272e-01, 1.831619999999999915e-01, 1.459189999999999932e-01, -5.948510000000000186e-01, -9.401920000000000277e-01, -9.738120000000000109e-01, -9.237769999999999593e-01, -7.546420000000000350e-01, -3.003569999999999851e-01, 3.133679999999999799e-01, 6.803900000000000226e-02, -6.910880000000000356e-01, -9.789090000000000291e-01, -9.996749999999999803e-01, -9.996680000000000010e-01, -9.746489999999999876e-01, -6.252220000000000555e-01, 1.648399999999999865e-01, 1.457479999999999887e-01, -4.983520000000000172e-01, -7.479339999999999877e-01, -6.952329999999999899e-01, -4.888680000000000248e-01, -9.849700000000000122e-02, 3.467500000000000027e-01, 4.453320000000000056e-01, -1.102709999999999940e-01, -7.708500000000000352e-01, -9.851339999999999542e-01, -9.997960000000000180e-01, -9.998120000000000340e-01, -9.841699999999999893e-01, -7.538399999999999546e-01, -1.127029999999999976e-01, 2.311529999999999974e-01, 4.328000000000000250e-03, -1.028030000000000055e-01, 1.871799999999999853e-02, 2.894169999999999798e-01, 6.092760000000000398e-01, 6.553400000000000336e-01, 1.334609999999999963e-01, -5.782640000000000002e-01, -9.283700000000000285e-01, -9.960729999999999862e-01, -9.999540000000000095e-01, -9.999479999999999480e-01, -9.954410000000000203e-01, -9.213390000000000191e-01, -6.063699999999999646e-01, -1.318699999999999872e-01, 9.272800000000000487e-02, 1.544679999999999942e-01, 2.092430000000000123e-01, 3.988920000000000243e-01, 6.904000000000000137e-01, 4.292009999999999992e-01, -3.758059999999999734e-01, -8.747880000000000100e-01, -9.900430000000000064e-01, -9.996939999999999715e-01, -9.999970000000000248e-01, -9.999959999999999960e-01, -9.995859999999999745e-01, -9.905049999999999688e-01, -9.211979999999999613e-01, -7.565330000000000110e-01, -6.303330000000000322e-01, -5.666109999999999758e-01, -3.800100000000000144e-01, 1.551700000000000024e-01, 4.869299999999999740e-01, -4.089999999999999886e-02, -7.291159999999999863e-01, -9.720569999999999489e-01, -9.988939999999999486e-01, -9.999869999999999592e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999869999999999592e-01, -9.995840000000000281e-01, -9.954250000000000043e-01, -9.841750000000000220e-01, -9.692950000000000177e-01, -8.891219999999999679e-01, -4.781320000000000014e-01, 2.457809999999999995e-01, 2.590979999999999950e-01, -4.726859999999999951e-01, -9.108519999999999950e-01, -9.947009999999999463e-01, -9.999050000000000438e-01, -9.999989999999999712e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999959999999999960e-01, -9.999430000000000263e-01, -9.992320000000000091e-01, -9.798390000000000155e-01, -7.648350000000000426e-01, -1.181730000000000003e-01, 3.464090000000000225e-01, -1.123030000000000000e-01, -7.580249999999999488e-01, -9.777379999999999960e-01, -9.992469999999999963e-01, -9.999930000000000208e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999730000000000008e-01, -9.974509999999999765e-01, -9.430300000000000349e-01, -5.511559999999999793e-01, 2.066419999999999924e-01, 1.977410000000000001e-01, -5.178369999999999918e-01, -9.222249999999999615e-01, -9.955880000000000285e-01, -9.999280000000000390e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999299999999999855e-01, -9.937310000000000310e-01, -8.853539999999999743e-01, -3.587739999999999818e-01, 3.026260000000000061e-01, -9.434099999999999431e-02, -7.619230000000000169e-01, -9.803380000000000427e-01, -9.994349999999999623e-01, -9.999949999999999672e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999010000000000398e-01, -9.912339999999999485e-01, -8.499409999999999465e-01, -2.860480000000000245e-01, 2.147119999999999862e-01, -3.605459999999999776e-01, -8.809749999999999526e-01, -9.931990000000000540e-01, -9.999099999999999655e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999299999999999855e-01, -9.938409999999999744e-01, -8.944029999999999481e-01, -4.974450000000000260e-01, -1.725480000000000069e-01, -6.308340000000000058e-01, -9.508029999999999538e-01, -9.977610000000000090e-01, -9.999759999999999760e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, }; -static const unsigned labels[numExamples] = { 9, 6, 3, 6, 6, 0, 0, 0, 6, 9 }; +static unsigned labels[numExamples] = { 9, 6, 3, 6, 6, 0, 0, 0, 6, 9 }; int main() { - float hiddenState[hiddenDims] = { 0.0 }; - float preComp[hiddenDims] = { 0.0 }; - float tempLRW[wRank] = { 0.0 }; - float tempLRU[uRank] = { 0.0 }; - float classScores[numClasses] = { 0.0 }; - float normalizedFeats[inputDims] = { 0.0 }; + float hiddenState[HIDDEN_DIMS] = { 0.0 }; + float classScores[NUM_CLASSES] = { 0.0 }; + + FastGRNN_LR_Params USPS_params = { + .mean = USPS_mean, + .stdDev = USPS_stdDev, + .W1 = USPS_W1, + .W2 = USPS_W2, + .wRank = USPS_wRank, + .U1 = USPS_U1, + .U2 = USPS_U2, + .uRank = USPS_uRank, + .Bg = USPS_Bg, + .Bh = USPS_Bh, + .zeta = USPS_zeta, + .nu = USPS_nu + }; + + float preComp[HIDDEN_DIMS] = { 0.0 }; + float tempLRW[USPS_wRank] = { 0.0 }; + float tempLRU[USPS_uRank] = { 0.0 }; + float normFeatures[INPUT_DIMS] = { 0.0 }; + FastGRNN_LR_Buffers buffers = { + .preComp = preComp, + .tempLRW = tempLRW, + .tempLRU = tempLRU, + .normFeatures = normFeatures + }; for (unsigned n = 0; n < numExamples; ++n) { - memset(hiddenState, 0, sizeof(float) * hiddenDims); - FastGRNN_LR(W1, W2, wRank, U1, U2, uRank, Bg, Bh, - zeta, nu, timeSteps, hiddenState, hiddenDims, - input + n * inputDims * timeSteps, inputDims, mean, stdDev, - preComp, tempLRW, tempLRU, normalizedFeats); - FC(FC_weights, FCbias, hiddenState, hiddenDims, classScores, numClasses); - unsigned predicted_class = argmax(classScores, numClasses); + memset(hiddenState, 0, sizeof(float) * HIDDEN_DIMS); + fastgrnn_lr(hiddenState, HIDDEN_DIMS, + input + n * INPUT_DIMS * TIME_STEPS, INPUT_DIMS, TIME_STEPS, + &USPS_params, &buffers); + FC(FC_weights, FCbias, hiddenState, HIDDEN_DIMS, classScores, NUM_CLASSES); printf("Example: %d Predicted class: %d Actual class: %d\n", - n, predicted_class, labels[n]); - // printVec(classScores, numClasses); + n, argmax(classScores, NUM_CLASSES), labels[n]); } } From 29f1cad40a951d797325053c05434c7a5a3b76a5 Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Mon, 20 Apr 2020 01:15:41 -0700 Subject: [PATCH 05/15] changed fastgenn signature --- c_reference/include/fastgrnn.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/c_reference/include/fastgrnn.h b/c_reference/include/fastgrnn.h index 91224b7af..a655256ca 100644 --- a/c_reference/include/fastgrnn.h +++ b/c_reference/include/fastgrnn.h @@ -70,8 +70,8 @@ typedef struct FastGRNN_LR_Buffers { * ERR_TEMPLRU_NOT_INIT if tempLRU not allocated * ERR_NORMFEAT_NOT_INIT if normFeatures not allocated */ -int fastgrnn_lr (float* const hiddenState, const unsigned hiddenDims, - const float* const input, const int inputDims, const unsigned steps, +int fastgrnn_lr (float* const hiddenState, unsigned hiddenDims, + const float* const input, unsigned inputDims, unsigned steps, const FastGRNN_LR_Params* params, FastGRNN_LR_Buffers * buffers) { if (buffers->preComp == 0) return ERR_PRECOMP_NOT_INIT; @@ -152,8 +152,8 @@ typedef struct FastGRNN_Buffers { * ERR_PRECOMP_NOT_INIT if preComp not allocated * ERR_NORMFEAT_NOT_INIT if normFeatures not allocated */ -int fatgrnn(float* const hiddenState, const unsigned hiddenDims, - const float* const input, const int inputDims, const unsigned steps, +int fastgrnn(float* const hiddenState, unsigned hiddenDims, + const float* const input, unsigned inputDims, unsigned steps, const FastGRNN_Params* params, FastGRNN_Buffers* buffers) { if (buffers->preComp == 0) return ERR_PRECOMP_NOT_INIT; From 894c6923da397117455ade7af8c1983cad5fb9f7 Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Fri, 24 Apr 2020 23:22:14 -0700 Subject: [PATCH 06/15] rnn pool code and test case --- c_reference/tests/rnnpool/vww_model/rnn1.h | 13 +++++++++++++ c_reference/tests/rnnpool/vww_model/rnn2.h | 11 +++++++++++ 2 files changed, 24 insertions(+) create mode 100644 c_reference/tests/rnnpool/vww_model/rnn1.h create mode 100644 c_reference/tests/rnnpool/vww_model/rnn2.h diff --git a/c_reference/tests/rnnpool/vww_model/rnn1.h b/c_reference/tests/rnnpool/vww_model/rnn1.h new file mode 100644 index 000000000..2be76e0d0 --- /dev/null +++ b/c_reference/tests/rnnpool/vww_model/rnn1.h @@ -0,0 +1,13 @@ +#define HIDDEN_DIMS1 8 + +static float mean1[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = {0.0}; +static float stdDev1[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = {1.0}; + +static float W1[INPUT_DIMS * HIDDEN_DIMS1] = { -6.669194251298904419e-02,-4.081934988498687744e-01,-9.548854231834411621e-01,-1.199822783470153809e+00,3.212589919567108154e-01,-8.398564457893371582e-01,1.377462625503540039e+00,1.293107271194458008e-01,4.241880401968955994e-02,3.874431252479553223e-01,6.743898242712020874e-02,4.235469996929168701e-01,7.616437077522277832e-01,-3.183248341083526611e-01,-6.704510450363159180e-01,3.916886448860168457e-01,1.779496856033802032e-02,-9.131602197885513306e-02,1.308344118297100067e-02,-2.176112309098243713e-02,7.672815918922424316e-01,-3.293828964233398438e-01,8.417400717735290527e-02,-4.810366034507751465e-01,2.434188500046730042e-02,-4.231898188591003418e-01,-5.101327300071716309e-01,-5.763933062553405762e-01,2.576289772987365723e-01,-1.621776819229125977e-01,6.603993773460388184e-01,-2.212110720574855804e-02,2.040588408708572388e-01,1.137487962841987610e-01,-2.034226208925247192e-01,-4.363142326474189758e-02,1.962029747664928436e-02,5.834429860115051270e-01,-1.158756241202354431e-01,-6.547657251358032227e-01,-6.289862841367721558e-02,-7.153615355491638184e-02,-3.552019000053405762e-01,-3.619972467422485352e-01,6.437804698944091797e-01,3.947886824607849121e-01,4.007513821125030518e-01,3.415162265300750732e-01,8.665277808904647827e-02,1.098951250314712524e-01,3.574696481227874756e-01,4.203165769577026367e-01,1.115008115768432617e+00,-6.720532774925231934e-01,-4.624451696872711182e-01,-3.584066927433013916e-01,-4.211997613310813904e-02,-5.568345189094543457e-01,-1.339200735092163086e-01,-1.205071806907653809e+00,8.542865514755249023e-02,3.155398648232221603e-03,1.793413400650024414e+00,3.155157715082168579e-02 }; +static float U1[HIDDEN_DIMS1 * HIDDEN_DIMS1] = { 4.257509708404541016e-01,2.090227305889129639e-01,-9.029741585254669189e-02,-1.581576466560363770e-01,-2.624719589948654175e-02,-1.679758429527282715e-01,1.883537024259567261e-01,8.153508603572845459e-02,-2.243996411561965942e-01,6.178687140345573425e-02,1.964072138071060181e-02,-7.558400928974151611e-02,-3.073738422244787216e-03,-7.507130037993192673e-03,5.114595890045166016e-01,9.405165910720825195e-03,4.599139690399169922e-01,-8.031798005104064941e-01,-2.055168338119983673e-02,-1.338823318481445312e+00,1.721778139472007751e-02,-1.409216374158859253e-01,1.616048932075500488e+00,1.780232340097427368e-01,-3.530698418617248535e-01,-9.047465324401855469e-01,5.608395114541053772e-02,1.076061371713876724e-02,-3.143182024359703064e-03,1.100406423211097717e-01,1.620839357376098633e+00,-5.950598046183586121e-02,2.927841432392597198e-02,1.150295138359069824e-01,-1.545069087296724319e-02,7.246796786785125732e-02,1.096169114112854004e+00,-1.400157362222671509e-01,-1.330980509519577026e-01,-5.966191366314888000e-02,1.921992599964141846e-01,-1.216369643807411194e-01,-3.085457533597946167e-02,-6.944761611521244049e-03,-4.858187958598136902e-02,1.513722836971282959e-01,9.179102256894111633e-03,1.019131317734718323e-01,7.122249808162450790e-03,8.977604657411575317e-02,7.987973280251026154e-03,-8.065721951425075531e-03,-8.912781253457069397e-03,-1.210445910692214966e-02,7.160065323114395142e-02,2.581899240612983704e-02,2.478006668388843536e-02,-3.528899326920509338e-02,-8.097411133348941803e-03,-2.095492556691169739e-02,-3.243596106767654419e-02,-8.220742642879486084e-02,2.354629104956984520e-03,1.182158961892127991e-01 }; + +static float Bg1[HIDDEN_DIMS1] = { -1.213001132011413574e+00,-3.357241451740264893e-01,-1.219372987747192383e+00,-2.052456587553024292e-01,-7.755046486854553223e-01,-7.103578448295593262e-01,-8.887031674385070801e-01,-5.140971541404724121e-01}; +static float Bh1[HIDDEN_DIMS1] = { -2.761822193861007690e-02,3.516794741153717041e-01,7.828953266143798828e-01,7.023379206657409668e-01,5.146764516830444336e-01,7.880625128746032715e-01,1.113372668623924255e-01,6.815895438194274902e-02 }; + +static float zeta1 = 9.999979734420776367e-01; +static float nu1 = 1.968302512977970764e-06; diff --git a/c_reference/tests/rnnpool/vww_model/rnn2.h b/c_reference/tests/rnnpool/vww_model/rnn2.h new file mode 100644 index 000000000..9a52af5a2 --- /dev/null +++ b/c_reference/tests/rnnpool/vww_model/rnn2.h @@ -0,0 +1,11 @@ +static float mean2[HIDDEN_DIMS1 * PATCH_DIM] = {0.0}; +static float stdDev2[HIDDEN_DIMS1 * PATCH_DIM] = {1.0}; + +static float W2[HIDDEN_DIMS1 * HIDDEN_DIMS2] = { 3.328921273350715637e-02,-3.237796723842620850e-01,-6.069063544273376465e-01,3.176147341728210449e-01,-8.808585256338119507e-02,4.995678067207336426e-01,-8.141241967678070068e-02,-5.527251958847045898e-02,4.839901626110076904e-02,-2.648477256298065186e-01,4.720874130725860596e-01,-2.042243480682373047e-01,1.615403443574905396e-01,4.996369481086730957e-01,-5.713146924972534180e-02,-6.109619140625000000e-02,8.630067855119705200e-02,2.549230158329010010e-01,5.098583698272705078e-01,3.439170718193054199e-01,-4.946086406707763672e-01,-8.396717905998229980e-02,6.110856309533119202e-02,2.462622970342636108e-01,-3.623228371143341064e-01,1.056594774127006531e-01,4.149395599961280823e-02,2.087370865046977997e-02,-1.174109801650047302e-02,-3.785453736782073975e-01,2.926556952297687531e-02,-1.656581298448145390e-04,3.617477416992187500e-02,-5.211604386568069458e-02,-2.221289835870265961e-02,2.785135433077812195e-02,2.072153845801949501e-03,1.230286993086338043e-02,-1.405209898948669434e-01,1.710500240325927734e+00,-1.013135910034179688e-01,-5.569029450416564941e-01,2.892487943172454834e-01,3.186852931976318359e-01,4.303685724735260010e-01,-3.816023766994476318e-01,-5.008732676506042480e-01,-6.598105430603027344e-01,-1.616892337799072266e+00,7.901080884039402008e-03,1.637366861104965210e-01,5.935984104871749878e-02,-7.063516974449157715e-02,1.118507459759712219e-01,5.522043444216251373e-03,2.383397147059440613e-02,9.920979291200637817e-02,4.476135373115539551e-01,-4.640549048781394958e-02,-3.889196217060089111e-01,-3.901343047618865967e-01,1.944433003664016724e-01,-8.167469501495361328e-01,-5.196015834808349609e-01 }; +static float U2[HIDDEN_DIMS2 * HIDDEN_DIMS2] = { 3.934212923049926758e-01,2.627835571765899658e-01,-9.242479503154754639e-02,1.917631626129150391e-01,2.150612622499465942e-01,7.392763346433639526e-02,-5.659309402108192444e-02,-4.473730921745300293e-02,-4.295524582266807556e-02,2.479245215654373169e-01,1.447719633579254150e-01,8.766186982393264771e-02,2.176617681980133057e-01,4.104424268007278442e-03,-4.538772255182266235e-02,-2.271021008491516113e-01,1.002475544810295105e-01,-2.347197830677032471e-01,3.752615749835968018e-01,-2.752942740917205811e-01,-9.746207296848297119e-02,-1.972307413816452026e-01,6.283282488584518433e-02,1.190942153334617615e-02,-1.167084053158760071e-01,2.314671277999877930e-01,2.763805091381072998e-01,2.459737062454223633e-01,3.679830208420753479e-02,-2.362748086452484131e-01,-3.104292228817939758e-02,-6.096216291189193726e-02,7.208147644996643066e-02,1.421915292739868164e-01,-7.362117618322372437e-02,4.787993803620338440e-02,2.094942629337310791e-01,3.649697601795196533e-01,-1.333466079086065292e-02,2.375180423259735107e-01,7.301057875156402588e-02,-4.386771023273468018e-01,-1.142739504575729370e-01,8.056888729333877563e-02,-2.684409022331237793e-01,3.465250432491302490e-01,-7.922663539648056030e-02,-1.497552990913391113e-01,7.414811104536056519e-02,4.338171705603599548e-02,1.064843088388442993e-01,2.883537299931049347e-02,6.217004358768463135e-02,7.446446269750595093e-02,6.666561216115951538e-02,-4.494012892246246338e-01,-1.667873002588748932e-02,1.125133633613586426e-01,-8.647724986076354980e-03,6.972444709390401840e-03,-3.187925368547439575e-02,5.720932036638259888e-02,4.965405911207199097e-02,-6.579961627721786499e-02 }; + +static float Bg2[HIDDEN_DIMS2] = { -1.537145614624023438e+00,-6.593755483627319336e-01,-8.165745735168457031e-01,-1.047435641288757324e+00,-1.003585577011108398e+00,-1.275580763816833496e+00,-9.717565178871154785e-01,-1.349884271621704102e+00 }; +static float Bh2[HIDDEN_DIMS2] = { 1.249589323997497559e+00,2.501939237117767334e-01,3.707601428031921387e-01,1.205096021294593811e-01,6.529558449983596802e-02,-2.186506539583206177e-01,-1.120083108544349670e-01,-1.578094959259033203e+00 }; + +static float zeta2 = 9.999979734420776367e-01; +static float nu2 = 1.968388687600963749e-06; From 5f8465efb52f50a98647909f58eaa828da458a13 Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Fri, 24 Apr 2020 23:23:53 -0700 Subject: [PATCH 07/15] I/O trace for rnn pool block --- c_reference/Makefile | 15 +-- c_reference/include/classifier.h | 11 +- c_reference/include/fastgrnn.h | 69 +--------- c_reference/include/rnnpool.h | 32 +++++ c_reference/include/utils.h | 118 ++++-------------- c_reference/src/Makefile | 29 +++++ c_reference/src/classifier.c | 12 ++ c_reference/src/fastgrnn.c | 80 ++++++++++++ c_reference/src/rnnpool.c | 40 ++++++ c_reference/src/utils.c | 114 +++++++++++++++++ c_reference/tests/Makefile | 27 ++++ .../tests/{ => fastgrnn}/test_fastgrnn_lr.c | 31 ++--- c_reference/tests/rnnpool/test_rnnpool.c | 66 ++++++++++ .../tests/rnnpool/traces/trace_0_0_input.h | 4 + .../tests/rnnpool/traces/trace_0_0_output.h | 3 + 15 files changed, 461 insertions(+), 190 deletions(-) create mode 100644 c_reference/include/rnnpool.h create mode 100644 c_reference/src/Makefile create mode 100644 c_reference/src/classifier.c create mode 100644 c_reference/src/fastgrnn.c create mode 100644 c_reference/src/rnnpool.c create mode 100644 c_reference/src/utils.c create mode 100644 c_reference/tests/Makefile rename c_reference/tests/{ => fastgrnn}/test_fastgrnn_lr.c (99%) create mode 100644 c_reference/tests/rnnpool/test_rnnpool.c create mode 100644 c_reference/tests/rnnpool/traces/trace_0_0_input.h create mode 100644 c_reference/tests/rnnpool/traces/trace_0_0_output.h diff --git a/c_reference/Makefile b/c_reference/Makefile index 29788045f..5a77e5e90 100644 --- a/c_reference/Makefile +++ b/c_reference/Makefile @@ -3,20 +3,21 @@ include config.mk -INCLUDE_DIR=include +SRC_DIR=src TEST_DIR=tests -IFLAGS = -I $(INCLUDE_DIR) - -all: test_fastgrnn_lr - -test_fastgrnn_lr: $(TEST_DIR)/test_fastgrnn_lr.c - $(CC) -o $(TEST_DIR)/$@ $(IFLAGS) $(CFLAGS) $^ -lm +all: + $(MAKE) -C $(SRC_DIR) + $(MAKE) -C $(TEST_DIR) .PHONY: clean cleanest clean: rm -f *.o *.gch + $(MAKE) -C $(SRC_DIR) clean + $(MAKE) -C $(TEST_DIR) clean cleanest: clean rm *~ + $(MAKE) -C $(SRC_DIR) cleanest + $(MAKE) -C $(TEST_DIR) cleanest diff --git a/c_reference/include/classifier.h b/c_reference/include/classifier.h index 126d6a06c..13021674d 100644 --- a/c_reference/include/classifier.h +++ b/c_reference/include/classifier.h @@ -4,13 +4,8 @@ #ifndef __CLASSIFIER_H__ #define __CLASSIFIER_H__ -#include "utils.h" - -void FC(const float *const FCweights, const float *const FCbias, - const float *const input, const unsigned inputLen, - float* const classScores, const unsigned numClasses) { - matVec(FCweights, input, numClasses, inputLen, 0.0f, 1.0f, classScores); - v_add(1.0f, FCbias, 1.0f, classScores, numClasses, classScores); -} +void FC(const float* const FCweights, const float* const FCbias, + const float* const input, const unsigned inputLen, + float* const classScores, const unsigned numClasses); #endif diff --git a/c_reference/include/fastgrnn.h b/c_reference/include/fastgrnn.h index a655256ca..9c4e627fe 100644 --- a/c_reference/include/fastgrnn.h +++ b/c_reference/include/fastgrnn.h @@ -4,8 +4,6 @@ #ifndef __FASTGRNN_H__ #define __FASRGRNN_H__ -#include "utils.h" - #define ERR_PRECOMP_NOT_INIT -1 #define ERR_TEMPLRW_NOT_INIT -2 #define ERR_TEMPLRU_NOT_INIT -3 @@ -64,48 +62,16 @@ typedef struct FastGRNN_LR_Buffers { * @param[in] steps number of steps of FastGRNN cell * @param[in] params pointer to model parameter * @param[in] buffers pointer to buffer spaces + * @param[in] backward direction of the pass, 0 for forward, 1 for backward * @return The function returns 0 on success * ERR_PRECOMP_NOT_INIT if preComp not allocated * ERR_TEMPLRW_NOT_INIT if tempLRW not allocated * ERR_TEMPLRU_NOT_INIT if tempLRU not allocated * ERR_NORMFEAT_NOT_INIT if normFeatures not allocated */ -int fastgrnn_lr (float* const hiddenState, unsigned hiddenDims, +int fastgrnn_lr(float* const hiddenState, unsigned hiddenDims, const float* const input, unsigned inputDims, unsigned steps, - const FastGRNN_LR_Params* params, FastGRNN_LR_Buffers * buffers) { - - if (buffers->preComp == 0) return ERR_PRECOMP_NOT_INIT; - if (buffers->tempLRW == 0) return ERR_TEMPLRW_NOT_INIT; - if (buffers->tempLRU == 0) return ERR_TEMPLRU_NOT_INIT; - if (buffers->normFeatures == 0) return ERR_NORMFEATURES_NOT_INIT; - - // #steps iterations of the RNN cell starting from hiddenState - for (unsigned t = 0; t < steps; t++) { - // Normalize the features - v_add(1.0f, input + t * inputDims, -1.0f, params->mean + t * inputDims, - inputDims, buffers->normFeatures); - v_div(params->stdDev + t * inputDims, buffers->normFeatures, inputDims, - buffers->normFeatures); - - // Process the new input and previous hidden state - matVec(params->W1, buffers->normFeatures, params->wRank, inputDims, - 0.0f, 1.0f, buffers->tempLRW); - matVec(params->W2, buffers->tempLRW, hiddenDims, params->wRank, - 0.0f, 1.0f, buffers->preComp); - matVec(params->U1, hiddenState, params->uRank, hiddenDims, - 0.0f, 1.0f, buffers->tempLRU); - matVec(params->U2, buffers->tempLRU, hiddenDims, params->uRank, - 1.0f, 1.0f, buffers->preComp); - - // Apply the gate to generate the new hidden state - for (unsigned i = 0; i < hiddenDims; i++) { - float gate = sigmoid(buffers->preComp[i] + params->Bg[i]); - float update = tanh(buffers->preComp[i] + params->Bh[i]); - hiddenState[i] = gate * hiddenState[i] + (params->zeta * (1.0 - gate) + params->nu) * update; - } - } - return 0; -} + const void* params, void* buffers, int backward); /** * @brief Model paramters for low-rank FastGRNN @@ -148,38 +114,13 @@ typedef struct FastGRNN_Buffers { * @param[in] steps number of steps of FastGRNN cell * @param[in] params pointer to model parameter * @param[in] buffers pointer to buffer spaces + * @param[in] backward direction of the pass, 0 for forward, 1 for backward * @return The function returns 0 on success * ERR_PRECOMP_NOT_INIT if preComp not allocated * ERR_NORMFEAT_NOT_INIT if normFeatures not allocated */ int fastgrnn(float* const hiddenState, unsigned hiddenDims, const float* const input, unsigned inputDims, unsigned steps, - const FastGRNN_Params* params, FastGRNN_Buffers* buffers) { - - if (buffers->preComp == 0) return ERR_PRECOMP_NOT_INIT; - if (buffers->normFeatures == 0) return ERR_NORMFEATURES_NOT_INIT; - - for (unsigned t = 0; t < steps; t++) { - // Normalize the features - v_add(1.0f, input + t * inputDims, -1.0f, params->mean + t * inputDims, - inputDims, buffers->normFeatures); - v_div(params->stdDev + t * inputDims, buffers->normFeatures, inputDims, - buffers->normFeatures); - - // Process the new input and previous hidden state - matVec(params->W, buffers->normFeatures, hiddenDims, inputDims, - 0.0f, 1.0f, buffers->preComp); - matVec(params->U, hiddenState, hiddenDims, hiddenDims, - 1.0f, 1.0f, buffers->preComp); - - // Apply the gate to generate the new hidden state - for (unsigned i = 0; i < hiddenDims; i++) { - float gate = sigmoid(buffers->preComp[i] + params->Bg[i]); - float update = tanh(buffers->preComp[i] + params->Bh[i]); - hiddenState[i] = gate * hiddenState[i] + (params->zeta * (1.0 - gate) + params->nu) * update; - } - } - return 0; -} + const void* params, void* buffers, int backward); #endif diff --git a/c_reference/include/rnnpool.h b/c_reference/include/rnnpool.h new file mode 100644 index 000000000..569c1a5d9 --- /dev/null +++ b/c_reference/include/rnnpool.h @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#ifndef __RNNPOOL_H__ +#define __RNNPOOL_H__ + +typedef int (*rnn_t)(float* const, unsigned, const float* const, unsigned, unsigned, const void*, void*, int); + +/** + * @param[in] patch pointer to the activation of the first pixel in the patch + * @param[in] inputDims dimemsion of each input pixel + * @param[in] patchDim number of rows and columns in a square patch + * @param[in] stride stride lenghth in the larger image to get to next row + * @param[in] rnn1 function pointer to RNN1 + * @param[in] hiddenDims1 dimension of the hidden state of RNN1 + * @param[in] rnn1_params pointer to parameters of RNN1 + * @param[in] rnn1_buffers pointer to buffers needed for RNN1 + * @param[in] rnn2 function pointer to RNN2 + * @param[in] hiddenDims2 dimension of the hidden state of RNN2 + * @param[in] rnn2_params pointer to parameters of RNN2 + * @param[in] rnn2_buffers pointer to buffers needed for RNN2 + * @param[out] output pointer to output, initialized to size 4 * hiddenDims2 + * @param[in,out] buffer pointer to buffer, intialized to size hiddenDims1 * max{nrows, cols} + */ +int rnnpool_block(const float* const patch, unsigned inputDims, + unsigned patchDim, unsigned stride, + rnn_t rnn1, unsigned hiddenDims1, const void* rnn1_params, void* rnn1_buffers, + rnn_t rnn2, unsigned hiddenDims2, const void* rnn2_params, void* rnn2_buffers, + float* const output, float* const buffer); + + +#endif \ No newline at end of file diff --git a/c_reference/include/utils.h b/c_reference/include/utils.h index f803ab3cf..4c5eef5ac 100644 --- a/c_reference/include/utils.h +++ b/c_reference/include/utils.h @@ -7,121 +7,47 @@ #include #include -inline float min(const float a, const float b) { - return (a < b) ? a : b; -} +float min(float a, float b); +float max(float a, float b); -inline float max(const float a, const float b) { - return (a > b) ? a : b; -} +float relu(float x); +float sigmoid(float x); +float tanhyperbolic(float x); +float quantTanh(float x); +float quantSigmoid(float x); -inline float relu(const float x) { - if (x < 0.0) return 0.0; - else return x; -} - -inline float sigmoid(const float x) { - return 1.0f / (1.0f + expf(-1.0f * x)); -} - -inline float tanhyperbolic(const float x) { - float ex = expf(x); - float enx = expf(-1.0f * x); - return (ex - enx) / (ex + enx); -} - -inline float quantTanh(const float x) { - return max(min(x, 1.0f), -1.0f); -} - -inline float quantSigmoid(const float x) { - return max(min((x + 1.0f) / 2.0f, 1.0f), 0.0f); -} - -void v_relu(const float* const vec, const unsigned len, float* const ret) { - for (unsigned i = 0; i < len; i++) ret[i] = relu(vec[i]); -} - -void v_sigmoid(const float* const vec, const unsigned len, float* const ret) { - for (unsigned i = 0; i < len; i++) ret[i] = sigmoid(vec[i]); -} - -void v_tanh(const float* const vec, const unsigned len, float* const ret) { - for (unsigned i = 0; i < len; i++) ret[i] = tanhyperbolic(vec[i]); -} - -void v_quantSigmoid(const float* const vec, const unsigned len, float* const ret) { - for (unsigned i = 0; i < len; i++) ret[i] = sigmoid(vec[i]); -} - -void v_quantTanh(const float* const vec, const unsigned len, float* const ret) { - for (unsigned i = 0; i < len; i++) ret[i] = tanh(vec[i]); -} +void v_relu(const float* const vec, unsigned len, float* const ret); +void v_sigmoid(const float* const vec, unsigned len, float* const ret); +void v_tanh(const float* const vec, unsigned len, float* const ret); +void v_quantSigmoid(const float* const vec, unsigned len, float* const ret); +void v_quantTanh(const float* const vec, unsigned len, float* const ret); /* Scaled matrix-vector multiplication: ret = alpha * ret + beta * mat * vec alpha and beta are scalars ret is of size nrows, vec is of size ncols mat is of size nrows * ncols, stored in row major */ void matVec(const float* const mat, const float* const vec, - const unsigned nrows, const unsigned ncols, - const float alpha, const float beta, - float* const ret) { - - for (unsigned row = 0; row < nrows; row++) { - float sum = 0.0f; - float* mat_offset = (float*)mat + row * ncols; - for (unsigned col = 0; col < ncols; col++) { - sum += *mat_offset++ * vec[col]; - } - ret[row] = alpha * ret[row] + beta * sum; - } -} + unsigned nrows, unsigned ncols, + float alpha, float beta, + float* const ret); // scaled vector addition: ret = scalar1 * vec1 + scalar2 * vector2 -void v_add(const float scalar1, const float* const vec1, - const float scalar2, const float* const vec2, - const unsigned len, float* const ret) { - for (unsigned i = 0; i < len; i++) - ret[i] = scalar1 * vec1[i] + scalar2 * vec2[i]; -} +void v_add(float scalar1, const float* const vec1, + float scalar2, const float* const vec2, + unsigned len, float* const ret); // point-wise vector division ret = vec2 / vec1 void v_mult(const float* const vec1, const float* const vec2, - const unsigned len, float* const ret) { - for (unsigned i = 0; i < len; i++) - ret[i] = vec1[i] * vec2[i]; -} + unsigned len, float* const ret); // point-wise vector division ret = vec2 / vec1 void v_div(const float* const vec1, const float* const vec2, - const unsigned len, float* const ret) { - for (unsigned i = 0; i < len; i++) - ret[i] = vec2[i] / vec1[i]; -} + unsigned len, float* const ret); // Return index with max value, if tied, return first tied index. -unsigned argmax(const float* const vec, const unsigned len) { - unsigned maxId = 0; - float maxScore = FLT_MIN; - for (unsigned i = 0; i < len; i++) { - if (vec[i] > maxScore) { - maxScore = vec[i]; - maxId = i; - } - } - return maxId; -} +unsigned argmax(const float* const vec, unsigned len); // ret[i] = exp(input[i]) / \sum_i exp(input[i]) -void softmax(const float* const input, const unsigned len, float* const ret) { - float m = input[argmax(input, len)]; - float sum = 0.0f; - for (unsigned i = 0; i < len; i++) - sum += expf(input[i] - m); - - float offset = m + logf(sum); - for (unsigned i = 0; i < len; i++) - ret[i] = expf(input[i] - offset); -} +void softmax(const float* const input, unsigned len, float* const ret); #endif diff --git a/c_reference/src/Makefile b/c_reference/src/Makefile new file mode 100644 index 000000000..8c7f6f141 --- /dev/null +++ b/c_reference/src/Makefile @@ -0,0 +1,29 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. + +include ../config.mk + +INCLUDE_DIR=../include +IFLAGS = -I $(INCLUDE_DIR) + +all: utils.o fastgrnn.o classifier.o rnnpool.o + +utils.o: utils.c + $(CC) -o $@ $(IFLAGS) $(CFLAGS) -c $^ + +fastgrnn.o: fastgrnn.c + $(CC) -o $@ $(IFLAGS) $(CFLAGS) -c $^ + +classifier.o: classifier.c + $(CC) -o $@ $(IFLAGS) $(CFLAGS) -c $^ + +rnnpool.o: rnnpool.c + $(CC) -o $@ $(IFLAGS) $(CFLAGS) -c $^ + +.PHONY: clean cleanest + +clean: + rm -f *.o *.gch + +cleanest: clean + rm *~ diff --git a/c_reference/src/classifier.c b/c_reference/src/classifier.c new file mode 100644 index 000000000..3eb8a4a56 --- /dev/null +++ b/c_reference/src/classifier.c @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#include "utils.h" +#include "classifier.h" + +void FC(const float* const FCweights, const float* const FCbias, + const float* const input, const unsigned inputLen, + float* const classScores, const unsigned numClasses) { + matVec(FCweights, input, numClasses, inputLen, 0.0f, 1.0f, classScores); + v_add(1.0f, FCbias, 1.0f, classScores, numClasses, classScores); +} diff --git a/c_reference/src/fastgrnn.c b/c_reference/src/fastgrnn.c new file mode 100644 index 000000000..930b28116 --- /dev/null +++ b/c_reference/src/fastgrnn.c @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#include "utils.h" +#include "fastgrnn.h" + +int fastgrnn_lr(float* const hiddenState, unsigned hiddenDims, + const float* const input, unsigned inputDims, unsigned steps, + const void* params, void* buffers, int backward) { + + const FastGRNN_LR_Params* tparams = (const FastGRNN_LR_Params*)params; + FastGRNN_LR_Buffers* tbuffers = (FastGRNN_LR_Buffers*)buffers; + + if (tbuffers->preComp == 0) return ERR_PRECOMP_NOT_INIT; + if (tbuffers->tempLRW == 0) return ERR_TEMPLRW_NOT_INIT; + if (tbuffers->tempLRU == 0) return ERR_TEMPLRU_NOT_INIT; + if (tbuffers->normFeatures == 0) return ERR_NORMFEATURES_NOT_INIT; + + // #steps iterations of the RNN cell starting from hiddenState + for (unsigned t = 0; t < steps; t++) { + // Normalize the features + unsigned offset = backward ? steps - t : t; + v_add(1.0f, input + offset * inputDims, -1.0f, tparams->mean + t * inputDims, + inputDims, tbuffers->normFeatures); + v_div(tparams->stdDev + t * inputDims, tbuffers->normFeatures, inputDims, + tbuffers->normFeatures); + + // Process the new input and previous hidden state + matVec(tparams->W1, tbuffers->normFeatures, tparams->wRank, inputDims, + 0.0f, 1.0f, tbuffers->tempLRW); + matVec(tparams->W2, tbuffers->tempLRW, hiddenDims, tparams->wRank, + 0.0f, 1.0f, tbuffers->preComp); + matVec(tparams->U1, hiddenState, tparams->uRank, hiddenDims, + 0.0f, 1.0f, tbuffers->tempLRU); + matVec(tparams->U2, tbuffers->tempLRU, hiddenDims, tparams->uRank, + 1.0f, 1.0f, tbuffers->preComp); + + // Apply the gate to generate the new hidden state + for (unsigned i = 0; i < hiddenDims; i++) { + float gate = sigmoid(tbuffers->preComp[i] + tparams->Bg[i]); + float update = tanh(tbuffers->preComp[i] + tparams->Bh[i]); + hiddenState[i] = gate * hiddenState[i] + (tparams->zeta * (1.0 - gate) + tparams->nu) * update; + } + } + return 0; +} + +int fastgrnn(float* const hiddenState, unsigned hiddenDims, + const float* const input, unsigned inputDims, unsigned steps, + const void* params, void* buffers, int backward) { + + const FastGRNN_Params* tparams = (const FastGRNN_Params*)params; + FastGRNN_Buffers* tbuffers = (FastGRNN_Buffers*)buffers; + + if (tbuffers->preComp == 0) return ERR_PRECOMP_NOT_INIT; + if (tbuffers->normFeatures == 0) return ERR_NORMFEATURES_NOT_INIT; + + for (unsigned t = 0; t < steps; t++) { + // Normalize the features + unsigned offset = backward ? steps - t : t; + v_add(1.0f, input + offset * inputDims, -1.0f, tparams->mean + t * inputDims, + inputDims, tbuffers->normFeatures); + v_div(tparams->stdDev + t * inputDims, tbuffers->normFeatures, inputDims, + tbuffers->normFeatures); + + // Process the new input and previous hidden state + matVec(tparams->W, tbuffers->normFeatures, hiddenDims, inputDims, + 0.0f, 1.0f, tbuffers->preComp); + matVec(tparams->U, hiddenState, hiddenDims, hiddenDims, + 1.0f, 1.0f, tbuffers->preComp); + + // Apply the gate to generate the new hidden state + for (unsigned i = 0; i < hiddenDims; i++) { + float gate = sigmoid(tbuffers->preComp[i] + tparams->Bg[i]); + float update = tanh(tbuffers->preComp[i] + tparams->Bh[i]); + hiddenState[i] = gate * hiddenState[i] + (tparams->zeta * (1.0 - gate) + tparams->nu) * update; + } + } + return 0; +} diff --git a/c_reference/src/rnnpool.c b/c_reference/src/rnnpool.c new file mode 100644 index 000000000..78f09e097 --- /dev/null +++ b/c_reference/src/rnnpool.c @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#include +#include "rnnpool.h" + +int rnnpool_block(const float* const patch, unsigned inputDims, + unsigned patchDim, unsigned stride, + rnn_t rnn1, unsigned hiddenDims1, const void* rnn1_params, void* rnn1_buffers, + rnn_t rnn2, unsigned hiddenDims2, const void* rnn2_params, void* rnn2_buffers, + float* const output, float* const buffer) { + + // Clear the output + memset(output, 0, sizeof(float) * 4 * hiddenDims2); + + // Horizontal pass over each row with RNN1 + memset(buffer, 0, sizeof(float) * hiddenDims1 * patchDim); + for (unsigned r = 0; r < patchDim; ++r) + rnn1(buffer + r * patchDim, hiddenDims1, + patch + stride * r * inputDims, inputDims, patchDim, + rnn1_params, rnn1_buffers, 0); + + // Bidirectional vertical pass over the row summaries + rnn2(output, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 0); + rnn2(output + hiddenDims2, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 1); + + // Vertical pass over each column with RNN1 + memset(buffer, 0, sizeof(float) * hiddenDims1 * patchDim); + for (unsigned c = 0; c < patchDim; ++c) + for (unsigned r = 0; r < patchDim; ++r) + rnn1(buffer + c * patchDim, hiddenDims1, + patch + (stride * r + c) * inputDims, inputDims, 1, + rnn1_params, rnn1_buffers, 0); + + // Bidirectional horizantal pass over the columns summaries + rnn2(output + 2 * hiddenDims2, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 0); + rnn2(output + 3 * hiddenDims2, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 1); + + return 0; +} diff --git a/c_reference/src/utils.c b/c_reference/src/utils.c new file mode 100644 index 000000000..880cb0068 --- /dev/null +++ b/c_reference/src/utils.c @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#include +#include +#include "utils.h" + +float min(float a, float b) { + return (a < b) ? a : b; +} + +float max(float a, float b) { + return (a > b) ? a : b; +} + +float relu(float x) { + if (x < 0.0) return 0.0; + else return x; +} + +float sigmoid(float x) { + return 1.0f / (1.0f + expf(-1.0f * x)); +} + +float tanhyperbolic(float x) { + float ex = expf(x); + float enx = expf(-1.0f * x); + return (ex - enx) / (ex + enx); +} + +float quantTanh(float x) { + return max(min(x, 1.0f), -1.0f); +} + +float quantSigmoid(float x) { + return max(min((x + 1.0f) / 2.0f, 1.0f), 0.0f); +} + +void v_relu(const float* const vec, unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) ret[i] = relu(vec[i]); +} + +void v_sigmoid(const float* const vec, unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) ret[i] = sigmoid(vec[i]); +} + +void v_tanh(const float* const vec, unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) ret[i] = tanhyperbolic(vec[i]); +} + +void v_quantSigmoid(const float* const vec, unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) ret[i] = sigmoid(vec[i]); +} + +void v_quantTanh(const float* const vec, unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) ret[i] = tanh(vec[i]); +} + +void matVec(const float* const mat, const float* const vec, + unsigned nrows, unsigned ncols, + float alpha, float beta, + float* const ret) { + + for (unsigned row = 0; row < nrows; row++) { + float sum = 0.0f; + float* mat_offset = (float*)mat + row * ncols; + for (unsigned col = 0; col < ncols; col++) { + sum += *mat_offset++ * vec[col]; + } + ret[row] = alpha * ret[row] + beta * sum; + } +} + +void v_add(float scalar1, const float* const vec1, + float scalar2, const float* const vec2, + unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) + ret[i] = scalar1 * vec1[i] + scalar2 * vec2[i]; +} + +void v_mult(const float* const vec1, const float* const vec2, + unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) + ret[i] = vec1[i] * vec2[i]; +} + +void v_div(const float* const vec1, const float* const vec2, + unsigned len, float* const ret) { + for (unsigned i = 0; i < len; i++) + ret[i] = vec2[i] / vec1[i]; +} + +unsigned argmax(const float* const vec, unsigned len) { + unsigned maxId = 0; + float maxScore = FLT_MIN; + for (unsigned i = 0; i < len; i++) { + if (vec[i] > maxScore) { + maxScore = vec[i]; + maxId = i; + } + } + return maxId; +} + +void softmax(const float* const input, unsigned len, float* const ret) { + float m = input[argmax(input, len)]; + float sum = 0.0f; + for (unsigned i = 0; i < len; i++) + sum += expf(input[i] - m); + + float offset = m + logf(sum); + for (unsigned i = 0; i < len; i++) + ret[i] = expf(input[i] - offset); +} diff --git a/c_reference/tests/Makefile b/c_reference/tests/Makefile new file mode 100644 index 000000000..ef6c5e395 --- /dev/null +++ b/c_reference/tests/Makefile @@ -0,0 +1,27 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. + +include ../config.mk + +INCLUDE_DIR=../include +SRC_DIR=../src +IFLAGS = -I $(INCLUDE_DIR) + +all: test_fastgrnn_lr test_rnnpool + +FASTGRNN_DIR=fastgrnn +test_fastgrnn_lr: $(FASTGRNN_DIR)/test_fastgrnn_lr.c $(SRC_DIR)/utils.o $(SRC_DIR)/fastgrnn.o $(SRC_DIR)/classifier.o + $(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm + +RNNPOOL_DIR=rnnpool +test_rnnpool: $(RNNPOOL_DIR)/test_rnnpool.c $(SRC_DIR)/utils.o $(SRC_DIR)/fastgrnn.o $(SRC_DIR)/rnnpool.o + $(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm + + +.PHONY: clean cleanest + +clean: + rm -f *.o *.gch test_fastgrnn_lr test_rnnpool + +cleanest: clean + rm *~ diff --git a/c_reference/tests/test_fastgrnn_lr.c b/c_reference/tests/fastgrnn/test_fastgrnn_lr.c similarity index 99% rename from c_reference/tests/test_fastgrnn_lr.c rename to c_reference/tests/fastgrnn/test_fastgrnn_lr.c index 813489637..a8c9a1e73 100644 --- a/c_reference/tests/test_fastgrnn_lr.c +++ b/c_reference/tests/fastgrnn/test_fastgrnn_lr.c @@ -4,6 +4,7 @@ #include #include +#include "utils.h" #include "fastgrnn.h" #include "classifier.h" @@ -16,17 +17,17 @@ #define HIDDEN_DIMS 32 -#define USPS_wRank 5 -#define USPS_uRank 5 +#define USPS_WRANK 5 +#define USPS_URANK 5 static float USPS_mean[INPUT_DIMS*TIME_STEPS] = { -0.9919499212727939, -0.9725694919764011, -0.9309642959813387, -0.853716200521184, -0.7349504700315451, -0.5802354099574815, -0.39248257687560045, -0.2269891389384171, -0.2174700892881636, -0.3516331625291455, -0.5171603246468245, -0.6708125888081178, -0.7990983028391132, -0.8932807097791728, -0.9539613342476979, -0.9857407134823684, -0.982065124537093, -0.9396279381429109, -0.8481889680427892, -0.6871382765052781, -0.46854966931833575, -0.23665195432725242, -0.010466119873817016, 0.16903683075024034, 0.16696242696475144, 0.000575173501577279, -0.19530754532985956, -0.4051392961185021, -0.6211168477575091, -0.7968383502948817, -0.9104805820875028, -0.9707068291043692, -0.972355607872715, -0.9089240443011889, -0.7740880982032617, -0.5530052536003301, -0.3013481248114096, -0.10879414689343007, 0.02414649869702375, 0.12112666931833796, 0.09386644177753416, -0.026313687560005544, -0.13068748580441636, -0.2786945901796741, -0.5084887787683436, -0.7343963726512096, -0.8844299572075165, -0.962161552736246, -0.9642070229049474, -0.8840199842271269, -0.7208337917981055, -0.48003281689754523, -0.2592399288163491, -0.15972010135783873, -0.13488242545604182, -0.11083945041832412, -0.14293412796598523, -0.19081482046358608, -0.18728045165272306, -0.25101744602935144, -0.4563265265395706, -0.7004354450692639, -0.8731881069812105, -0.9611915881223407, -0.9567694833356168, -0.8617201112330247, -0.683815164037853, -0.4513802841859834, -0.2767222655328479, -0.24271835893567434, -0.27267054121519685, -0.27519317062131443, -0.28616588533808773, -0.2777844744205183, -0.22406378836922136, -0.2557428004388969, -0.44326194554930604, -0.6840314127005878, -0.8646587673844441, -0.9602941933891046, -0.9477821902345276, -0.8393201226169212, -0.6594944069400636, -0.44880140515704203, -0.3044652061445627, -0.2859914052941979, -0.316657265121382, -0.3067866066383211, -0.28780289836785117, -0.2623772171169936, -0.22743563598957653, -0.28094515306542406, -0.46172105499931243, -0.6816232979015237, -0.853368788643532, -0.9539364379371749, -0.9359569141407178, -0.8178023395967626, -0.6458083161431897, -0.46078189713345175, -0.3343425966259763, -0.3040399067343306, -0.3020369240159101, -0.2565737191057453, -0.2143900148127831, -0.20347084844328667, -0.21882569194897866, -0.31159891482649676, -0.4869429131806326, -0.6789936108901359, -0.8352845457413198, -0.9403150890138469, -0.9219565331230252, -0.7991542114936192, -0.6391470298998767, -0.480406617885063, -0.3772339624194202, -0.3432734622136863, -0.3076273417912494, -0.22275086654779863, -0.1591171466191192, -0.15866637937182784, -0.21225642422164245, -0.3290358596900291, -0.4917353549581671, -0.6600453933616788, -0.8079168403511172, -0.9216502385132305, -0.9072759818954866, -0.7804653297215689, -0.6322083482375515, -0.5027187801398963, -0.4339113278013999, -0.41547600946372387, -0.3618670742010695, -0.24068855520504717, -0.1473811658208747, -0.14548218365107626, -0.21954138403511242, -0.33686426539569414, -0.473740655054176, -0.6233680076807026, -0.7741535508160722, -0.9028491551227509, -0.8929522782882959, -0.756864783705938, -0.6146212389246978, -0.513367757646413, -0.48232288945274865, -0.48646097517487225, -0.42513441489507686, -0.27327081648607815, -0.15083051817309004, -0.15585458030448487, -0.24761655191331758, -0.3462121758332204, -0.44668136702784256, -0.5835845624742833, -0.746094467699902, -0.8914101106844001, -0.8821387661500428, -0.7320792965299654, -0.5845565805787934, -0.4976560571938005, -0.4952595445069262, -0.5208868074338231, -0.4561778712110802, -0.2812537535317511, -0.14685717116993566, -0.17610946427101884, -0.277720601563572, -0.3429429920449862, -0.41290968659991617, -0.553466350569195, -0.7356155199561067, -0.8925808374708505, -0.884290182965297, -0.7233545645316107, -0.555796021533396, -0.45550774763406854, -0.4571342345357299, -0.49459585763269837, -0.4290731143876021, -0.24324041955835948, -0.12013004718145653, -0.17548549403374053, -0.26795098175833226, -0.30909644794952573, -0.38439246646550385, -0.5516582737621708, -0.7513137768481636, -0.905721511452472, -0.9041776875600014, -0.7504212261692499, -0.5617998211493601, -0.4151893102455081, -0.3705037724591977, -0.38054928884926614, -0.30209018968591367, -0.11544845686462707, -0.020367994925250304, -0.10257074612536023, -0.1971577605266772, -0.26616795720751535, -0.398158987244547, -0.6004331385269481, -0.7961418553010544, -0.927132169249758, -0.9355877185571251, -0.8164877640927145, -0.636413944314908, -0.4417967572349474, -0.30123951707584623, -0.21375640858592782, -0.07664012673158706, 0.11518739075572665, 0.16615884350569157, 0.02465076409271711, -0.14109523247839745, -0.3035931360581551, -0.5030459921821414, -0.7066635047318597, -0.8603180109724315, -0.9508067177341882, -0.9675336151419524, -0.9003715298312993, -0.7766258472088848, -0.5970459330681649, -0.3958499355369634, -0.19905987738307548, 0.02545309765464275, 0.23516244191468944, 0.23560784803182028, 0.00534759127691674, -0.2629597399533658, -0.4955072450966976, -0.6918777547661497, -0.8361089925936072, -0.9240889329310108, -0.972631745576734, -0.9893073183376733, -0.9649322459196252, -0.9132032637498255, -0.8204827562748569, -0.6831469591276887, -0.506931868330818, -0.2965040820189278, -0.11981037566863263, -0.13915219805239362, -0.3596030020573289, -0.5987721205595955, -0.7692781906459996, -0.8760536623234108, -0.9370363911671895, -0.9704590652859655, -0.9892901006720557 }; static float USPS_stdDev[INPUT_DIMS * TIME_STEPS] = { 0.05066656593826383, 0.11768215831858285, 0.19527142979975337, 0.2833393066737951, 0.37268899940299066, 0.43424831734200253, 0.4509077884558764, 0.4523467450088637, 0.4435444516292877, 0.453474411938222, 0.4511610370141509, 0.4090808907117051, 0.340842016175768, 0.2515266389290965, 0.1535781715584388, 0.06980490524925699, 0.08765943105043687, 0.19636324018365733, 0.32429032997742996, 0.4567512820282358, 0.5626439446484282, 0.6032659791055035, 0.5639062519215206, 0.5308776133306021, 0.5223175793565092, 0.5540930619255867, 0.6009820087794636, 0.5835468006853077, 0.5110815844557693, 0.39510080274123266, 0.25620023445987633, 0.1226867565488554, 0.11282186786555957, 0.2443736268637558, 0.3927773337244816, 0.5300792876318842, 0.611455535763247, 0.6137703781184999, 0.5486362827625642, 0.558238252221451, 0.5640102654180597, 0.5458372730410752, 0.6033813665182791, 0.6179035980472674, 0.5636690595511944, 0.4471630564471609, 0.2991307396396185, 0.14513349372261522, 0.13165609358200855, 0.27850705968930484, 0.43720035704012494, 0.5696589694535166, 0.6305106802282854, 0.6130665659135671, 0.5708937380167166, 0.6267080783818001, 0.6140579359769878, 0.5502386047872234, 0.6051362682299342, 0.635397491562088, 0.5917012576621496, 0.4694826022296184, 0.3049891980667035, 0.1417658489946166, 0.14660482167334782, 0.3108270739064537, 0.4796721806586266, 0.6021156740335395, 0.6438981023490464, 0.6149730879531347, 0.5786341846733203, 0.6260900111005044, 0.6088319125295019, 0.5527066903416282, 0.6139823813708458, 0.6469383840051754, 0.6087765126529255, 0.4896843988025161, 0.3130099011675707, 0.13746176784318512, 0.1651363517565353, 0.3525996924710074, 0.5214554460712036, 0.6228931000316578, 0.6466288953590107, 0.617026839758864, 0.5735516128512261, 0.6164884033345998, 0.6226536777808414, 0.579468571253997, 0.6226313291006089, 0.6420111615955644, 0.6028682944062023, 0.5012722033813212, 0.3390059533601551, 0.15299465137681406, 0.19251594791512783, 0.396952702268763, 0.552159431496869, 0.6320421473488981, 0.6443326365880183, 0.6170472505372365, 0.5834546203509037, 0.6456206774803475, 0.6632037104438387, 0.6136658430782906, 0.6282883980800487, 0.6266066841912776, 0.5877284692447173, 0.5083732571738568, 0.37672585693697697, 0.19071297464730821, 0.22738939517708093, 0.43216309636726685, 0.5672536909906605, 0.631729474977315, 0.639288052909488, 0.6083883492195362, 0.5889647486063578, 0.6632192879286241, 0.666693521410897, 0.6141086834297501, 0.6235523636944053, 0.6110232070097491, 0.5810599302729026, 0.5248683372032933, 0.416871751902074, 0.23245043001693613, 0.25787896223721457, 0.45642840103735277, 0.5706055474263793, 0.6215019791294262, 0.6240378390525279, 0.585872663503391, 0.5811279830268054, 0.6602994727745124, 0.6489034985750345, 0.603285958818, 0.6104761926038955, 0.6019458376723148, 0.593072552824263, 0.5541512721442687, 0.45442464044327674, 0.26421446020604794, 0.2750748340184962, 0.4759504899089418, 0.5801160408912686, 0.6171973056405151, 0.6084475754936072, 0.5662766326533075, 0.5725163997626637, 0.6523704000367663, 0.6439544061328982, 0.6038993966379462, 0.5936445165640896, 0.5988208807738072, 0.6134438430981234, 0.5822474624078565, 0.4781320392750622, 0.2744472002370629, 0.27978594406798046, 0.49000304569115505, 0.596927771017493, 0.6295636513656973, 0.6130992222136632, 0.5685432540366993, 0.5722666927638678, 0.6490460968540127, 0.6510618224925118, 0.5951965161993366, 0.579054281068931, 0.6133129715581599, 0.6399127837494875, 0.601009829227199, 0.4759842934093174, 0.25926034572427836, 0.2659329405966657, 0.48229673831219794, 0.6058557018009367, 0.6475577504899299, 0.6318593264440545, 0.5793441705514869, 0.5626352996175501, 0.6396798454937799, 0.6395304006230473, 0.5643649762025762, 0.5814789782426448, 0.6437155669568893, 0.6622897081277597, 0.5981077340856256, 0.4440137907748311, 0.22855334793658635, 0.23058280104056256, 0.4391108535116708, 0.5858018231169397, 0.6568158083074834, 0.660992447300762, 0.6050293531558012, 0.551566388582632, 0.6078442167019985, 0.5874351599908308, 0.5329056322660973, 0.6156086282390514, 0.6757254453683215, 0.658579754018323, 0.5568677508414656, 0.3855427765572426, 0.19247519514628053, 0.18151505693157194, 0.36316373873982777, 0.5198136719231422, 0.6273283747062883, 0.6745273153652143, 0.6455002272347471, 0.5585396598417464, 0.5410453171458859, 0.5096064443341672, 0.5429252747140453, 0.6545502373132852, 0.6698239302774162, 0.5980652613996279, 0.4668007421210614, 0.3114873386910331, 0.15654842294915372, 0.12168436193114814, 0.2528519135349363, 0.3889022669431662, 0.51681799362489, 0.6152354929585003, 0.6480000627279904, 0.5868680464219567, 0.5207594899432356, 0.5133934769539377, 0.5830576463663892, 0.6286429551523846, 0.5707288552482176, 0.4582805109955963, 0.3362912300487512, 0.224029788596469, 0.1134877995573401, 0.05688552112923371, 0.1253359275691928, 0.20678860013345332, 0.30178570214200107, 0.39857085075127774, 0.4710686511232531, 0.4809255781447563, 0.4517230712365873, 0.44968948316492025, 0.4579322493794554, 0.4218312472593008, 0.3369818647335357, 0.2510674309664235, 0.18299863726222423, 0.1220244940300115, 0.059526488182894154 }; -static float USPS_W1[INPUT_DIMS * USPS_wRank] = { 0.04437631741166115, 0.13164237141609192, 0.13089998066425323, -0.005882591009140015, 0.04586317017674446, 0.21047545969486237, 0.9706279635429382, -0.5048243999481201, -0.7511760592460632, 0.07774244248867035, 0.40391597151756287, -0.016807876527309418, 0.08794082701206207, 0.09336663037538528, 0.08842388540506363, -0.10721755772829056, -0.16265031695365906, -0.506087601184845, -0.2623403072357178, -0.41705453395843506, -0.3362988531589508, 0.20567356050014496, 0.09920496493577957, 0.399951696395874, -0.10302149504423141, -0.2829299569129944, -0.21695533394813538, -0.11943338066339493, -0.17138315737247467, -0.08943527936935425, 0.09248100966215134, -0.11688404530286789, -0.2544580101966858, 0.2178615778684616, -0.245102658867836, -0.2574276626110077, 0.022898254916071892, -0.4134445786476135, 0.028750110417604446, -0.047812022268772125, 0.4697933793067932, 0.4765063524246216, 0.35218697786331177, 0.29210469126701355, 0.1622641533613205, -0.1555808037519455, 0.04628629982471466, -0.031492870301008224, -0.23739324510097504, -0.0762714371085167, -0.16486185789108276, -0.2018968164920807, -0.5137050151824951, 0.14758920669555664, -0.5882534980773926, -0.7306461334228516, -0.7919453978538513, 0.07507729530334473, 0.1977670043706894, 0.21115902066230774, -0.12351129949092865, -0.07091476023197174, 0.06400024145841599, 0.021400034427642822, 0.10578139871358871, 0.17063069343566895, 0.3912162184715271, -0.02506481111049652, 0.09003248065710068, 0.42354777455329895, -0.37391015887260437, 0.14988373219966888, 0.2816886901855469, -0.35063880681991577, -0.05643891915678978, -0.15927889943122864, -0.47207891941070557, -0.5888171195983887, -0.18981651961803436, -0.41033101081848145 }; -static float USPS_W2[USPS_wRank * HIDDEN_DIMS] = { 0.2863377332687378, -1.2143335342407227, 0.610011875629425, 0.1656205952167511, -0.8666146397590637, -0.5734943747520447, 0.7413628101348877, 0.1714680939912796, 0.9024200439453125, 0.32295238971710205, -0.3873929977416992, -0.2707236707210541, 0.5344352126121521, -0.8188126683235168, 0.35341984033584595, -0.6474847197532654, 1.4979887008666992, -0.4152466952800751, 0.2156294882297516, 0.20376665890216827, 0.18564093112945557, -0.25238993763923645, 0.3459400534629822, 0.7960702776908875, -1.1047370433807373, 0.5615563988685608, -0.3268606960773468, 0.09511122852563858, 0.21674132347106934, -0.7735028862953186, -0.1510464996099472, -0.414810448884964, -0.41682058572769165, 0.5789415836334229, 0.5722947716712952, 0.4911503493785858, 0.9235195517539978, -0.22825153172016144, -0.17003802955150604, 1.5115245580673218, -0.3358864486217499, 0.5848679542541504, -0.0174887552857399, -0.325115442276001, 0.8525659441947937, 0.07604137063026428, -0.11137218028306961, -1.094437599182129, -0.21889141201972961, 0.6240004897117615, 0.6826394200325012, 0.3434017598628998, -0.1567269265651703, 0.2540211081504822, 0.177201509475708, -0.11570670455694199, 0.04361787065863609, 0.070060133934021, 0.40478208661079407, -0.16697058081626892, -0.27620503306388855, -0.12831233441829681, 0.11825147271156311, -0.13083836436271667, -0.4768890142440796, 0.9436963796615601, -0.8370056748390198, -0.3582906424999237, 0.2789956331253052, -0.7134209275245667, -0.03986117243766785, -0.32654106616973877, 0.6198241114616394, 0.4585057497024536, -0.6961711049079895, 0.5115857720375061, -0.22929508984088898, -0.44659942388534546, 0.3906383514404297, -0.29806071519851685, -0.4874197542667389, 0.22447143495082855, 0.902230978012085, -0.5234335660934448, -0.07662484794855118, 0.6974019408226013, 0.18268021941184998, 0.1972568929195404, -0.7540782690048218, 0.16145218908786774, -0.13156381249427795, 0.588074266910553, -1.0683441162109375, 0.30249473452568054, 0.8400665521621704, 0.47553586959838867, -0.4598252773284912, -0.2067403942346573, -0.8708492517471313, -0.283275842666626, -0.23203222453594208, -0.18401674926280975, -0.5495933294296265, 1.218782901763916, 0.239736407995224, 0.18521395325660706, -0.1917710155248642, -0.5461402535438538, 0.14571575820446014, 0.004668646026402712, -0.19929653406143188, 0.12697455286979675, -0.3280128836631775, -0.5886898636817932, 0.22302460670471191, -0.4971023499965668, -0.41075021028518677, 0.33907508850097656, 0.407676100730896, -0.27239513397216797, -0.45195865631103516, 0.14889605343341827, 0.3355768918991089, -0.5228666663169861, -0.12074578553438187, -0.5339986681938171, -0.06062544137239456, 1.006304144859314, -0.36918461322784424, 0.37021008133888245, 0.5438523292541504, -0.7772119641304016, -0.045975420624017715, -0.7924363613128662, 0.512947678565979, -0.003562948200851679, -0.009431581944227219, -0.4735417664051056, 0.13429303467273712, -0.11795001477003098, -0.07338037341833115, -0.15307340025901794, 0.07787186652421951, 0.174309641122818, -0.08390356600284576, 0.4766653776168823, -0.12070371210575104, -0.37375226616859436, -0.4071563184261322, 0.056958504021167755, 0.06188056617975235, 0.12964613735675812, -0.34358277916908264, 0.7809591889381409, 0.22712215781211853, -0.4458172023296356, 0.13437648117542267, 0.12954799830913544, 1.001265287399292, 0.18989679217338562 }; +static float USPS_W1[INPUT_DIMS * USPS_WRANK] = { 0.04437631741166115, 0.13164237141609192, 0.13089998066425323, -0.005882591009140015, 0.04586317017674446, 0.21047545969486237, 0.9706279635429382, -0.5048243999481201, -0.7511760592460632, 0.07774244248867035, 0.40391597151756287, -0.016807876527309418, 0.08794082701206207, 0.09336663037538528, 0.08842388540506363, -0.10721755772829056, -0.16265031695365906, -0.506087601184845, -0.2623403072357178, -0.41705453395843506, -0.3362988531589508, 0.20567356050014496, 0.09920496493577957, 0.399951696395874, -0.10302149504423141, -0.2829299569129944, -0.21695533394813538, -0.11943338066339493, -0.17138315737247467, -0.08943527936935425, 0.09248100966215134, -0.11688404530286789, -0.2544580101966858, 0.2178615778684616, -0.245102658867836, -0.2574276626110077, 0.022898254916071892, -0.4134445786476135, 0.028750110417604446, -0.047812022268772125, 0.4697933793067932, 0.4765063524246216, 0.35218697786331177, 0.29210469126701355, 0.1622641533613205, -0.1555808037519455, 0.04628629982471466, -0.031492870301008224, -0.23739324510097504, -0.0762714371085167, -0.16486185789108276, -0.2018968164920807, -0.5137050151824951, 0.14758920669555664, -0.5882534980773926, -0.7306461334228516, -0.7919453978538513, 0.07507729530334473, 0.1977670043706894, 0.21115902066230774, -0.12351129949092865, -0.07091476023197174, 0.06400024145841599, 0.021400034427642822, 0.10578139871358871, 0.17063069343566895, 0.3912162184715271, -0.02506481111049652, 0.09003248065710068, 0.42354777455329895, -0.37391015887260437, 0.14988373219966888, 0.2816886901855469, -0.35063880681991577, -0.05643891915678978, -0.15927889943122864, -0.47207891941070557, -0.5888171195983887, -0.18981651961803436, -0.41033101081848145 }; +static float USPS_W2[USPS_WRANK * HIDDEN_DIMS] = { 0.2863377332687378, -1.2143335342407227, 0.610011875629425, 0.1656205952167511, -0.8666146397590637, -0.5734943747520447, 0.7413628101348877, 0.1714680939912796, 0.9024200439453125, 0.32295238971710205, -0.3873929977416992, -0.2707236707210541, 0.5344352126121521, -0.8188126683235168, 0.35341984033584595, -0.6474847197532654, 1.4979887008666992, -0.4152466952800751, 0.2156294882297516, 0.20376665890216827, 0.18564093112945557, -0.25238993763923645, 0.3459400534629822, 0.7960702776908875, -1.1047370433807373, 0.5615563988685608, -0.3268606960773468, 0.09511122852563858, 0.21674132347106934, -0.7735028862953186, -0.1510464996099472, -0.414810448884964, -0.41682058572769165, 0.5789415836334229, 0.5722947716712952, 0.4911503493785858, 0.9235195517539978, -0.22825153172016144, -0.17003802955150604, 1.5115245580673218, -0.3358864486217499, 0.5848679542541504, -0.0174887552857399, -0.325115442276001, 0.8525659441947937, 0.07604137063026428, -0.11137218028306961, -1.094437599182129, -0.21889141201972961, 0.6240004897117615, 0.6826394200325012, 0.3434017598628998, -0.1567269265651703, 0.2540211081504822, 0.177201509475708, -0.11570670455694199, 0.04361787065863609, 0.070060133934021, 0.40478208661079407, -0.16697058081626892, -0.27620503306388855, -0.12831233441829681, 0.11825147271156311, -0.13083836436271667, -0.4768890142440796, 0.9436963796615601, -0.8370056748390198, -0.3582906424999237, 0.2789956331253052, -0.7134209275245667, -0.03986117243766785, -0.32654106616973877, 0.6198241114616394, 0.4585057497024536, -0.6961711049079895, 0.5115857720375061, -0.22929508984088898, -0.44659942388534546, 0.3906383514404297, -0.29806071519851685, -0.4874197542667389, 0.22447143495082855, 0.902230978012085, -0.5234335660934448, -0.07662484794855118, 0.6974019408226013, 0.18268021941184998, 0.1972568929195404, -0.7540782690048218, 0.16145218908786774, -0.13156381249427795, 0.588074266910553, -1.0683441162109375, 0.30249473452568054, 0.8400665521621704, 0.47553586959838867, -0.4598252773284912, -0.2067403942346573, -0.8708492517471313, -0.283275842666626, -0.23203222453594208, -0.18401674926280975, -0.5495933294296265, 1.218782901763916, 0.239736407995224, 0.18521395325660706, -0.1917710155248642, -0.5461402535438538, 0.14571575820446014, 0.004668646026402712, -0.19929653406143188, 0.12697455286979675, -0.3280128836631775, -0.5886898636817932, 0.22302460670471191, -0.4971023499965668, -0.41075021028518677, 0.33907508850097656, 0.407676100730896, -0.27239513397216797, -0.45195865631103516, 0.14889605343341827, 0.3355768918991089, -0.5228666663169861, -0.12074578553438187, -0.5339986681938171, -0.06062544137239456, 1.006304144859314, -0.36918461322784424, 0.37021008133888245, 0.5438523292541504, -0.7772119641304016, -0.045975420624017715, -0.7924363613128662, 0.512947678565979, -0.003562948200851679, -0.009431581944227219, -0.4735417664051056, 0.13429303467273712, -0.11795001477003098, -0.07338037341833115, -0.15307340025901794, 0.07787186652421951, 0.174309641122818, -0.08390356600284576, 0.4766653776168823, -0.12070371210575104, -0.37375226616859436, -0.4071563184261322, 0.056958504021167755, 0.06188056617975235, 0.12964613735675812, -0.34358277916908264, 0.7809591889381409, 0.22712215781211853, -0.4458172023296356, 0.13437648117542267, 0.12954799830913544, 1.001265287399292, 0.18989679217338562 }; -static float USPS_U1[HIDDEN_DIMS * USPS_uRank] = { 0.26560232043266296, 0.23243790864944458, 0.7191420197486877, -0.20894131064414978, 0.49118855595588684, 0.6319213509559631, 0.34289464354515076, 0.01801704801619053, -0.0745602548122406, -1.0685001611709595, -0.26240262389183044, 0.4905305802822113, 0.1572536826133728, -0.23067831993103027, -0.5052195191383362, 0.7681716680526733, 0.9279878735542297, -0.5277288556098938, -0.08344665914773941, 0.6202220916748047, -0.5001773238182068, -0.5095654726028442, -0.3295743465423584, 0.5233407616615295, -0.5727354288101196, -0.8839725852012634, -0.010022483766078949, -0.09335310012102127, -0.39809176325798035, -0.1842958629131317, 0.24937759339809418, -0.10589130222797394, 0.08205743134021759, 0.31646987795829773, -0.29515960812568665, 0.5459985733032227, 0.1268385350704193, 0.04255566745996475, 0.33306896686553955, -0.16022534668445587, -0.29528936743736267, -0.25233426690101624, -0.2937506437301636, 0.4037521183490753, 0.23886920511722565, 0.06710945069789886, 0.08734912425279617, 0.5572593808174133, -1.314361333847046, 0.03353128582239151, 0.2606905698776245, 0.6152605414390564, -0.3894504904747009, -0.32302090525627136, 0.36168500781059265, 0.6218935251235962, -0.38376080989837646, 0.09247376024723053, 1.026206612586975, 1.1414283514022827, -0.10093820095062256, 0.9370135068893433, 1.9249975681304932, -0.5042387247085571, 0.18620948493480682, -0.3022148311138153, 0.03854614496231079, 0.37739163637161255, -0.3281741440296173, -0.34284695982933044, 0.5523097515106201, 0.03876172751188278, -0.1751827448606491, -0.0030013038776814938, 0.05078490078449249, -0.29853954911231995, -0.6525045037269592, -0.05094808712601662, -0.20980416238307953, 0.03934936225414276, 0.7077404856681824, -0.5978014469146729, -0.03315050154924393, -0.9729236960411072, -0.8541942834854126, -0.23380915820598602, -0.8171064853668213, 0.08188191801309586, 0.3533187210559845, -0.3635164201259613, -0.8342750072479248, 0.726115882396698, 0.2952367961406708, -0.4665921926498413, 0.7437827587127686, 0.45183295011520386, 0.5798006057739258, 0.2457144558429718, 0.4404001533985138, 0.12141070514917374, 0.3805271089076996, -0.23846925795078278, 0.7316015958786011, -0.3569253087043762, 0.15102985501289368, -0.39612525701522827, 0.28232714533805847, -0.6851686239242554, 0.6952816247940063, 0.452238529920578, 0.08832887560129166, 1.4521069526672363, 0.36747226119041443, 0.31619787216186523, 0.19886334240436554, 0.23799069225788116, -0.5594980716705322, -0.3654753267765045, -0.19946272671222687, -0.10181467235088348, -0.12737073004245758, 0.7593855857849121, -0.9848454594612122, 0.6157532930374146, 0.2603704035282135, 0.999906063079834, -0.4353993237018585, -0.4969525635242462, -0.714335024356842, 0.04920447617769241, 0.151398703455925, -0.40162163972854614, -0.27132919430732727, 0.7902809977531433, -0.10028137266635895, 1.0021592378616333, -0.30421894788742065, 0.3746432662010193, 0.5291203856468201, -0.3812990188598633, 0.7990191578865051, 0.508926272392273, -0.1624583899974823, -0.1668565720319748, 0.2089664191007614, -0.13996511697769165, 0.3811531960964203, 0.2811248302459717, 0.6223021149635315, -0.7457583546638489, -0.33088400959968567, 1.0035068988800049, -0.35653096437454224, -0.4059991240501404, -0.1819305270910263, -0.4383915662765503, 0.7609431743621826, -0.7965887784957886, 0.5413278937339783, -0.3607611358165741 }; -static float USPS_U2[USPS_uRank * HIDDEN_DIMS] = { -1.1701158285140991, -0.1588035672903061, -1.1778416633605957, 0.11378461867570877, 0.1573396474123001, 0.13804543018341064, -0.28284865617752075, 0.8901959657669067, -0.5648555755615234, -0.6038640737533569, -0.4130585789680481, 0.7159488797187805, -1.263935923576355, 0.22861142456531525, 0.39220884442329407, 0.6647656559944153, 0.28182974457740784, 0.6640202403068542, 0.20066450536251068, -0.7047211527824402, 0.42111220955848694, -0.5956082344055176, -0.1325611025094986, 0.5465019941329956, -0.42245036363601685, -0.6001131534576416, -0.2538827061653137, -0.24035486578941345, -0.46974751353263855, 0.9539428949356079, 0.4083715081214905, 0.1597665399312973, 0.31555771827697754, -0.1176120713353157, -0.3248029053211212, 0.5774492025375366, 0.06316787749528885, 0.13469642400741577, 0.7753828167915344, -0.19036400318145752, 0.558892548084259, 0.2966901361942291, -0.2756923735141754, 0.0863649770617485, 0.5044283270835876, 0.5554067492485046, 1.2062954902648926, -0.06426048278808594, 0.251096248626709, 0.7044650316238403, 0.7219952940940857, 0.2331368625164032, 0.6588672995567322, -0.021296916529536247, -0.5537024140357971, 0.1907256543636322, -0.08542638272047043, -0.9375039339065552, -0.11962691694498062, -0.34279578924179077, -0.1679597795009613, 0.8744648694992065, 0.4903189241886139, -0.002235307591035962, 0.49500423669815063, -0.20796941220760345, -0.4931069314479828, 0.19794103503227234, 0.23972071707248688, 0.07782389968633652, -1.5402740240097046, 0.4908592104911804, 0.37148523330688477, 0.9664593935012817, -1.0712075233459473, -0.47738638520240784, 0.3663298785686493, 0.01408083550632, -0.5519229173660278, -0.5287301540374756, 0.2269572615623474, 0.05943543091416359, -0.813250720500946, 0.3974776566028595, 0.6844959855079651, 0.009752316400408745, -0.22982186079025269, -0.18944667279720306, -0.33985260128974915, 0.20089533925056458, 0.24146895110607147, -0.3968782126903534, -0.6829974055290222, 0.2860521376132965, 0.06187593191862106, -0.0817679762840271, 1.0080456733703613, 1.087625503540039, 0.8712841868400574, 1.0755778551101685, -0.474960595369339, -0.723259687423706, -0.9868606925010681, 0.8535012602806091, -0.5053154230117798, -0.30608052015304565, -0.7238053679466248, -0.04056096449494362, -0.37457355856895447, 0.14730329811573029, -0.1650729775428772, 0.4555414319038391, -0.0914393812417984, -0.027970634400844574, 0.48361921310424805, 0.09482058882713318, -0.6751720309257507, 0.7193213105201721, -0.3357415199279785, 0.033068787306547165, -0.6387664079666138, -0.08479925990104675, -0.19875706732273102, -0.9184507727622986, 0.700031578540802, 0.19395720958709717, 0.05879056081175804, -0.3861687183380127, 0.15968921780586243, -0.22974976897239685, 0.21669058501720428, 0.07636229693889618, 0.30239996314048767, -0.22337456047534943, 0.14845764636993408, -0.3706870675086975, -0.9184858798980713, 0.28799909353256226, -0.6701984405517578, -0.1726493388414383, -0.061379268765449524, -0.5134955048561096, 0.6964709758758545, -0.006153882015496492, -0.009776073507964611, 0.16820202767848969, 0.4359828531742096, 0.5606184601783752, -0.7106017470359802, 0.10443971306085587, 0.3130362927913666, -1.2240679264068604, 0.08121868968009949, 0.1808670610189438, -0.30179110169410706, 0.26126185059547424, 0.42505496740341187, -0.369361937046051, -0.02273283340036869, 0.059929925948381424 }; +static float USPS_U1[HIDDEN_DIMS * USPS_URANK] = { 0.26560232043266296, 0.23243790864944458, 0.7191420197486877, -0.20894131064414978, 0.49118855595588684, 0.6319213509559631, 0.34289464354515076, 0.01801704801619053, -0.0745602548122406, -1.0685001611709595, -0.26240262389183044, 0.4905305802822113, 0.1572536826133728, -0.23067831993103027, -0.5052195191383362, 0.7681716680526733, 0.9279878735542297, -0.5277288556098938, -0.08344665914773941, 0.6202220916748047, -0.5001773238182068, -0.5095654726028442, -0.3295743465423584, 0.5233407616615295, -0.5727354288101196, -0.8839725852012634, -0.010022483766078949, -0.09335310012102127, -0.39809176325798035, -0.1842958629131317, 0.24937759339809418, -0.10589130222797394, 0.08205743134021759, 0.31646987795829773, -0.29515960812568665, 0.5459985733032227, 0.1268385350704193, 0.04255566745996475, 0.33306896686553955, -0.16022534668445587, -0.29528936743736267, -0.25233426690101624, -0.2937506437301636, 0.4037521183490753, 0.23886920511722565, 0.06710945069789886, 0.08734912425279617, 0.5572593808174133, -1.314361333847046, 0.03353128582239151, 0.2606905698776245, 0.6152605414390564, -0.3894504904747009, -0.32302090525627136, 0.36168500781059265, 0.6218935251235962, -0.38376080989837646, 0.09247376024723053, 1.026206612586975, 1.1414283514022827, -0.10093820095062256, 0.9370135068893433, 1.9249975681304932, -0.5042387247085571, 0.18620948493480682, -0.3022148311138153, 0.03854614496231079, 0.37739163637161255, -0.3281741440296173, -0.34284695982933044, 0.5523097515106201, 0.03876172751188278, -0.1751827448606491, -0.0030013038776814938, 0.05078490078449249, -0.29853954911231995, -0.6525045037269592, -0.05094808712601662, -0.20980416238307953, 0.03934936225414276, 0.7077404856681824, -0.5978014469146729, -0.03315050154924393, -0.9729236960411072, -0.8541942834854126, -0.23380915820598602, -0.8171064853668213, 0.08188191801309586, 0.3533187210559845, -0.3635164201259613, -0.8342750072479248, 0.726115882396698, 0.2952367961406708, -0.4665921926498413, 0.7437827587127686, 0.45183295011520386, 0.5798006057739258, 0.2457144558429718, 0.4404001533985138, 0.12141070514917374, 0.3805271089076996, -0.23846925795078278, 0.7316015958786011, -0.3569253087043762, 0.15102985501289368, -0.39612525701522827, 0.28232714533805847, -0.6851686239242554, 0.6952816247940063, 0.452238529920578, 0.08832887560129166, 1.4521069526672363, 0.36747226119041443, 0.31619787216186523, 0.19886334240436554, 0.23799069225788116, -0.5594980716705322, -0.3654753267765045, -0.19946272671222687, -0.10181467235088348, -0.12737073004245758, 0.7593855857849121, -0.9848454594612122, 0.6157532930374146, 0.2603704035282135, 0.999906063079834, -0.4353993237018585, -0.4969525635242462, -0.714335024356842, 0.04920447617769241, 0.151398703455925, -0.40162163972854614, -0.27132919430732727, 0.7902809977531433, -0.10028137266635895, 1.0021592378616333, -0.30421894788742065, 0.3746432662010193, 0.5291203856468201, -0.3812990188598633, 0.7990191578865051, 0.508926272392273, -0.1624583899974823, -0.1668565720319748, 0.2089664191007614, -0.13996511697769165, 0.3811531960964203, 0.2811248302459717, 0.6223021149635315, -0.7457583546638489, -0.33088400959968567, 1.0035068988800049, -0.35653096437454224, -0.4059991240501404, -0.1819305270910263, -0.4383915662765503, 0.7609431743621826, -0.7965887784957886, 0.5413278937339783, -0.3607611358165741 }; +static float USPS_U2[USPS_URANK * HIDDEN_DIMS] = { -1.1701158285140991, -0.1588035672903061, -1.1778416633605957, 0.11378461867570877, 0.1573396474123001, 0.13804543018341064, -0.28284865617752075, 0.8901959657669067, -0.5648555755615234, -0.6038640737533569, -0.4130585789680481, 0.7159488797187805, -1.263935923576355, 0.22861142456531525, 0.39220884442329407, 0.6647656559944153, 0.28182974457740784, 0.6640202403068542, 0.20066450536251068, -0.7047211527824402, 0.42111220955848694, -0.5956082344055176, -0.1325611025094986, 0.5465019941329956, -0.42245036363601685, -0.6001131534576416, -0.2538827061653137, -0.24035486578941345, -0.46974751353263855, 0.9539428949356079, 0.4083715081214905, 0.1597665399312973, 0.31555771827697754, -0.1176120713353157, -0.3248029053211212, 0.5774492025375366, 0.06316787749528885, 0.13469642400741577, 0.7753828167915344, -0.19036400318145752, 0.558892548084259, 0.2966901361942291, -0.2756923735141754, 0.0863649770617485, 0.5044283270835876, 0.5554067492485046, 1.2062954902648926, -0.06426048278808594, 0.251096248626709, 0.7044650316238403, 0.7219952940940857, 0.2331368625164032, 0.6588672995567322, -0.021296916529536247, -0.5537024140357971, 0.1907256543636322, -0.08542638272047043, -0.9375039339065552, -0.11962691694498062, -0.34279578924179077, -0.1679597795009613, 0.8744648694992065, 0.4903189241886139, -0.002235307591035962, 0.49500423669815063, -0.20796941220760345, -0.4931069314479828, 0.19794103503227234, 0.23972071707248688, 0.07782389968633652, -1.5402740240097046, 0.4908592104911804, 0.37148523330688477, 0.9664593935012817, -1.0712075233459473, -0.47738638520240784, 0.3663298785686493, 0.01408083550632, -0.5519229173660278, -0.5287301540374756, 0.2269572615623474, 0.05943543091416359, -0.813250720500946, 0.3974776566028595, 0.6844959855079651, 0.009752316400408745, -0.22982186079025269, -0.18944667279720306, -0.33985260128974915, 0.20089533925056458, 0.24146895110607147, -0.3968782126903534, -0.6829974055290222, 0.2860521376132965, 0.06187593191862106, -0.0817679762840271, 1.0080456733703613, 1.087625503540039, 0.8712841868400574, 1.0755778551101685, -0.474960595369339, -0.723259687423706, -0.9868606925010681, 0.8535012602806091, -0.5053154230117798, -0.30608052015304565, -0.7238053679466248, -0.04056096449494362, -0.37457355856895447, 0.14730329811573029, -0.1650729775428772, 0.4555414319038391, -0.0914393812417984, -0.027970634400844574, 0.48361921310424805, 0.09482058882713318, -0.6751720309257507, 0.7193213105201721, -0.3357415199279785, 0.033068787306547165, -0.6387664079666138, -0.08479925990104675, -0.19875706732273102, -0.9184507727622986, 0.700031578540802, 0.19395720958709717, 0.05879056081175804, -0.3861687183380127, 0.15968921780586243, -0.22974976897239685, 0.21669058501720428, 0.07636229693889618, 0.30239996314048767, -0.22337456047534943, 0.14845764636993408, -0.3706870675086975, -0.9184858798980713, 0.28799909353256226, -0.6701984405517578, -0.1726493388414383, -0.061379268765449524, -0.5134955048561096, 0.6964709758758545, -0.006153882015496492, -0.009776073507964611, 0.16820202767848969, 0.4359828531742096, 0.5606184601783752, -0.7106017470359802, 0.10443971306085587, 0.3130362927913666, -1.2240679264068604, 0.08121868968009949, 0.1808670610189438, -0.30179110169410706, 0.26126185059547424, 0.42505496740341187, -0.369361937046051, -0.02273283340036869, 0.059929925948381424 }; static float USPS_Bg[HIDDEN_DIMS] = { 4.59620475769043, 0.1966695934534073, 1.9611409902572632, 3.5603864192962646, 4.187475204467773, 4.361924648284912, 0.3600460886955261, 1.3823245763778687, -0.677017092704773, 4.105582237243652, 5.264251232147217, -0.5598424077033997, 5.148655414581299, 2.0772266387939453, 4.553979873657227, 5.08613920211792, 4.782368183135986, 0.7364211678504944, 5.434220314025879, 3.580031394958496, 3.1102733612060547, -0.7808840870857239, 0.7291825413703918, 4.574047565460205, 3.3059921264648438, 0.3563838303089142, 2.718221664428711, 3.580395460128784, 3.4779181480407715, 2.5830607414245605, 2.9951508045196533, 0.9241535663604736 }; static float USPS_Bh[HIDDEN_DIMS] = { 0.4606550931930542, 0.790073573589325, -0.017053354531526566, 0.9936599731445312, 1.7931172847747803, 1.5456229448318481, 1.1712238788604736, 0.25801223516464233, 0.31747567653656006, 0.19287768006324768, 2.0994107723236084, 1.0495734214782715, 1.4762489795684814, 1.309980034828186, 0.3596293032169342, 1.5582088232040405, 0.40993940830230713, 1.8783470392227173, 1.493168830871582, -0.24529218673706055, 1.1273030042648315, 0.2839592695236206, 1.9818940162658691, 1.6705248355865479, 0.6683108806610107, 1.1119632720947266, 1.71348237991333, 2.004892110824585, 2.6525025367736816, 1.5513267517089844, 1.5202845335006714, -0.5777350068092346 }; @@ -38,8 +39,8 @@ static float FC_weights[HIDDEN_DIMS * NUM_CLASSES] = { -0.24747183918952942, -0. static float FCbias[NUM_CLASSES] = { 0.7145490646362305, 0.2392704039812088, 0.7243489027023315, -0.3943518102169037, -0.7943000793457031, 0.18482555449008942, 0.29146698117256165, -0.04441819712519646, 1.5886560678482056, -0.8504140377044678 }; // Here are 10 example with labels to check code correctness -#define numExamples 10 -static float input[numExamples * INPUT_DIMS * TIME_STEPS] = { +#define NUM_EXAMPLES 10 +static float input[NUM_EXAMPLES * INPUT_DIMS * TIME_STEPS] = { -9.999989999999999712e-01, -9.999280000000000390e-01, -9.978850000000000220e-01, -9.737289999999999557e-01, -8.557719999999999771e-01, -5.974159999999999471e-01, -2.892540000000000111e-01, 1.891000000000000103e-03, 1.991960000000000119e-01, 2.921619999999999773e-01, 5.840999999999999664e-02, -3.988849999999999896e-01, -7.828040000000000553e-01, -9.586670000000000469e-01, -9.971060000000000478e-01, -9.999299999999999855e-01, -9.999660000000000215e-01, -9.984709999999999974e-01, -9.743000000000000549e-01, -8.181580000000000519e-01, -3.776260000000000172e-01, 1.784530000000000005e-01, 4.618349999999999955e-01, 4.866269999999999762e-01, 4.564190000000000191e-01, 4.585899999999999976e-01, 4.410350000000000104e-01, 2.776770000000000072e-01, -2.715719999999999801e-01, -7.943890000000000118e-01, -9.763939999999999841e-01, -9.989860000000000406e-01, -9.994060000000000166e-01, -9.843779999999999752e-01, -8.419809999999999794e-01, -3.601309999999999789e-01, 2.763050000000000228e-01, 5.122529999999999584e-01, 3.171390000000000042e-01, -5.488300000000000123e-02, -3.208799999999999986e-01, -3.823739999999999917e-01, -1.500219999999999887e-01, 3.192159999999999997e-01, 2.445279999999999954e-01, -4.316969999999999974e-01, -8.891390000000000127e-01, -9.936409999999999965e-01, -9.952950000000000408e-01, -9.140859999999999541e-01, -4.970399999999999818e-01, 2.440730000000000122e-01, 4.769090000000000273e-01, 3.452399999999999913e-02, -4.699980000000000269e-01, -7.523990000000000400e-01, -8.733349999999999724e-01, -8.564300000000000246e-01, -5.707010000000000138e-01, 7.110299999999999954e-02, 5.098099999999999854e-01, 3.845200000000000007e-02, -7.229849999999999888e-01, -9.823070000000000412e-01, -9.843929999999999625e-01, -7.619580000000000242e-01, -5.724800000000000028e-02, 4.982750000000000234e-01, 1.289379999999999971e-01, -5.653420000000000112e-01, -9.008960000000000301e-01, -9.768630000000000368e-01, -9.654559999999999809e-01, -7.698230000000000350e-01, -2.443150000000000044e-01, 3.408079999999999998e-01, 6.986529999999999685e-01, 2.799619999999999886e-01, -6.274570000000000425e-01, -9.747249999999999526e-01, -9.740199999999999969e-01, -6.315579999999999528e-01, 2.490229999999999944e-01, 4.868640000000000190e-01, -2.849450000000000038e-01, -8.529759999999999565e-01, -9.786280000000000534e-01, -9.680050000000000043e-01, -8.506489999999999885e-01, -3.887789999999999857e-01, 3.913400000000000212e-01, 7.540489999999999693e-01, 6.519970000000000487e-01, 6.102400000000000185e-02, -7.050119999999999720e-01, -9.787219999999999809e-01, -9.727649999999999908e-01, -6.046329999999999760e-01, 3.010070000000000245e-01, 4.125269999999999770e-01, -4.544940000000000091e-01, -8.776140000000000052e-01, -8.431469999999999798e-01, -6.940309999999999535e-01, -3.879340000000000011e-01, 1.740309999999999913e-01, 7.366949999999999887e-01, 7.265779999999999461e-01, 1.642170000000000019e-01, -4.996470000000000078e-01, -8.923109999999999653e-01, -9.926230000000000331e-01, -9.797400000000000553e-01, -6.899070000000000480e-01, 9.411700000000000621e-02, 3.872579999999999911e-01, -1.671759999999999913e-01, -4.210010000000000141e-01, -2.404840000000000033e-01, 5.989099999999999979e-02, 4.223910000000000164e-01, 7.399440000000000461e-01, 8.160749999999999948e-01, 3.639479999999999937e-01, -4.222170000000000090e-01, -8.689219999999999722e-01, -9.837040000000000228e-01, -9.991529999999999578e-01, -9.896549999999999514e-01, -8.313369999999999926e-01, -2.835340000000000082e-01, 3.112550000000000039e-01, 4.447369999999999934e-01, 4.600369999999999737e-01, 5.187220000000000164e-01, 5.491030000000000078e-01, 6.715740000000000043e-01, 8.727289999999999770e-01, 6.886210000000000386e-01, -8.334999999999999354e-02, -7.613389999999999880e-01, -9.757749999999999480e-01, -9.987230000000000274e-01, -9.999609999999999888e-01, -9.974539999999999518e-01, -9.540859999999999896e-01, -7.398449999999999749e-01, -2.981320000000000081e-01, 1.168259999999999993e-01, 2.966269999999999740e-01, 2.590549999999999797e-01, 1.147709999999999980e-01, 3.006869999999999821e-01, 7.234869999999999912e-01, 4.759129999999999749e-01, -4.180459999999999732e-01, -9.063860000000000250e-01, -9.947169999999999623e-01, -9.999120000000000230e-01, -9.999989999999999712e-01, -9.998259999999999925e-01, -9.956909999999999927e-01, -9.592690000000000383e-01, -8.423429999999999529e-01, -6.910760000000000236e-01, -6.172760000000000469e-01, -6.201600000000000446e-01, -4.761870000000000269e-01, 1.655320000000000125e-01, 6.454130000000000145e-01, 2.260870000000000102e-01, -6.278190000000000159e-01, -9.656599999999999628e-01, -9.988850000000000229e-01, -9.999900000000000455e-01, -1.000000000000000000e+00, -9.999970000000000248e-01, -9.998519999999999630e-01, -9.978810000000000180e-01, -9.905059999999999976e-01, -9.802600000000000202e-01, -9.741710000000000091e-01, -9.412179999999999991e-01, -5.735930000000000195e-01, 3.320199999999999818e-01, 6.261999999999999789e-01, -3.573099999999999887e-02, -7.612609999999999655e-01, -9.845939999999999692e-01, -9.997819999999999485e-01, -9.999989999999999712e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999989999999999712e-01, -9.999770000000000048e-01, -9.998920000000000030e-01, -9.997390000000000443e-01, -9.965319999999999734e-01, -9.296180000000000554e-01, -4.550699999999999745e-01, 4.870189999999999797e-01, 5.592399999999999594e-01, -3.041880000000000139e-01, -8.719719999999999693e-01, -9.928409999999999735e-01, -9.999190000000000023e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999329999999999607e-01, -9.939230000000000009e-01, -8.872520000000000406e-01, -3.392859999999999765e-01, 5.403149999999999897e-01, 4.513349999999999862e-01, -4.945749999999999869e-01, -9.424919999999999964e-01, -9.976519999999999833e-01, -9.999759999999999760e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999259999999999815e-01, -9.933429999999999760e-01, -8.806059999999999999e-01, -3.493580000000000019e-01, 4.458260000000000001e-01, 3.244429999999999814e-01, -5.840009999999999923e-01, -9.678870000000000529e-01, -9.992910000000000403e-01, -9.999949999999999672e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999679999999999680e-01, -9.970299999999999718e-01, -9.415249999999999453e-01, -6.157479999999999620e-01, -2.896299999999999916e-02, -4.975899999999999768e-02, -6.953970000000000429e-01, -9.771060000000000301e-01, -9.995380000000000376e-01, -9.999970000000000248e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999970000000000248e-01, -9.998139999999999805e-01, -9.966190000000000326e-01, -9.780339999999999590e-01, -9.545759999999999801e-01, -9.752389999999999670e-01, -9.954779999999999740e-01, -9.997519999999999740e-01, -9.999970000000000248e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999980000000000535e-01, -9.998369999999999758e-01, -9.954880000000000395e-01, -9.504259999999999931e-01, -7.896699999999999831e-01, -6.470510000000000428e-01, -8.003550000000000386e-01, -9.586339999999999861e-01, -9.975939999999999808e-01, -9.999730000000000008e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999430000000000263e-01, -9.972550000000000026e-01, -9.556320000000000370e-01, -7.292520000000000113e-01, -2.420829999999999926e-01, -2.454399999999999984e-02, -5.075699999999999656e-01, -9.040599999999999747e-01, -9.945370000000000044e-01, -9.999390000000000223e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.992020000000000346e-01, -9.800210000000000310e-01, -8.063310000000000199e-01, -2.593779999999999974e-01, 3.189710000000000045e-01, 1.385699999999999987e-01, -5.933460000000000401e-01, -9.467590000000000172e-01, -9.975420000000000398e-01, -9.999730000000000008e-01, -9.999810000000000088e-01, -9.999059999999999615e-01, -9.997890000000000388e-01, -9.997160000000000490e-01, -9.997420000000000195e-01, -9.998690000000000078e-01, -9.933290000000000175e-01, -9.030359999999999498e-01, -4.857190000000000119e-01, 2.202580000000000093e-01, 3.925609999999999933e-01, -2.135680000000000078e-01, -8.084810000000000052e-01, -9.859269999999999978e-01, -9.996680000000000010e-01, -9.998460000000000125e-01, -9.982060000000000377e-01, -9.917500000000000204e-01, -9.816620000000000346e-01, -9.754720000000000057e-01, -9.776810000000000223e-01, -9.885800000000000143e-01, -9.579349999999999810e-01, -6.812009999999999454e-01, -1.472900000000000077e-02, 4.044590000000000130e-01, 1.744000000000000107e-03, -6.527589999999999781e-01, -9.469760000000000399e-01, -9.971389999999999976e-01, -9.990179999999999616e-01, -9.935869999999999980e-01, -9.621610000000000440e-01, -8.605129999999999724e-01, -7.114340000000000108e-01, -6.217570000000000041e-01, -6.545539999999999692e-01, -8.180990000000000206e-01, -8.326540000000000052e-01, -2.617280000000000162e-01, 3.754509999999999792e-01, 2.040089999999999959e-01, -4.992320000000000091e-01, -9.049289999999999834e-01, -9.926559999999999828e-01, -9.970080000000000053e-01, -9.778109999999999857e-01, -9.049239999999999506e-01, -7.120379999999999487e-01, -3.425619999999999776e-01, 6.654699999999999505e-02, 2.899360000000000270e-01, 2.038639999999999897e-01, -2.888930000000000109e-01, -6.016200000000000436e-01, 2.237599999999999867e-01, 4.728720000000000145e-01, -2.020810000000000106e-01, -8.067750000000000199e-01, -9.818890000000000118e-01, -9.959559999999999524e-01, -9.594920000000000115e-01, -8.015440000000000342e-01, -4.776880000000000015e-01, -5.933299999999999685e-02, 3.293409999999999949e-01, 4.718570000000000264e-01, 5.348239999999999661e-01, 6.105019999999999891e-01, 1.929130000000000011e-01, -3.182189999999999741e-01, 4.499960000000000071e-01, 2.788849999999999940e-01, -5.529119999999999591e-01, -9.429680000000000284e-01, -9.955770000000000453e-01, -9.679489999999999483e-01, -7.739960000000000173e-01, -2.748309999999999920e-01, 2.607160000000000033e-01, 4.484049999999999980e-01, 2.828910000000000036e-01, -7.138799999999999313e-02, -6.642099999999999393e-02, 4.065540000000000265e-01, 2.446029999999999871e-01, 3.899699999999999694e-02, 5.033360000000000056e-01, -4.535299999999999748e-02, -7.580999999999999961e-01, -9.829919999999999769e-01, -9.917150000000000132e-01, -8.703159999999999785e-01, -3.756889999999999952e-01, 3.230350000000000166e-01, 4.952420000000000155e-01, 9.888500000000000068e-02, -3.883220000000000005e-01, -4.875369999999999981e-01, -8.031599999999999850e-02, 3.734810000000000074e-01, -2.383000000000000049e-02, 2.615910000000000180e-01, 5.028839999999999977e-01, -2.584890000000000243e-01, -8.368999999999999773e-01, -9.704739999999999478e-01, -9.594789999999999708e-01, -6.982570000000000165e-01, 6.056000000000000272e-02, 5.625900000000000345e-01, 2.014019999999999977e-01, -3.725189999999999890e-01, -4.919939999999999869e-01, -1.114050000000000040e-01, 3.437359999999999860e-01, 2.275850000000000095e-01, -4.526970000000000161e-01, 1.003830000000000000e-01, 4.796369999999999800e-01, -4.047699999999999909e-02, -5.253360000000000252e-01, -6.631690000000000085e-01, -6.518180000000000085e-01, -3.370239999999999903e-01, 4.402659999999999907e-01, 7.036090000000000400e-01, 2.616310000000000024e-01, -4.629099999999999882e-02, 1.247849999999999931e-01, 3.785680000000000156e-01, 2.745529999999999915e-01, -3.034560000000000035e-01, -8.094130000000000491e-01, -3.392160000000000175e-01, 2.911190000000000166e-01, 4.478119999999999878e-01, 2.841810000000000169e-01, 1.725970000000000004e-01, 1.636219999999999897e-01, 3.333510000000000084e-01, 7.324669999999999792e-01, 8.364880000000000093e-01, 6.596779999999999866e-01, 4.947179999999999911e-01, 3.596230000000000260e-01, 6.418400000000000494e-02, -3.763210000000000166e-01, -7.848289999999999988e-01, -9.641279999999999850e-01, -7.788399999999999768e-01, -3.283260000000000067e-01, 1.826979999999999993e-01, 4.072209999999999996e-01, 4.398770000000000180e-01, 4.419750000000000068e-01, 4.685380000000000100e-01, 5.024669999999999970e-01, 4.371590000000000198e-01, 3.300500000000000100e-01, 8.870500000000000607e-02, -2.866989999999999816e-01, -6.432419999999999805e-01, -8.643650000000000500e-01, -9.685209999999999653e-01, -9.969440000000000524e-01, -9.666979999999999462e-01, -8.456479999999999553e-01, -6.185110000000000330e-01, -4.195189999999999753e-01, -3.446670000000000011e-01, -3.342269999999999963e-01, -3.463689999999999825e-01, -4.145019999999999816e-01, -5.345849999999999769e-01, -6.055599999999999872e-01, -7.047379999999999756e-01, -8.486580000000000235e-01, -9.541119999999999601e-01, -9.905789999999999873e-01, -9.983819999999999917e-01, -9.998939999999999495e-01, -9.982809999999999739e-01, -9.897010000000000529e-01, -9.606010000000000382e-01, -9.117140000000000244e-01, -8.874419999999999531e-01, -8.837279999999999580e-01, -8.886560000000000015e-01, -9.140369999999999884e-01, -9.559229999999999672e-01, -9.734709999999999752e-01, -9.812159999999999771e-01, -9.910759999999999570e-01, -9.978909999999999725e-01, -9.997979999999999645e-01, -9.999810000000000088e-01, -9.999989999999999712e-01, -9.981079999999999952e-01, -9.638900000000000245e-01, -7.673659999999999926e-01, -2.878439999999999888e-01, 2.341890000000000083e-01, 4.676179999999999781e-01, 5.042510000000000048e-01, 5.016939999999999733e-01, 4.801219999999999932e-01, 3.454900000000000193e-01, -6.736999999999999933e-03, -4.381289999999999907e-01, -7.494800000000000351e-01, -9.366400000000000281e-01, -9.944420000000000481e-01, -9.998240000000000460e-01, -9.919229999999999992e-01, -8.630259999999999598e-01, -3.455880000000000063e-01, 4.015329999999999733e-01, 7.366509999999999447e-01, 6.913629999999999498e-01, 5.819159999999999888e-01, 5.270550000000000512e-01, 5.444989999999999553e-01, 5.688980000000000148e-01, 5.186180000000000234e-01, 3.642090000000000050e-01, -1.064640000000000031e-01, -6.902979999999999672e-01, -9.535810000000000120e-01, -9.976319999999999633e-01, -9.868759999999999755e-01, -7.869169999999999776e-01, -1.141999999999999960e-01, 5.454299999999999704e-01, 4.628650000000000264e-01, 1.139000000000000038e-03, -3.319489999999999941e-01, -4.679980000000000251e-01, -4.026799999999999824e-01, -2.014759999999999884e-01, 1.090420000000000000e-01, 5.561369999999999925e-01, 4.693010000000000237e-01, -2.451190000000000035e-01, -8.299600000000000311e-01, -9.896859999999999546e-01, -9.922189999999999621e-01, -8.700480000000000436e-01, -4.169459999999999833e-01, 1.373399999999999968e-02, -2.686060000000000114e-01, -6.914200000000000346e-01, -8.835169999999999968e-01, -9.425860000000000349e-01, -9.128619999999999512e-01, -7.964980000000000393e-01, -4.124470000000000081e-01, 3.843889999999999807e-01, 7.012939999999999729e-01, 1.581490000000000118e-01, -6.815440000000000387e-01, -9.794960000000000333e-01, -9.982649999999999579e-01, -9.697109999999999896e-01, -8.481670000000000043e-01, -7.238719999999999599e-01, -8.331269999999999509e-01, -9.562640000000000029e-01, -9.904990000000000183e-01, -9.886059999999999848e-01, -9.499870000000000259e-01, -7.771839999999999860e-01, -2.510830000000000006e-01, 5.462240000000000428e-01, 7.753590000000000204e-01, 2.161720000000000030e-01, -6.596440000000000081e-01, -9.779849999999999932e-01, -9.998960000000000070e-01, -9.981590000000000185e-01, -9.904249999999999998e-01, -9.819870000000000543e-01, -9.862069999999999448e-01, -9.836279999999999468e-01, -9.545780000000000376e-01, -8.613840000000000385e-01, -6.529260000000000064e-01, -2.222439999999999971e-01, 3.960919999999999996e-01, 7.985600000000000476e-01, 6.370780000000000332e-01, -1.015319999999999973e-01, -7.826849999999999641e-01, -9.865279999999999605e-01, -9.999989999999999712e-01, -9.999749999999999472e-01, -9.995570000000000288e-01, -9.922720000000000429e-01, -9.375529999999999697e-01, -7.899850000000000483e-01, -5.878679999999999461e-01, -2.961349999999999816e-01, 1.050139999999999962e-01, 5.383170000000000455e-01, 7.839110000000000245e-01, 6.556429999999999758e-01, 1.581349999999999978e-01, -5.542070000000000052e-01, -9.249490000000000212e-01, -9.959500000000000020e-01, -1.000000000000000000e+00, -9.999719999999999720e-01, -9.974939999999999918e-01, -9.525150000000000006e-01, -7.039530000000000509e-01, -1.841490000000000071e-01, 2.693470000000000031e-01, 5.657489999999999464e-01, 7.621790000000000509e-01, 8.794899999999999940e-01, 7.069879999999999498e-01, 8.978600000000000469e-02, -5.292769999999999975e-01, -8.836690000000000378e-01, -9.877160000000000384e-01, -9.995009999999999728e-01, -1.000000000000000000e+00, -9.999419999999999975e-01, -9.948249999999999593e-01, -9.076969999999999761e-01, -4.979180000000000272e-01, 2.081250000000000044e-01, 6.160609999999999697e-01, 6.964740000000000375e-01, 6.877750000000000252e-01, 6.993089999999999584e-01, 5.238779999999999548e-01, -9.077899999999999858e-02, -6.546239999999999837e-01, -9.253200000000000314e-01, -9.932659999999999823e-01, -9.997629999999999573e-01, -9.999989999999999712e-01, -9.999609999999999888e-01, -9.978470000000000395e-01, -9.592690000000000383e-01, -7.384619999999999518e-01, -2.760850000000000248e-01, 2.470400000000000026e-02, -2.028900000000000148e-02, -1.128060000000000035e-01, -1.263700000000000066e-02, 2.434250000000000025e-01, 2.889909999999999979e-01, -1.155059999999999976e-01, -6.710180000000000033e-01, -9.444360000000000532e-01, -9.969860000000000388e-01, -9.999029999999999863e-01, -9.986140000000000017e-01, -9.962689999999999602e-01, -9.933499999999999552e-01, -9.518590000000000106e-01, -8.313700000000000534e-01, -7.355030000000000179e-01, -7.579700000000000326e-01, -7.949979999999999825e-01, -7.193739999999999579e-01, -3.583839999999999804e-01, 2.627740000000000076e-01, 4.156500000000000195e-01, -1.765680000000000027e-01, -7.989979999999999860e-01, -9.874110000000000387e-01, -9.980970000000000120e-01, -9.744159999999999489e-01, -9.319570000000000354e-01, -9.535059999999999647e-01, -9.797080000000000233e-01, -9.788189999999999946e-01, -9.721640000000000281e-01, -9.703990000000000116e-01, -9.638210000000000388e-01, -9.095929999999999849e-01, -5.962709999999999955e-01, 1.384900000000000020e-01, 6.472449999999999593e-01, 2.482080000000000120e-01, -6.367789999999999839e-01, -9.742520000000000069e-01, -9.878000000000000114e-01, -8.519309999999999938e-01, -5.778370000000000450e-01, -6.101900000000000102e-01, -7.677709999999999813e-01, -8.192359999999999642e-01, -8.127459999999999685e-01, -7.648099999999999898e-01, -6.593409999999999549e-01, -4.941920000000000202e-01, -1.190080000000000027e-01, 5.140879999999999894e-01, 7.980770000000000364e-01, 3.512669999999999959e-01, -5.896099999999999675e-01, -9.677379999999999871e-01, -9.724479999999999791e-01, -6.663019999999999499e-01, 2.621899999999999925e-02, 1.771210000000000007e-01, -6.968799999999999994e-02, -1.701680000000000137e-01, -1.531969999999999998e-01, -4.003899999999999820e-02, 2.042660000000000031e-01, 4.641270000000000118e-01, 6.479850000000000332e-01, 7.893719999999999626e-01, 6.452259999999999662e-01, 6.800799999999999901e-02, -6.987100000000000533e-01, -9.783699999999999619e-01, -9.786059999999999759e-01, -7.037609999999999699e-01, 2.787399999999999947e-02, 5.020740000000000203e-01, 5.929429999999999978e-01, 6.279829999999999579e-01, 6.403919999999999613e-01, 6.377840000000000176e-01, 6.714040000000000008e-01, 7.021939999999999849e-01, 6.126629999999999576e-01, 3.825479999999999992e-01, -2.902499999999999872e-02, -5.488520000000000065e-01, -8.998169999999999780e-01, -9.938010000000000455e-01, -9.937319999999999487e-01, -8.988930000000000531e-01, -5.493149999999999977e-01, -6.138500000000000206e-02, 2.785079999999999778e-01, 4.566049999999999831e-01, 4.704360000000000208e-01, 3.507660000000000222e-01, 1.918739999999999890e-01, 3.332899999999999752e-02, -2.258090000000000097e-01, -5.235830000000000206e-01, -7.471060000000000478e-01, -9.176849999999999730e-01, -9.883260000000000378e-01, -9.994210000000000038e-01, @@ -52,7 +53,7 @@ static float input[numExamples * INPUT_DIMS * TIME_STEPS] = { -1.000000000000000000e+00, -9.999959999999999960e-01, -9.996310000000000473e-01, -9.895479999999999832e-01, -8.874069999999999458e-01, -5.554470000000000240e-01, -1.209969999999999934e-01, 1.245330000000000048e-01, 9.912500000000000477e-02, -9.508199999999999985e-02, -4.457300000000000151e-01, -7.774109999999999632e-01, -9.535529999999999839e-01, -9.968029999999999946e-01, -9.999320000000000430e-01, -9.999989999999999712e-01, -9.999989999999999712e-01, -9.999080000000000190e-01, -9.954229999999999468e-01, -9.263820000000000388e-01, -5.735820000000000363e-01, 6.419700000000000406e-02, 3.456580000000000208e-01, 2.055079999999999962e-01, 1.974700000000000066e-02, 3.107000000000000040e-02, 8.932999999999999968e-03, -3.228949999999999876e-01, -7.930129999999999679e-01, -9.787099999999999689e-01, -9.992029999999999523e-01, -9.999919999999999920e-01, -9.999890000000000168e-01, -9.989069999999999894e-01, -9.722990000000000244e-01, -7.390849999999999920e-01, -1.042740000000000056e-01, 3.342359999999999776e-01, -1.014100000000000071e-02, -5.011839999999999629e-01, -6.861249999999999849e-01, -6.023859999999999770e-01, -2.539390000000000258e-01, 7.340000000000000170e-03, -5.360639999999999850e-01, -9.279899999999999816e-01, -9.963539999999999619e-01, -9.999599999999999600e-01, -9.999289999999999567e-01, -9.938409999999999744e-01, -8.910719999999999752e-01, -4.204680000000000084e-01, 2.440489999999999882e-01, 1.276470000000000105e-01, -5.459789999999999921e-01, -9.083539999999999948e-01, -9.746449999999999836e-01, -9.250709999999999766e-01, -5.068550000000000555e-01, 1.227619999999999961e-01, -3.371129999999999960e-01, -8.668350000000000222e-01, -9.923429999999999751e-01, -9.999120000000000230e-01, -9.997709999999999653e-01, -9.827839999999999909e-01, -7.364389999999999548e-01, -3.639099999999999974e-02, 2.855779999999999985e-01, -3.016949999999999910e-01, -8.421330000000000204e-01, -9.867240000000000455e-01, -9.945920000000000316e-01, -9.481870000000000021e-01, -5.469279999999999697e-01, 1.521359999999999935e-01, -1.868329999999999991e-01, -8.003930000000000211e-01, -9.872440000000000104e-01, -9.998209999999999598e-01, -9.996169999999999778e-01, -9.736749999999999572e-01, -6.188660000000000272e-01, 1.831619999999999915e-01, 1.459189999999999932e-01, -5.948510000000000186e-01, -9.401920000000000277e-01, -9.738120000000000109e-01, -9.237769999999999593e-01, -7.546420000000000350e-01, -3.003569999999999851e-01, 3.133679999999999799e-01, 6.803900000000000226e-02, -6.910880000000000356e-01, -9.789090000000000291e-01, -9.996749999999999803e-01, -9.996680000000000010e-01, -9.746489999999999876e-01, -6.252220000000000555e-01, 1.648399999999999865e-01, 1.457479999999999887e-01, -4.983520000000000172e-01, -7.479339999999999877e-01, -6.952329999999999899e-01, -4.888680000000000248e-01, -9.849700000000000122e-02, 3.467500000000000027e-01, 4.453320000000000056e-01, -1.102709999999999940e-01, -7.708500000000000352e-01, -9.851339999999999542e-01, -9.997960000000000180e-01, -9.998120000000000340e-01, -9.841699999999999893e-01, -7.538399999999999546e-01, -1.127029999999999976e-01, 2.311529999999999974e-01, 4.328000000000000250e-03, -1.028030000000000055e-01, 1.871799999999999853e-02, 2.894169999999999798e-01, 6.092760000000000398e-01, 6.553400000000000336e-01, 1.334609999999999963e-01, -5.782640000000000002e-01, -9.283700000000000285e-01, -9.960729999999999862e-01, -9.999540000000000095e-01, -9.999479999999999480e-01, -9.954410000000000203e-01, -9.213390000000000191e-01, -6.063699999999999646e-01, -1.318699999999999872e-01, 9.272800000000000487e-02, 1.544679999999999942e-01, 2.092430000000000123e-01, 3.988920000000000243e-01, 6.904000000000000137e-01, 4.292009999999999992e-01, -3.758059999999999734e-01, -8.747880000000000100e-01, -9.900430000000000064e-01, -9.996939999999999715e-01, -9.999970000000000248e-01, -9.999959999999999960e-01, -9.995859999999999745e-01, -9.905049999999999688e-01, -9.211979999999999613e-01, -7.565330000000000110e-01, -6.303330000000000322e-01, -5.666109999999999758e-01, -3.800100000000000144e-01, 1.551700000000000024e-01, 4.869299999999999740e-01, -4.089999999999999886e-02, -7.291159999999999863e-01, -9.720569999999999489e-01, -9.988939999999999486e-01, -9.999869999999999592e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999869999999999592e-01, -9.995840000000000281e-01, -9.954250000000000043e-01, -9.841750000000000220e-01, -9.692950000000000177e-01, -8.891219999999999679e-01, -4.781320000000000014e-01, 2.457809999999999995e-01, 2.590979999999999950e-01, -4.726859999999999951e-01, -9.108519999999999950e-01, -9.947009999999999463e-01, -9.999050000000000438e-01, -9.999989999999999712e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999959999999999960e-01, -9.999430000000000263e-01, -9.992320000000000091e-01, -9.798390000000000155e-01, -7.648350000000000426e-01, -1.181730000000000003e-01, 3.464090000000000225e-01, -1.123030000000000000e-01, -7.580249999999999488e-01, -9.777379999999999960e-01, -9.992469999999999963e-01, -9.999930000000000208e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999730000000000008e-01, -9.974509999999999765e-01, -9.430300000000000349e-01, -5.511559999999999793e-01, 2.066419999999999924e-01, 1.977410000000000001e-01, -5.178369999999999918e-01, -9.222249999999999615e-01, -9.955880000000000285e-01, -9.999280000000000390e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999299999999999855e-01, -9.937310000000000310e-01, -8.853539999999999743e-01, -3.587739999999999818e-01, 3.026260000000000061e-01, -9.434099999999999431e-02, -7.619230000000000169e-01, -9.803380000000000427e-01, -9.994349999999999623e-01, -9.999949999999999672e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999010000000000398e-01, -9.912339999999999485e-01, -8.499409999999999465e-01, -2.860480000000000245e-01, 2.147119999999999862e-01, -3.605459999999999776e-01, -8.809749999999999526e-01, -9.931990000000000540e-01, -9.999099999999999655e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -9.999299999999999855e-01, -9.938409999999999744e-01, -8.944029999999999481e-01, -4.974450000000000260e-01, -1.725480000000000069e-01, -6.308340000000000058e-01, -9.508029999999999538e-01, -9.977610000000000090e-01, -9.999759999999999760e-01, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, -1.000000000000000000e+00, }; -static unsigned labels[numExamples] = { 9, 6, 3, 6, 6, 0, 0, 0, 6, 9 }; +static unsigned labels[NUM_EXAMPLES] = { 9, 6, 3, 6, 6, 0, 0, 0, 6, 9 }; int main() { float hiddenState[HIDDEN_DIMS] = { 0.0 }; @@ -63,10 +64,10 @@ int main() { .stdDev = USPS_stdDev, .W1 = USPS_W1, .W2 = USPS_W2, - .wRank = USPS_wRank, + .wRank = USPS_WRANK, .U1 = USPS_U1, .U2 = USPS_U2, - .uRank = USPS_uRank, + .uRank = USPS_URANK, .Bg = USPS_Bg, .Bh = USPS_Bh, .zeta = USPS_zeta, @@ -74,8 +75,8 @@ int main() { }; float preComp[HIDDEN_DIMS] = { 0.0 }; - float tempLRW[USPS_wRank] = { 0.0 }; - float tempLRU[USPS_uRank] = { 0.0 }; + float tempLRW[USPS_WRANK] = { 0.0 }; + float tempLRU[USPS_URANK] = { 0.0 }; float normFeatures[INPUT_DIMS] = { 0.0 }; FastGRNN_LR_Buffers buffers = { .preComp = preComp, @@ -84,12 +85,12 @@ int main() { .normFeatures = normFeatures }; - for (unsigned n = 0; n < numExamples; ++n) { + for (unsigned n = 0; n < NUM_EXAMPLES; ++n) { memset(hiddenState, 0, sizeof(float) * HIDDEN_DIMS); fastgrnn_lr(hiddenState, HIDDEN_DIMS, input + n * INPUT_DIMS * TIME_STEPS, INPUT_DIMS, TIME_STEPS, - &USPS_params, &buffers); + &USPS_params, &buffers, 0); FC(FC_weights, FCbias, hiddenState, HIDDEN_DIMS, classScores, NUM_CLASSES); printf("Example: %d Predicted class: %d Actual class: %d\n", diff --git a/c_reference/tests/rnnpool/test_rnnpool.c b/c_reference/tests/rnnpool/test_rnnpool.c new file mode 100644 index 000000000..5b08e7312 --- /dev/null +++ b/c_reference/tests/rnnpool/test_rnnpool.c @@ -0,0 +1,66 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#include +#include + +#include "utils.h" +#include "fastgrnn.h" +#include "rnnpool.h" + +#include "traces/trace_0_0_input.h" +#include "traces/trace_0_0_output.h" + +#include "vww_model/rnn1.h" +#include "vww_model/rnn2.h" + +int main() { + FastGRNN_Params rnn1_params = { + .mean = mean1, + .stdDev = stdDev1, + .W = W1, + .U = U1, + .Bg = Bg1, + .Bh = Bh1, + .zeta = zeta1, + .nu = nu1 + }; + + FastGRNN_Params rnn2_params = { + .mean = mean2, + .stdDev = stdDev2, + .W = W2, + .U = U2, + .Bg = Bg2, + .Bh = Bh2, + .zeta = zeta2, + .nu = nu2 + }; + + float preComp1[HIDDEN_DIMS1] = { 0.0f }; + float normFeatures1[INPUT_DIMS] = { 0.0f }; + FastGRNN_LR_Buffers rnn1_buffers = { + .preComp = preComp1, + .normFeatures = normFeatures1 + }; + + float preComp2[HIDDEN_DIMS2] = { 0.0f }; + float normFeatures2[HIDDEN_DIMS1] = { 0.0f }; + FastGRNN_LR_Buffers rnn2_buffers = { + .preComp = preComp2, + .normFeatures = normFeatures2 + }; + + float output_test[4 * HIDDEN_DIMS2] = { 0.0f }; + float buffer[HIDDEN_DIMS1 * PATCH_DIM]; + + rnnpool_block(input, INPUT_DIMS, PATCH_DIM, PATCH_DIM, + fastgrnn, HIDDEN_DIMS1, (const void*)(&rnn1_params), (void*)(&rnn1_buffers), + fastgrnn, HIDDEN_DIMS2, (const void*)(&rnn2_params), (void*)(&rnn2_buffers), + output_test, buffer); + + float error = 0.0f; + for (unsigned d = 0; d < 4 * HIDDEN_DIMS2; ++d) + error += (output[d] - output_test[d]) * (output[d] - output_test[d]); + printf("Error: %f\n", error); +} diff --git a/c_reference/tests/rnnpool/traces/trace_0_0_input.h b/c_reference/tests/rnnpool/traces/trace_0_0_input.h new file mode 100644 index 000000000..91d15865a --- /dev/null +++ b/c_reference/tests/rnnpool/traces/trace_0_0_input.h @@ -0,0 +1,4 @@ +#define INPUT_DIMS 8 +#define PATCH_DIM 6 + +static float input[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = { 0.7200992703437805, 0.7349777221679688, 0.7079113721847534, 0.6715796589851379, 0.6360486149787903, 0.6181678175926208, 0.6949924826622009, 0.6887157559394836, 0.6792997717857361, 0.6641860008239746, 0.6378206610679626, 0.6020787358283997, 0.6583858132362366, 0.6504946947097778, 0.6543915867805481, 0.6391652226448059, 0.6279069185256958, 0.6154072284698486, 0.6118512153625488, 0.6372880339622498, 0.6516779661178589, 0.6370535492897034, 0.6009807586669922, 0.5409884452819824, 0.5989747047424316, 0.5680504441261292, 0.6023726463317871, 0.5878996253013611, 0.5835626125335693, 0.5694284439086914, 0.5550572872161865, 0.5069108605384827, 0.5337812900543213, 0.52616286277771, 0.561554491519928, 0.5735787749290466, 0.41231080889701843, 0.40285852551460266, 0.41635656356811523, 0.4204725921154022, 0.4240928590297699, 0.4383329749107361, 0.4411558210849762, 0.3846743106842041, 0.3825896680355072, 0.38936150074005127, 0.3793143033981323, 0.4018699526786804, 0.4508555829524994, 0.3837554156780243, 0.36597058176994324, 0.3861200213432312, 0.37042221426963806, 0.4045625329017639, 0.47081467509269714, 0.3541896343231201, 0.34396713972091675, 0.37952154874801636, 0.38299864530563354, 0.39670997858047485, 0.47050607204437256, 0.35676243901252747, 0.39243555068969727, 0.39968037605285645, 0.37453895807266235, 0.3848017156124115, 0.4913548529148102, 0.3710782825946808, 0.36010047793388367, 0.3920447528362274, 0.3572094440460205, 0.3733786940574646, 0.17323116958141327, 0.20359674096107483, 0.20153860747814178, 0.20618806779384613, 0.22070975601673126, 0.2060401737689972, 0.21987448632717133, 0.2533339560031891, 0.24124248325824738, 0.23531736433506012, 0.24751387536525726, 0.2394397109746933, 0.22678248584270477, 0.2546546161174774, 0.2479032427072525, 0.23856425285339355, 0.2302430421113968, 0.21921557188034058, 0.23807218670845032, 0.26436755061149597, 0.2464604675769806, 0.24020017683506012, 0.2464827448129654, 0.2502349317073822, 0.24391721189022064, 0.2545490860939026, 0.24392960965633392, 0.2439599633216858, 0.24557209014892578, 0.24523982405662537, 0.2519775629043579, 0.26771166920661926, 0.2587960362434387, 0.2566107511520386, 0.2548774778842926, 0.2513321340084076, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.06863410025835037, 0.07130047678947449, 0.0736127495765686, 0.07629992067813873, 0.0745755061507225, 0.0658278614282608, 0.08599031716585159, 0.07589893788099289, 0.0877695083618164, 0.08827068656682968, 0.08585715293884277, 0.07992246747016907, 0.09590772539377213, 0.09913501143455505, 0.09762068837881088, 0.10128127038478851, 0.08678226172924042, 0.09640080481767654, 0.10817965865135193, 0.09248774498701096, 0.08414977788925171, 0.10711938887834549, 0.09966813027858734, 0.07227060198783875, 0.10631150007247925, 0.0754939392209053, 0.10768674314022064, 0.10980423539876938, 0.09068633615970612, 0.06924690306186676, 0.11944665759801865, 0.10101458430290222, 0.09544815123081207, 0.09716922789812088, 0.07976146787405014, 0.0743701234459877, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5508990287780762, 0.5821520686149597, 0.5852815508842468, 0.5809692740440369, 0.6002235412597656, 0.6058157086372375, 0.5924373269081116, 0.6453736424446106, 0.6310368180274963, 0.6282166838645935, 0.639054536819458, 0.6502968072891235, 0.6067979335784912, 0.6644476652145386, 0.6406963467597961, 0.6468942165374756, 0.6553152799606323, 0.6551199555397034, 0.620813250541687, 0.6621618866920471, 0.6419146656990051, 0.6525743007659912, 0.6589815020561218, 0.6632933616638184, 0.6240749359130859, 0.6924310326576233, 0.6651476621627808, 0.670028030872345, 0.6629777550697327, 0.6618801951408386, 0.64516681432724, 0.7109054327011108, 0.690449595451355, 0.6899393796920776, 0.6776293516159058, 0.667388379573822, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1220691129565239, 0.054038867354393005, 0.07699074596166611, 0.16082628071308136, 0.0957900807261467, 0.0, 0.023300323635339737, 0.14994747936725616, 0.032479435205459595, 0.04333915561437607, 0.0, 0.0, 0.3011478781700134, 0.27780881524086, 0.050384946167469025, 0.12016911804676056, 0.11995742470026016, 0.0, 0.08450572937726974, 0.0, 0.0, 0.1426747739315033, 0.15586549043655396, 0.0, 0.026002665981650352, 0.14055205881595612, 0.013961758464574814, 0.24455945193767548, 0.20709866285324097 }; diff --git a/c_reference/tests/rnnpool/traces/trace_0_0_output.h b/c_reference/tests/rnnpool/traces/trace_0_0_output.h new file mode 100644 index 000000000..b6cde9a7e --- /dev/null +++ b/c_reference/tests/rnnpool/traces/trace_0_0_output.h @@ -0,0 +1,3 @@ +#define HIDDEN_DIMS2 8 + +static float output[4 * HIDDEN_DIMS2] = { 0.31664225459098816, 0.1301255226135254, 0.947460949420929, 0.020423999056220055, -0.4747508466243744, 0.32035547494888306, 0.12770484387874603, -0.7698633074760437, 0.43295028805732727, 0.3493753969669342, 0.9879876375198364, 0.08631967008113861, -0.3373697102069855, 0.09683486074209213, 0.15379029512405396, -0.8048453330993652, 0.732920229434967, 0.0077863335609436035, 0.8983030319213867, -0.03637560084462166, -0.5027041435241699, 0.32531240582466125, 0.1399036943912506, -0.7837912440299988, 0.25695696473121643, 0.16601762175559998, 0.9800294041633606, -0.0761747807264328, -0.4942656457424164, 0.07396475225687027, 0.12752710282802582, -0.7591384649276733 }; \ No newline at end of file From f718e66265dee329d352ca9e4ca7522098ea623c Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Mon, 27 Apr 2020 02:39:50 -0700 Subject: [PATCH 08/15] rnn pool block tested --- c_reference/include/fastgrnn.h | 6 ++-- c_reference/include/rnnpool.h | 6 ++-- c_reference/src/fastgrnn.c | 33 +++++++++++++------ c_reference/src/rnnpool.c | 16 ++++----- c_reference/tests/fastgrnn/test_fastgrnn_lr.c | 2 +- c_reference/tests/rnnpool/test_rnnpool.c | 4 +-- .../tests/rnnpool/traces/trace_0_0_input.h | 2 +- .../tests/rnnpool/traces/trace_0_0_output.h | 2 +- c_reference/tests/rnnpool/vww_model/rnn1.h | 5 ++- c_reference/tests/rnnpool/vww_model/rnn2.h | 4 +-- 10 files changed, 47 insertions(+), 33 deletions(-) diff --git a/c_reference/include/fastgrnn.h b/c_reference/include/fastgrnn.h index 9c4e627fe..fbcf893b6 100644 --- a/c_reference/include/fastgrnn.h +++ b/c_reference/include/fastgrnn.h @@ -63,6 +63,7 @@ typedef struct FastGRNN_LR_Buffers { * @param[in] params pointer to model parameter * @param[in] buffers pointer to buffer spaces * @param[in] backward direction of the pass, 0 for forward, 1 for backward + * @param[in] normalize apply mean-var normalization, 0 for no, 1 for yes * @return The function returns 0 on success * ERR_PRECOMP_NOT_INIT if preComp not allocated * ERR_TEMPLRW_NOT_INIT if tempLRW not allocated @@ -71,7 +72,7 @@ typedef struct FastGRNN_LR_Buffers { */ int fastgrnn_lr(float* const hiddenState, unsigned hiddenDims, const float* const input, unsigned inputDims, unsigned steps, - const void* params, void* buffers, int backward); + const void* params, void* buffers, int backward, int normalize); /** * @brief Model paramters for low-rank FastGRNN @@ -115,12 +116,13 @@ typedef struct FastGRNN_Buffers { * @param[in] params pointer to model parameter * @param[in] buffers pointer to buffer spaces * @param[in] backward direction of the pass, 0 for forward, 1 for backward + * @param[in] normalize apply mean-var normalization, 0 for no, 1 for yes * @return The function returns 0 on success * ERR_PRECOMP_NOT_INIT if preComp not allocated * ERR_NORMFEAT_NOT_INIT if normFeatures not allocated */ int fastgrnn(float* const hiddenState, unsigned hiddenDims, const float* const input, unsigned inputDims, unsigned steps, - const void* params, void* buffers, int backward); + const void* params, void* buffers, int backward, int normalize); #endif diff --git a/c_reference/include/rnnpool.h b/c_reference/include/rnnpool.h index 569c1a5d9..c2cd29f50 100644 --- a/c_reference/include/rnnpool.h +++ b/c_reference/include/rnnpool.h @@ -4,12 +4,12 @@ #ifndef __RNNPOOL_H__ #define __RNNPOOL_H__ -typedef int (*rnn_t)(float* const, unsigned, const float* const, unsigned, unsigned, const void*, void*, int); +typedef int (*rnn_t)(float* const, unsigned, const float* const, unsigned, unsigned, const void*, void*, int, int); /** - * @param[in] patch pointer to the activation of the first pixel in the patch + * @param[in] patch pointer to activation of patch (row, col, channel) * @param[in] inputDims dimemsion of each input pixel - * @param[in] patchDim number of rows and columns in a square patch + * @param[in] patchDim number of rows and columns in a square patch * @param[in] stride stride lenghth in the larger image to get to next row * @param[in] rnn1 function pointer to RNN1 * @param[in] hiddenDims1 dimension of the hidden state of RNN1 diff --git a/c_reference/src/fastgrnn.c b/c_reference/src/fastgrnn.c index 930b28116..8dfcc2f07 100644 --- a/c_reference/src/fastgrnn.c +++ b/c_reference/src/fastgrnn.c @@ -6,7 +6,7 @@ int fastgrnn_lr(float* const hiddenState, unsigned hiddenDims, const float* const input, unsigned inputDims, unsigned steps, - const void* params, void* buffers, int backward) { + const void* params, void* buffers, int backward, int normalize) { const FastGRNN_LR_Params* tparams = (const FastGRNN_LR_Params*)params; FastGRNN_LR_Buffers* tbuffers = (FastGRNN_LR_Buffers*)buffers; @@ -20,10 +20,16 @@ int fastgrnn_lr(float* const hiddenState, unsigned hiddenDims, for (unsigned t = 0; t < steps; t++) { // Normalize the features unsigned offset = backward ? steps - t : t; - v_add(1.0f, input + offset * inputDims, -1.0f, tparams->mean + t * inputDims, - inputDims, tbuffers->normFeatures); - v_div(tparams->stdDev + t * inputDims, tbuffers->normFeatures, inputDims, - tbuffers->normFeatures); + if (normalize) { + v_add(1.0f, input + offset * inputDims, -1.0f, tparams->mean + t * inputDims, + inputDims, tbuffers->normFeatures); + v_div(tparams->stdDev + t * inputDims, tbuffers->normFeatures, inputDims, + tbuffers->normFeatures); + } + else { + for (unsigned d=0; d< inputDims; ++d) + tbuffers->normFeatures[d] = input[offset * inputDims + d]; + } // Process the new input and previous hidden state matVec(tparams->W1, tbuffers->normFeatures, tparams->wRank, inputDims, @@ -47,7 +53,7 @@ int fastgrnn_lr(float* const hiddenState, unsigned hiddenDims, int fastgrnn(float* const hiddenState, unsigned hiddenDims, const float* const input, unsigned inputDims, unsigned steps, - const void* params, void* buffers, int backward) { + const void* params, void* buffers, int backward, int normalize) { const FastGRNN_Params* tparams = (const FastGRNN_Params*)params; FastGRNN_Buffers* tbuffers = (FastGRNN_Buffers*)buffers; @@ -58,10 +64,16 @@ int fastgrnn(float* const hiddenState, unsigned hiddenDims, for (unsigned t = 0; t < steps; t++) { // Normalize the features unsigned offset = backward ? steps - t : t; - v_add(1.0f, input + offset * inputDims, -1.0f, tparams->mean + t * inputDims, - inputDims, tbuffers->normFeatures); - v_div(tparams->stdDev + t * inputDims, tbuffers->normFeatures, inputDims, - tbuffers->normFeatures); + if (normalize) { + v_add(1.0f, input + offset * inputDims, -1.0f, tparams->mean + t * inputDims, + inputDims, tbuffers->normFeatures); + v_div(tparams->stdDev + t * inputDims, tbuffers->normFeatures, inputDims, + tbuffers->normFeatures); + } + else { + for (unsigned d = 0; d < inputDims; ++d) + tbuffers->normFeatures[d] = input[offset * inputDims + d]; + } // Process the new input and previous hidden state matVec(tparams->W, tbuffers->normFeatures, hiddenDims, inputDims, @@ -69,6 +81,7 @@ int fastgrnn(float* const hiddenState, unsigned hiddenDims, matVec(tparams->U, hiddenState, hiddenDims, hiddenDims, 1.0f, 1.0f, tbuffers->preComp); + // Apply the gate to generate the new hidden state for (unsigned i = 0; i < hiddenDims; i++) { float gate = sigmoid(tbuffers->preComp[i] + tparams->Bg[i]); diff --git a/c_reference/src/rnnpool.c b/c_reference/src/rnnpool.c index 78f09e097..28e71b59e 100644 --- a/c_reference/src/rnnpool.c +++ b/c_reference/src/rnnpool.c @@ -16,25 +16,25 @@ int rnnpool_block(const float* const patch, unsigned inputDims, // Horizontal pass over each row with RNN1 memset(buffer, 0, sizeof(float) * hiddenDims1 * patchDim); for (unsigned r = 0; r < patchDim; ++r) - rnn1(buffer + r * patchDim, hiddenDims1, + rnn1(buffer + r * hiddenDims1, hiddenDims1, patch + stride * r * inputDims, inputDims, patchDim, - rnn1_params, rnn1_buffers, 0); + rnn1_params, rnn1_buffers, 0, 0); // Bidirectional vertical pass over the row summaries - rnn2(output, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 0); - rnn2(output + hiddenDims2, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 1); + rnn2(output, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 0, 0); + rnn2(output + hiddenDims2, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 1, 0); // Vertical pass over each column with RNN1 memset(buffer, 0, sizeof(float) * hiddenDims1 * patchDim); for (unsigned c = 0; c < patchDim; ++c) for (unsigned r = 0; r < patchDim; ++r) - rnn1(buffer + c * patchDim, hiddenDims1, + rnn1(buffer + c * hiddenDims1, hiddenDims1, patch + (stride * r + c) * inputDims, inputDims, 1, - rnn1_params, rnn1_buffers, 0); + rnn1_params, rnn1_buffers, 0, 0); // Bidirectional horizantal pass over the columns summaries - rnn2(output + 2 * hiddenDims2, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 0); - rnn2(output + 3 * hiddenDims2, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 1); + rnn2(output + 2 * hiddenDims2, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 0, 0); + rnn2(output + 3 * hiddenDims2, hiddenDims2, buffer, hiddenDims1, patchDim, rnn2_params, rnn2_buffers, 1, 0); return 0; } diff --git a/c_reference/tests/fastgrnn/test_fastgrnn_lr.c b/c_reference/tests/fastgrnn/test_fastgrnn_lr.c index a8c9a1e73..ebee68d26 100644 --- a/c_reference/tests/fastgrnn/test_fastgrnn_lr.c +++ b/c_reference/tests/fastgrnn/test_fastgrnn_lr.c @@ -90,7 +90,7 @@ int main() { memset(hiddenState, 0, sizeof(float) * HIDDEN_DIMS); fastgrnn_lr(hiddenState, HIDDEN_DIMS, input + n * INPUT_DIMS * TIME_STEPS, INPUT_DIMS, TIME_STEPS, - &USPS_params, &buffers, 0); + &USPS_params, &buffers, 0, 1); FC(FC_weights, FCbias, hiddenState, HIDDEN_DIMS, classScores, NUM_CLASSES); printf("Example: %d Predicted class: %d Actual class: %d\n", diff --git a/c_reference/tests/rnnpool/test_rnnpool.c b/c_reference/tests/rnnpool/test_rnnpool.c index 5b08e7312..f5b4f4b10 100644 --- a/c_reference/tests/rnnpool/test_rnnpool.c +++ b/c_reference/tests/rnnpool/test_rnnpool.c @@ -39,14 +39,14 @@ int main() { float preComp1[HIDDEN_DIMS1] = { 0.0f }; float normFeatures1[INPUT_DIMS] = { 0.0f }; - FastGRNN_LR_Buffers rnn1_buffers = { + FastGRNN_Buffers rnn1_buffers = { .preComp = preComp1, .normFeatures = normFeatures1 }; float preComp2[HIDDEN_DIMS2] = { 0.0f }; float normFeatures2[HIDDEN_DIMS1] = { 0.0f }; - FastGRNN_LR_Buffers rnn2_buffers = { + FastGRNN_Buffers rnn2_buffers = { .preComp = preComp2, .normFeatures = normFeatures2 }; diff --git a/c_reference/tests/rnnpool/traces/trace_0_0_input.h b/c_reference/tests/rnnpool/traces/trace_0_0_input.h index 91d15865a..6ad8f85dd 100644 --- a/c_reference/tests/rnnpool/traces/trace_0_0_input.h +++ b/c_reference/tests/rnnpool/traces/trace_0_0_input.h @@ -1,4 +1,4 @@ #define INPUT_DIMS 8 #define PATCH_DIM 6 -static float input[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = { 0.7200992703437805, 0.7349777221679688, 0.7079113721847534, 0.6715796589851379, 0.6360486149787903, 0.6181678175926208, 0.6949924826622009, 0.6887157559394836, 0.6792997717857361, 0.6641860008239746, 0.6378206610679626, 0.6020787358283997, 0.6583858132362366, 0.6504946947097778, 0.6543915867805481, 0.6391652226448059, 0.6279069185256958, 0.6154072284698486, 0.6118512153625488, 0.6372880339622498, 0.6516779661178589, 0.6370535492897034, 0.6009807586669922, 0.5409884452819824, 0.5989747047424316, 0.5680504441261292, 0.6023726463317871, 0.5878996253013611, 0.5835626125335693, 0.5694284439086914, 0.5550572872161865, 0.5069108605384827, 0.5337812900543213, 0.52616286277771, 0.561554491519928, 0.5735787749290466, 0.41231080889701843, 0.40285852551460266, 0.41635656356811523, 0.4204725921154022, 0.4240928590297699, 0.4383329749107361, 0.4411558210849762, 0.3846743106842041, 0.3825896680355072, 0.38936150074005127, 0.3793143033981323, 0.4018699526786804, 0.4508555829524994, 0.3837554156780243, 0.36597058176994324, 0.3861200213432312, 0.37042221426963806, 0.4045625329017639, 0.47081467509269714, 0.3541896343231201, 0.34396713972091675, 0.37952154874801636, 0.38299864530563354, 0.39670997858047485, 0.47050607204437256, 0.35676243901252747, 0.39243555068969727, 0.39968037605285645, 0.37453895807266235, 0.3848017156124115, 0.4913548529148102, 0.3710782825946808, 0.36010047793388367, 0.3920447528362274, 0.3572094440460205, 0.3733786940574646, 0.17323116958141327, 0.20359674096107483, 0.20153860747814178, 0.20618806779384613, 0.22070975601673126, 0.2060401737689972, 0.21987448632717133, 0.2533339560031891, 0.24124248325824738, 0.23531736433506012, 0.24751387536525726, 0.2394397109746933, 0.22678248584270477, 0.2546546161174774, 0.2479032427072525, 0.23856425285339355, 0.2302430421113968, 0.21921557188034058, 0.23807218670845032, 0.26436755061149597, 0.2464604675769806, 0.24020017683506012, 0.2464827448129654, 0.2502349317073822, 0.24391721189022064, 0.2545490860939026, 0.24392960965633392, 0.2439599633216858, 0.24557209014892578, 0.24523982405662537, 0.2519775629043579, 0.26771166920661926, 0.2587960362434387, 0.2566107511520386, 0.2548774778842926, 0.2513321340084076, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.06863410025835037, 0.07130047678947449, 0.0736127495765686, 0.07629992067813873, 0.0745755061507225, 0.0658278614282608, 0.08599031716585159, 0.07589893788099289, 0.0877695083618164, 0.08827068656682968, 0.08585715293884277, 0.07992246747016907, 0.09590772539377213, 0.09913501143455505, 0.09762068837881088, 0.10128127038478851, 0.08678226172924042, 0.09640080481767654, 0.10817965865135193, 0.09248774498701096, 0.08414977788925171, 0.10711938887834549, 0.09966813027858734, 0.07227060198783875, 0.10631150007247925, 0.0754939392209053, 0.10768674314022064, 0.10980423539876938, 0.09068633615970612, 0.06924690306186676, 0.11944665759801865, 0.10101458430290222, 0.09544815123081207, 0.09716922789812088, 0.07976146787405014, 0.0743701234459877, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5508990287780762, 0.5821520686149597, 0.5852815508842468, 0.5809692740440369, 0.6002235412597656, 0.6058157086372375, 0.5924373269081116, 0.6453736424446106, 0.6310368180274963, 0.6282166838645935, 0.639054536819458, 0.6502968072891235, 0.6067979335784912, 0.6644476652145386, 0.6406963467597961, 0.6468942165374756, 0.6553152799606323, 0.6551199555397034, 0.620813250541687, 0.6621618866920471, 0.6419146656990051, 0.6525743007659912, 0.6589815020561218, 0.6632933616638184, 0.6240749359130859, 0.6924310326576233, 0.6651476621627808, 0.670028030872345, 0.6629777550697327, 0.6618801951408386, 0.64516681432724, 0.7109054327011108, 0.690449595451355, 0.6899393796920776, 0.6776293516159058, 0.667388379573822, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1220691129565239, 0.054038867354393005, 0.07699074596166611, 0.16082628071308136, 0.0957900807261467, 0.0, 0.023300323635339737, 0.14994747936725616, 0.032479435205459595, 0.04333915561437607, 0.0, 0.0, 0.3011478781700134, 0.27780881524086, 0.050384946167469025, 0.12016911804676056, 0.11995742470026016, 0.0, 0.08450572937726974, 0.0, 0.0, 0.1426747739315033, 0.15586549043655396, 0.0, 0.026002665981650352, 0.14055205881595612, 0.013961758464574814, 0.24455945193767548, 0.20709866285324097 }; +static float input[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = { 1.1889175176620483, 0.0, 0.686677873134613, 0.28590407967567444, 0.6756686568260193, 0.0, 1.0730130672454834, 1.5199142694473267, 1.2245371341705322, 0.0, 0.9322224259376526, 0.24574483931064606, 0.9178060293197632, 0.0, 1.2070866823196411, 1.2803878784179688, 1.2177472114562988, 0.0, 0.9349721074104309, 0.23399050533771515, 0.9389560222625732, 0.0, 1.20634925365448, 1.2531741857528687, 1.2091892957687378, 0.0, 0.9317412376403809, 0.2136395275592804, 0.9431822299957275, 0.0, 1.2010629177093506, 1.224714994430542, 1.2066428661346436, 0.0, 0.9345977306365967, 0.19556978344917297, 0.933709442615509, 0.0, 1.2079591751098633, 1.2254459857940674, 1.2132079601287842, 0.0, 0.9328851699829102, 0.17955024540424347, 0.9042797088623047, 0.0, 1.2169342041015625, 1.2241672277450562, 1.1965123414993286, 0.0, 0.9510436058044434, 0.22919078171253204, 0.9852019548416138, 0.0, 1.187132716178894, 1.0319616794586182, 1.2993309497833252, 0.0, 1.3039311170578003, 0.06124335899949074, 1.41031014919281, 0.0, 1.2472972869873047, 0.16132937371730804, 1.2937241792678833, 0.0, 1.3021215200424194, 0.06260563433170319, 1.4223699569702148, 0.0, 1.2345714569091797, 0.16947343945503235, 1.2845354080200195, 0.0, 1.3057010173797607, 0.058147184550762177, 1.4295300245285034, 0.0, 1.2378731966018677, 0.1907886415719986, 1.283066987991333, 0.0, 1.3140215873718262, 0.03941822052001953, 1.4319969415664673, 0.0, 1.2510833740234375, 0.18278124928474426, 1.293532371520996, 0.0, 1.311673641204834, 0.03419610112905502, 1.3864810466766357, 0.0, 1.2727792263031006, 0.2050451636314392, 1.1904404163360596, 0.0, 0.9395459294319153, 0.2246854305267334, 0.9816352128982544, 0.0, 1.1698871850967407, 1.0149723291397095, 1.3004311323165894, 0.0, 1.2942228317260742, 0.06068005785346031, 1.3776077032089233, 0.0, 1.2450120449066162, 0.18701013922691345, 1.2921385765075684, 0.0, 1.293941617012024, 0.06267154216766357, 1.4103981256484985, 0.0, 1.229309320449829, 0.18862979114055634, 1.2881702184677124, 0.0, 1.2982115745544434, 0.04518850892782211, 1.4149149656295776, 0.0, 1.2361881732940674, 0.16846024990081787, 1.2842456102371216, 0.0, 1.2991424798965454, 0.032028645277023315, 1.4036457538604736, 0.0, 1.240525722503662, 0.1888081133365631, 1.28203547000885, 0.0, 1.2897261381149292, 0.028658922761678696, 1.3826022148132324, 0.0, 1.24242103099823, 0.18638011813163757, 1.1907427310943604, 0.0, 0.9360589981079102, 0.24961833655834198, 1.0011098384857178, 0.0, 1.1607639789581299, 1.030193567276001, 1.296494483947754, 0.0, 1.296299934387207, 0.08141043037176132, 1.4052566289901733, 0.0, 1.2397780418395996, 0.19067169725894928, 1.2931671142578125, 0.0, 1.2930649518966675, 0.06282022595405579, 1.3982316255569458, 0.0, 1.2368018627166748, 0.18314552307128906, 1.293848991394043, 0.0, 1.2926746606826782, 0.04599253088235855, 1.3803800344467163, 0.0, 1.2454861402511597, 0.17322129011154175, 1.2910401821136475, 0.0, 1.3079243898391724, 0.0510125495493412, 1.4048796892166138, 0.0, 1.2561426162719727, 0.19181905686855316, 1.2922446727752686, 0.0, 1.2961087226867676, 0.05065854266285896, 1.3945356607437134, 0.0, 1.2462090253829956, 0.20390088856220245, 1.1844453811645508, 0.0, 0.9524935483932495, 0.24208222329616547, 1.0300124883651733, 0.0, 1.170817255973816, 1.0158674716949463, 1.2910248041152954, 0.0, 1.3042423725128174, 0.07530564814805984, 1.4385987520217896, 0.0, 1.2299007177352905, 0.1766124963760376, 1.2868092060089111, 0.0, 1.287881851196289, 0.05629950016736984, 1.4077354669570923, 0.0, 1.216823697090149, 0.1919325590133667, 1.2880289554595947, 0.0, 1.2860686779022217, 0.06910263001918793, 1.390699028968811, 0.0, 1.2278554439544678, 0.21591787040233612, 1.297263264656067, 0.0, 1.3117581605911255, 0.060278668999671936, 1.4131267070770264, 0.0, 1.2561383247375488, 0.18795517086982727, 1.2967503070831299, 0.0, 1.3005088567733765, 0.05568600445985794, 1.3861087560653687, 0.0, 1.2502738237380981, 0.21080316603183746, 1.1885993480682373, 0.0, 0.9490041732788086, 0.24165378510951996, 1.0236011743545532, 0.0, 1.1671867370605469, 1.015089750289917, 1.2957342863082886, 0.0, 1.3018475770950317, 0.08859658241271973, 1.4310593605041504, 0.0, 1.2304565906524658, 0.2020004540681839, 1.299179196357727, 0.0, 1.2856945991516113, 0.07151154428720474, 1.3883033990859985, 0.0, 1.2264938354492188, 0.1973874419927597, 1.296501636505127, 0.0, 1.2827900648117065, 0.06527338176965714, 1.3756159543991089, 0.0, 1.2313485145568848, 0.20322437584400177, 1.2951271533966064, 0.0, 1.2936677932739258, 0.04819206893444061, 1.3807140588760376, 0.0, 1.2414236068725586, 0.17494681477546692, 1.292358636856079, 0.0, 1.2943769693374634, 0.044796135276556015, 1.3858633041381836, 0.0, 1.2440060377120972, 0.16450615227222443 }; diff --git a/c_reference/tests/rnnpool/traces/trace_0_0_output.h b/c_reference/tests/rnnpool/traces/trace_0_0_output.h index b6cde9a7e..30eb29146 100644 --- a/c_reference/tests/rnnpool/traces/trace_0_0_output.h +++ b/c_reference/tests/rnnpool/traces/trace_0_0_output.h @@ -1,3 +1,3 @@ #define HIDDEN_DIMS2 8 -static float output[4 * HIDDEN_DIMS2] = { 0.31664225459098816, 0.1301255226135254, 0.947460949420929, 0.020423999056220055, -0.4747508466243744, 0.32035547494888306, 0.12770484387874603, -0.7698633074760437, 0.43295028805732727, 0.3493753969669342, 0.9879876375198364, 0.08631967008113861, -0.3373697102069855, 0.09683486074209213, 0.15379029512405396, -0.8048453330993652, 0.732920229434967, 0.0077863335609436035, 0.8983030319213867, -0.03637560084462166, -0.5027041435241699, 0.32531240582466125, 0.1399036943912506, -0.7837912440299988, 0.25695696473121643, 0.16601762175559998, 0.9800294041633606, -0.0761747807264328, -0.4942656457424164, 0.07396475225687027, 0.12752710282802582, -0.7591384649276733 }; \ No newline at end of file +static float output[4 * HIDDEN_DIMS2] = { 0.5294126868247986, -0.20457611978054047, 0.4791259169578552, 0.19910287857055664, 0.31750041246414185, 0.5080775618553162, 0.7030423879623413, -0.22070026397705078, 0.5181443095207214, -0.2173454910516739, 0.43674200773239136, 0.14881527423858643, 0.3039340376853943, 0.6192938089370728, 0.6908276081085205, -0.17399999499320984, 0.5586652159690857, -0.20808178186416626, 0.45953649282455444, 0.211704820394516, 0.32314151525497437, 0.5271204710006714, 0.7008429765701294, -0.2290748804807663, 0.5192272663116455, -0.2531609535217285, 0.42432403564453125, 0.16953076422214508, 0.3418102264404297, 0.6235758066177368, 0.6825319528579712, -0.18395471572875977 }; diff --git a/c_reference/tests/rnnpool/vww_model/rnn1.h b/c_reference/tests/rnnpool/vww_model/rnn1.h index 2be76e0d0..a9e8c1b00 100644 --- a/c_reference/tests/rnnpool/vww_model/rnn1.h +++ b/c_reference/tests/rnnpool/vww_model/rnn1.h @@ -3,9 +3,8 @@ static float mean1[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = {0.0}; static float stdDev1[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = {1.0}; -static float W1[INPUT_DIMS * HIDDEN_DIMS1] = { -6.669194251298904419e-02,-4.081934988498687744e-01,-9.548854231834411621e-01,-1.199822783470153809e+00,3.212589919567108154e-01,-8.398564457893371582e-01,1.377462625503540039e+00,1.293107271194458008e-01,4.241880401968955994e-02,3.874431252479553223e-01,6.743898242712020874e-02,4.235469996929168701e-01,7.616437077522277832e-01,-3.183248341083526611e-01,-6.704510450363159180e-01,3.916886448860168457e-01,1.779496856033802032e-02,-9.131602197885513306e-02,1.308344118297100067e-02,-2.176112309098243713e-02,7.672815918922424316e-01,-3.293828964233398438e-01,8.417400717735290527e-02,-4.810366034507751465e-01,2.434188500046730042e-02,-4.231898188591003418e-01,-5.101327300071716309e-01,-5.763933062553405762e-01,2.576289772987365723e-01,-1.621776819229125977e-01,6.603993773460388184e-01,-2.212110720574855804e-02,2.040588408708572388e-01,1.137487962841987610e-01,-2.034226208925247192e-01,-4.363142326474189758e-02,1.962029747664928436e-02,5.834429860115051270e-01,-1.158756241202354431e-01,-6.547657251358032227e-01,-6.289862841367721558e-02,-7.153615355491638184e-02,-3.552019000053405762e-01,-3.619972467422485352e-01,6.437804698944091797e-01,3.947886824607849121e-01,4.007513821125030518e-01,3.415162265300750732e-01,8.665277808904647827e-02,1.098951250314712524e-01,3.574696481227874756e-01,4.203165769577026367e-01,1.115008115768432617e+00,-6.720532774925231934e-01,-4.624451696872711182e-01,-3.584066927433013916e-01,-4.211997613310813904e-02,-5.568345189094543457e-01,-1.339200735092163086e-01,-1.205071806907653809e+00,8.542865514755249023e-02,3.155398648232221603e-03,1.793413400650024414e+00,3.155157715082168579e-02 }; -static float U1[HIDDEN_DIMS1 * HIDDEN_DIMS1] = { 4.257509708404541016e-01,2.090227305889129639e-01,-9.029741585254669189e-02,-1.581576466560363770e-01,-2.624719589948654175e-02,-1.679758429527282715e-01,1.883537024259567261e-01,8.153508603572845459e-02,-2.243996411561965942e-01,6.178687140345573425e-02,1.964072138071060181e-02,-7.558400928974151611e-02,-3.073738422244787216e-03,-7.507130037993192673e-03,5.114595890045166016e-01,9.405165910720825195e-03,4.599139690399169922e-01,-8.031798005104064941e-01,-2.055168338119983673e-02,-1.338823318481445312e+00,1.721778139472007751e-02,-1.409216374158859253e-01,1.616048932075500488e+00,1.780232340097427368e-01,-3.530698418617248535e-01,-9.047465324401855469e-01,5.608395114541053772e-02,1.076061371713876724e-02,-3.143182024359703064e-03,1.100406423211097717e-01,1.620839357376098633e+00,-5.950598046183586121e-02,2.927841432392597198e-02,1.150295138359069824e-01,-1.545069087296724319e-02,7.246796786785125732e-02,1.096169114112854004e+00,-1.400157362222671509e-01,-1.330980509519577026e-01,-5.966191366314888000e-02,1.921992599964141846e-01,-1.216369643807411194e-01,-3.085457533597946167e-02,-6.944761611521244049e-03,-4.858187958598136902e-02,1.513722836971282959e-01,9.179102256894111633e-03,1.019131317734718323e-01,7.122249808162450790e-03,8.977604657411575317e-02,7.987973280251026154e-03,-8.065721951425075531e-03,-8.912781253457069397e-03,-1.210445910692214966e-02,7.160065323114395142e-02,2.581899240612983704e-02,2.478006668388843536e-02,-3.528899326920509338e-02,-8.097411133348941803e-03,-2.095492556691169739e-02,-3.243596106767654419e-02,-8.220742642879486084e-02,2.354629104956984520e-03,1.182158961892127991e-01 }; - +static float W1[INPUT_DIMS * HIDDEN_DIMS1] = { -6.669194251298904419e-02,4.241880401968955994e-02,1.779496856033802032e-02,2.434188500046730042e-02,2.040588408708572388e-01,-6.289862841367721558e-02,8.665277808904647827e-02,-4.211997613310813904e-02,-4.081934988498687744e-01,3.874431252479553223e-01,-9.131602197885513306e-02,-4.231898188591003418e-01,1.137487962841987610e-01,-7.153615355491638184e-02,1.098951250314712524e-01,-5.568345189094543457e-01,-9.548854231834411621e-01,6.743898242712020874e-02,1.308344118297100067e-02,-5.101327300071716309e-01,-2.034226208925247192e-01,-3.552019000053405762e-01,3.574696481227874756e-01,-1.339200735092163086e-01,-1.199822783470153809e+00,4.235469996929168701e-01,-2.176112309098243713e-02,-5.763933062553405762e-01,-4.363142326474189758e-02,-3.619972467422485352e-01,4.203165769577026367e-01,-1.205071806907653809e+00,3.212589919567108154e-01,7.616437077522277832e-01,7.672815918922424316e-01,2.576289772987365723e-01,1.962029747664928436e-02,6.437804698944091797e-01,1.115008115768432617e+00,8.542865514755249023e-02,-8.398564457893371582e-01,-3.183248341083526611e-01,-3.293828964233398438e-01,-1.621776819229125977e-01,5.834429860115051270e-01,3.947886824607849121e-01,-6.720532774925231934e-01,3.155398648232221603e-03,1.377462625503540039e+00,-6.704510450363159180e-01,8.417400717735290527e-02,6.603993773460388184e-01,-1.158756241202354431e-01,4.007513821125030518e-01,-4.624451696872711182e-01,1.793413400650024414e+00,1.293107271194458008e-01,3.916886448860168457e-01,-4.810366034507751465e-01,-2.212110720574855804e-02,-6.547657251358032227e-01,3.415162265300750732e-01,-3.584066927433013916e-01,3.155157715082168579e-02 }; +static float U1[HIDDEN_DIMS1 * HIDDEN_DIMS1] = { 4.257509708404541016e-01,-2.243996411561965942e-01,4.599139690399169922e-01,-3.530698418617248535e-01,2.927841432392597198e-02,1.921992599964141846e-01,7.122249808162450790e-03,2.478006668388843536e-02,2.090227305889129639e-01,6.178687140345573425e-02,-8.031798005104064941e-01,-9.047465324401855469e-01,1.150295138359069824e-01,-1.216369643807411194e-01,8.977604657411575317e-02,-3.528899326920509338e-02,-9.029741585254669189e-02,1.964072138071060181e-02,-2.055168338119983673e-02,5.608395114541053772e-02,-1.545069087296724319e-02,-3.085457533597946167e-02,7.987973280251026154e-03,-8.097411133348941803e-03,-1.581576466560363770e-01,-7.558400928974151611e-02,-1.338823318481445312e+00,1.076061371713876724e-02,7.246796786785125732e-02,-6.944761611521244049e-03,-8.065721951425075531e-03,-2.095492556691169739e-02,-2.624719589948654175e-02,-3.073738422244787216e-03,1.721778139472007751e-02,-3.143182024359703064e-03,1.096169114112854004e+00,-4.858187958598136902e-02,-8.912781253457069397e-03,-3.243596106767654419e-02,-1.679758429527282715e-01,-7.507130037993192673e-03,-1.409216374158859253e-01,1.100406423211097717e-01,-1.400157362222671509e-01,1.513722836971282959e-01,-1.210445910692214966e-02,-8.220742642879486084e-02,1.883537024259567261e-01,5.114595890045166016e-01,1.616048932075500488e+00,1.620839357376098633e+00,-1.330980509519577026e-01,9.179102256894111633e-03,7.160065323114395142e-02,2.354629104956984520e-03,8.153508603572845459e-02,9.405165910720825195e-03,1.780232340097427368e-01,-5.950598046183586121e-02,-5.966191366314888000e-02,1.019131317734718323e-01,2.581899240612983704e-02,1.182158961892127991e-01 }; static float Bg1[HIDDEN_DIMS1] = { -1.213001132011413574e+00,-3.357241451740264893e-01,-1.219372987747192383e+00,-2.052456587553024292e-01,-7.755046486854553223e-01,-7.103578448295593262e-01,-8.887031674385070801e-01,-5.140971541404724121e-01}; static float Bh1[HIDDEN_DIMS1] = { -2.761822193861007690e-02,3.516794741153717041e-01,7.828953266143798828e-01,7.023379206657409668e-01,5.146764516830444336e-01,7.880625128746032715e-01,1.113372668623924255e-01,6.815895438194274902e-02 }; diff --git a/c_reference/tests/rnnpool/vww_model/rnn2.h b/c_reference/tests/rnnpool/vww_model/rnn2.h index 9a52af5a2..ac9c55efd 100644 --- a/c_reference/tests/rnnpool/vww_model/rnn2.h +++ b/c_reference/tests/rnnpool/vww_model/rnn2.h @@ -1,8 +1,8 @@ static float mean2[HIDDEN_DIMS1 * PATCH_DIM] = {0.0}; static float stdDev2[HIDDEN_DIMS1 * PATCH_DIM] = {1.0}; -static float W2[HIDDEN_DIMS1 * HIDDEN_DIMS2] = { 3.328921273350715637e-02,-3.237796723842620850e-01,-6.069063544273376465e-01,3.176147341728210449e-01,-8.808585256338119507e-02,4.995678067207336426e-01,-8.141241967678070068e-02,-5.527251958847045898e-02,4.839901626110076904e-02,-2.648477256298065186e-01,4.720874130725860596e-01,-2.042243480682373047e-01,1.615403443574905396e-01,4.996369481086730957e-01,-5.713146924972534180e-02,-6.109619140625000000e-02,8.630067855119705200e-02,2.549230158329010010e-01,5.098583698272705078e-01,3.439170718193054199e-01,-4.946086406707763672e-01,-8.396717905998229980e-02,6.110856309533119202e-02,2.462622970342636108e-01,-3.623228371143341064e-01,1.056594774127006531e-01,4.149395599961280823e-02,2.087370865046977997e-02,-1.174109801650047302e-02,-3.785453736782073975e-01,2.926556952297687531e-02,-1.656581298448145390e-04,3.617477416992187500e-02,-5.211604386568069458e-02,-2.221289835870265961e-02,2.785135433077812195e-02,2.072153845801949501e-03,1.230286993086338043e-02,-1.405209898948669434e-01,1.710500240325927734e+00,-1.013135910034179688e-01,-5.569029450416564941e-01,2.892487943172454834e-01,3.186852931976318359e-01,4.303685724735260010e-01,-3.816023766994476318e-01,-5.008732676506042480e-01,-6.598105430603027344e-01,-1.616892337799072266e+00,7.901080884039402008e-03,1.637366861104965210e-01,5.935984104871749878e-02,-7.063516974449157715e-02,1.118507459759712219e-01,5.522043444216251373e-03,2.383397147059440613e-02,9.920979291200637817e-02,4.476135373115539551e-01,-4.640549048781394958e-02,-3.889196217060089111e-01,-3.901343047618865967e-01,1.944433003664016724e-01,-8.167469501495361328e-01,-5.196015834808349609e-01 }; -static float U2[HIDDEN_DIMS2 * HIDDEN_DIMS2] = { 3.934212923049926758e-01,2.627835571765899658e-01,-9.242479503154754639e-02,1.917631626129150391e-01,2.150612622499465942e-01,7.392763346433639526e-02,-5.659309402108192444e-02,-4.473730921745300293e-02,-4.295524582266807556e-02,2.479245215654373169e-01,1.447719633579254150e-01,8.766186982393264771e-02,2.176617681980133057e-01,4.104424268007278442e-03,-4.538772255182266235e-02,-2.271021008491516113e-01,1.002475544810295105e-01,-2.347197830677032471e-01,3.752615749835968018e-01,-2.752942740917205811e-01,-9.746207296848297119e-02,-1.972307413816452026e-01,6.283282488584518433e-02,1.190942153334617615e-02,-1.167084053158760071e-01,2.314671277999877930e-01,2.763805091381072998e-01,2.459737062454223633e-01,3.679830208420753479e-02,-2.362748086452484131e-01,-3.104292228817939758e-02,-6.096216291189193726e-02,7.208147644996643066e-02,1.421915292739868164e-01,-7.362117618322372437e-02,4.787993803620338440e-02,2.094942629337310791e-01,3.649697601795196533e-01,-1.333466079086065292e-02,2.375180423259735107e-01,7.301057875156402588e-02,-4.386771023273468018e-01,-1.142739504575729370e-01,8.056888729333877563e-02,-2.684409022331237793e-01,3.465250432491302490e-01,-7.922663539648056030e-02,-1.497552990913391113e-01,7.414811104536056519e-02,4.338171705603599548e-02,1.064843088388442993e-01,2.883537299931049347e-02,6.217004358768463135e-02,7.446446269750595093e-02,6.666561216115951538e-02,-4.494012892246246338e-01,-1.667873002588748932e-02,1.125133633613586426e-01,-8.647724986076354980e-03,6.972444709390401840e-03,-3.187925368547439575e-02,5.720932036638259888e-02,4.965405911207199097e-02,-6.579961627721786499e-02 }; +static float W2[HIDDEN_DIMS1 * HIDDEN_DIMS2] = { 3.328921273350715637e-02,4.839901626110076904e-02,8.630067855119705200e-02,-3.623228371143341064e-01,3.617477416992187500e-02,-1.013135910034179688e-01,-1.616892337799072266e+00,9.920979291200637817e-02,-3.237796723842620850e-01,-2.648477256298065186e-01,2.549230158329010010e-01,1.056594774127006531e-01,-5.211604386568069458e-02,-5.569029450416564941e-01,7.901080884039402008e-03,4.476135373115539551e-01,-6.069063544273376465e-01,4.720874130725860596e-01,5.098583698272705078e-01,4.149395599961280823e-02,-2.221289835870265961e-02,2.892487943172454834e-01,1.637366861104965210e-01,-4.640549048781394958e-02,3.176147341728210449e-01,-2.042243480682373047e-01,3.439170718193054199e-01,2.087370865046977997e-02,2.785135433077812195e-02,3.186852931976318359e-01,5.935984104871749878e-02,-3.889196217060089111e-01,-8.808585256338119507e-02,1.615403443574905396e-01,-4.946086406707763672e-01,-1.174109801650047302e-02,2.072153845801949501e-03,4.303685724735260010e-01,-7.063516974449157715e-02,-3.901343047618865967e-01,4.995678067207336426e-01,4.996369481086730957e-01,-8.396717905998229980e-02,-3.785453736782073975e-01,1.230286993086338043e-02,-3.816023766994476318e-01,1.118507459759712219e-01,1.944433003664016724e-01,-8.141241967678070068e-02,-5.713146924972534180e-02,6.110856309533119202e-02,2.926556952297687531e-02,-1.405209898948669434e-01,-5.008732676506042480e-01,5.522043444216251373e-03,-8.167469501495361328e-01,-5.527251958847045898e-02,-6.109619140625000000e-02,2.462622970342636108e-01,-1.656581298448145390e-04,1.710500240325927734e+00,-6.598105430603027344e-01,2.383397147059440613e-02,-5.196015834808349609e-01 }; +static float U2[HIDDEN_DIMS2 * HIDDEN_DIMS2] = { 3.934212923049926758e-01,-4.295524582266807556e-02,1.002475544810295105e-01,-1.167084053158760071e-01,7.208147644996643066e-02,7.301057875156402588e-02,7.414811104536056519e-02,-1.667873002588748932e-02,2.627835571765899658e-01,2.479245215654373169e-01,-2.347197830677032471e-01,2.314671277999877930e-01,1.421915292739868164e-01,-4.386771023273468018e-01,4.338171705603599548e-02,1.125133633613586426e-01,-9.242479503154754639e-02,1.447719633579254150e-01,3.752615749835968018e-01,2.763805091381072998e-01,-7.362117618322372437e-02,-1.142739504575729370e-01,1.064843088388442993e-01,-8.647724986076354980e-03,1.917631626129150391e-01,8.766186982393264771e-02,-2.752942740917205811e-01,2.459737062454223633e-01,4.787993803620338440e-02,8.056888729333877563e-02,2.883537299931049347e-02,6.972444709390401840e-03,2.150612622499465942e-01,2.176617681980133057e-01,-9.746207296848297119e-02,3.679830208420753479e-02,2.094942629337310791e-01,-2.684409022331237793e-01,6.217004358768463135e-02,-3.187925368547439575e-02,7.392763346433639526e-02,4.104424268007278442e-03,-1.972307413816452026e-01,-2.362748086452484131e-01,3.649697601795196533e-01,3.465250432491302490e-01,7.446446269750595093e-02,5.720932036638259888e-02,-5.659309402108192444e-02,-4.538772255182266235e-02,6.283282488584518433e-02,-3.104292228817939758e-02,-1.333466079086065292e-02,-7.922663539648056030e-02,6.666561216115951538e-02,4.965405911207199097e-02,-4.473730921745300293e-02,-2.271021008491516113e-01,1.190942153334617615e-02,-6.096216291189193726e-02,2.375180423259735107e-01,-1.497552990913391113e-01,-4.494012892246246338e-01,-6.579961627721786499e-02 }; static float Bg2[HIDDEN_DIMS2] = { -1.537145614624023438e+00,-6.593755483627319336e-01,-8.165745735168457031e-01,-1.047435641288757324e+00,-1.003585577011108398e+00,-1.275580763816833496e+00,-9.717565178871154785e-01,-1.349884271621704102e+00 }; static float Bh2[HIDDEN_DIMS2] = { 1.249589323997497559e+00,2.501939237117767334e-01,3.707601428031921387e-01,1.205096021294593811e-01,6.529558449983596802e-02,-2.186506539583206177e-01,-1.120083108544349670e-01,-1.578094959259033203e+00 }; From 8f14f5b9b472d43c298719b51c375ecfd73bc0f2 Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Mon, 27 Apr 2020 02:42:56 -0700 Subject: [PATCH 09/15] added README --- c_reference/README.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 c_reference/README.md diff --git a/c_reference/README.md b/c_reference/README.md new file mode 100644 index 000000000..63cc38185 --- /dev/null +++ b/c_reference/README.md @@ -0,0 +1,7 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. + +This folder consists of C reference code for some EdgeML operators, +and sample parameter sets and input/output traces to verify them. +The code is intended to compile with gcc on Linux machines, +and is to be adapated as needed for other embedded platforms. From afeb86400f0e334d34098e66e18eea84362ef884 Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Mon, 27 Apr 2020 20:38:46 -0700 Subject: [PATCH 10/15] minor edits --- c_reference/include/utils.h | 6 ++++- c_reference/src/utils.c | 9 +++++++ c_reference/tests/rnnpool/test_rnnpool.c | 29 ++++++++++++---------- c_reference/tests/rnnpool/vww_model/rnn1.h | 3 --- c_reference/tests/rnnpool/vww_model/rnn2.h | 3 --- 5 files changed, 30 insertions(+), 20 deletions(-) diff --git a/c_reference/include/utils.h b/c_reference/include/utils.h index 4c5eef5ac..26d5242ba 100644 --- a/c_reference/include/utils.h +++ b/c_reference/include/utils.h @@ -36,7 +36,7 @@ void v_add(float scalar1, const float* const vec1, float scalar2, const float* const vec2, unsigned len, float* const ret); -// point-wise vector division ret = vec2 / vec1 +// point-wise vector multiplication ret = vec2 * vec1 void v_mult(const float* const vec1, const float* const vec2, unsigned len, float* const ret); @@ -44,6 +44,10 @@ void v_mult(const float* const vec1, const float* const vec2, void v_div(const float* const vec1, const float* const vec2, unsigned len, float* const ret); +// Return squared Euclidean distance between vec1 and vec2 +float l2squared(const float* const vec1, + const float* const vec2, unsigned dim); + // Return index with max value, if tied, return first tied index. unsigned argmax(const float* const vec, unsigned len); diff --git a/c_reference/src/utils.c b/c_reference/src/utils.c index 880cb0068..9628dc80c 100644 --- a/c_reference/src/utils.c +++ b/c_reference/src/utils.c @@ -90,6 +90,15 @@ void v_div(const float* const vec1, const float* const vec2, ret[i] = vec2[i] / vec1[i]; } +float l2squared(const float* const vec1, + const float* const vec2, unsigned dim) { + float sum = 0.0f; + for (unsigned i = 0; i < dim; i++) + sum += (vec1[i] - vec2[i]) * (vec1[i] - vec2[i]); + return sum; +} + + unsigned argmax(const float* const vec, unsigned len) { unsigned maxId = 0; float maxScore = FLT_MIN; diff --git a/c_reference/tests/rnnpool/test_rnnpool.c b/c_reference/tests/rnnpool/test_rnnpool.c index f5b4f4b10..bba0434bf 100644 --- a/c_reference/tests/rnnpool/test_rnnpool.c +++ b/c_reference/tests/rnnpool/test_rnnpool.c @@ -16,8 +16,8 @@ int main() { FastGRNN_Params rnn1_params = { - .mean = mean1, - .stdDev = stdDev1, + .mean = NULL, + .stdDev = NULL, .W = W1, .U = U1, .Bg = Bg1, @@ -27,8 +27,8 @@ int main() { }; FastGRNN_Params rnn2_params = { - .mean = mean2, - .stdDev = stdDev2, + .mean = NULL, + .stdDev = NULL, .W = W2, .U = U2, .Bg = Bg2, @@ -37,30 +37,33 @@ int main() { .nu = nu2 }; - float preComp1[HIDDEN_DIMS1] = { 0.0f }; - float normFeatures1[INPUT_DIMS] = { 0.0f }; + float preComp1[HIDDEN_DIMS1]; + float normFeatures1[INPUT_DIMS]; + memset(preComp1, 0, sizeof(float) * HIDDEN_DIMS1); + memset(normFeatures1, 0, sizeof(float) * INPUT_DIMS); FastGRNN_Buffers rnn1_buffers = { .preComp = preComp1, .normFeatures = normFeatures1 }; - float preComp2[HIDDEN_DIMS2] = { 0.0f }; - float normFeatures2[HIDDEN_DIMS1] = { 0.0f }; + float preComp2[HIDDEN_DIMS2]; + float normFeatures2[HIDDEN_DIMS1]; + memset(preComp2, 0, sizeof(float) * HIDDEN_DIMS2); + memset(normFeatures2, 0, sizeof(float) * HIDDEN_DIMS1); FastGRNN_Buffers rnn2_buffers = { .preComp = preComp2, .normFeatures = normFeatures2 }; - float output_test[4 * HIDDEN_DIMS2] = { 0.0f }; + float output_test[4 * HIDDEN_DIMS2]; float buffer[HIDDEN_DIMS1 * PATCH_DIM]; + memset(output_test, 0, sizeof(float) * 4 * HIDDEN_DIMS2); + memset(buffer, 0, sizeof(float) * HIDDEN_DIMS1 * PATCH_DIM); rnnpool_block(input, INPUT_DIMS, PATCH_DIM, PATCH_DIM, fastgrnn, HIDDEN_DIMS1, (const void*)(&rnn1_params), (void*)(&rnn1_buffers), fastgrnn, HIDDEN_DIMS2, (const void*)(&rnn2_params), (void*)(&rnn2_buffers), output_test, buffer); - float error = 0.0f; - for (unsigned d = 0; d < 4 * HIDDEN_DIMS2; ++d) - error += (output[d] - output_test[d]) * (output[d] - output_test[d]); - printf("Error: %f\n", error); + printf("Error: %f\n", l2squared(output, output_test, 4 * HIDDEN_DIMS2)); } diff --git a/c_reference/tests/rnnpool/vww_model/rnn1.h b/c_reference/tests/rnnpool/vww_model/rnn1.h index a9e8c1b00..4937d6b6c 100644 --- a/c_reference/tests/rnnpool/vww_model/rnn1.h +++ b/c_reference/tests/rnnpool/vww_model/rnn1.h @@ -1,8 +1,5 @@ #define HIDDEN_DIMS1 8 -static float mean1[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = {0.0}; -static float stdDev1[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = {1.0}; - static float W1[INPUT_DIMS * HIDDEN_DIMS1] = { -6.669194251298904419e-02,4.241880401968955994e-02,1.779496856033802032e-02,2.434188500046730042e-02,2.040588408708572388e-01,-6.289862841367721558e-02,8.665277808904647827e-02,-4.211997613310813904e-02,-4.081934988498687744e-01,3.874431252479553223e-01,-9.131602197885513306e-02,-4.231898188591003418e-01,1.137487962841987610e-01,-7.153615355491638184e-02,1.098951250314712524e-01,-5.568345189094543457e-01,-9.548854231834411621e-01,6.743898242712020874e-02,1.308344118297100067e-02,-5.101327300071716309e-01,-2.034226208925247192e-01,-3.552019000053405762e-01,3.574696481227874756e-01,-1.339200735092163086e-01,-1.199822783470153809e+00,4.235469996929168701e-01,-2.176112309098243713e-02,-5.763933062553405762e-01,-4.363142326474189758e-02,-3.619972467422485352e-01,4.203165769577026367e-01,-1.205071806907653809e+00,3.212589919567108154e-01,7.616437077522277832e-01,7.672815918922424316e-01,2.576289772987365723e-01,1.962029747664928436e-02,6.437804698944091797e-01,1.115008115768432617e+00,8.542865514755249023e-02,-8.398564457893371582e-01,-3.183248341083526611e-01,-3.293828964233398438e-01,-1.621776819229125977e-01,5.834429860115051270e-01,3.947886824607849121e-01,-6.720532774925231934e-01,3.155398648232221603e-03,1.377462625503540039e+00,-6.704510450363159180e-01,8.417400717735290527e-02,6.603993773460388184e-01,-1.158756241202354431e-01,4.007513821125030518e-01,-4.624451696872711182e-01,1.793413400650024414e+00,1.293107271194458008e-01,3.916886448860168457e-01,-4.810366034507751465e-01,-2.212110720574855804e-02,-6.547657251358032227e-01,3.415162265300750732e-01,-3.584066927433013916e-01,3.155157715082168579e-02 }; static float U1[HIDDEN_DIMS1 * HIDDEN_DIMS1] = { 4.257509708404541016e-01,-2.243996411561965942e-01,4.599139690399169922e-01,-3.530698418617248535e-01,2.927841432392597198e-02,1.921992599964141846e-01,7.122249808162450790e-03,2.478006668388843536e-02,2.090227305889129639e-01,6.178687140345573425e-02,-8.031798005104064941e-01,-9.047465324401855469e-01,1.150295138359069824e-01,-1.216369643807411194e-01,8.977604657411575317e-02,-3.528899326920509338e-02,-9.029741585254669189e-02,1.964072138071060181e-02,-2.055168338119983673e-02,5.608395114541053772e-02,-1.545069087296724319e-02,-3.085457533597946167e-02,7.987973280251026154e-03,-8.097411133348941803e-03,-1.581576466560363770e-01,-7.558400928974151611e-02,-1.338823318481445312e+00,1.076061371713876724e-02,7.246796786785125732e-02,-6.944761611521244049e-03,-8.065721951425075531e-03,-2.095492556691169739e-02,-2.624719589948654175e-02,-3.073738422244787216e-03,1.721778139472007751e-02,-3.143182024359703064e-03,1.096169114112854004e+00,-4.858187958598136902e-02,-8.912781253457069397e-03,-3.243596106767654419e-02,-1.679758429527282715e-01,-7.507130037993192673e-03,-1.409216374158859253e-01,1.100406423211097717e-01,-1.400157362222671509e-01,1.513722836971282959e-01,-1.210445910692214966e-02,-8.220742642879486084e-02,1.883537024259567261e-01,5.114595890045166016e-01,1.616048932075500488e+00,1.620839357376098633e+00,-1.330980509519577026e-01,9.179102256894111633e-03,7.160065323114395142e-02,2.354629104956984520e-03,8.153508603572845459e-02,9.405165910720825195e-03,1.780232340097427368e-01,-5.950598046183586121e-02,-5.966191366314888000e-02,1.019131317734718323e-01,2.581899240612983704e-02,1.182158961892127991e-01 }; static float Bg1[HIDDEN_DIMS1] = { -1.213001132011413574e+00,-3.357241451740264893e-01,-1.219372987747192383e+00,-2.052456587553024292e-01,-7.755046486854553223e-01,-7.103578448295593262e-01,-8.887031674385070801e-01,-5.140971541404724121e-01}; diff --git a/c_reference/tests/rnnpool/vww_model/rnn2.h b/c_reference/tests/rnnpool/vww_model/rnn2.h index ac9c55efd..cf8325a5d 100644 --- a/c_reference/tests/rnnpool/vww_model/rnn2.h +++ b/c_reference/tests/rnnpool/vww_model/rnn2.h @@ -1,6 +1,3 @@ -static float mean2[HIDDEN_DIMS1 * PATCH_DIM] = {0.0}; -static float stdDev2[HIDDEN_DIMS1 * PATCH_DIM] = {1.0}; - static float W2[HIDDEN_DIMS1 * HIDDEN_DIMS2] = { 3.328921273350715637e-02,4.839901626110076904e-02,8.630067855119705200e-02,-3.623228371143341064e-01,3.617477416992187500e-02,-1.013135910034179688e-01,-1.616892337799072266e+00,9.920979291200637817e-02,-3.237796723842620850e-01,-2.648477256298065186e-01,2.549230158329010010e-01,1.056594774127006531e-01,-5.211604386568069458e-02,-5.569029450416564941e-01,7.901080884039402008e-03,4.476135373115539551e-01,-6.069063544273376465e-01,4.720874130725860596e-01,5.098583698272705078e-01,4.149395599961280823e-02,-2.221289835870265961e-02,2.892487943172454834e-01,1.637366861104965210e-01,-4.640549048781394958e-02,3.176147341728210449e-01,-2.042243480682373047e-01,3.439170718193054199e-01,2.087370865046977997e-02,2.785135433077812195e-02,3.186852931976318359e-01,5.935984104871749878e-02,-3.889196217060089111e-01,-8.808585256338119507e-02,1.615403443574905396e-01,-4.946086406707763672e-01,-1.174109801650047302e-02,2.072153845801949501e-03,4.303685724735260010e-01,-7.063516974449157715e-02,-3.901343047618865967e-01,4.995678067207336426e-01,4.996369481086730957e-01,-8.396717905998229980e-02,-3.785453736782073975e-01,1.230286993086338043e-02,-3.816023766994476318e-01,1.118507459759712219e-01,1.944433003664016724e-01,-8.141241967678070068e-02,-5.713146924972534180e-02,6.110856309533119202e-02,2.926556952297687531e-02,-1.405209898948669434e-01,-5.008732676506042480e-01,5.522043444216251373e-03,-8.167469501495361328e-01,-5.527251958847045898e-02,-6.109619140625000000e-02,2.462622970342636108e-01,-1.656581298448145390e-04,1.710500240325927734e+00,-6.598105430603027344e-01,2.383397147059440613e-02,-5.196015834808349609e-01 }; static float U2[HIDDEN_DIMS2 * HIDDEN_DIMS2] = { 3.934212923049926758e-01,-4.295524582266807556e-02,1.002475544810295105e-01,-1.167084053158760071e-01,7.208147644996643066e-02,7.301057875156402588e-02,7.414811104536056519e-02,-1.667873002588748932e-02,2.627835571765899658e-01,2.479245215654373169e-01,-2.347197830677032471e-01,2.314671277999877930e-01,1.421915292739868164e-01,-4.386771023273468018e-01,4.338171705603599548e-02,1.125133633613586426e-01,-9.242479503154754639e-02,1.447719633579254150e-01,3.752615749835968018e-01,2.763805091381072998e-01,-7.362117618322372437e-02,-1.142739504575729370e-01,1.064843088388442993e-01,-8.647724986076354980e-03,1.917631626129150391e-01,8.766186982393264771e-02,-2.752942740917205811e-01,2.459737062454223633e-01,4.787993803620338440e-02,8.056888729333877563e-02,2.883537299931049347e-02,6.972444709390401840e-03,2.150612622499465942e-01,2.176617681980133057e-01,-9.746207296848297119e-02,3.679830208420753479e-02,2.094942629337310791e-01,-2.684409022331237793e-01,6.217004358768463135e-02,-3.187925368547439575e-02,7.392763346433639526e-02,4.104424268007278442e-03,-1.972307413816452026e-01,-2.362748086452484131e-01,3.649697601795196533e-01,3.465250432491302490e-01,7.446446269750595093e-02,5.720932036638259888e-02,-5.659309402108192444e-02,-4.538772255182266235e-02,6.283282488584518433e-02,-3.104292228817939758e-02,-1.333466079086065292e-02,-7.922663539648056030e-02,6.666561216115951538e-02,4.965405911207199097e-02,-4.473730921745300293e-02,-2.271021008491516113e-01,1.190942153334617615e-02,-6.096216291189193726e-02,2.375180423259735107e-01,-1.497552990913391113e-01,-4.494012892246246338e-01,-6.579961627721786499e-02 }; From d691a64c01597ea697515223fa9f471e199ae19d Mon Sep 17 00:00:00 2001 From: Harsha Vardhan Simhadri Date: Mon, 27 Apr 2020 23:53:30 -0700 Subject: [PATCH 11/15] fixed errors in backward rnn pass --- c_reference/include/fastgrnn.h | 16 ++++++++-------- c_reference/src/fastgrnn.c | 8 ++++---- c_reference/tests/fastgrnn/test_fastgrnn_lr.c | 8 ++++---- c_reference/tests/rnnpool/test_rnnpool.c | 8 ++++---- c_reference/tests/rnnpool/vww_model/rnn1.h | 4 ++-- c_reference/tests/rnnpool/vww_model/rnn2.h | 4 ++-- 6 files changed, 24 insertions(+), 24 deletions(-) diff --git a/c_reference/include/fastgrnn.h b/c_reference/include/fastgrnn.h index fbcf893b6..051f154a0 100644 --- a/c_reference/include/fastgrnn.h +++ b/c_reference/include/fastgrnn.h @@ -21,8 +21,8 @@ * @var uRank rank of U matrix * @var Bg pointer to bias for sigmoid * @var Bh pointer to bias for tanh - * @var zeta first weight parameter for update from input from next step - * @var nu second weight parameter for update from input from next step + * @var sigmoid_zeta first weight parameter for update from input from next step + * @var sigmoid_nu second weight parameter for update from input from next step */ typedef struct FastGRNN_LR_Params { float* mean; @@ -35,8 +35,8 @@ typedef struct FastGRNN_LR_Params { unsigned uRank; float* Bg; float* Bh; - float zeta; - float nu; + float sigmoid_zeta; + float sigmoid_nu; } FastGRNN_LR_Params; /** @@ -82,8 +82,8 @@ int fastgrnn_lr(float* const hiddenState, unsigned hiddenDims, * @var U pointer U matrix * @var Bg pointer to bias for sigmoid * @var Bh pointer to bias for tanh - * @var zeta first weight parameter for update from input from next step - * @var nu second weight parameter for update from input from next step + * @var sigmoid_zeta first weight parameter for update from input from next step + * @var sigmoid_nu second weight parameter for update from input from next step */ typedef struct FastGRNN_Params { float* mean; @@ -92,8 +92,8 @@ typedef struct FastGRNN_Params { float* U; float* Bg; float* Bh; - float zeta; - float nu; + float sigmoid_zeta; + float sigmoid_nu; } FastGRNN_Params; /** diff --git a/c_reference/src/fastgrnn.c b/c_reference/src/fastgrnn.c index 8dfcc2f07..135e39150 100644 --- a/c_reference/src/fastgrnn.c +++ b/c_reference/src/fastgrnn.c @@ -19,7 +19,7 @@ int fastgrnn_lr(float* const hiddenState, unsigned hiddenDims, // #steps iterations of the RNN cell starting from hiddenState for (unsigned t = 0; t < steps; t++) { // Normalize the features - unsigned offset = backward ? steps - t : t; + unsigned offset = backward ? steps - 1 - t : t; if (normalize) { v_add(1.0f, input + offset * inputDims, -1.0f, tparams->mean + t * inputDims, inputDims, tbuffers->normFeatures); @@ -45,7 +45,7 @@ int fastgrnn_lr(float* const hiddenState, unsigned hiddenDims, for (unsigned i = 0; i < hiddenDims; i++) { float gate = sigmoid(tbuffers->preComp[i] + tparams->Bg[i]); float update = tanh(tbuffers->preComp[i] + tparams->Bh[i]); - hiddenState[i] = gate * hiddenState[i] + (tparams->zeta * (1.0 - gate) + tparams->nu) * update; + hiddenState[i] = gate * hiddenState[i] + (tparams->sigmoid_zeta * (1.0 - gate) + tparams->sigmoid_nu) * update; } } return 0; @@ -63,7 +63,7 @@ int fastgrnn(float* const hiddenState, unsigned hiddenDims, for (unsigned t = 0; t < steps; t++) { // Normalize the features - unsigned offset = backward ? steps - t : t; + unsigned offset = backward ? steps - 1 - t : t; if (normalize) { v_add(1.0f, input + offset * inputDims, -1.0f, tparams->mean + t * inputDims, inputDims, tbuffers->normFeatures); @@ -86,7 +86,7 @@ int fastgrnn(float* const hiddenState, unsigned hiddenDims, for (unsigned i = 0; i < hiddenDims; i++) { float gate = sigmoid(tbuffers->preComp[i] + tparams->Bg[i]); float update = tanh(tbuffers->preComp[i] + tparams->Bh[i]); - hiddenState[i] = gate * hiddenState[i] + (tparams->zeta * (1.0 - gate) + tparams->nu) * update; + hiddenState[i] = gate * hiddenState[i] + (tparams->sigmoid_zeta * (1.0 - gate) + tparams->sigmoid_nu) * update; } } return 0; diff --git a/c_reference/tests/fastgrnn/test_fastgrnn_lr.c b/c_reference/tests/fastgrnn/test_fastgrnn_lr.c index ebee68d26..0c04d41b7 100644 --- a/c_reference/tests/fastgrnn/test_fastgrnn_lr.c +++ b/c_reference/tests/fastgrnn/test_fastgrnn_lr.c @@ -32,8 +32,8 @@ static float USPS_U2[USPS_URANK * HIDDEN_DIMS] = { -1.1701158285140991, -0.15880 static float USPS_Bg[HIDDEN_DIMS] = { 4.59620475769043, 0.1966695934534073, 1.9611409902572632, 3.5603864192962646, 4.187475204467773, 4.361924648284912, 0.3600460886955261, 1.3823245763778687, -0.677017092704773, 4.105582237243652, 5.264251232147217, -0.5598424077033997, 5.148655414581299, 2.0772266387939453, 4.553979873657227, 5.08613920211792, 4.782368183135986, 0.7364211678504944, 5.434220314025879, 3.580031394958496, 3.1102733612060547, -0.7808840870857239, 0.7291825413703918, 4.574047565460205, 3.3059921264648438, 0.3563838303089142, 2.718221664428711, 3.580395460128784, 3.4779181480407715, 2.5830607414245605, 2.9951508045196533, 0.9241535663604736 }; static float USPS_Bh[HIDDEN_DIMS] = { 0.4606550931930542, 0.790073573589325, -0.017053354531526566, 0.9936599731445312, 1.7931172847747803, 1.5456229448318481, 1.1712238788604736, 0.25801223516464233, 0.31747567653656006, 0.19287768006324768, 2.0994107723236084, 1.0495734214782715, 1.4762489795684814, 1.309980034828186, 0.3596293032169342, 1.5582088232040405, 0.40993940830230713, 1.8783470392227173, 1.493168830871582, -0.24529218673706055, 1.1273030042648315, 0.2839592695236206, 1.9818940162658691, 1.6705248355865479, 0.6683108806610107, 1.1119632720947266, 1.71348237991333, 2.004892110824585, 2.6525025367736816, 1.5513267517089844, 1.5202845335006714, -0.5777350068092346 }; -static float USPS_zeta = 0.8710977; -static float USPS_nu = 0.077582605; +static float USPS_sigmoid_zeta = 0.8710977; +static float USPS_sigmoid_nu = 0.077582605; static float FC_weights[HIDDEN_DIMS * NUM_CLASSES] = { -0.24747183918952942, -0.055960506200790405, 1.3475773334503174, -0.2660730183124542, 0.08773329854011536, 2.71574068069458, -1.4928890466690063, 1.5905754566192627, 1.4361884593963623, 1.3066115379333496, -0.41571110486984253, 0.9617563486099243, 0.40012961626052856, 0.8696961998939514, -1.6383168697357178, 0.7999024391174316, -0.16858834028244019, -1.0727401971817017, 0.7396827340126038, 0.3806271553039551, -0.8257421255111694, 0.1623869240283966, -0.39433446526527405, -3.482332468032837, -0.08032357692718506, 0.994373083114624, 0.9860239028930664, -5.6317973136901855, -3.062581777572632, -3.2377049922943115, -1.088222861289978, 0.7581420540809631, -0.1045861691236496, 1.0123625993728638, 2.7781565189361572, 4.226351737976074, -0.4395594894886017, -1.9928295612335205, -0.03426577150821686, 0.2318461388349533, -3.200232982635498, 0.7830891013145447, -2.003850221633911, -1.0072307586669922, -0.09394438564777374, -0.402126282453537, 2.8108479976654053, 0.027125360444188118, 1.893704891204834, -0.03775143623352051, 0.6053617596626282, 0.3430182933807373, -3.2976200580596924, -1.1353939771652222, 0.024645693600177765, 0.3784751296043396, 1.4342879056930542, -0.7492150664329529, -1.0270135402679443, 2.5554628372192383, 0.6594746112823486, 0.7780766487121582, 0.8985974788665771, -0.0034258293453603983, 0.21751202642917633, -2.3399763107299805, 1.1613740921020508, -1.447609305381775, -1.3636846542358398, 1.7248963117599487, -0.3620492219924927, -2.375091075897217, -1.3364042043685913, 1.359509825706482, -2.648242235183716, 1.4566280841827393, 0.6185098886489868, 0.9421749711036682, -1.8496538400650024, -1.3294904232025146, -0.565808892250061, -1.6445082426071167, 1.2565573453903198, 2.4306249618530273, -1.6949048042297363, 2.2069883346557617, 1.103385329246521, -0.9351933598518372, -0.824954628944397, -0.7599087953567505, -0.6911792755126953, 2.7740914821624756, 1.6341619491577148, 1.849193811416626, 1.146787166595459, -1.4661681652069092, 2.0738017559051514, -1.9961793422698975, -1.1605796813964844, 0.9941896200180054, 0.3308192789554596, 2.13922119140625, -0.17217597365379333, -0.9082329869270325, 0.7720779180526733, -1.0596287250518799, 1.586103081703186, -2.9859485626220703, 1.55707585811615, 1.1488341093063354, -3.2394535541534424, 1.169393539428711, -0.13278652727603912, 1.6355780363082886, -0.1245696097612381, 1.808440923690796, -1.1002291440963745, -0.3053940534591675, 1.6078038215637207, 3.8395557403564453, 0.019826073199510574, -0.3926658034324646, -1.9981871843338013, -0.6696834564208984, 0.08870892226696014, 1.6605280637741089, 0.5209671854972839, -2.3854024410247803, 1.5786619186401367, 1.8952832221984863, -1.304535150527954, 0.2743481695652008, 2.8763298988342285, -0.6256309747695923, 3.8730015754699707, -0.32314497232437134, -0.6618545651435852, -3.0481762886047363, -2.8654234409332275, -0.8415182828903198, -1.3170037269592285, 1.3599309921264648, 1.2142889499664307, 0.07019823044538498, -0.5422642827033997, 0.23863810300827026, 3.584157943725586, 0.7111842036247253, 0.9668632745742798, 1.3011258840560913, -0.003976037260144949, 1.7265373468399048, -0.48193755745887756, 0.463483989238739, -0.3804154098033905, 2.4481565952301025, -1.081111192703247, 1.9583369493484497, -3.963627338409424, 0.729573667049408, -0.4898405373096466, -0.5738614201545715, -1.7461729049682617, -1.8392359018325806, -0.4148902893066406, -1.158633828163147, -1.6964939832687378, 0.5787208080291748, 1.4248132705688477, -0.4257330894470215, 3.0490269660949707, -1.1780657768249512, 1.0951701402664185, 0.8462642431259155, 0.9555350542068481, 2.9707250595092773, -1.3199042081832886, 1.8216924667358398, -0.6233108639717102, 1.5412005186080933, 0.334654837846756, 0.2763754725456238, 1.3666235208511353, 1.851394534111023, -1.7485069036483765, 1.0322270393371582, -1.8656693696975708, -1.1901252269744873, 1.0325310230255127, -0.8999790549278259, 0.22713708877563477, -3.3022899627685547, -2.718987464904785, 0.6280394792556763, 0.7579594254493713, -2.2618398666381836, -1.1550352573394775, 1.0463181734085083, -0.2427310198545456, -0.1560579091310501, -0.19294323027133942, 0.3897946774959564, -1.5712190866470337, 1.0458306074142456, -0.7470991015434265, 1.2837566137313843, 2.3155717849731445, 2.0378687381744385, 0.7463016510009766, 1.3255469799041748, -1.7185251712799072, -0.1644330620765686, 2.248473882675171, -0.05582746863365173, -0.39194202423095703, -1.050262212753296, 1.1556638479232788, 0.03496933728456497, 1.5286030769348145, 0.01176676619797945, -1.1746597290039062, -0.038728803396224976, -0.3821633458137512, 0.9377774596214294, -0.3956509530544281, 1.074571967124939, -1.6802961826324463, -0.3645908534526825, -1.4564014673233032, 0.6331769227981567, 2.4816489219665527, 0.32858720421791077, 1.5533283948898315, 1.6947213411331177, 0.3252701461315155, 3.2225258350372314, 1.1926754713058472, 0.3901558518409729, -0.8612796664237976, -4.8346662521362305, -1.9908527135849, 0.7937301993370056, -1.5082682371139526, 0.4805694818496704, -1.419480323791504, 0.157501682639122, 2.0960652828216553, 0.005156002938747406, -2.6489176750183105, 1.263648271560669, -1.3384476900100708, 1.4031224250793457, 0.4655438959598541, 1.8326048851013184, 3.110736131668091, 0.26125067472457886, 2.7024500370025635, -0.9119302034378052, -0.6820136308670044, 3.8541572093963623, -1.3096107244491577, 1.7389343976974487, 2.067892551422119, 1.1543680429458618, 0.03984083607792854, 0.6176361441612244, -0.8746475577354431, 0.40996477007865906, -2.3278424739837646, 0.5317244529724121, -1.1554235219955444, 0.8648607730865479, 0.5743665099143982, 0.9955512881278992, 0.8316799998283386, -1.9429028034210205, 0.6146461367607117, -4.532263278961182, -0.8694373965263367, -0.31155335903167725, -0.030860910192131996, 1.173535704612732, 0.8387981057167053, -1.3379566669464111, 1.902561902999878, 2.197434663772583, 1.3871995210647583, -1.6537810564041138, -2.7861647605895996, -0.005632062442600727, -2.181979179382324, 2.3240818977355957, 0.914097785949707, 0.10216601192951202, 2.52095103263855, 0.6039048433303833, -1.1367847919464111, -2.309983015060425, 2.7826766967773438, -0.6315389275550842, -3.811366319656372, 2.09122633934021, -0.6774390339851379, -0.9190919995307922, 0.9899649620056152, 1.0903472900390625, -0.7736498713493347, -1.3925520181655884, 0.6861974596977234, 3.141139268875122, 0.7085739970207214, 0.35131436586380005, 1.6807632446289062, 1.0083352327346802, -0.38794782757759094, -1.839680790901184, -0.7718075513839722, 0.41827693581581116, 1.8001973628997803, 1.2126221656799316 }; static float FCbias[NUM_CLASSES] = { 0.7145490646362305, 0.2392704039812088, 0.7243489027023315, -0.3943518102169037, -0.7943000793457031, 0.18482555449008942, 0.29146698117256165, -0.04441819712519646, 1.5886560678482056, -0.8504140377044678 }; @@ -70,8 +70,8 @@ int main() { .uRank = USPS_URANK, .Bg = USPS_Bg, .Bh = USPS_Bh, - .zeta = USPS_zeta, - .nu = USPS_nu + .sigmoid_zeta = USPS_sigmoid_zeta, + .sigmoid_nu = USPS_sigmoid_nu }; float preComp[HIDDEN_DIMS] = { 0.0 }; diff --git a/c_reference/tests/rnnpool/test_rnnpool.c b/c_reference/tests/rnnpool/test_rnnpool.c index bba0434bf..f97a16786 100644 --- a/c_reference/tests/rnnpool/test_rnnpool.c +++ b/c_reference/tests/rnnpool/test_rnnpool.c @@ -22,8 +22,8 @@ int main() { .U = U1, .Bg = Bg1, .Bh = Bh1, - .zeta = zeta1, - .nu = nu1 + .sigmoid_zeta = sigmoid_zeta1, + .sigmoid_nu = sigmoid_nu1 }; FastGRNN_Params rnn2_params = { @@ -33,8 +33,8 @@ int main() { .U = U2, .Bg = Bg2, .Bh = Bh2, - .zeta = zeta2, - .nu = nu2 + .sigmoid_zeta = sigmoid_zeta2, + .sigmoid_nu = sigmoid_nu2 }; float preComp1[HIDDEN_DIMS1]; diff --git a/c_reference/tests/rnnpool/vww_model/rnn1.h b/c_reference/tests/rnnpool/vww_model/rnn1.h index 4937d6b6c..7357f2664 100644 --- a/c_reference/tests/rnnpool/vww_model/rnn1.h +++ b/c_reference/tests/rnnpool/vww_model/rnn1.h @@ -5,5 +5,5 @@ static float U1[HIDDEN_DIMS1 * HIDDEN_DIMS1] = { 4.257509708404541016e-01,-2.243 static float Bg1[HIDDEN_DIMS1] = { -1.213001132011413574e+00,-3.357241451740264893e-01,-1.219372987747192383e+00,-2.052456587553024292e-01,-7.755046486854553223e-01,-7.103578448295593262e-01,-8.887031674385070801e-01,-5.140971541404724121e-01}; static float Bh1[HIDDEN_DIMS1] = { -2.761822193861007690e-02,3.516794741153717041e-01,7.828953266143798828e-01,7.023379206657409668e-01,5.146764516830444336e-01,7.880625128746032715e-01,1.113372668623924255e-01,6.815895438194274902e-02 }; -static float zeta1 = 9.999979734420776367e-01; -static float nu1 = 1.968302512977970764e-06; +static float sigmoid_zeta1 = 9.999979734420776367e-01; +static float sigmoid_nu1 = 1.968302512977970764e-06; diff --git a/c_reference/tests/rnnpool/vww_model/rnn2.h b/c_reference/tests/rnnpool/vww_model/rnn2.h index cf8325a5d..1d6efca32 100644 --- a/c_reference/tests/rnnpool/vww_model/rnn2.h +++ b/c_reference/tests/rnnpool/vww_model/rnn2.h @@ -4,5 +4,5 @@ static float U2[HIDDEN_DIMS2 * HIDDEN_DIMS2] = { 3.934212923049926758e-01,-4.295 static float Bg2[HIDDEN_DIMS2] = { -1.537145614624023438e+00,-6.593755483627319336e-01,-8.165745735168457031e-01,-1.047435641288757324e+00,-1.003585577011108398e+00,-1.275580763816833496e+00,-9.717565178871154785e-01,-1.349884271621704102e+00 }; static float Bh2[HIDDEN_DIMS2] = { 1.249589323997497559e+00,2.501939237117767334e-01,3.707601428031921387e-01,1.205096021294593811e-01,6.529558449983596802e-02,-2.186506539583206177e-01,-1.120083108544349670e-01,-1.578094959259033203e+00 }; -static float zeta2 = 9.999979734420776367e-01; -static float nu2 = 1.968388687600963749e-06; +static float sigmoid_zeta2 = 9.999979734420776367e-01; +static float sigmoid_nu2 = 1.968388687600963749e-06; From 2c4cfea3b18a56e95c7bc7bd3a94156f27c7df1d Mon Sep 17 00:00:00 2001 From: Oindrila Saha Date: Tue, 28 Apr 2020 19:13:03 +0000 Subject: [PATCH 12/15] add face detection test --- c_reference/tests/Makefile | 5 +- c_reference/tests/rnnpool/face_model/rnn1.h | 10 +++ c_reference/tests/rnnpool/face_model/rnn2.h | 9 +++ c_reference/tests/rnnpool/test_rnnpool_face.c | 68 +++++++++++++++++++ .../rnnpool/traces_face/trace_0_0_input.h | 4 ++ .../rnnpool/traces_face/trace_0_0_output.h | 3 + 6 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 c_reference/tests/rnnpool/face_model/rnn1.h create mode 100644 c_reference/tests/rnnpool/face_model/rnn2.h create mode 100644 c_reference/tests/rnnpool/test_rnnpool_face.c create mode 100644 c_reference/tests/rnnpool/traces_face/trace_0_0_input.h create mode 100644 c_reference/tests/rnnpool/traces_face/trace_0_0_output.h diff --git a/c_reference/tests/Makefile b/c_reference/tests/Makefile index ef6c5e395..10486f9b9 100644 --- a/c_reference/tests/Makefile +++ b/c_reference/tests/Makefile @@ -7,7 +7,7 @@ INCLUDE_DIR=../include SRC_DIR=../src IFLAGS = -I $(INCLUDE_DIR) -all: test_fastgrnn_lr test_rnnpool +all: test_fastgrnn_lr test_rnnpool test_rnnpool_face FASTGRNN_DIR=fastgrnn test_fastgrnn_lr: $(FASTGRNN_DIR)/test_fastgrnn_lr.c $(SRC_DIR)/utils.o $(SRC_DIR)/fastgrnn.o $(SRC_DIR)/classifier.o @@ -17,6 +17,9 @@ RNNPOOL_DIR=rnnpool test_rnnpool: $(RNNPOOL_DIR)/test_rnnpool.c $(SRC_DIR)/utils.o $(SRC_DIR)/fastgrnn.o $(SRC_DIR)/rnnpool.o $(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm +test_rnnpool_face: $(RNNPOOL_DIR)/test_rnnpool_face.c $(SRC_DIR)/utils.o $(SRC_DIR)/fastgrnn.o $(SRC_DIR)/rnnpool.o + $(CC) -o $@ $^ $(IFLAGS) $(CFLAGS) -lm + .PHONY: clean cleanest diff --git a/c_reference/tests/rnnpool/face_model/rnn1.h b/c_reference/tests/rnnpool/face_model/rnn1.h new file mode 100644 index 000000000..cc258c3da --- /dev/null +++ b/c_reference/tests/rnnpool/face_model/rnn1.h @@ -0,0 +1,10 @@ +#define HIDDEN_DIMS1 8 + +static float W1[INPUT_DIMS * HIDDEN_DIMS1] = {0.05728379637002945, -0.017023758962750435, 0.25396355986595154, -0.5767111778259277, 0.0729413703083992, -0.06401490420103073, 0.016082603484392166, -0.17516161501407623, -0.9113835096359253, -0.3674522042274475, 0.10634513199329376, 0.36516982316970825, -0.31638288497924805, 0.48142242431640625, 0.052355583757162094, -0.2822858393192291, 0.020806409418582916, 0.08521196246147156, 0.05745209380984306, -0.12961868941783905, 0.646435022354126, 0.37815287709236145, -0.16816243529319763, -0.561792254447937, -0.08903513103723526, 0.17326748371124268, 0.23540081083774567, 0.18699470162391663, 0.7498922348022461, -0.6905604600906372, -0.10880530625581741, 0.15561559796333313}; +static float U1[HIDDEN_DIMS1 * HIDDEN_DIMS1] = {0.0885470062494278, 0.10189718753099442, 0.011457864195108414, -0.0054266913793981075, -0.11213689297437668, 0.055597949773073196, 0.023726800456643105, -0.04273271933197975, -0.646082878112793, 0.23134475946426392, -0.5081114768981934, 0.7146762609481812, -0.5283030271530151, 0.3773706555366516, 0.2069741189479828, 0.11082419008016586, 0.38814792037010193, 0.2782214879989624, -0.10075654089450836, -0.2194112241268158, 0.420135498046875, 0.3382737636566162, -0.10525326430797577, -0.15444065630435944, -0.09867070615291595, 0.03839907795190811, 0.14474035799503326, 0.1666630655527115, -0.06800684332847595, -0.11181867122650146, -0.06382069736719131, -0.03409789502620697, 0.02659057267010212, 0.21766456961631775, -0.057335011661052704, -0.10353385657072067, 0.03269200772047043, 0.018621621653437614, -0.18908125162124634, 0.3619883954524994, -0.6322037577629089, -0.1528451144695282, 0.5752084255218506, -0.26842501759529114, -0.3435758948326111, -0.05781722441315651, -0.14717720448970795, -0.013333129696547985, 0.095060795545578, -0.21655549108982086, 0.5354421138763428, 0.15595898032188416, -0.5853599905967712, 0.21818533539772034, 0.07148981094360352, 0.2145569622516632, -0.2858271598815918, -0.29919153451919556, -0.0278799906373024, 1.235137939453125, -0.17514251172542572, -0.03214624151587486, 0.08009274303913116, 0.03380195423960686}; +static float Bg1[HIDDEN_DIMS1] = {0.08699623495340347, 0.10146532207727432, 0.1157333254814148, -0.5457881689071655, -0.12949803471565247, -0.0922124832868576, 0.05129539594054222, 0.20176301896572113}; +static float Bh1[HIDDEN_DIMS1] = {0.529672384262085, 0.2443077713251114, 0.6968744993209839, 0.3934999406337738, 1.0972073078155518, 0.4284772276878357, 0.2538343369960785, 0.29379019141197205}; + +static float sigmoid_zeta1 = 1.0; +static float sigmoid_nu1 = 2.6489594e-30; + diff --git a/c_reference/tests/rnnpool/face_model/rnn2.h b/c_reference/tests/rnnpool/face_model/rnn2.h new file mode 100644 index 000000000..12115e64b --- /dev/null +++ b/c_reference/tests/rnnpool/face_model/rnn2.h @@ -0,0 +1,9 @@ +static float W2[HIDDEN_DIMS1 * HIDDEN_DIMS2] = {-0.27843931317329407, 0.7430717945098877, -0.0653676837682724, 0.0661972314119339, -0.5902142524719238, 0.13223540782928467, 0.19362707436084747, -0.4009245038032532, -0.1389789581298828, -0.21446110308170319, -0.23559026420116425, 0.39521726965904236, -0.5871433615684509, -0.40856194496154785, -0.48501619696617126, -0.02906256541609764, 0.508455216884613, -0.8196758031845093, 0.12408386170864105, -0.21606920659542084, -0.6777727007865906, 0.018213029950857162, -0.19179263710975647, 0.03546636179089546, 0.05343775078654289, 0.11252386122941971, -0.12614335119724274, -0.034954532980918884, -0.3433290421962738, -0.02379862777888775, -0.15605230629444122, -0.6679574847221375, 0.1207231655716896, 0.05915882810950279, -0.11480199545621872, 0.07342526316642761, -0.21928471326828003, -0.03171790391206741, -0.10479358583688736, -0.2953641712665558, 0.2769709527492523, -0.1657114028930664, -0.2848057448863983, -0.30946552753448486, -0.13970626890659332, -0.2841068506240845, -0.6684054732322693, -0.29907721281051636, -0.6760978102684021, -0.33453479409217834, 0.11317259073257446, -0.12374911457300186, -0.6061263680458069, 0.030005907639861107, -0.09125818312168121, 0.14368315041065216, -0.03244452923536301, 0.2922135591506958, -0.08628516644239426, 0.41961148381233215, -0.5010040402412415, -0.39320141077041626, 0.44576042890548706, 0.11532633751630783}; +static float U2[HIDDEN_DIMS2 * HIDDEN_DIMS2] = {0.11734726279973984, 0.38112249970436096, 0.7858313918113708, 0.07527834177017212, -0.25792068243026733, 0.15327812731266022, -0.07941184192895889, 0.012267069891095161, -0.09274256229400635, 0.36783820390701294, 0.3409440815448761, -0.0008370502619072795, -0.12084104120731354, 0.11360836029052734, -0.05575798079371452, 0.03235398605465889, 0.08827289938926697, -0.328266978263855, -0.0290474034845829, -0.040406424552202225, 0.3042513132095337, 0.08566228300333023, 0.15502256155014038, 0.0895792543888092, 0.14711031317710876, -0.035015176981687546, -0.19980542361736298, 0.27223655581474304, 0.21671053767204285, 0.14100730419158936, -0.4369487762451172, -0.2991533577442169, -0.12695346772670746, 0.06976692378520966, -0.8318540453910828, -0.11838176846504211, 0.27047157287597656, -0.4010297656059265, -0.11338013410568237, 0.24676059186458588, -0.022850319743156433, 0.036909811198711395, -0.2776567339897156, -0.01747751794755459, -0.03485561162233353, 0.19962218403816223, 0.09315236657857895, -0.09986457973718643, -0.05474138259887695, 0.09654474258422852, -0.15123814344406128, 0.18227840960025787, -0.029120849445462227, -0.23944710195064545, 0.21565955877304077, 0.10081177204847336, -0.0407288521528244, 0.27885398268699646, 0.2105490118265152, 0.27249160408973694, -0.14735695719718933, 0.23237888514995575, -0.3467356562614441, -0.11808214336633682}; + +static float Bg2[HIDDEN_DIMS2] = {-0.009815464727580547, 0.1790345311164856, 0.15949344635009766, 0.07449029386043549, 0.2533033490180969, -0.015116404742002487, 0.13510125875473022, 0.3280749022960663}; +static float Bh2[HIDDEN_DIMS2] = {0.5673038363456726, 0.7345506548881531, 0.699255108833313, 0.8589223027229309, 0.8605647683143616, 0.9171470403671265, 0.7011861205101013, 0.4001118838787079}; + +static float sigmoid_zeta2 = 1.0; +static float sigmoid_nu2 = 2.6489594e-30; + diff --git a/c_reference/tests/rnnpool/test_rnnpool_face.c b/c_reference/tests/rnnpool/test_rnnpool_face.c new file mode 100644 index 000000000..977fd56d5 --- /dev/null +++ b/c_reference/tests/rnnpool/test_rnnpool_face.c @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT license. + +#include +#include + +#include "utils.h" +#include "fastgrnn.h" +#include "rnnpool.h" + +#include "traces_face/trace_0_0_input.h" +#include "traces_face/trace_0_0_output.h" + +#include "face_model/rnn1.h" +#include "face_model/rnn2.h" + +int main() { + FastGRNN_Params rnn1_params = { + .mean = NULL, + .stdDev = NULL, + .W = W1, + .U = U1, + .Bg = Bg1, + .Bh = Bh1, + .sigmoid_zeta = sigmoid_zeta1, + .sigmoid_nu = sigmoid_nu1 + }; + + FastGRNN_Params rnn2_params = { + .mean = NULL, + .stdDev = NULL, + .W = W2, + .U = U2, + .Bg = Bg2, + .Bh = Bh2, + .sigmoid_zeta = sigmoid_zeta2, + .sigmoid_nu = sigmoid_nu2 + }; + + float preComp1[HIDDEN_DIMS1]; + float normFeatures1[INPUT_DIMS]; + memset(preComp1, 0, sizeof(float) * HIDDEN_DIMS1); + memset(normFeatures1, 0, sizeof(float) * INPUT_DIMS); + FastGRNN_Buffers rnn1_buffers = { + .preComp = preComp1, + .normFeatures = normFeatures1 + }; + + float preComp2[HIDDEN_DIMS2]; + float normFeatures2[HIDDEN_DIMS1]; + memset(preComp2, 0, sizeof(float) * HIDDEN_DIMS2); + memset(normFeatures2, 0, sizeof(float) * HIDDEN_DIMS1); + FastGRNN_Buffers rnn2_buffers = { + .preComp = preComp2, + .normFeatures = normFeatures2 + }; + + float output_test[4 * HIDDEN_DIMS2]; + float buffer[HIDDEN_DIMS1 * PATCH_DIM]; + memset(output_test, 0, sizeof(float) * 4 * HIDDEN_DIMS2); + memset(buffer, 0, sizeof(float) * HIDDEN_DIMS1 * PATCH_DIM); + rnnpool_block(input, INPUT_DIMS, PATCH_DIM, PATCH_DIM, + fastgrnn, HIDDEN_DIMS1, (const void*)(&rnn1_params), (void*)(&rnn1_buffers), + fastgrnn, HIDDEN_DIMS2, (const void*)(&rnn2_params), (void*)(&rnn2_buffers), + output_test, buffer); + + printf("Error: %f\n", l2squared(output, output_test, 4 * HIDDEN_DIMS2)); +} diff --git a/c_reference/tests/rnnpool/traces_face/trace_0_0_input.h b/c_reference/tests/rnnpool/traces_face/trace_0_0_input.h new file mode 100644 index 000000000..ef84d2ba7 --- /dev/null +++ b/c_reference/tests/rnnpool/traces_face/trace_0_0_input.h @@ -0,0 +1,4 @@ +#define INPUT_DIMS 4 +#define PATCH_DIM 8 + +static float input[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = {6.0, 3.864753484725952, 0.5032913684844971, 3.255429744720459, 3.4451184272766113, 6.0, 0.0, 0.6251522898674011, 2.5907797813415527, 6.0, 0.0, 0.6076173782348633, 2.5656816959381104, 6.0, 0.0, 0.5852630138397217, 2.495943307876587, 6.0, 0.0, 0.6127088665962219, 2.5315134525299072, 6.0, 0.0, 0.6456913948059082, 2.6090714931488037, 6.0, 0.0, 0.625369131565094, 2.5917551517486572, 6.0, 0.0, 0.5990842580795288, 6.0, 2.52181339263916, 2.0759196281433105, 2.896498203277588, 2.7697253227233887, 1.2512624263763428, 0.0, 0.07762821763753891, 1.819283127784729, 0.8549618124961853, 0.28929558396339417, 0.11453191936016083, 1.770524501800537, 0.9794550538063049, 0.2607428729534149, 0.07501084357500076, 1.6674928665161133, 0.9763496518135071, 0.2539285123348236, 0.11171048134565353, 1.7360005378723145, 1.0677502155303955, 0.28240182995796204, 0.08302449434995651, 1.7945091724395752, 1.0302512645721436, 0.26797160506248474, 0.06604445725679398, 1.818042278289795, 0.9007982611656189, 0.33631449937820435, 0.04834849387407303, 6.0, 2.857222318649292, 1.7300541400909424, 2.761772632598877, 1.7147572040557861, 1.0199624300003052, 0.0, 0.0, 0.8881229758262634, 0.7385762929916382, 0.2987729609012604, 0.0, 0.8871542811393738, 0.8776090145111084, 0.2119949907064438, 0.0, 0.7790001034736633, 0.8657834529876709, 0.22355401515960693, 0.0, 0.8204374313354492, 0.8970885872840881, 0.17433103919029236, 0.0, 0.7232602834701538, 0.8705824017524719, 0.17848879098892212, 0.0, 0.8223532438278198, 0.821057915687561, 0.20487169921398163, 0.0, 6.0, 2.889732837677002, 1.73497474193573, 2.7736072540283203, 1.6566625833511353, 0.9712777137756348, 0.0, 0.0, 1.0266156196594238, 0.6869328022003174, 0.38472726941108704, 0.0, 1.0866038799285889, 0.5747660994529724, 0.3301611840724945, 0.0, 0.9952712059020996, 0.540087103843689, 0.4362652003765106, 0.0, 0.9960271120071411, 0.5620536208152771, 0.3680923581123352, 0.0, 0.8625692129135132, 0.6513324975967407, 0.3328498601913452, 0.0, 0.8319399952888489, 0.8554271459579468, 0.22382153570652008, 0.0, 6.0, 2.863884449005127, 1.7456568479537964, 2.7763559818267822, 1.6321651935577393, 0.9665762782096863, 0.0, 0.0, 0.8071596026420593, 0.7250034213066101, 0.29839715361595154, 0.0, 0.8920531272888184, 0.4664871394634247, 0.2740165889263153, 0.0, 0.8944334387779236, 0.49432384967803955, 0.38937121629714966, 0.0, 0.9263056516647339, 0.552474319934845, 0.355324387550354, 0.0, 1.0150401592254639, 0.6216723918914795, 0.3391576409339905, 0.0, 0.9298738837242126, 0.7536592483520508, 0.24314981698989868, 0.0, 6.0, 2.888258457183838, 1.746010661125183, 2.7819788455963135, 1.6302540302276611, 1.062531590461731, 0.0, 0.0, 0.5961711406707764, 0.8987787365913391, 0.21776816248893738, 0.0, 0.6889306306838989, 0.804358959197998, 0.24634431302547455, 0.0, 0.8192529082298279, 0.8337866067886353, 0.22248630225658417, 0.0, 0.8940339684486389, 0.8404994010925293, 0.24657337367534637, 0.0, 1.022047996520996, 0.8240443468093872, 0.250453919172287, 0.0, 0.9583666324615479, 0.6557619571685791, 0.28978031873703003, 0.0, 6.0, 2.871509075164795, 1.7325565814971924, 2.785510301589966, 1.7297027111053467, 1.039949655532837, 0.0, 0.0, 0.6579188704490662, 0.7792840600013733, 0.2451086938381195, 0.0, 0.7413042187690735, 0.8059958219528198, 0.25876089930534363, 0.0, 0.7776035666465759, 0.8340652585029602, 0.19460541009902954, 0.0, 0.8829543590545654, 0.8143356442451477, 0.20926976203918457, 0.0, 0.838544487953186, 0.7972683310508728, 0.2223927527666092, 0.0, 0.8580051064491272, 0.5966948866844177, 0.391480416059494, 0.0, 6.0, 2.843898296356201, 1.7411582469940186, 2.779827356338501, 1.7269408702850342, 0.906764030456543, 0.0, 0.00856995489448309, 0.7447397112846375, 0.608645498752594, 0.37833335995674133, 0.0, 0.8624472618103027, 0.7215278744697571, 0.4094668924808502, 0.012554308399558067, 0.8872826099395752, 0.7605844736099243, 0.3559991717338562, 0.015747377648949623, 0.977584183216095, 0.9043928384780884, 0.30597585439682007, 0.0, 0.6844930052757263, 0.8694248795509338, 0.257193386554718, 0.0, 0.7443139553070068, 0.8488321304321289, 0.3280007243156433, 0.0}; \ No newline at end of file diff --git a/c_reference/tests/rnnpool/traces_face/trace_0_0_output.h b/c_reference/tests/rnnpool/traces_face/trace_0_0_output.h new file mode 100644 index 000000000..8b481492e --- /dev/null +++ b/c_reference/tests/rnnpool/traces_face/trace_0_0_output.h @@ -0,0 +1,3 @@ +#define HIDDEN_DIMS2 8 + +static float output[4 * HIDDEN_DIMS2] = {0.18747223913669586, 0.11261644959449768, 0.37986981868743896, 0.31620317697525024, 0.24251127243041992, 0.20095956325531006, -0.19935834407806396, 0.2894618511199951, 0.4219159483909607, 0.34062182903289795, -0.17108939588069916, 0.5273934602737427, 0.42910921573638916, 0.55300372838974, -0.4337252378463745, 0.2671497166156769, 0.17525342106819153, 0.13307057321071625, 0.4045558571815491, 0.32742565870285034, 0.24330148100852966, 0.22258351743221283, -0.1840265989303589, 0.2804866433143616, 0.30392521619796753, 0.14001306891441345, 0.10221753269433975, 0.399106502532959, 0.15672656893730164, 0.5337148308753967, 0.11137562245130539, 0.03801737353205681}; \ No newline at end of file From ed8505bf12214d62a6a8e8c701a1880a47b2c8bb Mon Sep 17 00:00:00 2001 From: Oindrila Saha Date: Thu, 30 Apr 2020 05:17:31 +0000 Subject: [PATCH 13/15] add header file --- .../ConvertNumpytoHeaderFilesRNNPool.py | 158 ++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py diff --git a/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py b/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py new file mode 100644 index 000000000..271c0a0dd --- /dev/null +++ b/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py @@ -0,0 +1,158 @@ +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. + +import numpy as np +import argparse +import os +import sys + +def sigmoid(x): + return 1.0 / (1.0 + np.exp(-x)) + +def loadTestData(dataDir): + test_input = np.load(dataDir + "/test_input.npy") + test_output = np.load(dataDir + "/test_output.npy") + return test_input, test_output + + +def loadModel(modelDir): + model = { + "W1": np.transpose(np.load(modelDir + "/W1.npy")), + "W2": np.transpose(np.load(modelDir + "/W2.npy")), + "U1": np.transpose(np.load(modelDir + "/U1.npy")), + "U2": np.transpose(np.load(modelDir + "/U2.npy")), + "Bg1": np.load(modelDir + "/Bg1.npy"), + "Bh1": np.load(modelDir + "/Bh1.npy"), + "Bg2": np.load(modelDir + "/Bg2.npy"), + "Bh2": np.load(modelDir + "/Bh2.npy"), + "zeta1": sigmoid(np.load(modelDir + "/zeta1.npy")), + "nu1": sigmoid(np.load(modelDir + "/nu1.npy")), + "zeta2": sigmoid(np.load(modelDir + "/zeta2.npy")), + "nu2": sigmoid(np.load(modelDir + "/nu2.npy")), + } + + return model + + + +def getArgs(): + ''' + Function to parse arguments for FastCells + ''' + parser = argparse.ArgumentParser( + description='HyperParams for Fast(G)RNN inference') + + parser.add_argument('-mdir', '--model-dir', required=True, + help='Model directory containing' + + 'FastRNN or FastGRNN model') + + parser.add_argument('-rnn1oF', '--rnn1-out-file', default="None", + help='Give a output file for the model to dump' + + 'default: stdout') + + parser.add_argument('-rnn2oF', '--rnn2-out-file', default="None", + help='Give a output file for the model to dump' + + 'default: stdout') + + parser.add_argument('-doF', '--data-out-file', default="None", + help='Give a output file for the data to dump' + + 'default: stdout') + + return parser.parse_args() + + +def saveReadableModel(modelDir, model): + if os.path.isdir(modelDir + '/ReadableModel') is False: + try: + os.mkdir(modelDir + '/ReadableModel') + except OSError: + print("Creation of the directory %s failed" % + modelDir + '/ReadableModel') + currDir = modelDir + '/ReadableModel' + + np.savetxt(currDir + "/W1.txt", + np.reshape(model["W1"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/W2.txt", + np.reshape(model["W2"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/U1.txt", + np.reshape(model["U1"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/U2.txt", + np.reshape(model["U2"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/Bg1.txt", + np.reshape(model["Bg1"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/Bh1.txt", + np.reshape(model["Bh1"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/Bg2.txt", + np.reshape(model["Bg2"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/Bh2.txt", + np.reshape(model["Bh2"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/zeta1.txt", + np.reshape(model["zeta1"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/nu1.txt", + np.reshape(model["nu1"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/zeta2.txt", + np.reshape(model["zeta2"], [1, -1]), delimiter=',') + np.savetxt(currDir + "/nu2.txt", + np.reshape(model["nu2"], [1, -1]), delimiter=',') + + return currDir + + +def convertMatrixToVecString(mat): + mat = str(np.reshape(mat, [1, -1])[0, :].tolist()) + mat = '{' + mat[1:-1] + '}' + return mat + + +def main(): + args = getArgs() + rnn1OutFile = args.rnn1_out_file + rnn2OutFile = args.rnn2_out_file + + rnn1OutFile = open(rnn1OutFile, 'w') + rnn2OutFile = open(rnn2OutFile, 'w') + + model = loadModel(args.model_dir) + + + inputDims = model["W1"].shape[1] + hiddenDims1 = model["W2"].shape[1] + hiddenDims2 = model["U2"].shape[1] + + + currDir = saveReadableModel(args.model_dir, model) + + print ("#define HIDDEN_DIMS1 8\n", file=rnn1OutFile) + + print("static float W1[INPUT_DIMS * HIDDEN_DIMS1] = " + convertMatrixToVecString(model['W1']) + ";", file=rnn1OutFile) + + print("static float U1[HIDDEN_DIMS1 * HIDDEN_DIMS1] = " + convertMatrixToVecString(model['U1']) + ";", file=rnn1OutFile) + + print("static float Bg1[HIDDEN_DIMS1] = " + convertMatrixToVecString(model['Bg1']) + ";", file=rnn1OutFile) + print("static float Bh1[HIDDEN_DIMS1] = " + + convertMatrixToVecString(model['Bh1']) + ";\n", file=rnn1OutFile) + + print("static float sigmoid_zeta1 = " + str(model['zeta1'][0][0]) + ";", file=rnn1OutFile) + print("static float sigmoid_nu1 = " + str(model['nu1'][0][0]) + ";\n", file=rnn1OutFile) + + + print("static float W2[HIDDEN_DIMS1 * HIDDEN_DIMS2] = " + convertMatrixToVecString(model['W2']) + ";", file=rnn2OutFile) + + print("static float U2[HIDDEN_DIMS2 * HIDDEN_DIMS2] = " + convertMatrixToVecString(model['U2']) + ";\n", file=rnn2OutFile) + + print("static float Bg2[HIDDEN_DIMS2] = " + convertMatrixToVecString(model['Bg2']) + ";", file=rnn2OutFile) + print("static float Bh2[HIDDEN_DIMS2] = " + + convertMatrixToVecString(model['Bh2']) + ";\n", file=rnn2OutFile) + + print("static float sigmoid_zeta2 = " + str(model['zeta2'][0][0]) + ";", file=rnn2OutFile) + print("static float sigmoid_nu2 = " + str(model['nu2'][0][0]) + ";\n", file=rnn2OutFile) + + + + + rnn1OutFile.flush() + rnn1OutFile.close() + rnn2OutFile.flush() + rnn2OutFile.close() + +main() \ No newline at end of file From 60eed7835cb3823de4d5b50d48668d876685c848 Mon Sep 17 00:00:00 2001 From: Oindrila Saha Date: Sun, 3 May 2020 07:55:38 +0000 Subject: [PATCH 14/15] converter with traces saving and readme --- .../ConvertNumpytoHeaderFilesRNNPool.py | 95 ++++++++++++------- c_reference/tests/converters/README.md | 19 ++++ 2 files changed, 82 insertions(+), 32 deletions(-) create mode 100644 c_reference/tests/converters/README.md diff --git a/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py b/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py index 271c0a0dd..a663d83ac 100644 --- a/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py +++ b/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py @@ -9,10 +9,37 @@ def sigmoid(x): return 1.0 / (1.0 + np.exp(-x)) -def loadTestData(dataDir): - test_input = np.load(dataDir + "/test_input.npy") - test_output = np.load(dataDir + "/test_output.npy") - return test_input, test_output +def saveTraces(tracesInputDir, tracesOutputDir): + if os.path.isdir(tracesOutputDir) is False: + try: + os.mkdir(tracesOutputDir) + except OSError: + print("Creation of the directory %s failed" % tracesOutputDir) + return + input_files = os.listdir(tracesInputDir+'/inputs/') + + for file in input_files: + trace_input = np.load(tracesInputDir + "/inputs/" + file) + trace_output = np.load(tracesInputDir + "/outputs/" + file) + + inputDims = trace_input.shape[-1] + patchDim = trace_input.shape[-2] + hiddenDims2 = int(trace_output.shape[0]/4) + + f_input = open(tracesOutputDir+'/'+str(file)[:-4]+'_input.h','w') + f_output = open(tracesOutputDir+'/'+str(file)[:-4]+'_output.h','w') + f_input.write('#define INPUT_DIMS '+str(inputDims)+'\n#define PATCH_DIM '+ str(patchDim)+'\n\n') + f_output.write('#define HIDDEN_DIMS2'+str(hiddenDims2)+'\n\n') + + f_input.write('static float input[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = ' + convertMatrixToVecString(trace_input) + ';') + f_output.write('static float output[4 * HIDDEN_DIMS2] = ' + convertMatrixToVecString(trace_output) + ';') + + f_input.flush() + f_input.close() + f_output.flush() + f_output.close() + + def loadModel(modelDir): @@ -34,29 +61,31 @@ def loadModel(modelDir): return model - def getArgs(): ''' Function to parse arguments for FastCells ''' parser = argparse.ArgumentParser( - description='HyperParams for Fast(G)RNN inference') + description='HyperParams for RNNPool inference') - parser.add_argument('-mdir', '--model-dir', required=True, + parser.add_argument('-mdir', '--model-dir', required=False, default=None, help='Model directory containing' + - 'FastRNN or FastGRNN model') + 'RNNPool model') - parser.add_argument('-rnn1oF', '--rnn1-out-file', default="None", - help='Give a output file for the model to dump' + - 'default: stdout') + parser.add_argument('-tidir', '--trace-input-dir', required=False, default=None, + help='Directory containing RnnPool input output numpy traces') - parser.add_argument('-rnn2oF', '--rnn2-out-file', default="None", - help='Give a output file for the model to dump' + + parser.add_argument('-todir', '--trace-output-dir', required=False, default=None, + help='Output Directory for saving RnnPool input output .h traces') + + parser.add_argument('-rnn1oF', '--rnn1-out-file', default=None, + help='Give a output header file name for the model to dump rnn1 weights' + 'default: stdout') - parser.add_argument('-doF', '--data-out-file', default="None", - help='Give a output file for the data to dump' + + parser.add_argument('-rnn2oF', '--rnn2-out-file', default=None, + help='Give a output header file name for the model to dump rnn2 weights' + 'default: stdout') + return parser.parse_args() @@ -104,24 +133,10 @@ def convertMatrixToVecString(mat): return mat -def main(): - args = getArgs() - rnn1OutFile = args.rnn1_out_file - rnn2OutFile = args.rnn2_out_file - +def saveModelHeader(rnn1OutFile, rnn2OutFile, model): rnn1OutFile = open(rnn1OutFile, 'w') rnn2OutFile = open(rnn2OutFile, 'w') - model = loadModel(args.model_dir) - - - inputDims = model["W1"].shape[1] - hiddenDims1 = model["W2"].shape[1] - hiddenDims2 = model["U2"].shape[1] - - - currDir = saveReadableModel(args.model_dir, model) - print ("#define HIDDEN_DIMS1 8\n", file=rnn1OutFile) print("static float W1[INPUT_DIMS * HIDDEN_DIMS1] = " + convertMatrixToVecString(model['W1']) + ";", file=rnn1OutFile) @@ -148,11 +163,27 @@ def main(): print("static float sigmoid_nu2 = " + str(model['nu2'][0][0]) + ";\n", file=rnn2OutFile) - - rnn1OutFile.flush() rnn1OutFile.close() rnn2OutFile.flush() rnn2OutFile.close() + + +def main(): + args = getArgs() + + if args.model_dir is not None: + model = loadModel(args.model_dir) + currDir = saveReadableModel(args.model_dir, model) + if args.rnn1_out_file is not None and args.rnn2_out_file is not None: + saveModelHeader(args.rnn1_out_file, args.rnn2_out_file, model) + else: + print('Not saving output header files as names are not specified') + + + if args.trace_input_dir is not None and args.trace_output_dir is not None: + saveTraces(args.trace_input_dir, args.trace_output_dir) + + main() \ No newline at end of file diff --git a/c_reference/tests/converters/README.md b/c_reference/tests/converters/README.md new file mode 100644 index 000000000..135903c48 --- /dev/null +++ b/c_reference/tests/converters/README.md @@ -0,0 +1,19 @@ +# Code for Converting Numpy Model Weights/Traces to Header Files + + +## RNNPool + +Specify the path to model weights saved in numpy format in and path to input output traces saved in numpy format in . Specify folder to save converted header files for first rnn (which does the row-wise/column-wise traversal) of RNNPool in and that of second rnn (which does the bidirectional summarization of outputs of first rnn pass) in . + +```shell + +python3 ConvertNumpytoHeaderFilesRNNPool.py --model-dir -tidir -todir -rnn1oF -rnn2oF + +``` + +eg. +```shell + +python3 ConvertNumpytoHeaderFilesRNNPool.py --model-dir ./model_weights_face -tidir ./model_traces_face -todir ./traces_headers -rnn1oF rnn1.h -rnn2oF rnn2.h + +``` \ No newline at end of file From ea882c36580dd2202cccab6d7e6e06c3e359c70c Mon Sep 17 00:00:00 2001 From: Oindrila Saha Date: Mon, 4 May 2020 03:37:54 +0000 Subject: [PATCH 15/15] converter update --- .../tests/converters/ConvertNumpytoHeaderFilesRNNPool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py b/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py index a663d83ac..906fedc24 100644 --- a/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py +++ b/c_reference/tests/converters/ConvertNumpytoHeaderFilesRNNPool.py @@ -29,7 +29,7 @@ def saveTraces(tracesInputDir, tracesOutputDir): f_input = open(tracesOutputDir+'/'+str(file)[:-4]+'_input.h','w') f_output = open(tracesOutputDir+'/'+str(file)[:-4]+'_output.h','w') f_input.write('#define INPUT_DIMS '+str(inputDims)+'\n#define PATCH_DIM '+ str(patchDim)+'\n\n') - f_output.write('#define HIDDEN_DIMS2'+str(hiddenDims2)+'\n\n') + f_output.write('#define HIDDEN_DIMS2 '+str(hiddenDims2)+'\n\n') f_input.write('static float input[INPUT_DIMS * PATCH_DIM * PATCH_DIM] = ' + convertMatrixToVecString(trace_input) + ';') f_output.write('static float output[4 * HIDDEN_DIMS2] = ' + convertMatrixToVecString(trace_output) + ';')