Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gpucache
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
tianxing wang
gpucache
Commits
114ad93e
Commit
114ad93e
authored
Feb 29, 2024
by
tianxing wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finish lfucache
parent
8f24d345
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
2 deletions
+32
-2
libgpucache.so
+0
-0
src/export.cu
+22
-0
test.ipynb
+10
-2
No files found.
libgpucache.so
View file @
114ad93e
No preview for this file type
src/export.cu
View file @
114ad93e
#include "lru_cache.h"
#include "lru_cache.h"
#include "fifo_cache.h"
#include "fifo_cache.h"
#include "lfu_cache.h"
#include <pybind11/pybind11.h>
#include <pybind11/pybind11.h>
...
@@ -70,6 +71,27 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m){
...
@@ -70,6 +71,27 @@ PYBIND11_MODULE(TORCH_EXTENSION_NAME, m){
/*-----------------------------------------------------------------------------------------------------------------------------------*/
/*-----------------------------------------------------------------------------------------------------------------------------------*/
/* lfucache */
/*-----------------------------------------------------------------------------------------------------------------------------------*/
py::class_<gpucache::lfucache::LFUCacheWrapper> lfu_cache(m, "LFUCache");
lfu_cache
.def(py::init<at::Tensor, gpucache::CacheConfig>())
.def("Get",&gpucache::lfucache::LFUCacheWrapper::Get,"get values for keys, find_mask return whether each key exists in cache")
.def("Put",&gpucache::lfucache::LFUCacheWrapper::Put,"put key-value pairs")
.def("Strategy",&gpucache::lfucache::LFUCacheWrapper::Strategy,"get evict strategy")
.def("Capacity",&gpucache::lfucache::LFUCacheWrapper::Capacity,"return cache capacity")
.def("KeySize",&gpucache::lfucache::LFUCacheWrapper::KeySize,"return key size")
.def("ValueSize",&gpucache::lfucache::LFUCacheWrapper::ValueSize,"return value size")
.def("MaxQueryNum",&gpucache::lfucache::LFUCacheWrapper::MaxQueryNum,"return max number of keys to get or key-values to put once")
.def("Clear",&gpucache::lfucache::LFUCacheWrapper::Clear,"clear cache")
.def("Device",&gpucache::lfucache::LFUCacheWrapper::DeviceId,"return device id")
.def("Dim",&gpucache::lfucache::LFUCacheWrapper::Dim,"return value dim");
m.def("NewLFUCache", &gpucache::lfucache::NewLFUCache, "create a lfu cache",py::return_value_policy::reference);
/*-----------------------------------------------------------------------------------------------------------------------------------*/
}
}
...
...
test.ipynb
View file @
114ad93e
...
@@ -51,14 +51,15 @@
...
@@ -51,14 +51,15 @@
"name": "stdout",
"name": "stdout",
"output_type": "stream",
"output_type": "stream",
"text": [
"text": [
"
FIFO
Cache: keySize: 4, valueSize: 128, dim: 32, capacity: 65536, maxQueryNum: 4096, deviceId: 0\n"
"
LFU
Cache: keySize: 4, valueSize: 128, dim: 32, capacity: 65536, maxQueryNum: 4096, deviceId: 0\n"
]
]
}
}
],
],
"source": [
"source": [
"t = torch.empty([1],dtype=torch.float32)\n",
"t = torch.empty([1],dtype=torch.float32)\n",
"# cache = libgpucache.NewLRUCache(t,cfg)\n",
"# cache = libgpucache.NewLRUCache(t,cfg)\n",
"cache = libgpucache.NewFIFOCache(t,cfg)"
"# cache = libgpucache.NewFIFOCache(t,cfg)\n",
"cache = libgpucache.NewLFUCache(t,cfg)"
]
]
},
},
{
{
...
@@ -169,6 +170,13 @@
...
@@ -169,6 +170,13 @@
"metadata": {},
"metadata": {},
"outputs": [],
"outputs": [],
"source": []
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
}
],
],
"metadata": {
"metadata": {
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment