From 03be33eea482accbcf4c547728c2db7e24b7ebb0 Mon Sep 17 00:00:00 2001 From: Laurent Mazare Date: Thu, 17 Aug 2023 11:12:05 +0100 Subject: Relax the requirements on CustomOp. (#486) * Relax the requirements on CustomOp. * Simplify the custom-ops when no backward is required. --- candle-core/src/op.rs | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'candle-core/src/op.rs') diff --git a/candle-core/src/op.rs b/candle-core/src/op.rs index 2b57f7f7..cf99f86e 100644 --- a/candle-core/src/op.rs +++ b/candle-core/src/op.rs @@ -118,13 +118,22 @@ pub enum Op { ToDevice(Tensor), Transpose(Tensor, usize, usize), Elu(Tensor, f64), - CustomOp1(Tensor, std::sync::Arc>), - CustomOp2(Tensor, Tensor, std::sync::Arc>), - CustomOp3(Tensor, Tensor, Tensor, std::sync::Arc>), + CustomOp1(Tensor, std::sync::Arc>), + CustomOp2( + Tensor, + Tensor, + std::sync::Arc>, + ), + CustomOp3( + Tensor, + Tensor, + Tensor, + std::sync::Arc>, + ), } /// Unary ops that can be defined in user-land. -pub trait CustomOp1: Send + Sync { +pub trait CustomOp1 { // Box does not support const yet, so use a function to get the name. fn name(&self) -> &'static str; @@ -148,7 +157,7 @@ pub trait CustomOp1: Send + Sync { } } -pub trait CustomOp2: Send + Sync { +pub trait CustomOp2 { fn name(&self) -> &'static str; /// The forward pass, as run on a cpu device. Note that the storage can use arbitrary strides, @@ -186,7 +195,7 @@ pub trait CustomOp2: Send + Sync { } } -pub trait CustomOp3: Send + Sync { +pub trait CustomOp3 { fn name(&self) -> &'static str; /// The forward pass, as run on a cpu device. Note that the storage can use arbitrary strides, -- cgit v1.2.3