Skip to content

Commit

Permalink
update 24.5
Browse files Browse the repository at this point in the history
  • Loading branch information
MadAlex1997 authored and forFudan committed Sep 14, 2024
1 parent 9c13692 commit 108d90b
Show file tree
Hide file tree
Showing 10 changed files with 1,565 additions and 1,549 deletions.
1 change: 1 addition & 0 deletions numojo/core/_array_funcs.mojo
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# from ..traits.NDArrayTraits import NDArrayBackend
from algorithm.functional import parallelize, vectorize, num_physical_cores
from sys import simdwidthof
from .ndarray import NDArray

"""
Expand Down
1 change: 1 addition & 0 deletions numojo/core/array_creation_routines.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Array creation routine.

from algorithm import parallelize
from builtin.math import pow
from sys import simdwidthof

from .ndarray import NDArray, NDArrayShape
from .ndarray_utils import _get_index
Expand Down
133 changes: 70 additions & 63 deletions numojo/core/ndarray.mojo

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions numojo/core/ndarray_utils.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ Implements N-DIMENSIONAL ARRAY UTILITY FUNCTIONS

from algorithm.functional import vectorize

from python import Python
from python import Python, PythonObject
from .ndarray import NDArray, NDArrayShape, NDArrayStride


fn fill_pointer[
dtype: DType
](inout array: DTypePointer[dtype], size: Int, value: Scalar[dtype]) raises:
](
inout array: UnsafePointer[Scalar[dtype]], size: Int, value: Scalar[dtype]
) raises:
"""
Fill a NDArray with a specific value.
Expand Down Expand Up @@ -260,9 +262,8 @@ fn to_numpy[dtype: DType](array: NDArray[dtype]) raises -> PythonObject:
np_dtype = np.int8

numpyarray = np.empty(np_arr_dim, dtype=np_dtype)
var pointer = numpyarray.__array_interface__["data"][0]
var pointer_d = DTypePointer[array.dtype](address=pointer)
memcpy(pointer_d, array.data, array.num_elements())
var pointer_d = numpyarray.__array_interface__["data"][0].unsafe_get_as_pointer[dtype]()
memcpy(pointer_d, array.unsafe_ptr(), array.num_elements())
_ = array

return numpyarray^
Expand Down
4 changes: 2 additions & 2 deletions numojo/math/__init__.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ from .statistics import *
from .calculus import *
from .math_funcs import (
Vectorized,
VectorizedParallelized,
# VectorizedParallelized,
VectorizedUnroll,
VectorizedVerbose,
VectorizedParallelizedNWorkers,
# VectorizedParallelizedNWorkers,
)
from .interpolate import *
1 change: 1 addition & 0 deletions numojo/math/arithmetic.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Implements array arithmetic
import math
from algorithm import parallelize
from algorithm import Static2DTileUnitFunc as Tile2DFunc
from utils import Variant

import . math_funcs as _mf
from ..core.ndarray import NDArray, NDArrayShape
Expand Down
1 change: 1 addition & 0 deletions numojo/math/linalg/matmul.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Matrix multiplication functions for NDArrays
import math
from algorithm import parallelize, vectorize
from algorithm import Static2DTileUnitFunc as Tile2DFunc
from sys import simdwidthof

import .. math_funcs as _mf
from ...core.ndarray import NDArray, NDArrayShape
Expand Down
Loading

0 comments on commit 108d90b

Please sign in to comment.