Repository: ivy-llc/ivy

Issue:
cross



Discussion:

Resolving patch:
diff --git a/ivy/functional/frontends/paddle/tensor/linalg.py b/ivy/functional/frontends/paddle/tensor/linalg.py
--- a/ivy/functional/frontends/paddle/tensor/linalg.py
+++ b/ivy/functional/frontends/paddle/tensor/linalg.py
@@ -7,6 +7,15 @@
 )
 
 
+@with_supported_dtypes(
+    {"2.4.2 and below": ("float32", "float64", "int32", "int64")}, "paddle"
+)
+@to_ivy_arrays_and_back
+def cross(x, y, /, *, axis=9, name=None):
+    x, y = promote_types_of_paddle_inputs(x, y)
+    return ivy.cross(x, y, axis=axis)
+
+
 # matmul
 @with_unsupported_dtypes({"2.4.2 and below": ("float16", "bfloat16")}, "paddle")
 @to_ivy_arrays_and_back


Test patch:
diff --git a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_linalg.py b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_linalg.py
--- a/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_linalg.py
+++ b/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_paddle_linalg.py
@@ -13,6 +13,67 @@
 # ------ #
 
 
+@st.composite
+def dtype_value1_value2_axis(
+    draw,
+    available_dtypes,
+    abs_smallest_val=None,
+    min_value=None,
+    max_value=None,
+    allow_inf=False,
+    exclude_min=False,
+    exclude_max=False,
+    min_num_dims=1,
+    max_num_dims=10,
+    min_dim_size=1,
+    max_dim_size=10,
+    specific_dim_size=3,
+    large_abs_safety_factor=4,
+    small_abs_safety_factor=4,
+    safety_factor_scale="log",
+):
+    # For cross product, a dim with size 3 is required
+    shape = draw(
+        helpers.get_shape(
+            allow_none=False,
+            min_num_dims=min_num_dims,
+            max_num_dims=max_num_dims,
+            min_dim_size=min_dim_size,
+            max_dim_size=max_dim_size,
+        )
+    )
+    axis = draw(helpers.ints(min_value=0, max_value=len(shape)))
+    # make sure there is a dim with specific dim size
+    shape = list(shape)
+    shape = shape[:axis] + [specific_dim_size] + shape[axis:]
+    shape = tuple(shape)
+
+    dtype = draw(st.sampled_from(draw(available_dtypes)))
+
+    values = []
+    for i in range(2):
+        values.append(
+            draw(
+                helpers.array_values(
+                    dtype=dtype,
+                    shape=shape,
+                    abs_smallest_val=abs_smallest_val,
+                    min_value=min_value,
+                    max_value=max_value,
+                    allow_inf=allow_inf,
+                    exclude_min=exclude_min,
+                    exclude_max=exclude_max,
+                    large_abs_safety_factor=large_abs_safety_factor,
+                    small_abs_safety_factor=small_abs_safety_factor,
+                    safety_factor_scale=safety_factor_scale,
+                )
+            )
+        )
+
+    value1, value2 = values[0], values[1]
+    return [dtype], value1, value2, axis
+
+
 @st.composite
 def _get_dtype_input_and_vectors(draw):
     dim_size = draw(helpers.ints(min_value=1, max_value=2))
@@ -110,6 +171,42 @@ def _dtype_values_axis(draw):
 # ----- #
 
 
+# cross
+@handle_frontend_test(
+    fn_tree="paddle.tensor.linalg.cross",
+    dtype_x_y_axis=dtype_value1_value2_axis(
+        available_dtypes=helpers.get_dtypes("valid"),
+        min_num_dims=1,
+        max_num_dims=5,
+        min_dim_size=3,
+        max_dim_size=3,
+        min_value=-1e5,
+        max_value=1e5,
+        abs_smallest_val=0.01,
+        safety_factor_scale="log",
+    ),
+)
+def test_paddle_cross(
+    *,
+    dtype_x_y_axis,
+    frontend,
+    test_flags,
+    fn_tree,
+    on_device,
+):
+    dtype, x, y, axis = dtype_x_y_axis
+    helpers.test_frontend_function(
+        input_dtypes=dtype,
+        frontend=frontend,
+        test_flags=test_flags,
+        fn_tree=fn_tree,
+        on_device=on_device,
+        x=x,
+        y=y,
+        axis=axis,
+    )
+
+
 # matmul
 @handle_frontend_test(
     fn_tree="paddle.matmul",