Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add broadcast_tensors method to paddle.tensor.Tensor #26789

Closed
wants to merge 4 commits into from

Conversation

Tinny-Robot
Copy link

PR Description

Changes Made

Added the broadcast_tensors function to the paddle.tensor.tensor.Tensor class and included the equivalent test case.

Details

  • Implemented the broadcast_tensors method to enable broadcasting operations for tensors in the paddle.tensor.tensor.Tensor class.
  • Added a corresponding test case to ensure the functionality of the newly added method.

This PR enhances the capabilities of the paddle.tensor.tensor.Tensor class by introducing the broadcast_tensors method and ensures its correctness through testing.

Related Issue

Close #25869

Checklist

  • Did you add a function?
  • Did you add the tests?
  • Did you run your tests and are your tests passing?
  • Did pre-commit not fail on any check?
  • Did you follow the steps we provided?

@github-actions
Copy link
Contributor

github-actions bot commented Oct 8, 2023

Thank you for this PR, here is the CI results:


This pull request does not result in any additional test failures. Congratulations!

@ivy-leaves ivy-leaves added the Paddle Frontend Developing the Paddle Frontend, checklist triggered by commenting add_frontend_checklist label Oct 9, 2023
@Tinny-Robot
Copy link
Author

Hello @Fayad-Alman .
Please can you review my pr

@ivy-seed ivy-seed assigned kurshakuz and unassigned Fayad-Alman Oct 13, 2023
@Tinny-Robot
Copy link
Author

hello @kurshakuz please review my pr

@Tinny-Robot
Copy link
Author

@clsandoval.
please can you help me review this pr?

@Tinny-Robot
Copy link
Author

@kurshakuz hello,
please is there any review you need for me?

Copy link
Contributor

@kurshakuz kurshakuz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey! Thank you for your contribution!

