Skip to content
This repository was archived by the owner on Feb 13, 2025. It is now read-only.

Commit 7ed2962

Browse files
authored
WordSeg: repair build on Windows (#692)
Importing `ucrt` is insufficient since we rely on the type-generic operation to convert the `Float` to what would be operations on `Double` otherwise.
1 parent eb8cf30 commit 7ed2962

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

BenchmarksCore/Models/WordSeg.swift

+8
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ import ModelSupport
1818
import TensorFlow
1919
import TextModels
2020

21+
#if os(Windows)
22+
#if canImport(CRT)
23+
import CRT
24+
#else
25+
import MSVCRT
26+
#endif
27+
#endif
28+
2129
let WordSegScore = wordSegSuite(
2230
name: "WordSegScore",
2331
operation: score)

Examples/WordSeg/main.swift

+8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ import ModelSupport
1717
import TensorFlow
1818
import TextModels
1919

20+
#if os(Windows)
21+
#if canImport(CRT)
22+
import CRT
23+
#else
24+
import MSVCRT
25+
#endif
26+
#endif
27+
2028
internal func runTraining(settings: WordSegSettings) throws {
2129
var trainingLossHistory = [Float]() // Keep track of loss.
2230
var validationLossHistory = [Float]() // Keep track of loss.

Models/Text/WordSeg/SemiRing.swift

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@
1515
#if os(iOS) || os(macOS) || os(tvOS) || os(watchOS)
1616
import Darwin
1717
#elseif os(Windows)
18-
import ucrt
18+
#if canImport(CRT)
19+
import CRT
20+
#else
21+
import MSVCRT
22+
#endif
1923
#else
2024
import Glibc
2125
#endif

0 commit comments

Comments
 (0)