From cf02afee9780b3243ab815e93f23f3e7b1b52b03 Mon Sep 17 00:00:00 2001 From: Corentin Godeau Date: Mon, 27 Jan 2025 17:56:31 +0000 Subject: [PATCH] zml/tensor.zig: add maximum as scatter operation --- zml/tensor.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zml/tensor.zig b/zml/tensor.zig index 23ab003b..f2e37497 100644 --- a/zml/tensor.zig +++ b/zml/tensor.zig @@ -2419,6 +2419,10 @@ pub const Tensor = struct { /// of the operator which is backend specific. update_fn: *const fn (Tensor, Tensor) Tensor = increment, + pub fn maximum(old_value: Tensor, new_value: Tensor) Tensor { + return old_value.maximum(new_value.convert(old_value.dtype())); + } + pub fn increment(old_value: Tensor, new_value: Tensor) Tensor { return old_value.add(new_value.convert(old_value.dtype())); }