File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,20 @@ class EmbeddingLocation(enum.IntEnum):
34
34
MTIA = 4
35
35
36
36
37
+ def str_to_embedding_location (key : str ) -> EmbeddingLocation :
38
+ lookup = {
39
+ "device" : EmbeddingLocation .DEVICE ,
40
+ "managed" : EmbeddingLocation .MANAGED ,
41
+ "managed_caching" : EmbeddingLocation .MANAGED_CACHING ,
42
+ "host" : EmbeddingLocation .HOST ,
43
+ "mtia" : EmbeddingLocation .MTIA ,
44
+ }
45
+ if key in lookup :
46
+ return lookup [key ]
47
+ else :
48
+ raise ValueError (f"Cannot parse value into EmbeddingLocation: { key } " )
49
+
50
+
37
51
class CacheAlgorithm (enum .Enum ):
38
52
LRU = 0
39
53
LFU = 1
@@ -57,6 +71,21 @@ class PoolingMode(enum.IntEnum):
57
71
MEAN = 1
58
72
NONE = 2
59
73
74
+ def do_pooling (self ) -> bool :
75
+ return self is not PoolingMode .NONE
76
+
77
+
78
+ def str_to_pooling_mode (key : str ) -> PoolingMode :
79
+ lookup = {
80
+ "sum" : PoolingMode .SUM ,
81
+ "mean" : PoolingMode .MEAN ,
82
+ "none" : PoolingMode .NONE ,
83
+ }
84
+ if key in lookup :
85
+ return lookup [key ]
86
+ else :
87
+ raise ValueError (f"Cannot parse value into PoolingMode: { key } " )
88
+
60
89
61
90
class BoundsCheckMode (enum .IntEnum ):
62
91
# Raise an exception (CPU) or device-side assert (CUDA)
You can’t perform that action at this time.
0 commit comments