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

The LazyTensor Datastructures #173

Merged
merged 17 commits into from
Jun 7, 2019
Merged

Conversation

bgogul
Copy link
Contributor

@bgogul bgogul commented Jun 4, 2019

First of a series of PRs to implement LazyTensor. This PR introduces the LazyTensor and LazyTensorOperation types and associated tests.

@bgogul bgogul requested review from rxwei and burmako June 4, 2019 07:32
}
}

public class LazyTensorOperation : TensorOperation {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason this type needs to be a public API?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually no. Removed public from class and all APIs.

public func evaluate() -> [LazyTensor] {
return Array((0..<outputCount).map {
LazyTensor(_lazyLive: self, index: $0)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
})
})

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor Author

@bgogul bgogul left a comment

Choose a reason for hiding this comment

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

Thanks for the review, @rxwei. I have addressed all your comments. PTAL.

public func evaluate() -> [LazyTensor] {
return Array((0..<outputCount).map {
LazyTensor(_lazyLive: self, index: $0)
})
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

}
}

public class LazyTensorOperation : TensorOperation {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually no. Removed public from class and all APIs.

@bgogul
Copy link
Contributor Author

bgogul commented Jun 6, 2019

@rxwei and @dan-zheng, are you OK with this PR?

typealias CTFTensor = OpaquePointer

@usableFromInline
class LazyTensor : _AnyTensorHandle {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class LazyTensor : _AnyTensorHandle {
class LazyTensor: _AnyTensorHandle {

import CTensorFlow

/// The `TF_Tensor *` type.
typealias CTFTensor = OpaquePointer
Copy link
Contributor

Choose a reason for hiding this comment

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

Could this be fileprivate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, this is an artifact of some earlier version. I removed this altogether.

case Input.single(let lazyTensor):
return "\(lazyTensor)"
case Input.list(let lazyTensorList): do {
let lazyTensors = lazyTensorList.map{ "\($0)" }
Copy link
Contributor

Choose a reason for hiding this comment

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

The indentation here seems incorrect. Also there should be a space before a trailing closure.

Suggested change
let lazyTensors = lazyTensorList.map{ "\($0)" }
let lazyTensors = lazyTensorList.map { "\($0)" }

@bgogul bgogul merged commit dbeeb06 into tensorflow:master Jun 7, 2019
@bgogul bgogul deleted the lazy_tensor_op branch June 7, 2019 06:47
@@ -0,0 +1,548 @@
import CTensorFlow
Copy link
Contributor

Choose a reason for hiding this comment

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

This missed a license header, fixed in #209.

case .concrete(let h, _):
return h
case .symbolic(let op, let index, _):
assert(false, "TODO: to be send out in a separate PR.")
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be fatalError instead of assert(false, ...).

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.

4 participants