Skip to content

Commit

Permalink
replace Tensor struct with Tensor::new() in return
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelDkhn committed Sep 21, 2023
1 parent b996c50 commit 47db631
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/lib.cairo
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
mod operators;
mod numbers;
mod tests;
// mod tests;
mod utils;

10 changes: 5 additions & 5 deletions src/operators/tensor/core.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -2536,7 +2536,7 @@ fn tensor_eq<T, impl TPartialEq: PartialEq<T>>(mut lhs: Tensor<T>, mut rhs: Tens
}

/// Cf: TensorTrait::slice docstring
fn slice<T, impl TCopy: Copy<T>, impl TDrop: Drop<T>>(
fn slice<T, impl TTensor: TensorTrait<T>, impl TCopy: Copy<T>, impl TDrop: Drop<T>>(
self: @Tensor<T>, starts: Span<usize>, ends: Span<usize>, axes: Option<Span<usize>>, steps: Option<Span<usize>>
) -> Tensor<T> {
let axes = match axes {
Expand Down Expand Up @@ -2624,7 +2624,7 @@ fn slice<T, impl TCopy: Copy<T>, impl TDrop: Drop<T>>(
processed_ends.append(end);
processed_steps.append(step);
output_shape.append(shape);

if i == stop_i {
break ();
}
Expand All @@ -2636,7 +2636,7 @@ fn slice<T, impl TCopy: Copy<T>, impl TDrop: Drop<T>>(
if is_empty {
return Tensor::<T> {shape: output_shape.span(), data: output_data.span()};
}

let stop_j = (*self.data).len() - 1;
let stop_k = (*self.shape).len() - 1;
let mut j: usize = 0;
Expand Down Expand Up @@ -2683,5 +2683,5 @@ fn slice<T, impl TCopy: Copy<T>, impl TDrop: Drop<T>>(
j += 1;
};

return Tensor::<T> {shape: output_shape.span(), data: output_data.span()};
}
return TensorTrait::new(output_shape.span(), output_data.span());
}
2 changes: 1 addition & 1 deletion src/operators/tensor/implementations/tensor_fp16x16.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl FP16x16Tensor of TensorTrait<FP16x16> {
axes: Option<Span<usize>>,
steps: Option<Span<usize>>
) -> Tensor<FP16x16> {
core::slice(self, starts, ends, axes, steps)
core::slice::<FP16x16>(self, starts, ends, axes, steps)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/operators/tensor/implementations/tensor_fp32x32.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl FP32x32Tensor of TensorTrait<FP32x32> {
axes: Option<Span<usize>>,
steps: Option<Span<usize>>
) -> Tensor<FP32x32> {
core::slice(self, starts, ends, axes, steps)
core::slice::<FP32x32>(self, starts, ends, axes, steps)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/operators/tensor/implementations/tensor_fp64x64.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl FP64x64Tensor of TensorTrait<FP64x64> {
axes: Option<Span<usize>>,
steps: Option<Span<usize>>
) -> Tensor<FP64x64> {
core::slice(self, starts, ends, axes, steps)
core::slice::<FP64x64>(self, starts, ends, axes, steps)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/operators/tensor/implementations/tensor_fp8x23.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl FP8x23Tensor of TensorTrait<FP8x23> {
axes: Option<Span<usize>>,
steps: Option<Span<usize>>
) -> Tensor<FP8x23> {
core::slice(self, starts, ends, axes, steps)
core::slice::<FP8x23>(self, starts, ends, axes, steps)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/operators/tensor/implementations/tensor_i32.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl I32Tensor of TensorTrait<i32> {
axes: Option<Span<usize>>,
steps: Option<Span<usize>>
) -> Tensor<i32> {
core::slice(self, starts, ends, axes, steps)
core::slice::<i32>(self, starts, ends, axes, steps)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/operators/tensor/implementations/tensor_i8.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl I8Tensor of TensorTrait<i8> {
axes: Option<Span<usize>>,
steps: Option<Span<usize>>
) -> Tensor<i8> {
core::slice(self, starts, ends, axes, steps)
core::slice::<i8>(self, starts, ends, axes, steps)
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/operators/tensor/implementations/tensor_u32.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ impl U32Tensor of TensorTrait<u32> {
axes: Option<Span<usize>>,
steps: Option<Span<usize>>
) -> Tensor<u32> {
core::slice(self, starts, ends, axes, steps)
core::slice::<u32>(self, starts, ends, axes, steps)
}
}

Expand Down

0 comments on commit 47db631

Please sign in to comment.