forked from mindspore-Ecosystem/mindspore
Add parameter validation
This commit is contained in:
parent
c20cd12216
commit
da38465be2
|
@ -18,21 +18,20 @@
|
||||||
import copy
|
import copy
|
||||||
from mindspore._c_dataengine import CacheClient
|
from mindspore._c_dataengine import CacheClient
|
||||||
|
|
||||||
|
from ..core.validator_helpers import type_check, check_uint32, check_uint64
|
||||||
|
|
||||||
class DatasetCache:
|
class DatasetCache:
|
||||||
"""
|
"""
|
||||||
A client to interface with tensor caching service
|
A client to interface with tensor caching service
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, session_id=None, size=None, spilling=False):
|
def __init__(self, session_id=None, size=0, spilling=False):
|
||||||
if session_id is None:
|
check_uint32(session_id, "session_id")
|
||||||
raise RuntimeError("Session generation is not implemented yet. session id required")
|
check_uint64(size, "size")
|
||||||
self.size = size if size is not None else 0
|
type_check(spilling, (bool,), "spilling")
|
||||||
if size < 0:
|
|
||||||
raise ValueError("cache size should be 0 or positive integer value but got: size={}".format(size))
|
|
||||||
if not isinstance(spilling, bool):
|
|
||||||
raise ValueError(
|
|
||||||
"spilling argument for cache should be a boolean value but got: spilling={}".format(spilling))
|
|
||||||
self.session_id = session_id
|
self.session_id = session_id
|
||||||
|
self.size = size
|
||||||
self.spilling = spilling
|
self.spilling = spilling
|
||||||
self.cache_client = CacheClient(session_id, size, spilling)
|
self.cache_client = CacheClient(session_id, size, spilling)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue