Skip to content

[TFLite] Strided slice handling of shrink_axis_mask improved#6998

Merged
FrozenGene merged 2 commits intoapache:mainfrom
d-smirnov:strided_slice_shrink_axis_mask
Jan 21, 2021
Merged

[TFLite] Strided slice handling of shrink_axis_mask improved#6998
FrozenGene merged 2 commits intoapache:mainfrom
d-smirnov:strided_slice_shrink_axis_mask

Conversation

@d-smirnov
Copy link
Copy Markdown
Contributor

  1. Added removal of dimensions if result is a scalar
    to mimic TensorFlow behaviour. E.g.:
    tf.strided_slice([1,2,3], [0], [1], [1], shrink_axis_mask=0)
    <tf.Tensor: shape=(1,), dtype=int32, numpy=array([1], dtype=int32)>

    tf.strided_slice([[[1,2,3],[4,5,6],[7,8,9]]], [0, 0, 0], [3, 3, 3], [1, 1, 1], shrink_axis_mask=7)
    <tf.Tensor: shape=(), dtype=int32, numpy=1>

  2. Added extra check to assert_allclose to check shape equalities
    as np.testing.assert_allclose() does not distinguish between cases like:

    np.testing.assert_allclose(1, np.array(1))
    np.testing.assert_allclose(1, np.array([1]))
    np.testing.assert_allclose(np.array(1), np.array([1]))

1. Added removal of dimensions if result is a scalar
to mimic TensorFlow behaviour. E.g.:
    tf.strided_slice([1,2,3], [0], [1], [1], shrink_axis_mask=0)
    <tf.Tensor: shape=(1,), dtype=int32, numpy=array([1], dtype=int32)>

    tf.strided_slice([[[1,2,3],[4,5,6],[7,8,9]]], [0, 0, 0], [3, 3, 3], [1, 1, 1], shrink_axis_mask=7)
    <tf.Tensor: shape=(), dtype=int32, numpy=1>

2. Added extra check to assert_allclose to check shape equalities
as np.testing.assert_allclose() does not distinguish between cases like:

    np.testing.assert_allclose(1, np.array(1))
    np.testing.assert_allclose(1, np.array([1]))
    np.testing.assert_allclose(np.array(1), np.array([1]))
@d-smirnov
Copy link
Copy Markdown
Contributor Author

Ping. How can we make some progress here?
@comaniac Please advise should the commit be split? What to do with failed unit tests?

@comaniac
Copy link
Copy Markdown
Contributor

comaniac commented Dec 9, 2020

Ping. How can we make some progress here?
@comaniac Please advise should the commit be split? What to do with failed unit tests?

I'm not familiar with TFLite frontend. cc @siju-samuel @FrozenGene

@d-smirnov
Copy link
Copy Markdown
Contributor Author

bump cc @siju-samuel @FrozenGene
Please, also advise on extra check to assert_allclose

@d-smirnov
Copy link
Copy Markdown
Contributor Author

How can we make a progress here?

@FrozenGene
Copy link
Copy Markdown
Member

@d-smirnov I will review it today, thanks!

@FrozenGene
Copy link
Copy Markdown
Member

please fix ci problem

@d-smirnov d-smirnov requested a review from FrozenGene January 18, 2021 18:50
Comment thread tests/python/integration/test_reduce.py
@d-smirnov d-smirnov requested a review from FrozenGene January 20, 2021 21:24
@FrozenGene FrozenGene merged commit e8ab607 into apache:main Jan 21, 2021
alexwong pushed a commit to alexwong/tvm that referenced this pull request Feb 11, 2021
…6998)

* [TFLite] Strided slice handlig of shrink_axis_mask improved

