Skip to content

Commit 80705fe

Browse files
Merge pull request #89 from Mojo-Numerics-and-Algorithms-group/experimental
Experimental to main for V0.2
2 parents 66c5d89 + 5b84a57 commit 80705fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5444
-2129
lines changed

.gitignore

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,13 @@
22
/build
33
/dist
44
/local
5-
/.vscode
5+
/.vscode
6+
.DS_Store
7+
*.html
8+
*.css
9+
*.py
10+
mojo
11+
numojo.mojopkg
12+
.gitignore
13+
bench.mojo
14+
test_ndarray.ipynb

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ Please follow the Mojo standard library style guide for all contributions. Consi
1010
- Write concise, well-documented code.
1111
- Adhere to formatting conventions for indentation, spacing, and line breaks.
1212

13+
Additionally refer to `style guide.md` for docstring and nameing conventions.
14+
1315
## Pull Requests
1416

1517
When submitting pull requests:

README.MD

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
<br />
1515
<!-- when we create docs -->
1616
<a href="https://github.com/Mojo-Numerics-and-Algorithms-group/NuMojo-Examples-and-Benchmarks/blob/main/docs/README.md"><strong>Explore the docs» </strong></a>
17+
<br>
18+
<a href="https://discord.com/channels/1149778565756366939/1149778566603620455"><strong>Check out our Discord» </strong></a>
1719
<br />
1820
<!-- <br /> -->
1921
<!-- <a href="">View Demo</a>
@@ -53,8 +55,8 @@
5355

5456
NuMojo intends to capture a wide swath of numerics capability present in the Python packages NumPy, SciPy and Scikit.
5557

56-
NuMojo intends to try and get the most out of the capabilities of Mojo including vectorization, parallelization, and GPU acceleration(once available). Currently, NuMojo extends (most of) the standard library math functions to work on tensor inputs.
57-
NuMojo intends to try and get the most out of the capabilities of Mojo including vectorization, parallelization, and GPU acceleration(once available). Currently, NuMojo extends (most of) the standard library math functions to work on tensor inputs.
58+
NuMojo intends to try and get the most out of the capabilities of Mojo including vectorization, parallelization, and GPU acceleration(once available). Currently, NuMojo extends (most of) the standard library math functions to work on array inputs.
59+
NuMojo intends to try and get the most out of the capabilities of Mojo including vectorization, parallelization, and GPU acceleration(once available). Currently, NuMojo extends (most of) the standard library math functions to work on array inputs.
5860

5961
NuMojo intends to be a building block for other Mojo packages that need fast math under the hood without the added weight of a ML back and forward propagation system
6062

Roadmap.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@ With that in mind NuMojo as a project is in an early stage of development. If yo
66

77
## TASKS
88

