diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0d551fbf3d..5b58986942 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -940,18 +940,6 @@ COMMAND $ --verbose --input 8 3 108 108 --weights 63 1 if(MIOPEN_TEST_DEEPBENCH) add_custom_test(test_deepbench_rnn GFX94X_ENABLED GFX103X_ENABLED GFX110X_ENABLED - COMMAND $ --verbose --batch-size 16 --seq-len 50 --vector-len 1760 --hidden-size 1760 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 50 --vector-len 1760 --hidden-size 1760 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 64 --seq-len 50 --vector-len 1760 --hidden-size 1760 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 128 --seq-len 50 --vector-len 1760 --hidden-size 1760 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 16 --seq-len 50 --vector-len 2048 --hidden-size 2048 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 50 --vector-len 2048 --hidden-size 2048 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 64 --seq-len 50 --vector-len 2048 --hidden-size 2048 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 128 --seq-len 50 --vector-len 2048 --hidden-size 2048 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 16 --seq-len 50 --vector-len 2560 --hidden-size 2560 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 50 --vector-len 2560 --hidden-size 2560 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 64 --seq-len 50 --vector-len 2560 --hidden-size 2560 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 128 --seq-len 50 --vector-len 2560 --hidden-size 2560 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill COMMAND $ --verbose --batch-size 16 --seq-len 25 --vector-len 512 --hidden-size 512 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill COMMAND $ --verbose --batch-size 32 --seq-len 25 --vector-len 512 --hidden-size 512 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill COMMAND $ --verbose --batch-size 64 --seq-len 25 --vector-len 512 --hidden-size 512 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill @@ -974,77 +962,9 @@ if(MIOPEN_TEST_DEEPBENCH) COMMAND $ --verbose --batch-size 16 --seq-len 150 --vector-len 256 --hidden-size 256 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill COMMAND $ --verbose --batch-size 32 --seq-len 150 --vector-len 256 --hidden-size 256 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill COMMAND $ --verbose --batch-size 64 --seq-len 150 --vector-len 256 --hidden-size 256 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 1500 --vector-len 2816 --hidden-size 2816 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 750 --vector-len 2816 --hidden-size 2816 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 375 --vector-len 2816 --hidden-size 2816 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 187 --vector-len 2816 --hidden-size 2816 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 1500 --vector-len 2048 --hidden-size 2048 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 750 --vector-len 2048 --hidden-size 2048 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 375 --vector-len 2048 --hidden-size 2048 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 187 --vector-len 2048 --hidden-size 2048 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 1500 --vector-len 1536 --hidden-size 1536 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 750 --vector-len 1536 --hidden-size 1536 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 375 --vector-len 1536 --hidden-size 1536 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 187 --vector-len 1536 --hidden-size 1536 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 1500 --vector-len 2560 --hidden-size 2560 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 750 --vector-len 2560 --hidden-size 2560 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 375 --vector-len 2560 --hidden-size 2560 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 187 --vector-len 2560 --hidden-size 2560 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 1 --vector-len 512 --hidden-size 512 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 32 --seq-len 1500 --vector-len 1024 --hidden-size 1024 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill - COMMAND $ --verbose --batch-size 64 --seq-len 1500 --vector-len 1024 --hidden-size 1024 --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill ) endif() - -add_custom_test(test_rnn_extra SKIP_UNLESS_ALL GFX94X_ENABLED GFX103X_ENABLED GFX110X_ENABLED -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --no-hx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --no-hx --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 1 --no-hx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 1 --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 1 --no-hx --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 0 --no-hx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 0 --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 0 --no-hx --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 1 --no-hx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 1 --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 1 --no-hx --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --no-hy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --no-hy --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 1 --no-hy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 1 --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 1 --no-hy --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 0 --no-hy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 0 --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 0 --no-hy --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 1 --no-hy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 1 --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 1 --no-hy --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --no-hx --no-dhy --no-hy --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --rnn-mode 1 --no-hx --no-dhy --no-hy --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 0 --no-hx --no-dhy --no-hy --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --rnn-mode 1 --no-hx --no-dhy --no-hy --no-dhx -) - -add_custom_test(test_gru_extra SKIP_UNLESS_ALL GFX94X_ENABLED GFX103X_ENABLED GFX110X_ENABLED -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --no-hx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --no-hx --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --no-hx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --no-hx --no-dhy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --no-hy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --no-hy --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --no-hy -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --no-hy --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --no-hx --no-dhy --no-hy --no-dhx -COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 1 --no-hx --no-dhy --no-hy --no-dhx -) - add_custom_test(test_lstm_extra SKIP_UNLESS_ALL GFX94X_ENABLED GFX103X_ENABLED GFX110X_ENABLED COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --no-hx COMMAND $ --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 --hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0 -dir-mode 0 --no-dhy diff --git a/test/gru.cpp b/test/gru.cpp index dce9790b2c..f337c16785 100644 --- a/test/gru.cpp +++ b/test/gru.cpp @@ -24,45 +24,7 @@ * *******************************************************************************/ -#include "gru_common.hpp" - -template -struct gru_driver : gru_basic_driver -{ - gru_driver() : gru_basic_driver() - { - std::vector modes(2, 0); - modes[1] = 1; - std::vector defaultBS(1); - - this->add(this->batchSize, "batch-size", this->generate_data(get_gru_batchSize(), {17})); - this->add(this->seqLength, "seq-len", this->generate_data(get_gru_seq_len(), {2})); - this->add(this->inVecLen, "vector-len", this->generate_data(get_gru_vector_len())); - this->add(this->hiddenSize, "hidden-size", this->generate_data(get_gru_hidden_size())); - this->add(this->numLayers, "num-layers", this->generate_data(get_gru_num_layers())); - this->add(this->nohx, "no-hx", this->flag()); - this->add(this->nodhy, "no-dhy", this->flag()); - this->add(this->nohy, "no-hy", this->flag()); - this->add(this->nodhx, "no-dhx", this->flag()); - this->add(this->flatBatchFill, "flat-batch-fill", this->flag()); - this->add(this->useDropout, "use-dropout", this->generate_data({0})); - -#if(MIO_GRU_TEST_DEBUG == 3) - this->biasMode = 0; - this->dirMode = 1; - this->inputMode = 0; -#else - this->add(this->inputMode, "in-mode", this->generate_data(modes)); - this->add(this->biasMode, "bias-mode", this->generate_data(modes)); - this->add(this->dirMode, "dir-mode", this->generate_data(modes)); -#endif - this->add( - this->batchSeq, - "batch-seq", - this->lazy_generate_data( - [=] { return generate_batchSeq(this->batchSize, this->seqLength); }, defaultBS)); - } -}; +#include "gru.hpp" int main(int argc, const char* argv[]) { diff --git a/test/gru.hpp b/test/gru.hpp new file mode 100644 index 0000000000..907828bace --- /dev/null +++ b/test/gru.hpp @@ -0,0 +1,66 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2017 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +#pragma once + +#include "gru_common.hpp" + +template +struct gru_driver : gru_basic_driver +{ + gru_driver() : gru_basic_driver() + { + std::vector modes(2, 0); + modes[1] = 1; + std::vector defaultBS(1); + + this->add(this->batchSize, "batch-size", this->generate_data(get_gru_batchSize(), {17})); + this->add(this->seqLength, "seq-len", this->generate_data(get_gru_seq_len(), {2})); + this->add(this->inVecLen, "vector-len", this->generate_data(get_gru_vector_len())); + this->add(this->hiddenSize, "hidden-size", this->generate_data(get_gru_hidden_size())); + this->add(this->numLayers, "num-layers", this->generate_data(get_gru_num_layers())); + this->add(this->nohx, "no-hx", this->flag()); + this->add(this->nodhy, "no-dhy", this->flag()); + this->add(this->nohy, "no-hy", this->flag()); + this->add(this->nodhx, "no-dhx", this->flag()); + this->add(this->flatBatchFill, "flat-batch-fill", this->flag()); + this->add(this->useDropout, "use-dropout", this->generate_data({0})); + +#if(MIO_GRU_TEST_DEBUG == 3) + this->biasMode = 0; + this->dirMode = 1; + this->inputMode = 0; +#else + this->add(this->inputMode, "in-mode", this->generate_data(modes)); + this->add(this->biasMode, "bias-mode", this->generate_data(modes)); + this->add(this->dirMode, "dir-mode", this->generate_data(modes)); +#endif + this->add( + this->batchSeq, + "batch-seq", + this->lazy_generate_data( + [=] { return generate_batchSeq(this->batchSize, this->seqLength); }, defaultBS)); + } +}; diff --git a/test/gtest/deepbench_gru.cpp b/test/gtest/deepbench_gru.cpp new file mode 100644 index 0000000000..56491bc818 --- /dev/null +++ b/test/gtest/deepbench_gru.cpp @@ -0,0 +1,120 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +#include +#include +#include +#include "../gru.hpp" +#include "get_handle.hpp" + +MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_DEEPBENCH) + +namespace deepbench_gru { +static bool SkipTest(void) { return !miopen::IsEnabled(ENV(MIOPEN_TEST_DEEPBENCH)); } + +void GetArgs(const std::string& param, std::vector& tokens) +{ + std::stringstream ss(param); + std::istream_iterator begin(ss); + std::istream_iterator end; + while(begin != end) + tokens.push_back(*begin++); +} + +class DeepBenchGRUConfigWithFloat : public testing::TestWithParam> +{ +}; + +void Run2dDriverFloat(void) +{ + std::vector params = DeepBenchGRUConfigWithFloat::GetParam(); + + for(const auto& test_value : params) + { + std::vector tokens; + GetArgs(test_value, tokens); + std::vector ptrs; + + std::transform(tokens.begin(), tokens.end(), std::back_inserter(ptrs), [](const auto& str) { + return str.data(); + }); + + testing::internal::CaptureStderr(); + test_drive(ptrs.size(), ptrs.data()); + auto capture = testing::internal::GetCapturedStderr(); + std::cout << capture; + } +}; + +std::vector GetTestCases(void) +{ + std::string flags = " --verbose"; + std::string commonFlags = + " --num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill"; + + const std::vector test_cases = { + // clang-format off + {flags + " --batch-size 32 --seq-len 1500 --vector-len 2816 --hidden-size 2816" + commonFlags}, + {flags + " --batch-size 32 --seq-len 750 --vector-len 2816 --hidden-size 2816" + commonFlags}, + {flags + " --batch-size 32 --seq-len 375 --vector-len 2816 --hidden-size 2816" + commonFlags}, + {flags + " --batch-size 32 --seq-len 187 --vector-len 2816 --hidden-size 2816" + commonFlags}, + {flags + " --batch-size 32 --seq-len 1500 --vector-len 2048 --hidden-size 2048" + commonFlags}, + {flags + " --batch-size 32 --seq-len 750 --vector-len 2048 --hidden-size 2048" + commonFlags}, + {flags + " --batch-size 32 --seq-len 375 --vector-len 2048 --hidden-size 2048" + commonFlags}, + {flags + " --batch-size 32 --seq-len 187 --vector-len 2048 --hidden-size 2048" + commonFlags}, + {flags + " --batch-size 32 --seq-len 1500 --vector-len 1536 --hidden-size 1536" + commonFlags}, + {flags + " --batch-size 32 --seq-len 750 --vector-len 1536 --hidden-size 1536" + commonFlags}, + {flags + " --batch-size 32 --seq-len 375 --vector-len 1536 --hidden-size 1536" + commonFlags}, + {flags + " --batch-size 32 --seq-len 187 --vector-len 1536 --hidden-size 1536" + commonFlags}, + {flags + " --batch-size 32 --seq-len 1500 --vector-len 2560 --hidden-size 2560" + commonFlags}, + {flags + " --batch-size 32 --seq-len 750 --vector-len 2560 --hidden-size 2560" + commonFlags}, + {flags + " --batch-size 32 --seq-len 375 --vector-len 2560 --hidden-size 2560" + commonFlags}, + {flags + " --batch-size 32 --seq-len 187 --vector-len 2560 --hidden-size 2560" + commonFlags}, + {flags + " --batch-size 32 --seq-len 1 --vector-len 512 --hidden-size 512" + commonFlags}, + {flags + " --batch-size 32 --seq-len 1500 --vector-len 1024 --hidden-size 1024" + commonFlags}, + {flags + " --batch-size 64 --seq-len 1500 --vector-len 1024 --hidden-size 1024" + commonFlags} + // clang-format on + }; + + return test_cases; +} + +} // namespace deepbench_gru + +using namespace deepbench_gru; + +TEST_P(DeepBenchGRUConfigWithFloat, FloatTest_deepbench_gru) +{ + if(SkipTest()) + { + GTEST_SKIP(); + } + else + { + Run2dDriverFloat(); + } +}; + +INSTANTIATE_TEST_SUITE_P(ConvTrans, DeepBenchGRUConfigWithFloat, testing::Values(GetTestCases())); diff --git a/test/gtest/deepbench_rnn.cpp b/test/gtest/deepbench_rnn.cpp new file mode 100644 index 0000000000..2045b3449f --- /dev/null +++ b/test/gtest/deepbench_rnn.cpp @@ -0,0 +1,116 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +#include +#include +#include +#include "../rnn_vanilla.hpp" +#include "get_handle.hpp" + +MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_DEEPBENCH) +MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) + +namespace deepbench_rnn { +static bool SkipTest(void) { return !miopen::IsEnabled(ENV(MIOPEN_TEST_DEEPBENCH)); } + +void GetArgs(const std::string& param, std::vector& tokens) +{ + std::stringstream ss(param); + std::istream_iterator begin(ss); + std::istream_iterator end; + while(begin != end) + tokens.push_back(*begin++); +} + +class DeepBenchRNNConfigWithFloat : public testing::TestWithParam> +{ +}; + +void Run2dDriverFloat(void) +{ + + std::vector params = DeepBenchRNNConfigWithFloat::GetParam(); + + for(const auto& test_value : params) + { + std::vector tokens; + GetArgs(test_value, tokens); + std::vector ptrs; + + std::transform(tokens.begin(), tokens.end(), std::back_inserter(ptrs), [](const auto& str) { + return str.data(); + }); + + testing::internal::CaptureStderr(); + test_drive(ptrs.size(), ptrs.data()); + auto capture = testing::internal::GetCapturedStderr(); + std::cout << capture; + } +}; + +std::vector GetTestCases(void) +{ + std::string flags = " --verbose"; + + std::string postFlags = + "--num-layers 1 --in-mode 1 --bias-mode 0 -dir-mode 0 --rnn-mode 0 --flat-batch-fill"; + + const std::vector test_cases = { + // clang-format off + {flags + " --batch-size 16 --seq-len 50 --vector-len 1760 --hidden-size 1760 " + postFlags}, + {flags + " --batch-size 32 --seq-len 50 --vector-len 1760 --hidden-size 1760 " + postFlags}, + {flags + " --batch-size 64 --seq-len 50 --vector-len 1760 --hidden-size 1760 " + postFlags}, + {flags + " --batch-size 128 --seq-len 50 --vector-len 1760 --hidden-size 1760 " + postFlags}, + {flags + " --batch-size 16 --seq-len 50 --vector-len 2048 --hidden-size 2048 " + postFlags}, + {flags + " --batch-size 32 --seq-len 50 --vector-len 2048 --hidden-size 2048 " + postFlags}, + {flags + " --batch-size 64 --seq-len 50 --vector-len 2048 --hidden-size 2048 " + postFlags}, + {flags + " --batch-size 128 --seq-len 50 --vector-len 2048 --hidden-size 2048 " + postFlags}, + {flags + " --batch-size 16 --seq-len 50 --vector-len 2560 --hidden-size 2560 " + postFlags}, + {flags + " --batch-size 32 --seq-len 50 --vector-len 2560 --hidden-size 2560 " + postFlags}, + {flags + " --batch-size 64 --seq-len 50 --vector-len 2560 --hidden-size 2560 " + postFlags}, + {flags + " --batch-size 128 --seq-len 50 --vector-len 2560 --hidden-size 2560 " + postFlags} + // clang-format on + }; + + return test_cases; +} + +} // namespace deepbench_rnn + +using namespace deepbench_rnn; + +TEST_P(DeepBenchRNNConfigWithFloat, FloatTest_deepbench_rnn) +{ + if(SkipTest()) + { + GTEST_SKIP(); + } + else + { + Run2dDriverFloat(); + } +}; + +INSTANTIATE_TEST_SUITE_P(ConvTrans, DeepBenchRNNConfigWithFloat, testing::Values(GetTestCases())); diff --git a/test/gtest/gru_extra.cpp b/test/gtest/gru_extra.cpp new file mode 100644 index 0000000000..e3551c791d --- /dev/null +++ b/test/gtest/gru_extra.cpp @@ -0,0 +1,121 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +#include +#include +#include +#include "../gru.hpp" +#include "get_handle.hpp" + +MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) +MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) + +namespace gru_extra { + +void GetArgs(const std::string& param, std::vector& tokens) +{ + std::stringstream ss(param); + std::istream_iterator begin(ss); + std::istream_iterator end; + while(begin != end) + tokens.push_back(*begin++); +} + +class GRUExtraConfigWithFloat : public testing::TestWithParam> +{ +}; + +void Run2dDriverFloat(void) +{ + + std::vector params = GRUExtraConfigWithFloat::GetParam(); + + for(const auto& test_value : params) + { + std::vector tokens; + GetArgs(test_value, tokens); + std::vector ptrs; + + std::transform(tokens.begin(), tokens.end(), std::back_inserter(ptrs), [](const auto& str) { + return str.data(); + }); + + testing::internal::CaptureStderr(); + test_drive(ptrs.size(), ptrs.data()); + auto capture = testing::internal::GetCapturedStderr(); + std::cout << capture; + } +}; + +std::vector GetTestCases(void) +{ + std::string commonFlags = + " --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 " + "--hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0"; + std::string dir0 = " -dir-mode 0"; + std::string dir1 = " -dir-mode 1"; + std::string rnn0 = " --rnn-mode 0"; + std::string rnn1 = " --rnn-mode 1"; + std::string no_hx = " --no-hx"; + std::string no_hy = " --no-hy"; + std::string no_dhx = " --no-dhx"; + std::string no_dhy = " --no-dhy"; + + const std::vector test_cases = { + // clang-format off + {commonFlags + dir0 + no_hx}, + {commonFlags + dir0 + no_dhy}, + {commonFlags + dir0 + no_hx + no_dhy}, + {commonFlags + dir1 + no_hx}, + {commonFlags + dir1 + no_dhy}, + {commonFlags + dir1 + no_hx + no_dhy}, + {commonFlags + dir0 + no_hy}, + {commonFlags + dir0 + no_dhx}, + {commonFlags + dir0 + no_hy + no_dhx}, + {commonFlags + dir1 + no_hy}, + {commonFlags + dir1 + no_dhx}, + {commonFlags + dir1 + no_hy + no_dhx}, + {commonFlags + dir0 + no_hx + no_dhy + no_hy + no_dhx}, + {commonFlags + dir1 + no_hx + no_dhy + no_hy + no_dhx} + // clang-format on + }; + + return test_cases; +} + +} // namespace gru_extra +using namespace gru_extra; + +TEST_P(GRUExtraConfigWithFloat, FloatTest_gru_extra) +{ + if((miopen::IsUnset(ENV(MIOPEN_TEST_ALL)) || + (miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && + miopen::GetStringEnv(ENV(MIOPEN_TEST_FLOAT_ARG)) == "--float"))) + Run2dDriverFloat(); + else + GTEST_SKIP(); +}; + +INSTANTIATE_TEST_SUITE_P(ConvTrans, GRUExtraConfigWithFloat, testing::Values(GetTestCases())); diff --git a/test/gtest/rnn_extra.cpp b/test/gtest/rnn_extra.cpp new file mode 100644 index 0000000000..1fb1dd67ac --- /dev/null +++ b/test/gtest/rnn_extra.cpp @@ -0,0 +1,134 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +#include +#include +#include +#include "../rnn_vanilla.hpp" +#include "get_handle.hpp" + +MIOPEN_DECLARE_ENV_VAR_STR(MIOPEN_TEST_FLOAT_ARG) +MIOPEN_DECLARE_ENV_VAR_BOOL(MIOPEN_TEST_ALL) + +namespace rnn_extra { + +void GetArgs(const std::string& param, std::vector& tokens) +{ + std::stringstream ss(param); + std::istream_iterator begin(ss); + std::istream_iterator end; + while(begin != end) + tokens.push_back(*begin++); +} + +class RNNExtraConfigWithFloat : public testing::TestWithParam> +{ +}; + +void Run2dDriverFloat(void) +{ + + std::vector params = RNNExtraConfigWithFloat::GetParam(); + + for(const auto& test_value : params) + { + std::vector tokens; + GetArgs(test_value, tokens); + std::vector ptrs; + + std::transform(tokens.begin(), tokens.end(), std::back_inserter(ptrs), [](const auto& str) { + return str.data(); + }); + + testing::internal::CaptureStderr(); + test_drive(ptrs.size(), ptrs.data()); + auto capture = testing::internal::GetCapturedStderr(); + std::cout << capture; + } +}; + +std::vector GetTestCases(void) +{ + std::string commonFlags = + " --verbose --batch-size 32 --seq-len 3 --batch-seq 32 32 32 --vector-len 128 " + "--hidden-size 128 --num-layers 1 --in-mode 0 --bias-mode 0"; + std::string dir0 = " -dir-mode 0"; + std::string dir1 = " -dir-mode 1"; + std::string rnn0 = " --rnn-mode 0"; + std::string rnn1 = " --rnn-mode 1"; + std::string no_hx = " --no-hx"; + std::string no_hy = " --no-hy"; + std::string no_dhx = " --no-dhx"; + std::string no_dhy = " --no-dhy"; + + const std::vector test_cases = { + // clang-format off + {commonFlags + dir0 + rnn0 + no_hx}, + {commonFlags + dir0 + rnn0 + no_dhy}, + {commonFlags + dir0 + rnn0 + no_hx + no_dhy}, + {commonFlags + dir0 + rnn1 + no_hx}, + {commonFlags + dir0 + rnn1 + no_dhy}, + {commonFlags + dir0 + rnn1 + no_hx + no_dhy}, + {commonFlags + dir1 + rnn0 + no_hx}, + {commonFlags + dir1 + rnn0 + no_dhy}, + {commonFlags + dir1 + rnn0 + no_hx + no_dhy}, + {commonFlags + dir1 + rnn1 + no_hx}, + {commonFlags + dir1 + rnn1 + no_dhy}, + {commonFlags + dir1 + rnn1 + no_hx + no_dhy}, + {commonFlags + dir0 + rnn0 + no_hy}, + {commonFlags + dir0 + rnn0 + no_dhx}, + {commonFlags + dir0 + rnn0 + no_hy + no_dhx}, + {commonFlags + dir0 + rnn1 + no_hy}, + {commonFlags + dir0 + rnn1 + no_dhx}, + {commonFlags + dir0 + rnn1 + no_hy + no_dhx}, + {commonFlags + dir1 + rnn0 + no_hy}, + {commonFlags + dir1 + rnn0 + no_dhx}, + {commonFlags + dir1 + rnn0 + no_hy + no_dhx}, + {commonFlags + dir1 + rnn1 + no_hy}, + {commonFlags + dir1 + rnn1 + no_dhx}, + {commonFlags + dir1 + rnn1 + no_hy + no_dhx}, + {commonFlags + dir0 + rnn0 + no_hx + no_dhy + no_hy + no_dhx}, + {commonFlags + dir0 + rnn1 + no_hx + no_dhy + no_hy + no_dhx}, + {commonFlags + dir1 + rnn0 + no_hx + no_dhy + no_hy + no_dhx}, + {commonFlags + dir1 + rnn1 + no_hx + no_dhy + no_hy + no_dhx} + // clang-format on + }; + + return test_cases; +} +} // namespace rnn_extra +using namespace rnn_extra; + +TEST_P(RNNExtraConfigWithFloat, FloatTest_rnn_extra) +{ + if((miopen::IsUnset(ENV(MIOPEN_TEST_ALL)) || + (miopen::IsEnabled(ENV(MIOPEN_TEST_ALL)) && + miopen::GetStringEnv(ENV(MIOPEN_TEST_FLOAT_ARG)) == "--float"))) + Run2dDriverFloat(); + else + GTEST_SKIP(); +}; + +INSTANTIATE_TEST_SUITE_P(ConvTrans, RNNExtraConfigWithFloat, testing::Values(GetTestCases())); diff --git a/test/rnn_vanilla.cpp b/test/rnn_vanilla.cpp index 41c800d056..1d34c8b271 100644 --- a/test/rnn_vanilla.cpp +++ b/test/rnn_vanilla.cpp @@ -23,48 +23,7 @@ * SOFTWARE. * *******************************************************************************/ - -#include "rnn_vanilla_common.hpp" - -template -struct rnn_vanilla_driver : rnn_basic_vanilla_driver -{ - rnn_vanilla_driver() : rnn_basic_vanilla_driver() - { - std::vector modes(2, 0); - modes[1] = 1; - std::vector defaultBS(1); - - this->add(this->batchSize, "batch-size", this->generate_data(get_rnn_batchSize(), {5})); - this->add(this->seqLength, "seq-len", this->generate_data(get_rnn_seq_len(), {1})); - this->add(this->inVecLen, "vector-len", this->generate_data(get_rnn_vector_len())); - this->add(this->hiddenSize, "hidden-size", this->generate_data(get_rnn_hidden_size())); - this->add(this->numLayers, "num-layers", this->generate_data(get_rnn_num_layers())); - this->add(this->nohx, "no-hx", this->flag()); - this->add(this->nodhy, "no-dhy", this->flag()); - this->add(this->nohy, "no-hy", this->flag()); - this->add(this->nodhx, "no-dhx", this->flag()); - this->add(this->flatBatchFill, "flat-batch-fill", this->flag()); - this->add(this->useDropout, "use-dropout", this->generate_data({0})); - -#if(MIO_RNN_TEST_DEBUG == 3) - this->biasMode = 0; - this->dirMode = 1; - this->rnnMode = 0; - this->inputMode = 0; -#else - this->add(this->inputMode, "in-mode", this->generate_data(modes)); - this->add(this->biasMode, "bias-mode", this->generate_data(modes)); - this->add(this->dirMode, "dir-mode", this->generate_data(modes)); - this->add(this->rnnMode, "rnn-mode", this->generate_data(modes)); -#endif - this->add( - this->batchSeq, - "batch-seq", - this->lazy_generate_data( - [=] { return generate_batchSeq(this->batchSize, this->seqLength); }, defaultBS)); - } -}; +#include "rnn_vanilla.hpp" int main(int argc, const char* argv[]) { diff --git a/test/rnn_vanilla.hpp b/test/rnn_vanilla.hpp new file mode 100644 index 0000000000..657a0fef91 --- /dev/null +++ b/test/rnn_vanilla.hpp @@ -0,0 +1,68 @@ +/******************************************************************************* + * + * MIT License + * + * Copyright (c) 2023 Advanced Micro Devices, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + *******************************************************************************/ +#pragma once + +#include "rnn_vanilla_common.hpp" + +template +struct rnn_vanilla_driver : rnn_basic_vanilla_driver +{ + rnn_vanilla_driver() : rnn_basic_vanilla_driver() + { + std::vector modes(2, 0); + modes[1] = 1; + std::vector defaultBS(1); + + this->add(this->batchSize, "batch-size", this->generate_data(get_rnn_batchSize(), {5})); + this->add(this->seqLength, "seq-len", this->generate_data(get_rnn_seq_len(), {1})); + this->add(this->inVecLen, "vector-len", this->generate_data(get_rnn_vector_len())); + this->add(this->hiddenSize, "hidden-size", this->generate_data(get_rnn_hidden_size())); + this->add(this->numLayers, "num-layers", this->generate_data(get_rnn_num_layers())); + this->add(this->nohx, "no-hx", this->flag()); + this->add(this->nodhy, "no-dhy", this->flag()); + this->add(this->nohy, "no-hy", this->flag()); + this->add(this->nodhx, "no-dhx", this->flag()); + this->add(this->flatBatchFill, "flat-batch-fill", this->flag()); + this->add(this->useDropout, "use-dropout", this->generate_data({0})); + +#if(MIO_RNN_TEST_DEBUG == 3) + this->biasMode = 0; + this->dirMode = 1; + this->rnnMode = 0; + this->inputMode = 0; +#else + this->add(this->inputMode, "in-mode", this->generate_data(modes)); + this->add(this->biasMode, "bias-mode", this->generate_data(modes)); + this->add(this->dirMode, "dir-mode", this->generate_data(modes)); + this->add(this->rnnMode, "rnn-mode", this->generate_data(modes)); +#endif + this->add( + this->batchSeq, + "batch-seq", + this->lazy_generate_data( + [=] { return generate_batchSeq(this->batchSize, this->seqLength); }, defaultBS)); + } +};