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

Commit 9ebc457

Browse files
committed
Canonicalize the attribute list when printing a LazyTensorOperation
1 parent b6955d1 commit 9ebc457

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

Sources/TensorFlow/Core/LazyTensorOperation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ extension LazyTensor: CustomStringConvertible {
682682

683683
extension LazyTensorOperation: CustomStringConvertible {
684684
public var description: String {
685-
let attrsDesc = attrs.map { (name, value) in "\(name): \(value)" }
685+
let attrsDesc = attrs.keys.sorted(by: <).map { "\($0): \(attrs[$0]!)" }
686686
let inputsDesc = inputs.map { (input: Input) -> String in
687687
switch input {
688688
case Input.single(let lazyTensor):

Tests/TensorFlowTests/LazyTensorOperationTests.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,7 @@ final class LazyTensorOperationTests: XCTestCase {
166166
_id: "0", name: "Nop", outputCount: 1)
167167
op0.updateAttribute("b", true)
168168
op0.updateAttribute("s", "hello")
169-
XCTAssert(
170-
(op0.description == "%0 = Nop[b: true, s: \"hello\"]()") ||
171-
(op0.description == "%0 = Nop[s: \"hello\", b: true]()")
172-
)
169+
XCTAssertEqual(op0.description, "%0 = Nop[b: true, s: \"hello\"]()")
173170
}
174171

175172
static var allTests = [

0 commit comments

Comments
 (0)