Skip to content

Commit fff4458

Browse files
committed
Adding the permute method to remap the GPU.
1 parent 5b0ca5a commit fff4458

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
55

66
git_repository(
77
name = "ccv",
8-
commit = "4ecbf13a9551ff50949f91af01dcbb3b451e1082",
8+
commit = "9a5680888d4c25d22cfcbe3ce1edf6dccf5c2a0c",
99
remote = "https://github.com/liuliu/ccv.git",
10-
shallow_since = "1731696551 -0500",
10+
shallow_since = "1732044336 -0500",
1111
)
1212

1313
load("@ccv//config:ccv.bzl", "ccv_deps", "ccv_setting")

deps.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ def s4nnc_deps():
1717
git_repository,
1818
name = "ccv",
1919
remote = "https://github.com/liuliu/ccv.git",
20-
commit = "4ecbf13a9551ff50949f91af01dcbb3b451e1082",
21-
shallow_since = "1731696551 -0500",
20+
commit = "9a5680888d4c25d22cfcbe3ce1edf6dccf5c2a0c",
21+
shallow_since = "1732044336 -0500",
2222
)
2323

2424
_maybe(

nnc/Tensor.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,18 @@ public enum DeviceKind {
3939
public static var count: Int {
4040
Int(ccv_nnc_device_count(Int32(CCV_STREAM_CONTEXT_GPU)))
4141
}
42+
43+
/**
44+
* Remap GPU devices. It supports at most 64 devices remapping. Call this method
45+
* again would clear up the old remap.
46+
*/
47+
public static func permute(_ ordinals: Int...) {
48+
Array(ordinals.map { Int32($0) }).withUnsafeBytes {
49+
ccv_nnc_set_device_permutation(
50+
Int32(CCV_STREAM_CONTEXT_GPU), $0.baseAddress?.assumingMemoryBound(to: Int32.self),
51+
Int32(ordinals.count))
52+
}
53+
}
4254
}
4355

4456
@usableFromInline

0 commit comments

Comments
 (0)