-
Notifications
You must be signed in to change notification settings - Fork 10.6k
TensorShape.swift file updated to improve TensorShape printing #24253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TensorShape.swift file updated to improve TensorShape printing #24253
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please add a test to test/TensorFlowRuntime/tensor.swift?
Something like:
TensorTests.testAllBackends("TensorShapeDescription") {
expectEqual("TensorShape([2, 2])", Tensor<Int32>(ones: [2, 2]).shape.description)
expectEqual("TensorShape([])", Tensor(1).shape.description)
}| @inlinable | ||
| public var description: String { | ||
| return "TensorShape(\(dimensions))" | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix indentation:
| } | |
| } |
|
A thought: how about using just |
|
I agree that just |
| } | ||
|
|
||
| extension TensorShape : CustomStringConvertible { | ||
| @inlinable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no need for @inlinable here.
| extension TensorShape : CustomStringConvertible { | ||
| @inlinable | ||
| public var description: String { | ||
| return "TensorShape(\(dimensions))" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we think that [2, 2] is more ideal, calling dimensions.description should be sufficient.
| return "TensorShape(\(dimensions))" | |
| return dimensions.description |
Added test to test/TensorFlowRuntime/tensor.swift
|
@swift-ci please test tensorflow |
1 similar comment
|
@swift-ci please test tensorflow |
|
Updated changes as suggested i.e. Also added test to test/TensorFlowRuntime/tensor.swift as below: |
|
Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Added description property to
TensorShapeby conforming toCustomStringConvertibleso that we can obtain the desiredTensorShapeprinting.Resolves TF-447.