From 5e644b912ec10ec0fac02ccdc0f9a4d8342d8f4c Mon Sep 17 00:00:00 2001 From: Woosuk Kwon Date: Thu, 9 Feb 2023 11:26:50 +0000 Subject: [PATCH] Add utils --- cacheflow/utils.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 cacheflow/utils.py diff --git a/cacheflow/utils.py b/cacheflow/utils.py new file mode 100644 index 00000000..485e18f6 --- /dev/null +++ b/cacheflow/utils.py @@ -0,0 +1,20 @@ +import enum + + +class Device(enum.Enum): + GPU = enum.auto() + CPU = enum.auto() + + +class Counter: + + def __init__(self, start: int = 0) -> None: + self.counter = start + + def next(self) -> int: + id = self.counter + self.counter += 1 + return id + + def reset(self) -> None: + self.counter = 0