| 2004 | |
| 2005 | template <class T> |
| 2006 | bool MIOpenSupport::DoRnnForwardImpl( |
| 2007 | Stream* stream, const MIOpenRnnDescriptor& rnn_desc, |
| 2008 | const MIOpenRnnSequenceTensorDescriptor& input_desc, |
| 2009 | const DeviceMemory<T>& input_data, |
| 2010 | const MIOpenRnnStateTensorDescriptor& input_h_desc, |
| 2011 | const DeviceMemory<T>& input_h_data, |
| 2012 | const MIOpenRnnStateTensorDescriptor& input_c_desc, |
| 2013 | const DeviceMemory<T>& input_c_data, const DeviceMemory<T>& params, |
| 2014 | const MIOpenRnnSequenceTensorDescriptor& output_desc, |
| 2015 | DeviceMemory<T>* output_data, |
| 2016 | const MIOpenRnnStateTensorDescriptor& output_h_desc, |
| 2017 | DeviceMemory<T>* output_h_data, |
| 2018 | const MIOpenRnnStateTensorDescriptor& output_c_desc, |
| 2019 | DeviceMemory<T>* output_c_data, bool is_training, |
| 2020 | ScratchAllocator* reserve_space_allocator, |
| 2021 | ScratchAllocator* workspace_allocator, |
| 2022 | dnn::ProfileResult* output_profile_result) { |
| 2023 | // extract model parameters |
| 2024 | RnnModelDims model_dims; |
| 2025 | bool res = ExtractAndCheckRnnForward( |
| 2026 | rnn_desc, input_desc, input_data, input_h_desc, input_h_data, |
| 2027 | input_c_desc, input_c_data, params, output_desc, *output_data, |
| 2028 | output_h_desc, *output_h_data, output_c_desc, *output_c_data, |
| 2029 | &model_dims); |
| 2030 | if (!res) { |
| 2031 | LOG(ERROR) << "Invalid parameters for RNN Model"; |
| 2032 | return false; |
| 2033 | } |
| 2034 | |
| 2035 | auto miopen = miopen_->GetHandle(parent_, stream); |
| 2036 | |
| 2037 | // check params size |
| 2038 | |
| 2039 | if (!CheckRNNParameterSize(miopen.handle(), rnn_desc, input_desc)) { |
| 2040 | LOG(ERROR) << "Invalid parameters"; |
| 2041 | return false; |
| 2042 | } |
| 2043 | |
| 2044 | // create the workspace |
| 2045 | DeviceMemory<uint8> workspace; |
| 2046 | if (!CreateRnnWorkspace(stream, miopen.handle(), rnn_desc, input_desc, |
| 2047 | workspace_allocator, &workspace)) { |
| 2048 | LOG(ERROR) << "Unable to create rnn workspace"; |
| 2049 | |
| 2050 | return false; |
| 2051 | } |
| 2052 | |
| 2053 | // query the reserve space size |
| 2054 | // allocate the reserve space |
| 2055 | DeviceMemory<uint8> reserve_space; |
| 2056 | if (is_training) { |
| 2057 | size_t reserve_space_size_in_bytes = 0; |
| 2058 | auto status = wrap::miopenGetRNNTrainingReserveSize( |
| 2059 | miopen.handle() /*handle*/, rnn_desc.handle() /*rnnDesc*/, |
| 2060 | model_dims.seq_length /*seqLength*/, input_desc.handles() /*xDesc*/, |
| 2061 | &reserve_space_size_in_bytes /*sizeInBytes*/); |
| 2062 | if (status != miopenStatusSuccess) { |
| 2063 | LOG(ERROR) << "Unable to query reserve space size: " << ToString(status); |
nothing calls this directly
no test coverage detected