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

Conversation

Shashi456
Copy link
Contributor

Fix #69

@Shashi456
Copy link
Contributor Author

A few choices I took would be to create a separate core file for reshape, flatten, dense and other layers we might have. In the case of swift, we also have a layer protocol defined hence i decided to keep the layer.swift
One last thing is, I've added the Tensorflow disclaimer and imported tensorflow in each of the files, I wasn't very sure if that was mandatory.

I know this review might take a while.

It breaks #76 and #100.

@Shashi456 Shashi456 changed the title Breaking down Layers into a directory Breaking down Layers.swift into a directory Apr 19, 2019
@Shashi456 Shashi456 changed the title Breaking down Layers.swift into a directory Breaking down Layer.swift into a directory Apr 19, 2019
@saeta
Copy link
Contributor

saeta commented Apr 19, 2019

Hi @Shashi456 !

Thanks for making this refactoring. I think this is absolutely the right thing to do. However to be fully transparent, we're right in the middle of landing our final fixes for the v0.3 release, and working to get a high quality, stable release. As a result, I think it probably makes most sense to revisit this in ~1.5-2 weeks after we have a solid v0.3 release shipped. Hope that helps provide a bit more context!

All the best,
-Brennan

@Shashi456
Copy link
Contributor Author

Shashi456 commented Apr 19, 2019

@saeta should i close this pull till then?

I don't mind the delay, I know v0.3 is launching. GOOD LUCK! hope it goes smoothly.

@rxwei
Copy link
Contributor

rxwei commented Apr 19, 2019

