Skip to content

Commit

Permalink
Comment out RbShape
Browse files Browse the repository at this point in the history
  • Loading branch information
kojix2 committed Sep 11, 2023
1 parent 25f7f50 commit 5f8863c
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions ext/candle/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@ pub fn wrap_err(err: candle_core::Error) -> Error {
Error::new(magnus::exception::runtime_error(), err.to_string())
}

#[derive(Clone, Debug)]
struct RbShape(Vec<usize>);

impl magnus::TryConvert for RbShape {
fn try_convert(val: magnus::Value) -> PyResult<Self> {
let ary = magnus::RArray::try_convert(val)?;
let shape = ary
.each()
.map(|v| magnus::Integer::try_convert(v?).map(|v| v.to_usize().unwrap()))
.collect::<PyResult<Vec<_>>>()?;
Ok(Self(shape))
}
}

impl magnus::IntoValue for RbShape {
fn into_value_with(self, ruby: &Ruby) -> magnus::Value {
let ary = magnus::RArray::from_vec(self.0);
ary.into_value_with(ruby)
}
}
// #[derive(Clone, Debug)]
// struct RbShape(Vec<usize>);

// impl magnus::TryConvert for RbShape {
// fn try_convert(val: magnus::Value) -> PyResult<Self> {
// let ary = magnus::RArray::try_convert(val)?;
// let shape = ary
// .each()
// .map(|v| magnus::Integer::try_convert(v?).map(|v| v.to_usize().unwrap()))
// .collect::<PyResult<Vec<_>>>()?;
// Ok(Self(shape))
// }
// }

// impl magnus::IntoValue for RbShape {
// fn into_value_with(self, ruby: &Ruby) -> magnus::Value {
// let ary = magnus::RArray::from_vec(self.0);
// ary.into_value_with(ruby)
// }
//}

#[derive(Clone, Debug)]
#[magnus::wrap(class = "Candle::Tensor", free_immediately, size)]
Expand Down

0 comments on commit 5f8863c

Please sign in to comment.