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

chore: Add check for convert op. #24

Merged
merged 1 commit into from
Sep 26, 2024
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: 1 addition & 1 deletion thriller-core/src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::shape::Ix;
use crate::{next_id, Dim, Layout, Shape};

/// Buffer type.
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BufType {
/// Global Tile
GlobalTile,
Expand Down
6 changes: 3 additions & 3 deletions thriller-core/src/shape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub trait Dimension {
}

/// Stride description.
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum Layout<D> {
/// Row-major
RowMajor,
Expand Down Expand Up @@ -54,7 +54,7 @@ where
///
/// [`Dim`] describes the number of axes and the length of each axis
/// in an array. It is also used as an index type.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct Dim {
dims: SmallVec<[Ix; 4]>,
ndim: usize,
Expand Down Expand Up @@ -140,7 +140,7 @@ impl Dimension for Dim {
}

/// Shape description.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
pub struct Shape {
dims: Dim,
layout: Layout<Dim>,
Expand Down
8 changes: 8 additions & 0 deletions thriller-core/src/task/compute/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ impl Convert {
src_type: DataType,
dst_type: DataType,
) -> Self {
// `src_buf` and `dst_buf` must have the same typing.
// TODO(KuanjuX): Don't use assert here.
assert_eq!(src_buf.get_typing(), dst_buf.get_typing());

// `src_buf` and `dst_buf` must have the same shape.
// TODO(KuanjuX): Don't use assert here.
assert_eq!(src_buf.get_shape(), dst_buf.get_shape());

Self {
src_buf,
dst_buf,
Expand Down
Loading