diff --git a/include/cudnn_frontend_Operation.h b/include/cudnn_frontend_Operation.h index 7ff22aef6..e79252ecc 100644 --- a/include/cudnn_frontend_Operation.h +++ b/include/cudnn_frontend_Operation.h @@ -1806,8 +1806,21 @@ class OperationBuilder_v8 { } #if (CUDNN_VERSION >= 92200) - // Set reshape mode if it's not NOT_SET - if (m_operation.reshape_mode != ReshapeMode_t::NOT_SET) { + // Same runtime-vs-compile-time split as cudnn_frontend/node/reshape.h. The attribute does + // not exist before 9.22 and setting it there returns BAD_PARAM. This builder is worse off + // than the graph API: reshape_mode defaults to VIEW_ONLY rather than NOT_SET, so the guard + // below is always true and every legacy reshape sends the attribute to whatever runtime is + // loaded. A pre-9.22 reshape is view-only by construction, so only an explicit LOGICAL + // request has to be refused rather than silently downgraded. + if (detail::get_backend_version() < 92200) { + if (m_operation.reshape_mode == ReshapeMode_t::LOGICAL) { + set_error_and_throw_exception( + &m_operation, + CUDNN_STATUS_NOT_SUPPORTED, + "CUDNN_BACKEND_OPERATION: ReshapeMode_t::LOGICAL requires a cuDNN 9.22 or newer runtime"); + return std::move(m_operation); + } + } else if (m_operation.reshape_mode != ReshapeMode_t::NOT_SET) { cudnnBackendReshapeMode_t cudnn_reshape_mode; status = detail::convert_to_cudnn_type(m_operation.reshape_mode, cudnn_reshape_mode); if (status == CUDNN_STATUS_SUCCESS) {