summaryrefslogtreecommitdiff
path: root/candle-core/src/tensor.rs
diff options
context:
space:
mode:
authorLaurent Mazare <laurent.mazare@gmail.com>2023-08-29 20:48:18 +0100
committerGitHub <noreply@github.com>2023-08-29 20:48:18 +0100
commit59b731de99f2f351fdb6ecb428224a29e8cf2d35 (patch)
tree7d68c0fc3f88b302b9bbeb0dba195bfa144979d6 /candle-core/src/tensor.rs
parent2d3fcad26788dff3fa73996a3cc8e5fd5382f6b2 (diff)
downloadcandle-59b731de99f2f351fdb6ecb428224a29e8cf2d35.tar.gz
candle-59b731de99f2f351fdb6ecb428224a29e8cf2d35.tar.bz2
candle-59b731de99f2f351fdb6ecb428224a29e8cf2d35.zip
Add the powf op. (#664)
* Add the powf op. * Cuda kernels and backprop. * Add a test.
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 {