// SPDX-License-Identifier: MIT // Copyright (c) 2025, Advanced Micro Devices, Inc. All rights reserved. #pragma once #include #include #include #include "ck/ck.hpp" #include "ck/utility/type.hpp" #include "ck/tensor_operation/gpu/device/tensor_layout.hpp" namespace ck { namespace utils { template inline void validate_gemm_stride(int M, int N, int stride, const std::string& stride_name = "Stride") { if(ck::is_same_v) { if(stride < M) { throw std::runtime_error( "Error: For ColumnMajor layout, " + stride_name + " (" + std::to_string(stride) + ") must be greater than or equal to dim (" + std::to_string(M) + ")"); } } else // RowMajor { if(stride < N) { throw std::runtime_error( "Error: For RowMajor layout, " + stride_name + " (" + std::to_string(stride) + ") must be greater than or equal to dim (" + std::to_string(N) + ")"); } } } // Convenience functions for common GEMM patterns template inline void validate_gemm_strides_abc(int M, int N, int K, int StrideA, int StrideB, int StrideC) { validate_gemm_stride(M, K, StrideA, "StrideA"); validate_gemm_stride(K, N, StrideB, "StrideB"); validate_gemm_stride(M, N, StrideC, "StrideC"); } } // namespace utils } // namespace ck