summaryrefslogtreecommitdiff
path: root/candle-core/src/tensor.rs
diff options
context:
space:
mode:
Diffstat (limited to 'candle-core/src/tensor.rs')
-rw-r--r--candle-core/src/tensor.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/candle-core/src/tensor.rs b/candle-core/src/tensor.rs
index f834e040..12e98029 100644
--- a/candle-core/src/tensor.rs
+++ b/candle-core/src/tensor.rs
@@ -535,6 +535,13 @@ impl Tensor {
Ok(from_storage(storage, self.shape(), op, false))
}
+ /// Raise the tensor to some float exponent `e`.
+ pub fn powf(&self, e: f64) -> Result<Self> {
+ let storage = self.storage().powf(self.layout(), e)?;
+ let op = BackpropOp::new1(self, |t| Op::Powf(t, e));
+ Ok(from_storage(storage, self.shape(), op, false))
+ }
+
fn check_dim(&self, dim: usize, op: &'static str) -> Result<()> {
if dim >= self.dims().len() {
Err(Error::DimOutOfRange {