From badf99653a32639826ac322840bdcc99c503da15 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Wed, 26 May 2021 00:02:00 -0400 Subject: [PATCH] [spv-in] refactor the matrix stride check --- src/front/spv/error.rs | 2 -- src/front/spv/mod.rs | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/front/spv/error.rs b/src/front/spv/error.rs index 1ae8b23137..688127a271 100644 --- a/src/front/spv/error.rs +++ b/src/front/spv/error.rs @@ -108,6 +108,4 @@ pub enum Error { #[error("invalid barrier memory semantics %{0}")] InvalidBarrierMemorySemantics(spirv::Word), // incomplete implementation errors - #[error("unsupported matrix stride {0}")] - UnsupportedMatrixStride(spirv::Word), } diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index 86998bbc27..78100c067f 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -2965,14 +2965,25 @@ impl> Parser { let offset = decor.offset.unwrap_or(0); if let crate::TypeInner::Matrix { - columns: _, + columns, rows, width, } = module.types[ty].inner { if let Some(stride) = decor.matrix_stride { - if stride.get() != (rows as u32) * (width as u32) { - return Err(Error::UnsupportedMatrixStride(stride.get())); + let rounded_rows = if rows > crate::VectorSize::Bi { + 4 + } else { + rows as u32 + }; + if stride.get() != rounded_rows * (width as u32) { + log::warn!( + "Unexpected matrix stride {} for an {}x{} matrix with scalar width={}", + stride.get(), + columns as u8, + rows as u8, + width, + ); } } }