Repository: ivy-llc/ivy

Issue:
numpy.dot



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/numpy/__init__.py b/ivy/functional/frontends/numpy/__init__.py
--- a/ivy/functional/frontends/numpy/__init__.py
+++ b/ivy/functional/frontends/numpy/__init__.py
@@ -619,7 +619,10 @@ def promote_types_of_numpy_inputs(
     _logical_xor,
 )
 
-from ivy.functional.frontends.numpy.linalg.matrix_and_vector_products import _matmul
+from ivy.functional.frontends.numpy.linalg.matrix_and_vector_products import (
+    _matmul,
+    dot,
+)
 
 from ivy.functional.frontends.numpy.mathematical_functions.extrema_finding import (
     _maximum,
diff --git a/ivy/functional/frontends/numpy/linalg/matrix_and_vector_products.py b/ivy/functional/frontends/numpy/linalg/matrix_and_vector_products.py
--- a/ivy/functional/frontends/numpy/linalg/matrix_and_vector_products.py
+++ b/ivy/functional/frontends/numpy/linalg/matrix_and_vector_products.py
@@ -68,3 +68,10 @@ def cross(a, b, *, axisa=-1, axisb=-1, axisc=-1, axis=None):
 @to_ivy_arrays_and_back
 def multi_dot(arrays, *, out=None):
     return ivy.multi_dot(arrays, out=out)
+
+
+@handle_numpy_out
+@to_ivy_arrays_and_back
+def dot(a, b, out=None):
+    a, b = promote_types_of_numpy_inputs(a, b)
+    return ivy.matmul(a, b)


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_numpy/test_linear_algebra/test_matrix_and_vector_products.py b/ivy_tests/test_ivy/test_frontends/test_numpy/test_linear_algebra/test_matrix_and_vector_products.py
--- a/ivy_tests/test_ivy/test_frontends/test_numpy/test_linear_algebra/test_matrix_and_vector_products.py
+++ b/ivy_tests/test_ivy/test_frontends/test_numpy/test_linear_algebra/test_matrix_and_vector_products.py
@@ -325,3 +325,58 @@ def test_numpy_multi_dot(
         rtol=1e-3,
         atol=1e-3,
     )
+
+
+# dot
+@st.composite
+def _get_dtype_input_and_vectors(draw):
+    dim_size = draw(helpers.ints(min_value=1, max_value=5))
+    dtype = draw(helpers.get_dtypes("float", index=1, full=False))
+    if dim_size == 1:
+        vec1 = draw(
+            helpers.array_values(
+                dtype=dtype[0], shape=(dim_size,), min_value=2, max_value=5
+            )
+        )
+        vec2 = draw(
+            helpers.array_values(
+                dtype=dtype[0], shape=(dim_size,), min_value=2, max_value=5
+            )
+        )
+    else:
+        vec1 = draw(
+            helpers.array_values(
+                dtype=dtype[0], shape=(dim_size, dim_size), min_value=2, max_value=5
+            )
+        )
+        vec2 = draw(
+            helpers.array_values(
+                dtype=dtype[0], shape=(dim_size, dim_size), min_value=2, max_value=5
+            )
+        )
+    return dtype, vec1, vec2
+
+
+@handle_frontend_test(
+    fn_tree="numpy.dot",
+    dtype_a_b=_get_dtype_input_and_vectors(),
+)
+def test_numpy_dot(
+    dtype_a_b,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+):
+    dtype, a, b = dtype_a_b
+    helpers.test_frontend_function(
+        input_dtypes=dtype,
+        frontend=frontend,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        test_flags=test_flags,
+        rtol=1e-01,
+        atol=1e-01,
+        a=a,
+        b=b,
+    )