Browse Source

commit test.py for Dockerfile demonstration

Alex Cheema 8 months ago
parent
commit
23de337217
1 changed files with 27 additions and 0 deletions
  1. 27 0
      test.py

+ 27 - 0
test.py

@@ -0,0 +1,27 @@
+import mlx.core as mx
+import numpy as np
+
+# Create some test arrays
+a = mx.array([[1, 2, 3], [4, 5, 6]], dtype=mx.float32)
+b = mx.array([[7, 8, 9], [10, 11, 12]], dtype=mx.float32)
+
+# Test basic operations
+print("Array a:")
+print(a)
+print("\nArray b:")
+print(b)
+
+# Test multiplication
+c = mx.multiply(a, b)
+print("\nElement-wise multiplication (a * b):")
+print(c)
+
+# Test matrix multiplication
+d = a @ b.transpose()
+print("\nMatrix multiplication (a @ b.T):")
+print(d)
+
+# Test converting to numpy
+print("\nConvert to numpy array:")
+numpy_array = np.array(c)
+print(numpy_array)