-
Notifications
You must be signed in to change notification settings - Fork 74
/
dataset.h
118 lines (104 loc) · 3.05 KB
/
dataset.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
// SPDX-License-Identifier: Apache-2.0
/**
* Copyright (C) 2020 Parichay Kapoor <[email protected]>
*
* @file dataset.h
* @date 14 October 2020
* @see https://github.com/nnstreamer/nntrainer
* @author Jijoong Moon <[email protected]>
* @author Parichay Kapoor <[email protected]>
* @bug No known bugs except for NYI items
* @brief This is dataset interface for c++ API
*
* @note This is experimental API and not stable.
*/
#ifndef __ML_TRAIN_DATASET_H__
#define __ML_TRAIN_DATASET_H__
#if __cplusplus >= MIN_CPP_VERSION
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include <common.h>
namespace ml {
namespace train {
/**
* @brief Dataset generator callback type declaration
*/
typedef std::function<std::remove_pointer<ml_train_datagen_cb>::type>
datagen_cb;
/**
* @brief Enumeration for dataset type
*/
enum class DatasetType {
GENERATOR, /** Dataset with generators */
FILE, /** Dataset with files */
DIR, /** Dataset with directory */
UNKNOWN /** Unknown dataset type */
};
/**
* @brief Enumeration of data mode type
*/
enum class DatasetModeType {
MODE_TRAIN = ML_TRAIN_DATASET_MODE_TRAIN, /** data for training */
MODE_VALID = ML_TRAIN_DATASET_MODE_VALID, /** data for validation */
MODE_TEST = ML_TRAIN_DATASET_MODE_TEST, /** data for test */
MODE_UNKNOWN /** data not known */
};
/**
* @class Dataset for class for input data
* @brief Dataset for read and manage data
*/
class Dataset {
public:
/**
* @brief Destructor
*/
virtual ~Dataset() = default;
/**
* @brief set property
* @param[in] values values of property
* @details Properties (values) is in the format -
* { std::string property_name, std::string property_val, ...}
*/
virtual void setProperty(const std::vector<std::string> &values) = 0;
};
/**
* @brief Create a Dataset object with given arguements
*
* @param type dataset type
* @param properties property representations
* @return std::unique_ptr<Dataset> created dataset
*/
std::unique_ptr<Dataset>
createDataset(DatasetType type,
const std::vector<std::string> &properties = {});
/**
* @brief Create a Dataset object
*
* @param type dataset type
* @param path path to a file or folder
* @param properties property representations
* @return std::unique_ptr<Dataset> created dataset
*/
std::unique_ptr<Dataset>
createDataset(DatasetType type, const char *path,
const std::vector<std::string> &properties = {});
/**
* @brief Create a Dataset object
*
* @param type dataset type
* @param cb callback
* @param user_data user data
* @param properties property representations
* @return std::unique_ptr<Dataset> created dataset
*/
std::unique_ptr<Dataset>
createDataset(DatasetType type, datagen_cb cb, void *user_data = nullptr,
const std::vector<std::string> &properties = {});
} // namespace train
} // namespace ml
#else
#error "CPP versions c++17 or over are only supported"
#endif // __cpluscplus
#endif // __ML_TRAIN_DATASET_H__