Function mindspore::dataset::CreateDatasetCache
Defined in File datasets.h
Function Documentation
-
inline std::shared_ptr<DatasetCache> mindspore::dataset::CreateDatasetCache(session_id_type id, uint64_t mem_sz, bool spill, const std::optional<std::string> &hostname = std::nullopt, const std::optional<int32_t> &port = std::nullopt, const std::optional<int32_t> &num_connections = std::nullopt, const std::optional<int32_t> &prefetch_sz = std::nullopt)
Function the create a cache to be attached to a dataset.
- Parameters
id – [in] A user assigned session id for the current pipeline.
mem_sz – [in] Size of the memory set aside for the row caching (default=0 which means unlimited, note that it might bring in the risk of running out of memory on the machine).
spill – [in] Spill to disk if out of memory.
hostname – [in] optional host name (default=std::nullopt, means to use “127.0.0.1”).
port – [in] optional port (default=std::nullopt, means to use 50052).
num_connections – [in] optional number of connections (default=std::nullopt, means to use 12).
prefetch_sz – [in] optional prefetch size (default=std::nullopt, means to use 20).
- Returns
Shared pointer to DatasetCache. If error, nullptr is returned.
Example/* Define a Cache object */ std::shared_ptr<DatasetCache> cache = CreateDatasetCache(233, 0, false, "127.0.0.1", 50053, 1, 1); /* Define dataset path and MindData object */ std::string folder_path = "/path/to/image_directory"; std::shared_ptr<Dataset> ds = ImageFolder(folder_path, false, nullptr, {}, {}, cache); /* Create iterator to read dataset */ std::shared_ptr<Iterator> iter = ds->CreateIterator();