Skip to content

Commit

Permalink
remove algorithms that are in penguin now (#195)
Browse files Browse the repository at this point in the history
saeta/penguin#120 moved these into Penguin.

For some reason, defining them in both places causes a compiler crash.

This PR fixes #194.
  • Loading branch information
marcrasi authored Oct 20, 2020
1 parent cfcbe9a commit 4ae925c
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 63 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
uses: actions/checkout@master
- name: Install toolchain
run: |
sudo xcode-select -s /Applications/Xcode_12_beta.app
sudo xcode-select -s /Applications/Xcode_12.2.app
wget https://storage.googleapis.com/swift-tensorflow-artifacts/macos-toolchains/swift-tensorflow-DEVELOPMENT-2020-08-26-a-osx.pkg
sudo installer -pkg swift-tensorflow-DEVELOPMENT-2020-08-26-a-osx.pkg -target /
echo "::set-env name=PATH::/Library/Developer/Toolchains/swift-latest/usr/bin:${PATH}"
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"repositoryURL": "https://github.com/saeta/penguin.git",
"state": {
"branch": "master",
"revision": "056ba98601ea5273647893d1c00ecf82919382d4",
"revision": "b3a3bea7f1b3237183e446f37b7d28c7b19169b5",
"version": null
}
},
Expand All @@ -24,7 +24,7 @@
"repositoryURL": "https://github.com/google/swift-benchmark.git",
"state": {
"branch": "master",
"revision": "f70bf472b00aeaa05e2374373568c2fe459c11c7",
"revision": "9a47e0326086f7e0b2a8c69e56217485fd9aa80d",
"version": null
}
},
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftFusion/Core/Vector.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Foundation
import PenguinStructures
import TensorFlow

/// A vector, in a Euclidean vector space with standard orthonormal basis.
Expand Down
60 changes: 0 additions & 60 deletions Sources/SwiftFusion/Inference/PenguinExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -754,66 +754,6 @@ extension Dictionary {
}
}

extension MutableCollection {
mutating func writePrefix<I: IteratorProtocol>(from source: inout I)
-> (writtenCount: Int, unwrittenStart: Index)
where I.Element == Element
{
var writtenCount = 0
var unwrittenStart = startIndex
while unwrittenStart != endIndex {
guard let x = source.next() else { break }
self[unwrittenStart] = x
self.formIndex(after: &unwrittenStart)
writtenCount += 1
}
return (writtenCount, unwrittenStart)
}

mutating func writePrefix<Source: Collection>(from source: Source)
-> (writtenCount: Int, unwrittenStart: Index, unreadStart: Source.Index)
where Source.Element == Element
{
var writtenCount = 0
var unwrittenStart = startIndex
var unreadStart = source.startIndex
while unwrittenStart != endIndex && unreadStart != source.endIndex {
self[unwrittenStart] = source[unreadStart]
self.formIndex(after: &unwrittenStart)
source.formIndex(after: &unreadStart)
writtenCount += 1
}
return (writtenCount, unwrittenStart, unreadStart)
}

@discardableResult
mutating func assign<Source: Sequence>(_ sourceElements: Source) -> Int
where Source.Element == Element
{
var stream = sourceElements.makeIterator()
let (count, unwritten) = writePrefix(from: &stream)
precondition(unwritten == endIndex, "source too short")
precondition(stream.next() == nil, "source too long")
return count
}

@discardableResult
mutating func assign<Source: Collection>(_ sourceElements: Source) -> Int
where Source.Element == Element
{
let (writtenCount, unwritten, unread) = writePrefix(from: sourceElements)
precondition(unwritten == endIndex, "source too short")
precondition(unread == sourceElements.endIndex, "source too long")
return writtenCount
}
}

extension Collection {
func index(atOffset n: Int) -> Index {
index(startIndex, offsetBy: n)
}
}

/// The consecutive `SubSequence`s of a `Base` collection having a given maximum size.
struct Batched<Base: Collection>: Collection {
public let base: Base
Expand Down

0 comments on commit 4ae925c

Please sign in to comment.