Skip to content

Conversation

@anna-charlotte
Copy link
Contributor

@anna-charlotte anna-charlotte commented Jan 30, 2023

Signed-off-by: anna-charlotte [email protected]

Goals:

Add Tensorflow support to v2:

  • Add TF tensor type
    • As of right now, I haven't found a solution on how to subclass a tf.Tensor (see here), so for now we weill store the tf.Tensor instance as an attribute of a TensorFlowTensor instance.
  • Add TF computational backend
  • check and update documentation, if required. See guide

@anna-charlotte anna-charlotte linked an issue Jan 30, 2023 that may be closed by this pull request
3 tasks
@github-actions
Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

2 similar comments
@github-actions
Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@github-actions
Copy link

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@github-actions github-actions bot added size/l and removed size/xl labels Jan 31, 2023
@anna-charlotte anna-charlotte mentioned this pull request Feb 1, 2023
47 tasks
@github-actions github-actions bot added size/xl and removed size/l labels Feb 1, 2023
@github-actions
Copy link

github-actions bot commented Feb 1, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@anna-charlotte anna-charlotte force-pushed the feat-tensorflow-support branch from e410061 to efac716 Compare February 1, 2023 18:34
@github-actions
Copy link

github-actions bot commented Feb 1, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

3 similar comments
@github-actions
Copy link

github-actions bot commented Feb 2, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@github-actions
Copy link

github-actions bot commented Feb 2, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@github-actions
Copy link

github-actions bot commented Feb 2, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

return t.tensor


class TensorFlowCompBackend(AbstractNumpyBasedBackend[TensorFlowTensor]):
Copy link
Member

Choose a reason for hiding this comment

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

general comment about the class, to me it looks good I like that we rely on tnp as much as we can.

Maybe norm_left, norm_right should be named differenlty

norm_left could be : cast_output
norm_right could be: get_tensor

this will make the code clearer

maybe @JohannesMessner as a better idea for the name.

Copy link
Member

@samsja samsja left a comment

Choose a reason for hiding this comment

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

I added few comments

@anna-charlotte anna-charlotte force-pushed the feat-tensorflow-support branch from 5352804 to 494a9eb Compare February 3, 2023 16:05
@github-actions
Copy link

github-actions bot commented Feb 3, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@github-actions
Copy link

github-actions bot commented Feb 8, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Signed-off-by: anna-charlotte <[email protected]>
@github-actions
Copy link

github-actions bot commented Feb 8, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@github-actions
Copy link

github-actions bot commented Feb 8, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@github-actions
Copy link

github-actions bot commented Feb 8, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Signed-off-by: anna-charlotte <[email protected]>
@github-actions
Copy link

github-actions bot commented Feb 8, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

Comment on lines +36 to +39
try:
import tensorflow as tf # type: ignore

from docarray.typing import TensorFlowTensor
Copy link
Member

Choose a reason for hiding this comment

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

for torch i moved this thing to a helper in utils, so this check only has to be done once globally. Can we do the same for tf?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, saw that and started doing this in the TF embedding/video/audio PR, so i'll do this refactor there if that's fine with you @JohannesMessner

@github-actions
Copy link

github-actions bot commented Feb 8, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@anna-charlotte anna-charlotte marked this pull request as ready for review February 8, 2023 11:19
README.md Outdated
return inputs
```

Much nicer, don't you think? One main difference to using DocArray with PyTorch, is that when using TensorFlowTensor's, you have to access it's `.tensor` attribute directly, as it can be seen in `.forward_podcast()` above. This is due to the fact that while `TorchTensor` is a subclass of `torch.Tensor`, `TensorFlowTensor` is not a subclass of `tf.Tensor` but instead stores a `tf.Tensor` in its `.tensor` attribute.
Copy link
Member

Choose a reason for hiding this comment

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

It may be good to explain why this is the case?

Copy link
Member

Choose a reason for hiding this comment

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

Why is this different?

Copy link
Member

Choose a reason for hiding this comment

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

Why is this different?
@anna-charlotte you can probably add due to a technical limitation on tf.Tensor

@github-actions
Copy link

github-actions bot commented Feb 8, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

schema definition (see below). Everything handles in a pythonic manner by relying on type hints.


## Coming from TensorFlow
Copy link
Member

Choose a reason for hiding this comment

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

this part is too big IMO. We just need to show that there is a (tiny ?) difference and that you need to access tensor.tensor. No need to show the full example

README.md Outdated
return inputs
```

Much nicer, don't you think? One main difference to using DocArray with PyTorch, is that when using TensorFlowTensor's, you have to access it's `.tensor` attribute directly, as it can be seen in `.forward_podcast()` above. This is due to the fact that while `TorchTensor` is a subclass of `torch.Tensor`, `TensorFlowTensor` is not a subclass of `tf.Tensor` but instead stores a `tf.Tensor` in its `.tensor` attribute.
Copy link
Member

Choose a reason for hiding this comment

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

Why is this different?
@anna-charlotte you can probably add due to a technical limitation on tf.Tensor

@github-actions
Copy link

github-actions bot commented Feb 8, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@github-actions
Copy link

github-actions bot commented Feb 8, 2023

This PR exceeds the recommended size of 1000 lines. Please make sure you are NOT addressing multiple issues with one PR. Note this PR might be rejected due to its size.

@github-actions
Copy link

github-actions bot commented Feb 8, 2023

📝 Docs are deployed on https://ft-feat-tensorflow-support--jina-docs.netlify.app 🎉

1 similar comment
@github-actions
Copy link

github-actions bot commented Feb 8, 2023

📝 Docs are deployed on https://ft-feat-tensorflow-support--jina-docs.netlify.app 🎉

Copy link
Member

@JohannesMessner JohannesMessner left a comment

Choose a reason for hiding this comment

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

LGTM

@samsja samsja merged commit 6b0d13c into feat-rewrite-v2 Feb 8, 2023
@samsja samsja deleted the feat-tensorflow-support branch February 8, 2023 14:27
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.

v2: Add Tensforflow support

5 participants