9-
* Implement tensor version all SIMDable standard library math functions (mostly done waiting on std lib [issue 2492](https://github.com/modularml/mojo/issues/2492))
9+
* Implement array version all SIMDable standard library math functions (mostly done waiting on std lib [issue 2492](https://github.com/modularml/mojo/issues/2492))
1010
* Build statistics functions
1111
* Build optimizers (newton raphson, bisection,etc)
1212
* Build function approximators
1313

1414
## N-dimensional Arrays
1515

16-
Now that Modular has decided to no longer support Tensor and to open source and deprecate it NuMojo intends to take Tensor and Make it our own Once they do.
16+
Now that Modular has decided to no longer support array and to open source and deprecate it NuMojo intends to take array and Make it our own Once they do.
1717

18-
Which means that we will be trying to add many of the features from numpy.array that tensor currently lacks, while not sacrificing performance.
18+
Which means that we will be trying to add many of the features from numpy.array that array currently lacks, while not sacrificing performance.
1919

2020
## Notional organization of functions and features
2121

numojo/__init__.mojo

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
"""
2-
# ===----------------------------------------------------------------------=== #
3-
A Mathematics and Algorithm Library for Mojo.
4-
# ===----------------------------------------------------------------------=== #
2+
An Array Mathematics library for Mojo.
53
"""
64

75
from .core import *
86
from .math import *
97
from .math.statistics import stats
108

11-
# from .comparison import *
12-
# from .tensor_func_bit_ops import * #Doesn't work yet due to type issues
13-
# from .constants import Constants
14-
# var pi: Float64 = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555954930381966446229489
9+
# Constants
10+
alias pi = core.constants.Constants.pi
11+
alias e = core.constants.Constants.e
12+
alias c = core.constants.Constants.c

numojo/core/_array_funcs.mojo

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,24 @@ Implementing backend for array keeping it simple for now
77
"""
88

99

10-
fn _math_func_1_array_in_one_array_out[
10+
fn math_func_1_array_in_one_array_out[
1111
dtype: DType,
1212
func: fn[type: DType, simd_w: Int] (SIMD[type, simd_w]) -> SIMD[
1313
type, simd_w
1414
],
1515
](array: NDArray[dtype]) raises -> NDArray[dtype]:
1616
"""
17-
Apply a SIMD function of one variable and one return to a NDArray
17+
Apply a SIMD compatible function to a NDArray and returns a new NDArray.
1818
1919
Parameters:
20-
dtype: The element type.
21-
func: the SIMD function to to apply.
20+
dtype: The NDArray element type.
21+
func: The SIMD compatible function to act on the NDArray.
2222
2323
Args:
24-
array: A NDArray
24+
array: A NDArray.
2525
2626
Returns:
27-
A a new NDArray that is NDArray with the function func applied.
27+
A new NDArray that is the result of applying the function to the NDArray.
2828
"""
2929
var result_array: NDArray[dtype] = NDArray[dtype](array.shape())
3030
alias opt_nelts = simdwidthof[dtype]()
@@ -41,28 +41,28 @@ fn _math_func_1_array_in_one_array_out[
4141
return result_array
4242

4343

44-
fn _math_func_2_array_in_one_array_out[
44+
fn math_func_2_array_in_one_array_out[
4545
dtype: DType,
4646
func: fn[type: DType, simd_w: Int] (
4747
SIMD[type, simd_w], SIMD[type, simd_w]
4848
) -> SIMD[type, simd_w],
4949
](array1: NDArray[dtype], array2: NDArray[dtype]) raises -> NDArray[dtype]:
5050
"""
51-
Apply a SIMD function of two variable and one return to a NDArray
51+
Apply a SIMD compatible function to two NDArrays and returns a new NDArray.
5252
53-
Constraints:
54-
Both arrays must have the same shape
53+
Raises:
54+
Error if the two arrays do not have the same shape.
5555
5656
Parameters:
57-
dtype: The element type.
58-
func: the SIMD function to to apply.
57+
dtype: The NDArray element type.
58+
func: The SIMD compatible function to act on the NDArrays.
5959
6060
Args:
61-
array1: A NDArray
62-
array2: A NDArray
61+
array1: A NDArray.
62+
array2: A NDArray.
6363
6464
Returns:
65-
A a new NDArray that is NDArray with the function func applied.
65+
A new NDArray that is the result of applying the function to the input NDArrays.
6666
"""
6767

6868
if array1.shape() != array2.shape():
@@ -83,28 +83,25 @@ fn _math_func_2_array_in_one_array_out[
8383
return result_array
8484

8585

86-
fn _math_func_one_array_one_SIMD_in_one_array_out[
86+
fn math_func_one_array_one_SIMD_in_one_array_out[
8787
dtype: DType,
8888
func: fn[type: DType, simd_w: Int] (
8989
SIMD[type, simd_w], SIMD[type, simd_w]
9090
) -> SIMD[type, simd_w],
9191
](array: NDArray[dtype], scalar: SIMD[dtype, 1]) raises -> NDArray[dtype]:
9292
"""
93-
Apply a SIMD function of two variable and one return to a NDArray
94-
95-
Constraints:
96-
Both arrays must have the same shape
93+
Apply a SIMD compatible function to a NDArray and a SIMD value and returns a new NDArray.
9794
9895
Parameters:
99-
dtype: The element type.
100-
func: the SIMD function to to apply.
96+
dtype: The NDArray element type.
97+
func: The SIMD compatible function to act on the NDArray and SIMD value.
10198
10299
Args:
103-
array: A NDArray
104-
scalar: scalar value
100+
array: A NDArray.
101+
scalar: A scalar value.
105102
106103
Returns:
107-
A a new NDArray that is NDArray with the function func applied.
104+
A new NDArray that is the result of applying the function to the input NDArray and SIMD value.
108105
"""
109106

110107
var result_array: NDArray[dtype] = NDArray[dtype](array.shape())

0 commit comments

Comments
 (0)