Skip to content

Commit 4bb33b5

Browse files
committed
ai review
1 parent 112b567 commit 4bb33b5

1 file changed

Lines changed: 19 additions & 3 deletions

File tree

cpp/include/raft/linalg/detail/cublaslt_wrappers.hpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,24 @@ struct cublastlt_matmul_desc {
203203
}
204204
};
205205

206+
/** Preference descriptor for a cublasLt matmul heuristic query. */
207+
struct cublastlt_matmul_preference {
208+
cublasLtMatmulPreference_t res{nullptr};
209+
210+
inline cublastlt_matmul_preference() { RAFT_CUBLAS_TRY(cublasLtMatmulPreferenceCreate(&res)); }
211+
inline cublastlt_matmul_preference(const cublastlt_matmul_preference&) = delete;
212+
inline auto operator=(const cublastlt_matmul_preference&)
213+
-> cublastlt_matmul_preference& = delete;
214+
215+
inline ~cublastlt_matmul_preference() noexcept
216+
{
217+
RAFT_CUBLAS_TRY_NO_THROW(cublasLtMatmulPreferenceDestroy(res));
218+
}
219+
220+
// NOLINTNEXTLINE
221+
inline operator cublasLtMatmulPreference_t() const noexcept { return res; }
222+
};
223+
206224
/** Full description of matmul. */
207225
struct matmul_desc {
208226
cublastlt_matmul_desc desc;
@@ -227,8 +245,7 @@ struct matmul_desc {
227245
}
228246

229247
int algo_count;
230-
cublasLtMatmulPreference_t preference;
231-
RAFT_CUBLAS_TRY(cublasLtMatmulPreferenceCreate(&preference));
248+
cublastlt_matmul_preference preference;
232249
const auto query_heuristic = [&](cublasLtMatrixLayout_t a_layout,
233250
cublasLtMatrixLayout_t c_layout) {
234251
RAFT_CUBLAS_TRY(cublasLtMatmulAlgoGetHeuristic(resource::get_cublaslt_handle(res),
@@ -251,7 +268,6 @@ struct matmul_desc {
251268
} else {
252269
query_heuristic(r.a, r.c);
253270
}
254-
RAFT_CUBLAS_TRY(cublasLtMatmulPreferenceDestroy(preference));
255271

256272
RAFT_EXPECTS(algo_count > 0, "cuBLASLt did not return a matmul algorithm");
257273
constexpr int faulty_algorithm = 68;

0 commit comments

Comments
 (0)