@@ -27,18 +27,21 @@ infix operator .==: ComparisonPrecedence
27
27
public extension Tensor {
28
28
/// The rank of the tensor, represented as a `Tensor<Int32>`.
29
29
@inlinable
30
+ @_semantics ( " autodiff.nonvarying " )
30
31
var rankTensor : Tensor < Int32 > {
31
32
return Raw . rank ( self )
32
33
}
33
34
34
35
/// The dimensions of the tensor, represented as a `Tensor<Int32>`.
35
36
@inlinable
37
+ @_semantics ( " autodiff.nonvarying " )
36
38
var shapeTensor : Tensor < Int32 > {
37
39
return Raw . shape ( self )
38
40
}
39
41
40
42
/// The number of scalars in the tensor, represented as a `Tensor<Int32>`.
41
43
@inlinable
44
+ @_semantics ( " autodiff.nonvarying " )
42
45
var scalarCountTensor : Tensor < Int32 > {
43
46
return Raw . size ( self )
44
47
}
@@ -53,6 +56,7 @@ extension Tensor: CustomStringConvertible {
53
56
/// A textual representation of the tensor.
54
57
///
55
58
/// - Note: use `fullDescription` for a non-pretty-printed description showing all scalars.
59
+ @_semantics ( " autodiff.nonvarying " )
56
60
public var description : String {
57
61
return array. description
58
62
}
@@ -69,6 +73,7 @@ public extension Tensor {
69
73
/// via ellipses (`...`).
70
74
/// - summarizing: If true, summarize description if element count exceeds twice
71
75
/// `edgeElementCount`.
76
+ @_semantics ( " autodiff.nonvarying " )
72
77
func description(
73
78
lineWidth: Int = 80 ,
74
79
edgeElementCount: Int = 3 ,
@@ -82,20 +87,23 @@ public extension Tensor {
82
87
83
88
/// A full, non-pretty-printed textual representation of the tensor, showing
84
89
/// all scalars.
90
+ @_semantics ( " autodiff.nonvarying " )
85
91
var fullDescription : String {
86
92
return array. fullDescription
87
93
}
88
94
}
89
95
90
96
// Xcode Playground display conversion.
91
97
extension Tensor : CustomPlaygroundDisplayConvertible {
98
+ @_semantics ( " autodiff.nonvarying " )
92
99
public var playgroundDescription : Any {
93
100
return description
94
101
}
95
102
}
96
103
97
104
// Mirror representation, used by debugger/REPL.
98
105
extension Tensor : CustomReflectable {
106
+ @_semantics ( " autodiff.nonvarying " )
99
107
public var customMirror : Mirror {
100
108
return Mirror ( self , children: [ ] , displayStyle: . struct)
101
109
}
0 commit comments