Skip to content

Commit

Permalink
x64: conv: handle dilation int overflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tczeszun authored and vpirogov committed Jan 11, 2025
1 parent 124cf4a commit 38055e0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/cpu/x64/jit_avx512_common_conv_kernel.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2016-2024 Intel Corporation
* Copyright 2016-2025 Intel Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -20,6 +20,7 @@
#include "common/type_helpers.hpp"
#include "common/utils.hpp"

#include "cpu/cpu_convolution_pd.hpp"
#include "cpu/platform.hpp"
#include "cpu/x64/cpu_barrier.hpp"
#include "cpu/x64/injectors/injector_utils.hpp"
Expand Down Expand Up @@ -822,6 +823,13 @@ status_t jit_avx512_common_conv_fwd_kernel::init_conf(jit_conv_conf_t &jcp,
jcp.stride_h = (ndims == 3) ? 1 : cd.strides[ndims - 4];
jcp.stride_w = cd.strides[ndims - 3];

// Big int (> INT_MAX) values are unsupported and jcp fields may overflow
// TODO: change data type of jcp fields to size_t
VDISPATCH_CONV_IC(!((ndims == 5 && cd.dilates[ndims - 5] > INT_MAX)
|| (ndims >= 4 && cd.dilates[ndims - 4] > INT_MAX)
|| (cd.dilates[ndims - 3] > INT_MAX)),
VERBOSE_BAD_PARAM, "dilates");

jcp.dilate_d = (ndims == 5) ? cd.dilates[0] : 0;
jcp.dilate_h = (ndims == 3) ? 0 : cd.dilates[ndims - 4];
jcp.dilate_w = cd.dilates[ndims - 3];
Expand Down

0 comments on commit 38055e0

Please sign in to comment.