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

[spv-in] refactor the matrix stride check #908

Merged
merged 1 commit into from
May 26, 2021
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
2 changes: 0 additions & 2 deletions src/front/spv/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
17 changes: 14 additions & 3 deletions src/front/spv/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2965,14 +2965,25 @@ impl<I: Iterator<Item = u32>> Parser<I> {
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,
);
}
}
}
Expand Down