RAII wrapper for all calls to MIOpen with a MIOpen handle argument. See MIOpenAccess::GetHandle() for details.
| 95 | // |
| 96 | // See MIOpenAccess::GetHandle() for details. |
| 97 | class MIOpenHandle { |
| 98 | public: |
| 99 | // Takes ownership of the executor context and the lock to access MIOpen |
| 100 | // using handle. |
| 101 | MIOpenHandle(gpu::ScopedActivateExecutorContext context, |
| 102 | std::unique_ptr<absl::MutexLock> lock, miopenHandle_t handle) |
| 103 | : context_(std::move(context)), lock_(std::move(lock)), handle_(handle) {} |
| 104 | |
| 105 | // Returns MIOpen handle. To be passed directly to MIOpen APIs, don't keep |
| 106 | // a copy. |
| 107 | miopenHandle_t handle() const { return handle_; } |
| 108 | |
| 109 | private: |
| 110 | gpu::ScopedActivateExecutorContext context_; |
| 111 | std::unique_ptr<absl::MutexLock> lock_; |
| 112 | miopenHandle_t handle_; // Not owned. |
| 113 | }; |
| 114 | |
| 115 | namespace wrap { |
| 116 |