1. Added removal of dimensions if result is a scalar
to mimic TensorFlow behaviour. E.g.:
    tf.strided_slice([1,2,3], [0], [1], [1], shrink_axis_mask=0)
    <tf.Tensor: shape=(1,), dtype=int32, numpy=array([1], dtype=int32)>

    tf.strided_slice([[[1,2,3],[4,5,6],[7,8,9]]], [0, 0, 0], [3, 3, 3], [1, 1, 1], shrink_axis_mask=7)
    <tf.Tensor: shape=(), dtype=int32, numpy=1>

2. Added extra check to assert_allclose to check shape equalities
as np.testing.assert_allclose() does not distinguish between cases like:

    np.testing.assert_allclose(1, np.array(1))
    np.testing.assert_allclose(1, np.array([1]))
    np.testing.assert_allclose(np.array(1), np.array([1]))

* unit tests fixed
electriclilies pushed a commit to electriclilies/tvm that referenced this pull request Feb 18, 2021
…6998)

* [TFLite] Strided slice handlig of shrink_axis_mask improved

1. Added removal of dimensions if result is a scalar
to mimic TensorFlow behaviour. E.g.:
    tf.strided_slice([1,2,3], [0], [1], [1], shrink_axis_mask=0)
    <tf.Tensor: shape=(1,), dtype=int32, numpy=array([1], dtype=int32)>

    tf.strided_slice([[[1,2,3],[4,5,6],[7,8,9]]], [0, 0, 0], [3, 3, 3], [1, 1, 1], shrink_axis_mask=7)
    <tf.Tensor: shape=(), dtype=int32, numpy=1>

2. Added extra check to assert_allclose to check shape equalities
as np.testing.assert_allclose() does not distinguish between cases like:

    np.testing.assert_allclose(1, np.array(1))
    np.testing.assert_allclose(1, np.array([1]))
    np.testing.assert_allclose(np.array(1), np.array([1]))

* unit tests fixed
Lokiiiiii pushed a commit to Lokiiiiii/tvm that referenced this pull request Mar 2, 2021
…6998)

* [TFLite] Strided slice handlig of shrink_axis_mask improved

1. Added removal of dimensions if result is a scalar
to mimic TensorFlow behaviour. E.g.:
    tf.strided_slice([1,2,3], [0], [1], [1], shrink_axis_mask=0)
    <tf.Tensor: shape=(1,), dtype=int32, numpy=array([1], dtype=int32)>

    tf.strided_slice([[[1,2,3],[4,5,6],[7,8,9]]], [0, 0, 0], [3, 3, 3], [1, 1, 1], shrink_axis_mask=7)
    <tf.Tensor: shape=(), dtype=int32, numpy=1>

2. Added extra check to assert_allclose to check shape equalities
as np.testing.assert_allclose() does not distinguish between cases like:

    np.testing.assert_allclose(1, np.array(1))
    np.testing.assert_allclose(1, np.array([1]))
    np.testing.assert_allclose(np.array(1), np.array([1]))

* unit tests fixed
trevor-m pushed a commit to neo-ai/tvm that referenced this pull request Mar 2, 2021
…6998)

* [TFLite] Strided slice handlig of shrink_axis_mask improved

1. Added removal of dimensions if result is a scalar
to mimic TensorFlow behaviour. E.g.:
    tf.strided_slice([1,2,3], [0], [1], [1], shrink_axis_mask=0)
    <tf.Tensor: shape=(1,), dtype=int32, numpy=array([1], dtype=int32)>

    tf.strided_slice([[[1,2,3],[4,5,6],[7,8,9]]], [0, 0, 0], [3, 3, 3], [1, 1, 1], shrink_axis_mask=7)
    <tf.Tensor: shape=(), dtype=int32, numpy=1>

2. Added extra check to assert_allclose to check shape equalities
as np.testing.assert_allclose() does not distinguish between cases like:

    np.testing.assert_allclose(1, np.array(1))
    np.testing.assert_allclose(1, np.array([1]))
    np.testing.assert_allclose(np.array(1), np.array([1]))

* unit tests fixed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants