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

Fix test failures caused by Optional: KeyPathIterable conformance #1090

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/TensorFlow/Core/CopyableToDevice.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ extension _KeyPathIterableBase {
let joinedKeyPath = rootKeyPath.appending(path: kp)!
if let valueType = type(of: joinedKeyPath).valueType as? _CopyableToDevice.Type {
valueType._move(&root, joinedKeyPath, to: device)
} else if let nested = self[keyPath: kp] as? _KeyPathIterableBase {
} else if let value = self[keyPath: kp], let nested = value as? _KeyPathIterableBase {
nested._move(&root, joinedKeyPath, to: device)
}
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/TensorFlow/Core/MixedPrecision.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ import _Differentiation
let joinedKeyPath = rootKeyPath.appending(path: kp)!
if let valueType = type(of: joinedKeyPath).valueType as? _ReducedPrecisionConvertible.Type {
valueType._convertToReducedPrecision(&root, joinedKeyPath)
} else if let nested = self[keyPath: kp] as? _KeyPathIterableBase {
} else if let value = self[keyPath: kp], let nested = value as? _KeyPathIterableBase {
nested._convertToReducedPrecision(&root, joinedKeyPath)
}
}
Expand All @@ -107,7 +107,7 @@ import _Differentiation
let joinedKeyPath = rootKeyPath.appending(path: kp)!
if let valueType = type(of: joinedKeyPath).valueType as? _ReducedPrecisionConvertible.Type {
valueType._convertToFullPrecision(&root, joinedKeyPath)
} else if let nested = self[keyPath: kp] as? _KeyPathIterableBase {
} else if let value = self[keyPath: kp], let nested = value as? _KeyPathIterableBase {
nested._convertToFullPrecision(&root, joinedKeyPath)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ extension _KeyPathIterableBase {
if let child = nested._buildWrappedVisitorPlan(kp as! PartialKeyPath<Base>) {
plan.elements.append(.node(child))
}
} else if let nested = self[keyPath: kp] as? _KeyPathIterableBase {
} else if let value = self[keyPath: kp], let nested = value as? _KeyPathIterableBase {
if let child = nested._buildWrappedVisitorPlan(kp as! PartialKeyPath<Base>) {
plan.elements.append(.node(child))
}
Expand Down