Thanks! An earlier pending PR (#70) has the similar goal of breaking down Layers.swift. I think it would be nice to iterate on that one together since it's already been iterated on for some time. This PR introduces a nice structure in that it groups all layer files under a Layers directory. Perhaps you and @eaplatanios can work together on #70?

@Shashi456
Copy link
Contributor Author

@rxwei afaik, @eaplatanios told me he was working on creating an operators directory, and that i should work on breaking down on layers.

@eaplatanios any comments?

@eaplatanios
Copy link
Contributor

@Shashi456 @rxwei we can definitely bring that in as part of #70. I can port your changes over if you want and we can keep iterating there.

@Shashi456
Copy link
Contributor Author

@rxwei #70 works on an operators directory, while this is for a layers directory. I don't mind the merging but wouldn't it make the PR too large to handle?

I will put this on hold for a while and look into it after v0.3 is released.

@rxwei
Copy link
Contributor

rxwei commented Apr 19, 2019

Oh yes, that makes sense to me now! Sorry I had the wrong impression that #70 handled both layers and operators. Ok, let's merge this one for layers next week. Thanks @Shashi456 and @eaplatanios for coordinating!

@rxwei rxwei added the enhancement New feature or request label Apr 19, 2019
@rxwei rxwei self-assigned this Apr 19, 2019
@rxwei rxwei self-requested a review April 19, 2019 22:18
Copy link
Contributor

@rxwei rxwei left a comment

Choose a reason for hiding this comment

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

Note: To be merged in the week of 4/22

Thanks for taking on this!

@Shashi456
Copy link
Contributor Author

@rxwei have docker builds been turned off xD?

@rxwei
Copy link
Contributor

rxwei commented Apr 19, 2019

Investigating!

@rxwei rxwei requested review from dan-zheng and jekbradbury April 19, 2019 22:24
Copy link
Member

@dan-zheng dan-zheng left a comment

Choose a reason for hiding this comment

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

LGTM if tests pass!

@Shashi456
Copy link
Contributor Author

@rxwei I will delete the Sources\DeepLearning\Layer.swift file when we are ready to merge. I kept it for now, in case there are any additions to the layer file.

@Shashi456
Copy link
Contributor Author

Shashi456 commented Apr 21, 2019

@rxwei I think this can be merged now.

Docker hasn't been building for a while.

@rxwei
Copy link
Contributor

rxwei commented Apr 21, 2019

We'll revisit this next week!

@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.

@Shashi456
Copy link
Contributor Author

@rxwei can i start working on this again?

@rxwei
Copy link
Contributor

rxwei commented Apr 28, 2019

Yes. Thanks!

@Shashi456
Copy link
Contributor Author

Shashi456 commented May 19, 2019

@dan-zheng @rxwei So I have reflected changes from the PR's before this, and i have built and test it there are no errors. So if you review this, I will delete the Layer.swift file and finalize this PR.

It's been on hold for a while, and I think this is the right time to bring about this change.

Edit: I tried testing on the nightly and a few errors popped up, most probably because these changes haven't been updated into it. But i will put the errors here. Please do comment if you have any thoughts on them.

/home/paws/swift-apis/Tests/DeepLearningTests/LayerTests.swift:46:21: error: use of unresolved identifier 'MaxPool3D'
        let layer = MaxPool3D<Float>(poolSize: (2, 2, 2), strides: (1, 1, 1), padding: .valid)
                    ^~~~~~~~~
TensorFlow.MaxPool1D:1:15: note: did you mean 'MaxPool1D'?
public struct MaxPool1D<Scalar> : TensorFlow.Layer where Scalar : TensorFlow.TensorFlowFloatingPoint {
              ^
TensorFlow.MaxPool2D:1:15: note: did you mean 'MaxPool2D'?
public struct MaxPool2D<Scalar> : TensorFlow.Layer where Scalar : TensorFlow.TensorFlowFloatingPoint {
              ^
/home/paws/swift-apis/Tests/DeepLearningTests/LayerTests.swift:70:21: error: use of unresolved identifier 'AvgPool3D'
        let layer = AvgPool3D<Float>(poolSize: (2, 4, 5), strides: (1, 1, 1), padding: .valid)
                    ^~~~~~~~~
TensorFlow.AvgPool1D:1:15: note: did you mean 'AvgPool1D'?
public struct AvgPool1D<Scalar> : TensorFlow.Layer where Scalar : TensorFlow.TensorFlowFloatingPoint {
              ^
TensorFlow.AvgPool2D:1:15: note: did you mean 'AvgPool2D'?
public struct AvgPool2D<Scalar> : TensorFlow.Layer where Scalar : TensorFlow.TensorFlowFloatingPoint {
              ^
/home/paws/swift-apis/Tests/DeepLearningTests/LayerTests.swift:158:9: error: global function 'XCTAssertEqual(_:_:_:file:line:)' requires that 'SimpleRNNCell<Float>.State' conform to 'Equatable'
        XCTAssertEqual(output, expected)
        ^
XCTest.XCTAssertEqual:1:13: note: where 'T' = 'SimpleRNNCell<Float>.State'
public func XCTAssertEqual<T>(_ expression1: @autoclosure () throws -> T, _ expression2: @autoclosure () throws -> T, _ message: @autoclosure () -> String = "", file: StaticString = #file, line: UInt = #line) where T : Equatable
            ^
/home/paws/swift-apis/Tests/DeepLearningTests/LayerTests.swift:175:65: error: cannot convert value of type 'SimpleRNNCell<Float>.State' to closure result type '_'
        let (𝛁rnn, 𝛁inputs) = pullback(.init(inputs.map { SimpleRNNCell<Float>.State($0) }))

@Shashi456
Copy link
Contributor Author

@rxwei will you look at it this week?

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@Shashi456
Copy link
Contributor Author

@rxwei could you please look at this soon?

@rxwei
Copy link
Contributor

rxwei commented May 26, 2019

Could you merge in the latest changes from master? I’ll look tonight.

@Shashi456
Copy link
Contributor Author

@rxwei My latest commit includes the changes in #131 and #128. Should i delete layer.swift?

Copy link
Contributor

@rxwei rxwei left a comment

Choose a reason for hiding this comment

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

Thanks @Shashi456. The changes look good overall. I have one more request other than some inline comments about formatting: I think that Layer.swift should be placed directly under DeepLearning/ instead of being included in Layers because 1) Layer.swift does not define any concrete layer and 2) it may get confused with Core.swift when they reside in the same directory.

@Shashi456
Copy link
Contributor Author

@rxwei I will take care of the comments, once I address them, could you trigger a Kokoro build?

@rxwei
Copy link
Contributor

rxwei commented May 28, 2019

@rxwei I will take care of the comments, once I address them, could you trigger a Kokoro build?

Yes.

@Shashi456
Copy link
Contributor Author

@rxwei one final thing, probably not needed now, but do you want the layertest.swift to be broken down as well? I'm just saying that because ultimately we have a lot of different functionality within layers that needs to be tested. Or would you rather continue with what we have, and think about breaking it down later on?

@rxwei
Copy link
Contributor

rxwei commented May 28, 2019

Yes, it should be broken into a few test files, but I'd suggest doing so only after the ongoing refactoring (e.g. #109).

@Shashi456
Copy link
Contributor Author

@rxwei I'm sorry for the minor indentation errors. I also just wanted to know, if there is any package like flake8 for python, which takes care of these indentations and style errors within swift? Something like that could make it convenient.

@rxwei
Copy link
Contributor

rxwei commented May 28, 2019

Swift toolchains come with a swift-format tool. However, it is not a finished product -- it doesn't always respect the indentation rules for function parameters. Things are moving and the community has been discussing about an official code formatter.

@Shashi456
Copy link
Contributor Author

@rxwei Feels good to have no build errors for once xD.

Copy link
Contributor

@rxwei rxwei left a comment

Choose a reason for hiding this comment

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

LGTM

@rxwei
Copy link
Contributor

rxwei commented May 28, 2019

After this gets merged, we need to update the revision of swift-apis that gets pulled into a toolchain build directory. Could you please start a PR to update https://github.com/apple/swift/blob/cdf3234b9b5f64b5202ba57d51d3b180aafc1b85/utils/update_checkout/update-checkout-config.json#L355 to the latest commit hash in swift-apis?

@Shashi456
Copy link
Contributor Author

@rxwei I will, but what does e5a288b7ce561fe1b18757d1a440c26eb0c7172d mean and what do i replace it by?

@rxwei rxwei merged commit 087618b into tensorflow:master May 28, 2019
@rxwei
Copy link
Contributor

rxwei commented May 28, 2019

This PR got merged as 087618b, which has hash 087618b57b565cd8cf93a23d51da86e30c102460. The hash in update-checkout-config.json should be replaced with this.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Breaking down the Layers.swift file

7 participants