summaryrefslogtreecommitdiff
path: root/candle-nn/src/ops.rs
diff options
context:
space:
mode:
Diffstat (limited to 'candle-nn/src/ops.rs')
-rw-r--r--candle-nn/src/ops.rs23
1 files changed, 22 insertions, 1 deletions
diff --git a/candle-nn/src/ops.rs b/candle-nn/src/ops.rs
index 2a76ee5e..9a360c47 100644
--- a/candle-nn/src/ops.rs
+++ b/candle-nn/src/ops.rs
@@ -1,4 +1,4 @@
-use candle::{CpuStorage, DType, Layout, Result, Shape, Tensor, D};
+use candle::{CpuStorage, DType, Layout, Module, Result, Shape, Tensor, D};
use rayon::prelude::*;
/// Applies the softmax function to the input tensor, rescaling the element so that elements on
@@ -926,3 +926,24 @@ pub fn replication_pad2d(xs: &Tensor, pad: usize) -> Result<Tensor> {
n => candle::bail!("replication-pad with a size of {n} is not supported"),
}
}
+
+#[derive(Clone, Debug)]
+pub struct Identity;
+
+impl Identity {
+ pub fn new() -> Identity {
+ Self
+ }
+}
+
+impl Default for Identity {
+ fn default() -> Self {
+ Self
+ }
+}
+
+impl Module for Identity {
+ fn forward(&self, xs: &Tensor) -> Result<Tensor> {
+ Ok(xs.clone())
+ }
+}