File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change 9
9
import logging
10
10
import os
11
11
from pathlib import Path
12
- from typing import List
12
+ from typing import List , Dict
13
13
14
14
import torch
15
15
@@ -133,10 +133,20 @@ def device_sync(device="cpu"):
133
133
134
134
135
135
#########################################################################
136
- ### general utilkity functions ###
136
+ ### general utility functions ###
137
137
138
138
139
139
# in fbcode, we can intercept certain local paths that
140
140
# should be interpreted as part of an XAR package
141
141
def canonical_path (path ):
142
142
return path
143
+
144
+
145
+ #########################################################################
146
+ ### general utility functions ###
147
+
148
+ def state_dict_device (d , device = "cpu" ) -> Dict :
149
+ for key , weight in d .items ():
150
+ d [key ] = weight .to (device = device )
151
+
152
+ return d
You can’t perform that action at this time.
0 commit comments