diff --git a/recipes/endia/image.jpeg b/recipes/endia/image.jpeg deleted file mode 100644 index 13fccfaf..00000000 Binary files a/recipes/endia/image.jpeg and /dev/null differ diff --git a/recipes/endia/recipe.yaml b/recipes/endia/recipe.yaml deleted file mode 100644 index ce0e2657..00000000 --- a/recipes/endia/recipe.yaml +++ /dev/null @@ -1,44 +0,0 @@ -context: - version: "24.6.0" - -package: - name: "endia" - version: ${{ version }} - -source: - - git: https://github.com/endia-ai/Endia.git - rev: eeafbd1d1a519dbc63fd863c8922f37ec8f84a46 - -build: - number: 0 - script: - - mojo package endia -o ${{ PREFIX }}/lib/mojo/endia.mojopkg - -requirements: - host: - - max =24.6 - run: - - ${{ pin_compatible('max') }} - -tests: - - script: - - if: unix - then: - - mojo run test.mojo - requirements: - run: - - max =24.6 - files: - recipe: - - test.mojo - -about: - homepage: https://endia.vercel.app/ - license: Apache-2.0 - license_file: LICENSE - summary: Dynamic Neural Networks in Mojo - repository: https://github.com/endia-ai/Endia - -extra: - maintainers: - - TilliFe diff --git a/recipes/endia/test.mojo b/recipes/endia/test.mojo deleted file mode 100644 index d1c70285..00000000 --- a/recipes/endia/test.mojo +++ /dev/null @@ -1,41 +0,0 @@ -import endia -import testing - -# Define the function -def foo(x: endia.Array) -> endia.Array: - return endia.sum(x**2) - - -def main(): - # Initialize variable - requires_grad=True needed! - x = endia.array("[1.0, 2.0, 3.0]", requires_grad=True) - - # Compute result, first aendia secoendia order derivatives - y = foo(x) - y.backward(create_graph=True) - dy_dx = x.grad() - d2y_dx2 = endia.autograd.functional.grad(outs=dy_dx, inputs=x)[0] - - # Create callables for the jacobian aendia hessian - foo_jac = endia.grad(foo) - foo_hes = endia.grad(foo_jac) - - # Initialize variable - no requires_grad=True needed - x = endia.array("[1.0, 2.0, 3.0]") - - # Compute result aendia derivatives (with type hints) - y = foo(x) - dy_dx = foo_jac(x)[endia.Array] - d2y_dx2 = foo_hes(x)[endia.Array] - - testing.assert_equal(y.size(), 1) - testing.assert_equal(y.load(0), 14.0) - - testing.assert_equal(dy_dx.size(), 3) - testing.assert_equal(dy_dx.load(0), 2.0) - - testing.assert_equal(d2y_dx2.size(), 9) - testing.assert_equal(d2y_dx2.load(0), 2.0) - testing.assert_equal(d2y_dx2.load(1), 0.0) - - diff --git a/recipes/nabla/image.jpeg b/recipes/nabla/image.jpeg new file mode 100644 index 00000000..6657f1ef Binary files /dev/null and b/recipes/nabla/image.jpeg differ diff --git a/recipes/nabla/recipe.yaml b/recipes/nabla/recipe.yaml new file mode 100644 index 00000000..c3fbbd23 --- /dev/null +++ b/recipes/nabla/recipe.yaml @@ -0,0 +1,43 @@ +context: + version: "25.3.0" + +package: + name: "nabla" + version: ${{ version }} + +source: + - git: https://github.com/nabla-ml/nabla.git + rev: f677a02a82caada7d233e11bf4e189fdb702ef7f + +build: + number: 0 + script: + - mojo package nabla -o ${{ PREFIX }}/lib/mojo/nabla.mojopkg +requirements: + host: + - max =25.3 + run: + - ${{ pin_compatible('max') }} + +tests: + - script: + - if: unix + then: + - mojo test.mojo + requirements: + run: + - max =25.3 + files: + recipe: + - test.mojo + +about: + homepage: https://github.com/nabla-ml/nabla + license: Apache-2.0 + license_file: LICENSE + summary: Differtiable Programming in Mojo. + repository: https://github.com/nabla-ml/nabla + +extra: + maintainers: + - TilliFe \ No newline at end of file diff --git a/recipes/nabla/test.mojo b/recipes/nabla/test.mojo new file mode 100644 index 00000000..8b759c5e --- /dev/null +++ b/recipes/nabla/test.mojo @@ -0,0 +1,37 @@ +import nabla + + +fn main() raises: + + # Simple test to check if nabla is callable, extensive testing is done elsewhere! + + fn foo(args: List[nabla.Array]) raises -> List[nabla.Array]: + return List( + nabla.sum(nabla.sin(args[0] * args[1])), + nabla.sum(nabla.cos(args[0] * args[1])), + ) + + var foo_vmapped = nabla.vmap(foo) + var foo_d1 = nabla.jacrev(foo_vmapped) + var foo_d2 = nabla.jacfwd(foo_d1) + var foo_d3 = nabla.jacfwd(foo_d2) + + var args = List(nabla.arange((2, 3)), nabla.arange((2, 3))) + + var res = foo(args) + print("foo checksum: ", nabla.sum(res[0])) # , nabla.sum(res[1])) + + var d1 = foo_d1(args) + print( + "foo_d1 checksum: ", nabla.sum(d1[0]) + ) # , nabla.sum(d1[1]), nabla.sum(d1[2]), nabla.sum(d1[3])) + + var d2 = foo_d2(args) + print( + "foo_d2 checksum: ", nabla.sum(d2[0]) + ) # , nabla.sum(d2[1]), nabla.sum(d2[2]), nabla.sum(d2[3]), nabla.sum(d2[4]), nabla.sum(d2[5]), nabla.sum(d2[6]), nabla.sum(d2[7])) + + var d3 = foo_d3(args) + print( + "foo_d3 checksum: ", nabla.sum(d3[0]) + ) # , nabla.sum(d3[1]), nabla.sum(d3[2]), nabla.sum(d3[3]), nabla.sum(d3[4]), nabla.sum(d3[5]), nabla.sum(d3[6]), nabla.sum(d3[7]), nabla.sum(d3[8]), nabla.sum(d3[9]), nabla.sum(d3[10]), nabla.sum(d3[11]), nabla.sum(d3[12]), nabla.sum(d3[13]), nabla.sum(d3[14]), nabla.sum(d3[15])) \ No newline at end of file