forked from swiftlang/swift
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneric_real_vector.swift
47 lines (39 loc) · 1.09 KB
/
generic_real_vector.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// RUN: %target-swift-frontend -emit-sil %s | %FileCheck %s
// XFAIL: *
@_fixed_layout
public struct Vector<T> : VectorNumeric {
public var x: T
public var y: T
public typealias ScalarElement = T
public typealias Dimensionality = ()
public init(dimensionality: (), repeating repeatedValue: T) {
self.init(repeatedValue)
}
public init(_ scalar: T) {
self.x = scalar
self.y = scalar
}
}
// This exists to minimize generated SIL.
@inline(never) func abort() -> Never { fatalError() }
@differentiable(reverse, adjoint: fakeAdj)
public func + <T>(lhs: Vector<T>, rhs: Vector<T>) -> Vector<T> {
abort()
}
@differentiable(reverse, adjoint: fakeAdj)
public func - <T>(lhs: Vector<T>, rhs: Vector<T>) -> Vector<T> {
abort()
}
@differentiable(reverse, adjoint: fakeAdj)
public func * <T>(lhs: Vector<T>, rhs: Vector<T>) -> Vector<T> {
abort()
}
public func fakeAdj<T>(lhs: Vector<T>, rhs: Vector<T>, y: Vector<T>, seed: Vector<T>) -> (Vector<T>, Vector<T>) {
abort()
}
public func test1() {
func foo(_ x: Vector<Float>) -> Vector<Float> {
return x + x
}
_ = #gradient(foo)
}