| 2287 | } |
| 2288 | |
| 2289 | MIOpenRnnParamsDescriptor::MIOpenRnnParamsDescriptor( |
| 2290 | miopenHandle_t miopen_handle, const MIOpenRnnDescriptor& rnn_desc) |
| 2291 | : handle_(nullptr), rnn_desc_(&rnn_desc), params_size_in_bytes_(0) { |
| 2292 | miopenTensorDescriptor_t input_desc = nullptr; |
| 2293 | { |
| 2294 | // Query the params size. |
| 2295 | auto status = wrap::miopenCreateTensorDescriptor(&input_desc); |
| 2296 | RETURN_IF_MIOPEN_ERROR(status, "MIOpen fails to create tensor descriptor"); |
| 2297 | std::array<int, 2> dims = {{1, rnn_desc.input_size()}}; |
| 2298 | status = wrap::miopenSetTensorDescriptor( |
| 2299 | input_desc /*tensorDesc*/, rnn_desc.data_type() /*dataType*/, |
| 2300 | 2 /*nbDims*/, dims.data() /*dimA*/, nullptr /*strideA*/); |
| 2301 | RETURN_IF_MIOPEN_ERROR(status, "MIOpen fails to set tensor descriptor"); |
| 2302 | |
| 2303 | size_t params_size = 0; |
| 2304 | status = wrap::miopenGetRNNParamsSize( |
| 2305 | miopen_handle /*handle*/, rnn_desc.handle() /*rnnDesc*/, |
| 2306 | input_desc /*xDesc*/, ¶ms_size /*sizeInBytes*/, |
| 2307 | rnn_desc.data_type() /*dataType*/); |
| 2308 | RETURN_IF_MIOPEN_ERROR(status, "MIOpen fails to get RNN parameter size"); |
| 2309 | params_size_in_bytes_ = static_cast<int64>(params_size); |
| 2310 | } |
| 2311 | |
| 2312 | { |
| 2313 | // Create the params descriptor. |
| 2314 | auto status = wrap::miopenCreateTensorDescriptor(&handle_); |
| 2315 | RETURN_IF_MIOPEN_ERROR(status, |
| 2316 | "MIOpen fails to create RNN params descriptor"); |
| 2317 | status = wrap::miopenGetRNNParamsDescriptor(miopen_handle, |
| 2318 | rnn_desc.handle(), input_desc, |
| 2319 | handle_, rnn_desc.data_type()); |
| 2320 | RETURN_IF_MIOPEN_ERROR(status, |
| 2321 | "MIOpen fails to update RNN filter descriptor"); |
| 2322 | } |
| 2323 | { |
| 2324 | // Release the dummy input tensor descriptor. |
| 2325 | auto status = wrap::miopenDestroyTensorDescriptor(input_desc); |
| 2326 | RETURN_IF_MIOPEN_ERROR(status, "MIOpen fails to destroy tensor descriptor"); |
| 2327 | } |
| 2328 | } |
| 2329 | |
| 2330 | port::StatusOr<std::unique_ptr<dnn::RnnDescriptor>> |
| 2331 | MIOpenSupport::createRnnDescriptor( |
nothing calls this directly
no test coverage detected