Commit f2f42fa9 authored by Jayaram Bobba's avatar Jayaram Bobba Committed by Robert Kimball

IAT: Add bounds check for MKLDNN layout creation (#1769)

* Added a bounds check for mkldnn layout descriptor creation

* Added dims check
parent c5f0bd9d
......@@ -311,6 +311,20 @@ bool runtime::cpu::mkldnn_utils::is_perm_sorted(const Strides& a, const AxisVect
mkldnn::memory::desc runtime::cpu::mkldnn_utils::create_blocked_mkldnn_md(
const Shape& dims, const Strides& strides, const ngraph::element::Type type)
{
if (dims.size() > TENSOR_MAX_DIMS || strides.size() > TENSOR_MAX_DIMS)
{
throw ngraph_error("In create_blocked_mkldnn_md: Dimensions (dims, stride): (" +
std::to_string(dims.size()) + ", " + std::to_string(strides.size()) +
") exceed maximum supported by MKLDNN " +
std::to_string(TENSOR_MAX_DIMS));
}
if (dims.size() != strides.size())
{
throw ngraph_error("In create_blocked_mkldnn_md: Rank mismatch between shape and strides " +
std::to_string(dims.size()) + " " + std::to_string(strides.size()));
}
memory::dims dim(dims.begin(), dims.end());
memory::dims stride(strides.begin(), strides.end());
memory::data_type dtype = get_mkldnn_data_type(type);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment