From fb9b57dd8a0ecb506d7d85eb8e9c6a7bfd4aa45a Mon Sep 17 00:00:00 2001 From: Joe Eli McIlvain Date: Sat, 17 Jun 2023 00:47:45 -0700 Subject: [PATCH] Update for latest Savi syntax. Many parens that were previously necessary are now unnecessary. --- src/Tensor.Gen.Random.savi | 2 +- src/Tensor.Graph.Operation.savi | 4 ++-- src/Tensor.Graph.Output.savi | 2 +- src/Tensor.Graph.savi | 4 ++-- src/Tensor.Shape.savi | 4 +++- src/Tensor.savi | 8 +++++--- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/Tensor.Gen.Random.savi b/src/Tensor.Gen.Random.savi index c717de5..970adae 100644 --- a/src/Tensor.Gen.Random.savi +++ b/src/Tensor.Gen.Random.savi @@ -119,7 +119,7 @@ g.add(name @_base_counter g.const("\(name).const" - if (@algorithm == Tensor.Gen.Random.Algorithm.Philox) ( + if @algorithm == Tensor.Gen.Random.Algorithm.Philox ( Tensor(U64).from_array([0, offset]) | Tensor(U64).from_array([offset]) diff --git a/src/Tensor.Graph.Operation.savi b/src/Tensor.Graph.Operation.savi index 46bac7d..7205d3c 100644 --- a/src/Tensor.Graph.Operation.savi +++ b/src/Tensor.Graph.Operation.savi @@ -53,7 +53,7 @@ :fun ref add_input_list(can_outputs Array(Tensor.Graph.CanOutput)'box) return @ if @_ptr.is_null outputs = Array(_FFI.Output).new(can_outputs.size) - can_outputs.each -> (can_output | try (outputs << can_output.output._to_ffi!)) + can_outputs.each -> (can_output | try outputs << can_output.output._to_ffi!) @_ffi.add_input_list(@_ptr, outputs.cpointer, outputs.size.i32) @ @@ -88,7 +88,7 @@ return @ if @_ptr.is_null dimensions_i64_ptr = - if (USize.byte_width == I64.byte_width) ( + if USize.byte_width == I64.byte_width ( _FFI.Cast(CPointer(USize), CPointer(I64)).pointer(dimensions.cpointer) | dimensions_i64 Array(I64) = [] diff --git a/src/Tensor.Graph.Output.savi b/src/Tensor.Graph.Output.savi index 8b80144..9ec1f08 100644 --- a/src/Tensor.Graph.Output.savi +++ b/src/Tensor.Graph.Output.savi @@ -28,7 +28,7 @@ ) shape = Array(I64).new(rank) - while (shape.size < rank) (shape << I64.zero) + while shape.size < rank shape << I64.zero // TODO: make the above process more efficient - use the // `resize_possibly_including_uninitialized_memory` method on `Bytes` // for inspiration, but generalize to `Array`. diff --git a/src/Tensor.Graph.savi b/src/Tensor.Graph.savi index a1cb690..4acc7a0 100644 --- a/src/Tensor.Graph.savi +++ b/src/Tensor.Graph.savi @@ -39,12 +39,12 @@ y_ffis = Array(_FFI.Output).new(y_list.size) dy_ffis = Array(_FFI.Output).new(y_list.size) y_list.each -> (y | - try (y_ffis << y.output._to_ffi!) + try y_ffis << y.output._to_ffi! dy_ffis << _FFI.Output._new_temporarily_null ) x_ffis = Array(_FFI.Output).new(x_list.size) - x_list.each -> (x | try (x_ffis << x.output._to_ffi!)) + x_list.each -> (x | try x_ffis << x.output._to_ffi!) @_ffi.add_gradients( @_ptr diff --git a/src/Tensor.Shape.savi b/src/Tensor.Shape.savi index 0a69d20..a1e970d 100644 --- a/src/Tensor.Shape.savi +++ b/src/Tensor.Shape.savi @@ -52,7 +52,9 @@ out << "[" array.each_with_index -> (dimension, i | - if (i > 0) (out << ", ") + if i > 0 ( + out << ", " + ) dimension.into_string(out) ) out << "]" diff --git a/src/Tensor.savi b/src/Tensor.savi index 0994cf1..35b5f0e 100644 --- a/src/Tensor.savi +++ b/src/Tensor.savi @@ -71,7 +71,7 @@ // TODO: Do this without the intermediate array? elements Array(T) = [] total_element_count.times -> (index | - elements << yield index + elements << (yield index) ) @from_array(elements) @@ -84,7 +84,7 @@ shape.each -> (dimension | element_count = element_count * dimension.usize ) - error! unless (element_count == @element_count) + error! unless element_count == @element_count @_ffi.set_shape( @_ptr @@ -98,7 +98,9 @@ size = @element_count.usize data.reserve(orig_size + size) - while (data.size < size) (data << T.zero) + while data.size < size ( + data << T.zero + ) // TODO: make the above process more efficient - use the // `resize_possibly_including_uninitialized_memory` method on `Bytes` // for inspiration, but generalize to `Array`.