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

Commit aa20df2

Browse files
authored
Revert "Minor fix for AD. (#106)" (#107)
This reverts commit c499e16.
1 parent c499e16 commit aa20df2

File tree

2 files changed

+2
-10
lines changed

2 files changed

+2
-10
lines changed

Sources/DeepLearning/Operators/Math.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -875,7 +875,7 @@ public extension Tensor where Scalar == Bool {
875875
@inlinable
876876
func all() -> Bool {
877877
let axes = Tensor<Int32>(rangeFrom: 0, to: Int32(rank), stride: 1)
878-
return Raw.all(self, reductionIndices: axes).scalarized()
878+
return _TFGetScalarOrDie(Raw.all(self, reductionIndices: axes).handle)
879879
}
880880

881881
/// Returns `true` if any scalars are equal to `true`. Otherwise, returns `false`.
@@ -884,7 +884,7 @@ public extension Tensor where Scalar == Bool {
884884
@inlinable
885885
func any() -> Bool {
886886
let axes = Tensor<Int32>(rangeFrom: 0, to: Int32(rank), stride: 1)
887-
return Raw.any(self, reductionIndices: axes).scalarized()
887+
return _TFGetScalarOrDie(Raw.any(self, reductionIndices: axes).handle)
888888
}
889889

890890
/// Performs a logical AND operation along the specified axes. The reduced dimensions are

Sources/DeepLearning/Tensors.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,18 @@ infix operator .==: ComparisonPrecedence
2727
public extension Tensor {
2828
/// The rank of the tensor, represented as a `Tensor<Int32>`.
2929
@inlinable
30-
@_semantics("autodiff.nonvarying")
3130
var rankTensor: Tensor<Int32> {
3231
return Raw.rank(self)
3332
}
3433

3534
/// The dimensions of the tensor, represented as a `Tensor<Int32>`.
3635
@inlinable
37-
@_semantics("autodiff.nonvarying")
3836
var shapeTensor: Tensor<Int32> {
3937
return Raw.shape(self)
4038
}
4139

4240
/// The number of scalars in the tensor, represented as a `Tensor<Int32>`.
4341
@inlinable
44-
@_semantics("autodiff.nonvarying")
4542
var scalarCountTensor: Tensor<Int32> {
4643
return Raw.size(self)
4744
}
@@ -56,7 +53,6 @@ extension Tensor: CustomStringConvertible {
5653
/// A textual representation of the tensor.
5754
///
5855
/// - Note: use `fullDescription` for a non-pretty-printed description showing all scalars.
59-
@_semantics("autodiff.nonvarying")
6056
public var description: String {
6157
return array.description
6258
}
@@ -73,7 +69,6 @@ public extension Tensor {
7369
/// via ellipses (`...`).
7470
/// - summarizing: If true, summarize description if element count exceeds twice
7571
/// `edgeElementCount`.
76-
@_semantics("autodiff.nonvarying")
7772
func description(
7873
lineWidth: Int = 80,
7974
edgeElementCount: Int = 3,
@@ -87,23 +82,20 @@ public extension Tensor {
8782

8883
/// A full, non-pretty-printed textual representation of the tensor, showing
8984
/// all scalars.
90-
@_semantics("autodiff.nonvarying")
9185
var fullDescription: String {
9286
return array.fullDescription
9387
}
9488
}
9589

9690
// Xcode Playground display conversion.
9791
extension Tensor: CustomPlaygroundDisplayConvertible {
98-
@_semantics("autodiff.nonvarying")
9992
public var playgroundDescription: Any {
10093
return description
10194
}
10295
}
10396

10497
// Mirror representation, used by debugger/REPL.
10598
extension Tensor: CustomReflectable {
106-
@_semantics("autodiff.nonvarying")
10799
public var customMirror: Mirror {
108100
return Mirror(self, children: [], displayStyle: .struct)
109101
}

0 commit comments

Comments
 (0)