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

stack adhering to Array API standard #536

Merged
merged 17 commits into from
Apr 1, 2022
Merged

stack adhering to Array API standard #536

merged 17 commits into from
Apr 1, 2022

Conversation

juliagsy
Copy link
Contributor

No description provided.

@juliagsy
Copy link
Contributor Author

Hello! I'm working on the stack function for manipulation functions and I'm good to go once the Tensorflow test has passed. However, I'm kinda stuck now so could someone help in giving it a look?

@juliagsy
Copy link
Contributor Author

juliagsy commented Mar 15, 2022

The errors are as follows:

__________________________________ test_stack __________________________________
[183](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:183)

[184](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:184)
    @given(
[185](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:185)
>       shape=shared_shapes(min_dims=1),
[186](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:186)
        dtypes=hh.mutually_promotable_dtypes(None),
[187](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:187)
        kw=hh.kwargs(
[188](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:188)
            axis=shared_shapes(min_dims=1).flatmap(
[189](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:189)
                lambda s: st.integers(-len(s), len(s) - 1)
[190](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:190)
            )
[191](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:191)
        ),
[192](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:192)
        data=st.data(),
[193](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:193)
    )
[194](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:194)

[195](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:195)
ivy/ivy_tests/test_array_api/array_api_tests/test_manipulation_functions.py:322: 
[196](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:196)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[197](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:197)
ivy/ivy_tests/test_array_api/array_api_tests/test_manipulation_functions.py:337: in test_stack
[198](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:198)
    out = xp.stack(arrays, **kw)
[199](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:199)
ivy/ivy/func_wrapper.py:50: in _method_wrapped
[200](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:200)
    native_ret = fn(*native_args, **native_kwargs)
[201](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:201)
usr/local/lib/python3.8/dist-packages/tensorflow/python/util/traceback_utils.py:153: in error_handler
[202](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:202)
    raise e.with_traceback(filtered_tb) from None
[203](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:203)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[204](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:204)

[205](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:205)
e = _NotOkStatusException(), name = 'stack'
[206](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:206)

[207](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:207)
    def raise_from_not_ok_status(e, name):
[208](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:208)
      e.message += (" name: " + name if name is not None else "")
[209](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:209)
>     raise core._status_to_exception(e) from None  # pylint: disable=protected-access
[210](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:210)
E     tensorflow.python.framework.errors_impl.InvalidArgumentError: cannot compute Pack as input #1(zero-based) was expected to be a uint8 tensor but is a uint16 tensor [Op:Pack] name: stack
[211](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:211)

[212](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:212)
usr/local/lib/python3.8/dist-packages/tensorflow/python/framework/ops.py:7186: InvalidArgumentError
[213](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:213)
----------------------------- Captured stdout call -----------------------------
[214](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:214)
f_idx=':'
[215](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:215)
f_idx=':'
[216](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:216)
f_idx=':'
[217](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:217)
f_idx=':'
[218](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:218)
f_idx=':'
[219](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:219)
f_idx=':'
[220](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:220)
f_idx=':'
[221](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:221)
f_idx=':'
[222](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:222)
f_idx=':'
[223](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:223)
f_idx=':'
[224](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:224)
---------------------------------- Hypothesis ----------------------------------
[225](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:225)
Falsifying example: test_stack(
[226](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:226)
    shape=(0,), dtypes=(tf.uint8, tf.uint16), kw={}, data=data(...),
[227](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:227)
)
[228](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:228)
Draw 1 (x1): ivy.array([], dtype=uint8)
[229](https://github.com/unifyai/ivy/runs/5548977686?check_suite_focus=true#step:3:229)
Draw 2 (x2): ivy.array([], dtype=uint16)

@juliagsy
Copy link
Contributor Author

juliagsy commented Mar 15, 2022

My function implementation for Tensorflow backend stack is:

def stack(x: Union[Tuple[Tensor], List[Tensor]],
          axis: Optional[int] = None)\
          -> Tensor:
    x = tf.cast(x, dtype=tf.uint8)
    if axis is None:
        new_axis = 0
    else:
        new_axis = axis
    return tf.stack(x, axis=new_axis)

@juliagsy
Copy link
Contributor Author

I've added type casting as I thought the errors looked associated with type (uint8 and uint16) but the error did not actually go off. Thanks in advance!

@juliagsy juliagsy marked this pull request as ready for review March 15, 2022 06:56
@djl11 djl11 requested a review from 1Doomdie1 March 15, 2022 08:28
@mattbarrett98 mattbarrett98 changed the title stack stack adhering to Array API standard Apr 1, 2022
@mattbarrett98 mattbarrett98 linked an issue Apr 1, 2022 that may be closed by this pull request
@mattbarrett98 mattbarrett98 merged commit 5882c45 into ivy-llc:master Apr 1, 2022
@mattbarrett98
Copy link
Contributor

Thanks for contributing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stack
4 participants