Skip to content
This repository was archived by the owner on Jul 1, 2023. It is now read-only.

Remove check for equal shapes in isAlmostEqual #367

Merged
merged 4 commits into from
Jul 29, 2019

Conversation

dominikgrewe
Copy link
Contributor

No description provided.

Co-Authored-By: Anthony Platanios <[email protected]>
@googlebot
Copy link

So there's good news and bad news.

👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there.

😕 The bad news is that it appears that one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request.

Note to project maintainer: This is a terminal state, meaning the cla/google commit status will not change from this state. It's up to you to confirm consent of all the commit author(s), set the cla label to yes (if enabled on your project), and then merge this pull request when appropriate.

ℹ️ Googlers: Go here for more info.

@@ -229,14 +229,12 @@ public extension StringTensor {
}

public extension Tensor where Scalar: TensorFlowFloatingPoint {
/// Returns `true` if tensors are of equal shape and all pairs of scalars are approximately
/// equal.
/// Returns `true` if all elements of this tensor are approximately equal to those of `other`.
Copy link
Contributor

Choose a reason for hiding this comment

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

Semantically, does isAlmostEqual(to:tolerance:) support arguments with incompatible shapes? If only compatible shapes are accepted, saying "all elements ... are approximately equal" sounds like a scalar comparison on flattened arrays. It'd be good to say something about shapes here as well as in elementsAlmostEqual(_:tolerance:).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The underlying TF op requires the shapes to be the same, see https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/cwise_ops_common.h#L172

I added that condition to the comment.

Is this something we want to catch at the Swift level? It seems generally we don't catch shape errors at the Swift level, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

@bgogul has been working on tracking Tensor shapes in the Swift Tensor object as part of his work on Lazy Tensor. I'll let him comment further. :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

@saeta could we also discuss this during Friday's meeting?

Copy link
Contributor

Choose a reason for hiding this comment

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

Here is a work in progress prototype of shape inference: https://github.com/tensorflow/swift-apis/pull/388/files

Note that this requires some changes from TF. So, you won't be able to try it right away. However, this gives the gist of what will be available on the Swift side. Essentially, we will be able to examine shapes on Swift side without actually executing the op (with a few exceptions, where we may need to materialize.)

Happy to fill in more during the open design meeting this Friday.

@dominikgrewe
Copy link
Contributor Author

Can this be merged?

@rxwei
Copy link
Contributor

rxwei commented Jul 29, 2019

Yes. Thanks for the ping!

@rxwei rxwei merged commit 719d7fa into tensorflow:master Jul 29, 2019
@dominikgrewe dominikgrewe deleted the allcloseto branch July 29, 2019 21:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants