/******************************************************************************* * * MIT License * * Copyright (c) 2025 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 "gtest_common.hpp" #include "compare_helper.hpp" #include "gtest_desc_guard.hpp" #include "../dropout_util.hpp" #include "get_handle.hpp" #include "random.hpp" #include #include #include #include #include #include // // Native rnn tensor format // #include "../seq_tensor_holder.hpp" #include "../rnn_util.hpp" #include "../cpu_rnn.hpp" /// namespace { using RNNSeqApiParam = std::tuple, bool, bool, bool, bool, bool, bool, bool>; auto RNNSeqGenCases() { return ::testing::Combine(::testing::ValuesIn({7}), ::testing::ValuesIn({13}), ::testing::ValuesIn({0, 1}), ::testing::ValuesIn({0, 1}), ::testing::ValuesIn({3}), ::testing::ValuesIn({0, 1}), ::testing::ValuesIn({1}), ::testing::ValuesIn({0, 1}), ::testing::ValuesIn({2}), ::testing::ValuesIn({2}), ::testing::ValuesIn({3}), ::testing::ValuesIn({6}), ::testing::ValuesIn({15}), ::testing::ValuesIn({std::vector{1, 15, 14, 15, 14, 1}, std::vector{1, 0, 3, 4, 2, 0}, std::vector{1, 2, 3, 4}, std::vector{4, 3, 2, 1}, std::vector{4, 4, 4, 4}, std::vector{1}}), ::testing::ValuesIn({false}), ::testing::ValuesIn({false, true}), ::testing::ValuesIn({false}), ::testing::ValuesIn({false, true}), ::testing::ValuesIn({false, true}), ::testing::ValuesIn({false}), ::testing::ValuesIn({false})); } auto LstmMSGenCases() { return ::testing::Combine(::testing::ValuesIn({1, 7}), ::testing::ValuesIn({13, 1}), ::testing::ValuesIn({0}), ::testing::ValuesIn({0}), ::testing::ValuesIn({3}), ::testing::ValuesIn({0}), ::testing::ValuesIn({0, 1}), ::testing::ValuesIn({0}), ::testing::ValuesIn({2}), ::testing::ValuesIn({0}), ::testing::ValuesIn({2}), ::testing::ValuesIn({1, 6}), ::testing::ValuesIn({38}), ::testing::ValuesIn({std::vector{34, 3, 2, 1}, std::vector{1, 15, 34, 15, 34, 1}, std::vector{}}), ::testing::ValuesIn({false, true}), ::testing::ValuesIn({false, true}), ::testing::ValuesIn({false, true}), ::testing::ValuesIn({false, true}), ::testing::ValuesIn({false, true}), ::testing::ValuesIn({false}), ::testing::ValuesIn({false})); } template miopen::Allocator::ManageDataPtr createTensorAtGPUOrNullptr(const miopen::Handle& handle, TensorT& tensor, bool is_nullptr) { if(!is_nullptr) return handle.Create(tensor.GetDataByteSize()); else return nullptr; } template miopen::Allocator::ManageDataPtr transferTensorToGPUOrNullptr(const miopen::Handle& handle, TensorT& tensor, bool is_nullptr) { if(!is_nullptr) return handle.Write(tensor.data); else return nullptr; } // read from GPU cnt elements of type T template