mirror of
https://github.com/huggingface/candle.git
synced 2025-06-17 19:18:50 +00:00
Fix an error message.
This commit is contained in:
@ -3,12 +3,10 @@ use candle::{Device, Tensor};
|
|||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let device = Device::new_cuda(0)?;
|
let device = Device::new_cuda(0)?;
|
||||||
let x = Tensor::new(&[[11f32, 22.], [33., 44.], [55., 66.], [77., 78.]], &device)?;
|
let ids = Tensor::new(&[0u32, 3u32, 1u32], &device)?;
|
||||||
println!("> {:?}", x.sum(&[0])?.to_vec2::<f32>()?);
|
let t = Tensor::new(&[[0f32, 1f32], [1f32, 2f32], [2f32, 3f32]], &device)?;
|
||||||
println!("> {:?}", x.sum(&[1])?.to_vec2::<f32>()?);
|
let hs = Tensor::embedding(&ids, &t)?;
|
||||||
println!("> {:?}", x.sum(&[0, 1])?.to_vec2::<f32>()?);
|
println!("> {:?}", hs.to_vec2::<f32>());
|
||||||
let x = x.to_dtype(candle::DType::F16)?;
|
|
||||||
println!("> {:?}", x.sum(&[0])?.to_vec2::<half::f16>()?);
|
|
||||||
|
|
||||||
let x = Tensor::new(&[3f32, 1., 4., 1., 5.], &device)?;
|
let x = Tensor::new(&[3f32, 1., 4., 1., 5.], &device)?;
|
||||||
println!("{:?}", x.to_vec1::<f32>()?);
|
println!("{:?}", x.to_vec1::<f32>()?);
|
||||||
|
@ -700,7 +700,7 @@ impl CudaStorage {
|
|||||||
let ids = match &self.slice {
|
let ids = match &self.slice {
|
||||||
CudaStorageSlice::U32(slice) => slice,
|
CudaStorageSlice::U32(slice) => slice,
|
||||||
_ => Err(CudaError::UnexpectedDType {
|
_ => Err(CudaError::UnexpectedDType {
|
||||||
msg: "embedding ids should be u32",
|
msg: "where conditions should be u32",
|
||||||
expected: DType::U32,
|
expected: DType::U32,
|
||||||
got: self.dtype(),
|
got: self.dtype(),
|
||||||
})?,
|
})?,
|
||||||
|
Reference in New Issue
Block a user