Skip to content

Commit

Permalink
chore: Add check for convert op. (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
KuangjuX authored Sep 26, 2024
1 parent 73b2313 commit f8a58bd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
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

0 comments on commit f8a58bd

Please sign in to comment.