From dfb8bf9748ff86fe9f6679d2d1028e54788752fe Mon Sep 17 00:00:00 2001 From: lyken Date: Mon, 29 Jul 2024 13:35:43 +0800 Subject: [PATCH] core/ndstrides: fix and rewrite is_c_contiguous --- nac3core/irrt/irrt/ndarray/basic.hpp | 7 +++---- nac3core/src/codegen/irrt/ndarray/basic.rs | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/nac3core/irrt/irrt/ndarray/basic.hpp b/nac3core/irrt/irrt/ndarray/basic.hpp index 9e0565b9..ed7009e3 100644 --- a/nac3core/irrt/irrt/ndarray/basic.hpp +++ b/nac3core/irrt/irrt/ndarray/basic.hpp @@ -223,10 +223,9 @@ bool is_c_contiguous(const NDArray* ndarray) { return false; } - for (SizeT i = 1; i < ndarray->ndims; i++) { - SizeT axis_i = ndarray->ndims - i - 1; - if (ndarray->strides[axis_i] != - ndarray->shape[axis_i + 1] + ndarray->strides[axis_i + 1]) { + for (SizeT i = 0; i < ndarray->ndims - 1; i++) { + if (ndarray->strides[i] != + ndarray->shape[i + 1] + ndarray->strides[i + 1]) { return false; } } diff --git a/nac3core/src/codegen/irrt/ndarray/basic.rs b/nac3core/src/codegen/irrt/ndarray/basic.rs index df3577ea..85a38571 100644 --- a/nac3core/src/codegen/irrt/ndarray/basic.rs +++ b/nac3core/src/codegen/irrt/ndarray/basic.rs @@ -121,7 +121,7 @@ pub fn call_nac3_ndarray_copy_data<'ctx, G: CodeGenerator + ?Sized>( ctx: &mut CodeGenContext<'ctx, '_>, src_ndarray: Ptr<'ctx, StructModel>, dst_ndarray: Ptr<'ctx, StructModel>, -) -> Int<'ctx, Bool> { +) { let tyctx = generator.type_context(ctx.ctx); CallFunction::begin( @@ -131,7 +131,7 @@ pub fn call_nac3_ndarray_copy_data<'ctx, G: CodeGenerator + ?Sized>( ) .arg("src_ndarray", src_ndarray) .arg("dst_ndarray", dst_ndarray) - .returning("is_c_contiguous") + .returning_void(); } pub fn call_nac3_ndarray_get_nth_pelement<'ctx, G: CodeGenerator + ?Sized>(