Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some prefast warnings #12936

Merged
merged 2 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Status QOrderedMatMul::QOrderedMatMul::ComputeInternal(OpKernelContext* context)
TensorShape output_shape(tensor_A.Shape());
output_shape[output_shape.NumDimensions() - 1] = cols_B;

const float zero = 0.0f;
constexpr float zero = 0.0f;
const float* scale_C = &zero;

const int8_t* C = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Status QOrdered_MatMul(cublasLtHandle_t cublasLt_handle, cudaStream_t stream,
cublasLtMatrixLayout_t desc_D = nullptr;
auto clean_desc_D = gsl::finally([&desc_D]() {if (desc_D) cublasLtMatrixLayoutDestroy(desc_D); });

const float beta_zero = 0.0f;
constexpr float beta_zero = 0.0f;
beta = (C == nullptr ? &beta_zero : beta);

CUBLAS_RETURN_IF_ERROR(cublasLtMatmulDescCreate(&matmul_desc, CUBLAS_COMPUTE_32I, CUDA_R_32F));
Expand Down
4 changes: 2 additions & 2 deletions onnxruntime/core/providers/cuda/math/binary_elementwise_ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct BinaryElementwisePreparation {
auto offset = out_rank - lhs_rank;
for (auto i = offset; i < out_rank; ++i) {
// the stride for broadcast dimension is kept as 0
if (lhs_shape.GetDims()[i - offset] != 1) {
if (lhs_shape.GetDims()[static_cast<size_t>(i) - offset] != 1) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arithmetic overflow warning

lhs_padded_strides[i] = original_lhs_padded_strides[i];
}
}
Expand All @@ -92,7 +92,7 @@ struct BinaryElementwisePreparation {
auto offset = out_rank - rhs_rank;
for (auto i = offset; i < out_rank; ++i) {
// the stride for broadcast dimension is kept as 0
if (rhs_shape.GetDims()[i - offset] != 1) {
if (rhs_shape.GetDims()[static_cast<size_t>(i) - offset] != 1) {
rhs_padded_strides[i] = original_rhs_padded_strides[i];
}
}
Expand Down