Your implementation is currently throwing the following error. Can you please resolve it?

  + Exception Group Traceback (most recent call last):
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/_pytest/runner.py", line 341, in from_call
  |     result: Optional[TResult] = func()
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/_pytest/runner.py", line 262, in <lambda>
  |     lambda: ihook(item=item, **kwds), when=when, reraise=reraise
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/pluggy/_hooks.py", line 493, in __call__
  |     return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/pluggy/_manager.py", line 115, in _hookexec
  |     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/pluggy/_callers.py", line 152, in _multicall
  |     return outcome.get_result()
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/pluggy/_result.py", line 114, in get_result
  |     raise exc.with_traceback(exc.__traceback__)
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/pluggy/_callers.py", line 77, in _multicall
  |     res = hook_impl.function(*args)
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/_pytest/runner.py", line 177, in pytest_runtest_call
  |     raise e
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/_pytest/runner.py", line 169, in pytest_runtest_call
  |     item.runtest()
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/_pytest/python.py", line 1792, in runtest
  |     self.ihook.pytest_pyfunc_call(pyfuncitem=self)
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/pluggy/_hooks.py", line 493, in __call__
  |     return self._hookexec(self.name, self._hookimpls, kwargs, firstresult)
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/pluggy/_manager.py", line 115, in _hookexec
  |     return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/pluggy/_callers.py", line 113, in _multicall
  |     raise exception.with_traceback(exception.__traceback__)
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/pluggy/_callers.py", line 77, in _multicall
  |     res = hook_impl.function(*args)
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/_pytest/python.py", line 194, in pytest_pyfunc_call
  |     result = testfunction(**testargs)
  |   File "/workspaces/ivy/ivy_tests/test_ivy/helpers/testing_helpers.py", line 896, in wrapped_test
  |     raise e
  |   File "/workspaces/ivy/ivy_tests/test_ivy/helpers/testing_helpers.py", line 889, in wrapped_test
  |     hypothesis_test_fn(*args, **kwargs)
  |   File "/workspaces/ivy/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py", line 1286, in test_paddle_tensor_broadcast_tensors
  |     class_tree=CLASS_TREE,
  |   File "/opt/miniconda/envs/multienv/lib/python3.10/site-packages/hypothesis/core.py", line 1471, in wrapped_test
  |     raise the_error_hypothesis_found
  | exceptiongroup.ExceptionGroup: Hypothesis found 2 distinct failures. (2 sub-exceptions)
  +-+---------------- 1 ----------------
    | Traceback (most recent call last):
    |   File "/workspaces/ivy/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py", line 1303, in test_paddle_tensor_broadcast_tensors
    |     helpers.test_frontend_method(
    |   File "/workspaces/ivy/ivy_tests/test_ivy/helpers/function_testing.py", line 2210, in test_frontend_method
    |     frontend_ret = ins_gt.__getattribute__(frontend_method_data.method_name)(
    |   File "/opt/fw/paddle/paddle/tensor/manipulation.py", line 1230, in broadcast_tensors
    |     return _C_ops.broadcast_tensors(input)
    | ValueError: (InvalidArgument) broadcast_tensors(): argument 'input' (position 0) must be list of Tensors, but got Tensor (at /paddle/paddle/fluid/pybind/eager_utils.cc:1080)
    | 
    | Falsifying example: test_paddle_tensor_broadcast_tensors(
    |     frontend='paddle',
    |     on_device='cpu',
    |     backend_fw='paddle',
    |     dtype_and_x=(['float64'], [array([1.])]),
    |     method_flags=FrontendMethodTestFlags(
    |         num_positional_args=0,
    |         as_variable=[False],
    |         native_arrays=[False],
    |         precision_mode=False,
    |         inplace=False,
    |         test_trace=False,
    |         generate_frontend_arrays=False,
    |     ),
    |     frontend_method_data=FrontendMethodData(ivy_init_module='ivy.functional.frontends.paddle', framework_init_module='paddle', init_name='to_tensor', method_name='broadcast_tensors'),
    |     init_flags=FrontendInitTestFlags(
    |         num_positional_args=1,
    |         as_variable=[False],
    |         native_arrays=[False],
    |     ),
    | )
    | 
    | You can reproduce this example by temporarily adding @reproduce_failure('6.88.1', b'AXicY2BkYWBgFGVhZIACOIOBAQAC9wAi') as a decorator on your test case
    +---------------- 2 ----------------
    | Traceback (most recent call last):
    |   File "/workspaces/ivy/ivy_tests/test_ivy/test_frontends/test_paddle/test_tensor/test_tensor.py", line 1303, in test_paddle_tensor_broadcast_tensors
    |     helpers.test_frontend_method(
    |   File "/workspaces/ivy/ivy_tests/test_ivy/helpers/function_testing.py", line 2210, in test_frontend_method
    |     frontend_ret = ins_gt.__getattribute__(frontend_method_data.method_name)(
    |   File "/opt/fw/paddle/paddle/tensor/manipulation.py", line 1228, in broadcast_tensors
    |     num_inputs = len(input)
    |   File "/opt/fw/paddle/paddle/fluid/dygraph/math_op_patch.py", line 134, in _len_
    |     assert var.ndim > 0, "len() of a 0-D tensor is wrong"
    | AssertionError: len() of a 0-D tensor is wrong
    | Falsifying example: test_paddle_tensor_broadcast_tensors(
    |     frontend='paddle',
    |     on_device='cpu',
    |     backend_fw='paddle',
    |     dtype_and_x=(['float64'], [array(-1.)]),  # or any other generated value
    |     method_flags=FrontendMethodTestFlags(
    |         num_positional_args=0,
    |         as_variable=[False],
    |         native_arrays=[False],
    |         precision_mode=False,
    |         inplace=False,
    |         test_trace=False,
    |         generate_frontend_arrays=False,
    |     ),
    |     frontend_method_data=FrontendMethodData(ivy_init_module='ivy.functional.frontends.paddle', framework_init_module='paddle', init_name='to_tensor', method_name='broadcast_tensors'),
    |     init_flags=FrontendInitTestFlags(
    |         num_positional_args=1,
    |         as_variable=[False],
    |         native_arrays=[False],
    |     ),
    | )
    | 
    | You can reproduce this example by temporarily adding @reproduce_failure('6.88.1', b'AXicY2AAAkYGCIDRQAAAADYAAw==') as a decorator on your test case

Please request a review only once you resolved it and tested it locally. After doing so, please show the results of passing tests. Thanks!

@Tinny-Robot
Copy link
Author

@kurshakuz I have fixed the issue

@Sarvesh-Kesharwani
Copy link
Contributor

@reproduce_failure('6.97.1', b'AXicY2AAAkYGCGBEY0MBAAB4AAU=')
image
it is failing for all the backends, please fix the function return type.
image

@ivy-seed ivy-seed added the Stale label Mar 24, 2024
@ivy-seed
Copy link

This PR has been labelled as stale because it has been inactive for more than 7 days. If you would like to continue working on this PR, then please add another comment or this PR will be closed in 7 days.

@Ishticode
Copy link
Contributor

Thank you very much for the PR. Closing this due to lack of activity with changes requested remaining unresolved for several months. Please feel free to reopen if you would like to continue working on this. :)

@Ishticode Ishticode closed this Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Paddle Frontend Developing the Paddle Frontend, checklist triggered by commenting add_frontend_checklist Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

broadcast_tensors
8 participants