diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/audio.h b/mindspore/ccsrc/minddata/dataset/include/dataset/audio.h index 6b11f39c265..80c26f470c6 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/audio.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/audio.h @@ -38,7 +38,7 @@ class TensorOperation; namespace audio { /// \brief Compute the angle of complex tensor input. -class Angle final : public TensorTransform { +class MS_API Angle final : public TensorTransform { public: /// \brief Constructor. Angle(); @@ -52,7 +52,7 @@ class Angle final : public TensorTransform { }; /// \brief Design two-pole band filter. -class BandBiquad final : public TensorTransform { +class MS_API BandBiquad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), the value can't be zero. @@ -75,7 +75,7 @@ class BandBiquad final : public TensorTransform { }; /// \brief Design two-pole allpass filter. Similar to SoX implementation. -class AllpassBiquad final : public TensorTransform { +class MS_API AllpassBiquad final : public TensorTransform { public: /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), the value can't be zero. /// \param[in] central_freq Central frequency (in Hz). @@ -97,7 +97,7 @@ class AllpassBiquad final : public TensorTransform { /// \brief AmplitudeToDB TensorTransform. /// \notes Turn a tensor from the power/amplitude scale to the decibel scale. -class AmplitudeToDB final : public TensorTransform { +class MS_API AmplitudeToDB final : public TensorTransform { public: /// \brief Constructor. /// \param[in] stype Scale of input tensor, must be one of [ScaleType::kPower, ScaleType::kMagnitude] (Default: @@ -122,7 +122,7 @@ class AmplitudeToDB final : public TensorTransform { }; /// \brief Design two-pole band-pass filter. -class BandpassBiquad final : public TensorTransform { +class MS_API BandpassBiquad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), the value can't be zero. @@ -146,7 +146,7 @@ class BandpassBiquad final : public TensorTransform { }; /// \brief Design two-pole band-reject filter. Similar to SoX implementation. -class BandrejectBiquad final : public TensorTransform { +class MS_API BandrejectBiquad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), the value can't be zero. @@ -168,7 +168,7 @@ class BandrejectBiquad final : public TensorTransform { }; /// \brief Design a bass tone-control effect. -class BassBiquad final : public TensorTransform { +class MS_API BassBiquad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), the value can't be zero. @@ -191,7 +191,7 @@ class BassBiquad final : public TensorTransform { }; /// \brief Perform a biquad filter of input tensor. -class Biquad final : public TensorTransform { +class MS_API Biquad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] b0 Numerator coefficient of current input, x[n]. @@ -217,7 +217,7 @@ class Biquad final : public TensorTransform { /// \brief ComplexNorm TensorTransform. /// \notes Compute the norm of complex tensor input. -class ComplexNorm final : public TensorTransform { +class MS_API ComplexNorm final : public TensorTransform { public: /// \brief Constructor. /// \param[in] power Power of the norm, which must be non-negative (Default: 1.0). @@ -238,7 +238,7 @@ class ComplexNorm final : public TensorTransform { /// \brief ComputeDeltas Transform. /// \note Compute delta coefficients of a spectrogram. -class ComputeDeltas final : public TensorTransform { +class MS_API ComputeDeltas final : public TensorTransform { public: /// \brief Construct a new Compute Deltas object. /// \param[in] win_length The window length used for computing delta, must be no less than 3 (Default: 5). @@ -259,7 +259,7 @@ class ComputeDeltas final : public TensorTransform { }; /// \brief Apply contrast effect. -class Contrast final : public TensorTransform { +class MS_API Contrast final : public TensorTransform { public: /// \brief Constructor. /// \param[in] enhancement_amount Controls the amount of the enhancement (Default: 75.0). @@ -279,7 +279,7 @@ class Contrast final : public TensorTransform { }; /// \brief Turn a waveform from the decibel scale to the power/amplitude scale. -class DBToAmplitude final : public TensorTransform { +class MS_API DBToAmplitude final : public TensorTransform { public: /// \brief Constructor /// \param[in] ref Reference which the output will be scaled by. @@ -300,7 +300,7 @@ class DBToAmplitude final : public TensorTransform { }; /// \brief Apply a DC shift to the audio. -class DCShift : public TensorTransform { +class MS_API DCShift : public TensorTransform { public: /// \brief Constructor /// \param[in] shift Indicates the amount to shift the audio, the value must be in the range [-2.0, 2.0]. @@ -332,7 +332,7 @@ class DCShift : public TensorTransform { Status CreateDct(mindspore::MSTensor *output, int32_t n_mfcc, int32_t n_mels, NormMode norm = NormMode::kNone); /// \brief Design two-pole deemph filter. Similar to SoX implementation. -class DeemphBiquad final : public TensorTransform { +class MS_API DeemphBiquad final : public TensorTransform { public: /// \param[in] sample_rate Sampling rate of the waveform, the value can only be 44100 (Hz) or 48000(hz). explicit DeemphBiquad(int32_t sample_rate); @@ -351,7 +351,7 @@ class DeemphBiquad final : public TensorTransform { }; /// \brief Detect pitch frequency. -class DetectPitchFrequency final : public TensorTransform { +class MS_API DetectPitchFrequency final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), the value can't be zero. @@ -378,7 +378,7 @@ class DetectPitchFrequency final : public TensorTransform { }; /// \brief EqualizerBiquad TensorTransform. Apply highpass biquad filter on audio. -class EqualizerBiquad final : public TensorTransform { +class MS_API EqualizerBiquad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), the value can't be zero. @@ -401,7 +401,7 @@ class EqualizerBiquad final : public TensorTransform { }; /// \brief Add fade in or/and fade out on the input audio. -class Fade final : public TensorTransform { +class MS_API Fade final : public TensorTransform { public: /// \brief Constructor. /// \param[in] fade_in_len Length of fade-in (time frames), which must be non-negative @@ -425,7 +425,7 @@ class Fade final : public TensorTransform { }; /// \brief Apply a flanger effect to the audio. -class Flanger final : public TensorTransform { +class MS_API Flanger final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz). @@ -458,7 +458,7 @@ class Flanger final : public TensorTransform { /// \brief FrequencyMasking TensorTransform. /// \notes Apply masking to a spectrogram in the frequency domain. -class FrequencyMasking final : public TensorTransform { +class MS_API FrequencyMasking final : public TensorTransform { public: /// \brief Constructor. /// \param[in] iid_masks Whether to apply different masks to each example. @@ -484,7 +484,7 @@ class FrequencyMasking final : public TensorTransform { }; /// \brief HighpassBiquad TensorTransform. Apply highpass biquad filter on audio. -class HighpassBiquad final : public TensorTransform { +class MS_API HighpassBiquad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), the value can't be zero. @@ -506,7 +506,7 @@ class HighpassBiquad final : public TensorTransform { }; /// \brief Design filter. Similar to SoX implementation. -class LFilter final : public TensorTransform { +class MS_API LFilter final : public TensorTransform { public: /// \param[in] a_coeffs Numerator coefficients of difference equation of dimension of (n_order + 1). /// Lower delays coefficients are first, e.g. [a0, a1, a2, ...]. @@ -531,7 +531,7 @@ class LFilter final : public TensorTransform { }; /// \brief Design biquad lowpass filter and perform filtering. Similar to SoX implementation. -class LowpassBiquad final : public TensorTransform { +class MS_API LowpassBiquad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), the value can't be zero. @@ -553,7 +553,7 @@ class LowpassBiquad final : public TensorTransform { }; /// \brief Separate a complex-valued spectrogram with shape (..., 2) into its magnitude and phase. -class Magphase final : public TensorTransform { +class MS_API Magphase final : public TensorTransform { public: /// \brief Constructor. /// \param[in] power Power of the norm, which must be non-negative (Default: 1.0). @@ -574,7 +574,7 @@ class Magphase final : public TensorTransform { /// \brief MuLawDecoding TensorTransform. /// \note Decode mu-law encoded signal. -class MuLawDecoding final : public TensorTransform { +class MS_API MuLawDecoding final : public TensorTransform { public: /// \brief Constructor. /// \param[in] quantization_channels Number of channels, which must be positive (Default: 256). @@ -595,7 +595,7 @@ class MuLawDecoding final : public TensorTransform { /// \brief MuLawEncoding TensorTransform. /// \note Encode signal based on mu-law companding. -class MuLawEncoding final : public TensorTransform { +class MS_API MuLawEncoding final : public TensorTransform { public: /// \brief Constructor. /// \param[in] quantization_channels Number of channels, which must be positive (Default: 256). @@ -615,7 +615,7 @@ class MuLawEncoding final : public TensorTransform { }; /// \brief Overdrive TensorTransform. -class Overdrive final : public TensorTransform { +class MS_API Overdrive final : public TensorTransform { public: /// \brief Constructor. /// \param[in] gain Coefficient of overload in dB, in range of [0, 100] (Default: 20.0). @@ -636,7 +636,7 @@ class Overdrive final : public TensorTransform { }; /// \brief Phaser TensorTransform. -class Phaser final : public TensorTransform { +class MS_API Phaser final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz). @@ -666,7 +666,7 @@ class Phaser final : public TensorTransform { }; /// \brief Apply RIAA vinyl playback equalization. -class RiaaBiquad final : public TensorTransform { +class MS_API RiaaBiquad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), @@ -687,7 +687,7 @@ class RiaaBiquad final : public TensorTransform { }; /// \brief Apply sliding-window cepstral mean (and optionally variance) normalization per utterance. -class SlidingWindowCmn final : public TensorTransform { +class MS_API SlidingWindowCmn final : public TensorTransform { public: /// \brief Constructor of SlidingWindowCmnOp. /// \param[in] cmn_window The window in frames for running average CMN computation (Default: 600). @@ -714,7 +714,7 @@ class SlidingWindowCmn final : public TensorTransform { /// \brief TimeMasking TensorTransform. /// \notes Apply masking to a spectrogram in the time domain. -class TimeMasking final : public TensorTransform { +class MS_API TimeMasking final : public TensorTransform { public: /// \brief Constructor. /// \param[in] iid_masks Whether to apply different masks to each example. @@ -741,7 +741,7 @@ class TimeMasking final : public TensorTransform { /// \brief TimeStretch TensorTransform /// \notes Stretch STFT in time at a given rate, without changing the pitch. -class TimeStretch final : public TensorTransform { +class MS_API TimeStretch final : public TensorTransform { public: /// \brief Constructor. /// \param[in] hop_length Length of hop between STFT windows (Default: None, will use ((n_freq - 1) * 2) // 2). @@ -765,7 +765,7 @@ class TimeStretch final : public TensorTransform { }; /// \brief Design a treble tone-control effect. -class TrebleBiquad final : public TensorTransform { +class MS_API TrebleBiquad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] sample_rate Sampling rate of the waveform, e.g. 44100 (Hz), the value can't be zero. @@ -789,7 +789,7 @@ class TrebleBiquad final : public TensorTransform { /// \brief Vol TensorTransform. /// \notes Add a volume to an waveform. -class Vol final : public TensorTransform { +class MS_API Vol final : public TensorTransform { public: /// \brief Constructor. /// \param[in] gain Gain value, varies according to the value of gain_type. If gain_type is GainType::kAmplitude, diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/config.h b/mindspore/ccsrc/minddata/dataset/include/dataset/config.h index eba15a765c2..884402c5414 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/config.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/config.h @@ -37,7 +37,7 @@ namespace config { /// // Operations with randomness will use the seed value to generate random values. /// bool rc = config::set_seed(5); /// \endcode -bool set_seed(int32_t seed); +bool MS_API set_seed(int32_t seed); /// \brief A function to get the seed. /// \return The seed set in the configuration. @@ -47,7 +47,7 @@ bool set_seed(int32_t seed); /// // If set_seed() is never called before, the default value(std::mt19937::default_seed) will be returned. /// uint32_t seed = config::get_seed(); /// \endcode -uint32_t get_seed(); +uint32_t MS_API get_seed(); /// \brief A function to set the number of rows to be prefetched. /// \param[in] prefetch_size Total number of rows to be prefetched. @@ -57,7 +57,7 @@ uint32_t get_seed(); /// // Set a new global configuration value for the prefetch size. /// bool rc = config::set_prefetch_size(1000); /// \endcode -bool set_prefetch_size(int32_t prefetch_size); +bool MS_API set_prefetch_size(int32_t prefetch_size); /// \brief A function to get the prefetch size in number of rows. /// \return Total number of rows to be prefetched. @@ -67,7 +67,7 @@ bool set_prefetch_size(int32_t prefetch_size); /// // If set_prefetch_size() is never called before, the default value(16) will be returned. /// int32_t prefetch_size = config::get_prefetch_size(); /// \endcode -int32_t get_prefetch_size(); +int32_t MS_API get_prefetch_size(); /// \brief A function to set the default number of parallel workers. /// \param[in] num_parallel_workers Number of parallel workers to be used as the default for each operation. @@ -78,7 +78,7 @@ int32_t get_prefetch_size(); /// // Now parallel dataset operators will run with 16 workers. /// bool rc = config::set_num_parallel_workers(16); /// \endcode -bool set_num_parallel_workers(int32_t num_parallel_workers); +bool MS_API set_num_parallel_workers(int32_t num_parallel_workers); /// \brief A function to get the default number of parallel workers. /// \return Number of parallel workers to be used as the default for each operation. @@ -88,7 +88,7 @@ bool set_num_parallel_workers(int32_t num_parallel_workers); /// // If set_num_parallel_workers() is never called before, the default value(8) will be returned. /// int32_t parallel_workers = config::get_num_parallel_workers(); /// \endcode -int32_t get_num_parallel_workers(); +int32_t MS_API get_num_parallel_workers(); /// \brief A function to set the default interval (in milliseconds) for monitor sampling. /// \param[in] interval Interval (in milliseconds) to be used for performance monitor sampling. @@ -98,7 +98,7 @@ int32_t get_num_parallel_workers(); /// // Set a new global configuration value for the monitor sampling interval. /// bool rc = config::set_monitor_sampling_interval(100); /// \endcode -bool set_monitor_sampling_interval(int32_t interval); +bool MS_API set_monitor_sampling_interval(int32_t interval); /// \brief A function to get the default interval of performance monitor sampling. /// \return Interval (in milliseconds) for performance monitor sampling. @@ -108,7 +108,7 @@ bool set_monitor_sampling_interval(int32_t interval); /// // If set_monitor_sampling_interval() is never called before, the default value(1000) will be returned. /// int32_t sampling_interval = config::get_monitor_sampling_interval(); /// \endcode -int32_t get_monitor_sampling_interval(); +int32_t MS_API get_monitor_sampling_interval(); /// \brief A function to set the default timeout (in seconds) for DSWaitedCallback. In case of a deadlock, the wait /// function will exit after the timeout period. @@ -119,7 +119,7 @@ int32_t get_monitor_sampling_interval(); /// // Set a new global configuration value for the timeout value. /// bool rc = config::set_callback_timeout(100); /// \endcode -bool set_callback_timeout(int32_t timeout); +bool MS_API set_callback_timeout(int32_t timeout); /// \brief A function to get the default timeout for DSWaitedCallback. In case of a deadback, the wait function /// will exit after the timeout period. @@ -130,14 +130,14 @@ bool set_callback_timeout(int32_t timeout); /// // If set_callback_timeout() is never called before, the default value(60) will be returned. /// int32_t callback_timeout = config::get_callback_timeout(); /// \endcode -int32_t get_callback_timeout(); +int32_t MS_API get_callback_timeout(); /// \brief A function to load the configuration from a file. /// \param[in] file Path of the configuration file to be loaded. /// \return The config file is loaded successfully or not. /// \note The reason for using this API is that std::string will be constrained by the /// compiler option '_GLIBCXX_USE_CXX11_ABI' while char is free of this restriction. -bool load(const std::vector &file); +bool MS_API load(const std::vector &file); /// \brief A function to load the configuration from a file. /// \param[in] file Path of the configuration file to be loaded. @@ -155,7 +155,7 @@ bool load(const std::vector &file); /// std::string config_file = "/path/to/config/file"; /// bool rc = config::load(config_file); /// \endcode -inline bool load(std::string file) { return load(StringToChar(file)); } +inline bool MS_API load(std::string file) { return load(StringToChar(file)); } } // namespace config } // namespace dataset diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h b/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h index d783a245f77..1021835c7db 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/constants.h @@ -20,6 +20,8 @@ #include #include +#include "include/api/types.h" + namespace mindspore { namespace dataset { // Various type defines for convenience @@ -27,26 +29,26 @@ using uchar = unsigned char; using dsize_t = int64_t; /// \brief The modulation in Flanger -enum class Modulation { +enum class MS_API Modulation { kSinusoidal = 0, ///< Use sinusoidal modulation. kTriangular = 1 ///< Use triangular modulation. }; /// \brief The interpolation in Flanger -enum class Interpolation { +enum class MS_API Interpolation { kLinear = 0, ///< Use linear for delay-line interpolation. kQuadratic = 1 ///< Use quadratic for delay-line interpolation. }; /// \brief The dataset auto augment policy in AutoAugment -enum class AutoAugmentPolicy { +enum class MS_API AutoAugmentPolicy { kImageNet = 0, ///< AutoAugment policy learned on the ImageNet dataset. kCifar10 = 1, ///< AutoAugment policy learned on the Cifar10 dataset. kSVHN = 2 ///< AutoAugment policy learned on the SVHN dataset. }; /// \brief The color conversion code -enum class ConvertMode { +enum class MS_API ConvertMode { COLOR_BGR2BGRA = 0, ///< Add alpha channel to BGR image. COLOR_RGB2RGBA = COLOR_BGR2BGRA, ///< Add alpha channel to RGB image. COLOR_BGRA2BGR = 1, ///< Remove alpha channel to BGR image. @@ -70,20 +72,20 @@ enum class ConvertMode { }; /// \brief Values of norm in CreateDct. -enum class NormMode { +enum class MS_API NormMode { kNone = 0, ///< None type norm. kOrtho = 1 ///< Ortho type norm. }; /// \brief Target devices to perform map operation. -enum class MapTargetDevice { +enum class MS_API MapTargetDevice { kCpu, ///< CPU Device. kGpu, ///< Gpu Device. kAscend310 ///< Ascend310 Device. }; /// \brief The initial type of tensor implementation. -enum class TensorImpl { +enum class MS_API TensorImpl { kNone, ///< None type tensor. kFlexible, ///< Flexible type tensor, can be converted to any type. kCv, ///< CV type tensor. @@ -91,7 +93,7 @@ enum class TensorImpl { }; /// \brief The mode for shuffling data. -enum class ShuffleMode { +enum class MS_API ShuffleMode { kFalse = 0, ///< No shuffling is performed. kFiles = 1, ///< Shuffle files only. kGlobal = 2, ///< Shuffle both the files and samples. @@ -99,20 +101,20 @@ enum class ShuffleMode { }; /// \brief Possible scale for input audio. -enum class ScaleType { +enum class MS_API ScaleType { kMagnitude = 0, ///< Audio scale is magnitude. kPower = 1, ///< Audio scale is power. }; /// \brief The scale for gain type. -enum class GainType { +enum class MS_API GainType { kAmplitude = 0, ///< Audio gain type is amplitude. kPower = 1, ///< Audio gain type is power. kDb = 2, ///< Audio gain type is db. }; /// \brief The method of padding. -enum class BorderType { +enum class MS_API BorderType { kConstant = 0, ///< Fill the border with constant values. kEdge = 1, ///< Fill the border with the last value on the edge. kReflect = 2, ///< Reflect the values on the edge omitting the last value of edge. @@ -120,7 +122,7 @@ enum class BorderType { }; /// \brief Possible fix rotation angle for Rotate Op. -enum class FixRotationAngle { +enum class MS_API FixRotationAngle { k0Degree = 1, ///< Rotate 0 degree. k0DegreeAndMirror = 2, ///< Rotate 0 degree and apply horizontal flip. k180Degree = 3, ///< Rotate 180 degree. @@ -132,20 +134,20 @@ enum class FixRotationAngle { }; /// \brief Possible options for Image format types in a batch. -enum class ImageBatchFormat { +enum class MS_API ImageBatchFormat { kNHWC = 0, ///< Indicate the input batch is of NHWC format. kNCHW = 1 ///< Indicate the input batch is of NCHW format. }; /// \brief Possible options for Image format types. -enum class ImageFormat { +enum class MS_API ImageFormat { HWC = 0, ///< Indicate the input batch is of NHWC format CHW = 1, ///< Indicate the input batch is of NHWC format HW = 2 ///< Indicate the input batch is of NHWC format }; /// \brief Possible options for interpolation method. -enum class InterpolationMode { +enum class MS_API InterpolationMode { kLinear = 0, ///< Interpolation method is linear interpolation. kNearestNeighbour = 1, ///< Interpolation method is nearest-neighbor interpolation. kCubic = 2, ///< Interpolation method is bicubic interpolation. @@ -154,26 +156,26 @@ enum class InterpolationMode { }; /// \brief Possible tokenize modes for JiebaTokenizer. -enum class JiebaMode { +enum class MS_API JiebaMode { kMix = 0, ///< Tokenize with MPSegment algorithm. kMp = 1, ///< Tokenize with Hiddel Markov Model Segment algorithm. kHmm = 2 ///< Tokenize with a mix of MPSegment and HMMSegment algorithm. }; /// \brief Possible options for SPieceTokenizerOutType. -enum class SPieceTokenizerOutType { +enum class MS_API SPieceTokenizerOutType { kString = 0, ///< Output of sentencepiece tokenizer is string type. kInt = 1 ///< Output of sentencepiece tokenizer is int type. }; /// \brief Possible options for SPieceTokenizerLoadType. -enum class SPieceTokenizerLoadType { +enum class MS_API SPieceTokenizerLoadType { kFile = 0, ///< Load sentencepiece tokenizer from local sentencepiece vocab file. kModel = 1 ///< Load sentencepiece tokenizer from sentencepiece vocab instance. }; /// \brief Type options for SentencePiece Model. -enum class SentencePieceModel { +enum class MS_API SentencePieceModel { kUnigram = 0, ///< Based on Unigram model. kBpe = 1, ///< Based on Byte Pair Encoding (BPE) model. kChar = 2, ///< Based on Char model. @@ -181,7 +183,7 @@ enum class SentencePieceModel { }; /// \brief Possible options to specify a specific normalize mode. -enum class NormalizeForm { +enum class MS_API NormalizeForm { kNone = 0, ///< Keep the input string tensor unchanged. kNfc, ///< Normalize with Normalization Form C. kNfkc, ///< Normalize with Normalization Form KC. @@ -190,7 +192,7 @@ enum class NormalizeForm { }; /// \brief Possible options for Mask. -enum class RelationalOp { +enum class MS_API RelationalOp { kEqual = 0, ///< equal to `==` kNotEqual, ///< equal to `!=` kLess, ///< equal to `<` @@ -200,26 +202,26 @@ enum class RelationalOp { }; /// \brief Possible modes for slice patches. -enum class SliceMode { +enum class MS_API SliceMode { kPad = 0, ///< Pad some pixels before slice to patches. kDrop = 1, ///< Drop remainder pixels before slice to patches. }; /// \brief Possible options for SamplingStrategy. -enum class SamplingStrategy { +enum class MS_API SamplingStrategy { kRandom = 0, ///< Random sampling with replacement. kEdgeWeight = 1 ///< Sampling with edge weight as probability. }; /// \brief Possible values for output format in get all neighbors function of gnn dataset -enum class OutputFormat { +enum class MS_API OutputFormat { kNormal = 0, ///< Normal format. kCoo = 1, ///< COO format. kCsr = 2 ///< CSR format. }; /// \brief Possible options for fade shape. -enum class FadeShape { +enum class MS_API FadeShape { kLinear = 0, ///< Fade shape is linear mode. kExponential = 1, ///< Fade shape is exponential mode. kLogarithmic = 2, ///< Fade shape is logarithmic mode. @@ -231,12 +233,12 @@ enum class FadeShape { /// \param[in] bits a 32bit int to be tested /// \param[in] bitMask a 32bit int representing bit mask /// \return bool Result for the check -inline bool BitTest(uint32_t bits, uint32_t bitMask) { return (bits & bitMask) == bitMask; } +inline bool MS_API BitTest(uint32_t bits, uint32_t bitMask) { return (bits & bitMask) == bitMask; } /// \brief Convenience function to set bitmask for a 32bit int /// \param[in] bits a 32bit int to deal with /// \param[in] bitMask a 32bit int representing bit mask -inline void BitSet(uint32_t *bits, uint32_t bitMask) { +inline void MS_API BitSet(uint32_t *bits, uint32_t bitMask) { if (bits == nullptr) { return; } @@ -246,7 +248,7 @@ inline void BitSet(uint32_t *bits, uint32_t bitMask) { /// \brief Convenience function to clear bitmask from a 32bit int /// \param[in] bits a 32bit int to deal with /// \param[in] bitMask a 32bit int representing bit mask -inline void BitClear(uint32_t *bits, uint32_t bitMask) { +inline void MS_API BitClear(uint32_t *bits, uint32_t bitMask) { if (bits == nullptr) { return; } diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/data_helper.h b/mindspore/ccsrc/minddata/dataset/include/dataset/data_helper.h index 61116044924..2a462d0362c 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/data_helper.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/data_helper.h @@ -33,7 +33,7 @@ namespace mindspore { namespace dataset { /// \brief Simple class to do data manipulation, contains helper function to update json files in dataset -class DataHelper { +class MS_API DataHelper { public: /// \brief constructor DataHelper() {} diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/datasets.h b/mindspore/ccsrc/minddata/dataset/include/dataset/datasets.h index e4416699a15..0a712aea4ce 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/datasets.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/datasets.h @@ -83,7 +83,7 @@ class ZipDataset; /// \class Dataset datasets.h /// \brief A base class to represent a dataset in the data pipeline. -class Dataset : public std::enable_shared_from_this { +class MS_API Dataset : public std::enable_shared_from_this { public: // need friend class so they can access the children_ field friend class Iterator; @@ -641,7 +641,7 @@ class Dataset : public std::enable_shared_from_this { /// \class SchemaObj /// \brief A schema object to set column type, data type and data shape. -class SchemaObj { +class MS_API SchemaObj { public: /// \brief Constructor explicit SchemaObj(const std::string &schema_file = "") : SchemaObj(StringToChar(schema_file)) {} @@ -764,7 +764,7 @@ class SchemaObj { /// \class BatchDataset /// \brief The result of applying Batch operator to the input dataset. -class BatchDataset : public Dataset { +class MS_API BatchDataset : public Dataset { public: /// \brief Constructor of BatchDataset. /// \note Combines batch_size number of consecutive rows into batches. @@ -782,7 +782,7 @@ class BatchDataset : public Dataset { /// \class BucketBatchByLengthDataset /// \brief The result of applying BucketBatchByLength operator to the input dataset. -class BucketBatchByLengthDataset : public Dataset { +class MS_API BucketBatchByLengthDataset : public Dataset { public: /// \brief Constructor of BucketBatchByLengthDataset. /// \note Bucket elements according to their lengths. Each bucket will be padded and batched when @@ -823,7 +823,7 @@ class BucketBatchByLengthDataset : public Dataset { /// \class ConcatDataset /// \brief The result of applying concat dataset operator to the input Dataset. -class ConcatDataset : public Dataset { +class MS_API ConcatDataset : public Dataset { public: /// \brief Constructor of ConcatDataset. /// \note Concat the datasets in the input. @@ -836,7 +836,7 @@ class ConcatDataset : public Dataset { /// \class FilterDataset /// \brief The result of applying filter predicate to the input Dataset. -class FilterDataset : public Dataset { +class MS_API FilterDataset : public Dataset { public: /// \brief Constructor of FilterDataset. /// \note If input_columns is not provided or empty, all columns will be used. @@ -852,7 +852,7 @@ class FilterDataset : public Dataset { /// \class MapDataset /// \brief The result of applying the Map operator to the input Dataset. -class MapDataset : public Dataset { +class MS_API MapDataset : public Dataset { public: /// \brief Constructor of MapDataset. /// \note Applies each operation in operations to this dataset. @@ -882,7 +882,7 @@ class MapDataset : public Dataset { /// \class ProjectDataset /// \brief The result of applying the Project operator to the input Dataset. -class ProjectDataset : public Dataset { +class MS_API ProjectDataset : public Dataset { public: /// \brief Constructor of ProjectDataset. /// \note Applies project to the dataset. @@ -896,7 +896,7 @@ class ProjectDataset : public Dataset { /// \class RenameDataset /// \brief The result of applying the Rename operator to the input Dataset. -class RenameDataset : public Dataset { +class MS_API RenameDataset : public Dataset { public: /// \brief Constructor of RenameDataset. /// \note Renames the columns in the input dataset. @@ -912,7 +912,7 @@ class RenameDataset : public Dataset { /// \class RepeatDataset /// \brief The result of applying the Repeat operator to the input Dataset. -class RepeatDataset : public Dataset { +class MS_API RepeatDataset : public Dataset { public: /// \brief Constructor of RepeatDataset. /// \note Repeats this dataset count times. Repeat indefinitely if count is -1. @@ -926,7 +926,7 @@ class RepeatDataset : public Dataset { /// \class ShuffleDataset /// \brief The result of applying the Shuffle operator to the input Dataset. -class ShuffleDataset : public Dataset { +class MS_API ShuffleDataset : public Dataset { public: /// \brief Constructor of ShuffleDataset. /// \note Randomly shuffles the rows of this dataset. @@ -940,7 +940,7 @@ class ShuffleDataset : public Dataset { /// \class SkipDataset /// \brief The result of applying the Skip operator to the input Dataset. -class SkipDataset : public Dataset { +class MS_API SkipDataset : public Dataset { public: /// \brief Constructor of SkipDataset. /// \note Skips count elements in this dataset. @@ -954,7 +954,7 @@ class SkipDataset : public Dataset { /// \class TakeDataset /// \brief The result of applying the Take operator to the input Dataset. -class TakeDataset : public Dataset { +class MS_API TakeDataset : public Dataset { public: /// \brief Constructor of TakeDataset. /// \note Takes count elements in this dataset. @@ -968,7 +968,7 @@ class TakeDataset : public Dataset { /// \class ZipDataset /// \brief The result of applying the Zip operator to the input Dataset. -class ZipDataset : public Dataset { +class MS_API ZipDataset : public Dataset { public: /// \brief Constructor of ZipDataset. /// \note Applies zip to the dataset. @@ -984,18 +984,18 @@ class ZipDataset : public Dataset { /// \note The reason for using this API is that std::string will be constrained by the /// compiler option '_GLIBCXX_USE_CXX11_ABI' while char is free of this restriction. /// \return Shared pointer to the current schema. -std::shared_ptr SchemaCharIF(const std::vector &schema_file); +std::shared_ptr MS_API SchemaCharIF(const std::vector &schema_file); /// \brief Function to create a SchemaObj. /// \param[in] schema_file Path of schema file. /// \return Shared pointer to the current schema. -inline std::shared_ptr Schema(const std::string &schema_file = "") { +inline std::shared_ptr MS_API Schema(const std::string &schema_file = "") { return SchemaCharIF(StringToChar(schema_file)); } /// \class AGNewsDataset /// \brief A source dataset that reads and parses AG News datasets. -class AGNewsDataset : public Dataset { +class MS_API AGNewsDataset : public Dataset { public: /// \brief Constructor of AGNewsDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -1035,17 +1035,17 @@ class AGNewsDataset : public Dataset { /// specified only when num_shards is also specified (Default = 0). /// \param[in] cache Tensor cache to use.(default=nullptr which means no cache is used). /// \return Shared pointer to the AGNewsDataset. -inline std::shared_ptr AGNews(const std::string &dataset_dir, const std::string &usage = "all", - int64_t num_samples = 0, ShuffleMode shuffle = ShuffleMode::kGlobal, - int32_t num_shards = 1, int32_t shard_id = 0, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API AGNews(const std::string &dataset_dir, const std::string &usage = "all", + int64_t num_samples = 0, ShuffleMode shuffle = ShuffleMode::kGlobal, + int32_t num_shards = 1, int32_t shard_id = 0, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), num_samples, shuffle, num_shards, shard_id, cache); } /// \class AlbumDataset /// \brief A source dataset for reading and parsing Album dataset. -class AlbumDataset : public Dataset { +class MS_API AlbumDataset : public Dataset { public: /// \brief Constructor of AlbumDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -1113,10 +1113,10 @@ class AlbumDataset : public Dataset { /// /* Note: As we defined before, each data dictionary owns keys "image", "label" and "id" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr Album(const std::string &dataset_dir, const std::string &data_schema, - const std::vector &column_names = {}, bool decode = false, - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +Album(const std::string &dataset_dir, const std::string &data_schema, const std::vector &column_names = {}, + bool decode = false, const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(data_schema), VectorStringToChar(column_names), decode, sampler, cache); } @@ -1129,10 +1129,10 @@ inline std::shared_ptr Album(const std::string &dataset_dir, const /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the AlbumDataset -inline std::shared_ptr Album(const std::string &dataset_dir, const std::string &data_schema, - const std::vector &column_names, bool decode, - const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Album(const std::string &dataset_dir, const std::string &data_schema, + const std::vector &column_names, bool decode, + const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(data_schema), VectorStringToChar(column_names), decode, sampler, cache); } @@ -1145,17 +1145,17 @@ inline std::shared_ptr Album(const std::string &dataset_dir, const /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the AlbumDataset. -inline std::shared_ptr Album(const std::string &dataset_dir, const std::string &data_schema, - const std::vector &column_names, bool decode, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Album(const std::string &dataset_dir, const std::string &data_schema, + const std::vector &column_names, bool decode, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(data_schema), VectorStringToChar(column_names), decode, sampler, cache); } /// \class CelebADataset /// \brief A source dataset for reading and parsing CelebA dataset. -class CelebADataset : public Dataset { +class MS_API CelebADataset : public Dataset { public: /// \brief Constructor of CelebADataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -1219,10 +1219,10 @@ class CelebADataset : public Dataset { /// /* Note: In CelebA dataset, each data dictionary owns keys "image" and "attr" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr CelebA( - const std::string &dataset_dir, const std::string &usage = "all", - const std::shared_ptr &sampler = std::make_shared(), bool decode = false, - const std::set &extensions = {}, const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +CelebA(const std::string &dataset_dir, const std::string &usage = "all", + const std::shared_ptr &sampler = std::make_shared(), bool decode = false, + const std::set &extensions = {}, const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, decode, SetStringToChar(extensions), cache); } @@ -1237,10 +1237,10 @@ inline std::shared_ptr CelebA( /// \param[in] extensions Set of file extensions to be included in the dataset (default={}). /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the CelebADataset. -inline std::shared_ptr CelebA(const std::string &dataset_dir, const std::string &usage, - const Sampler *sampler, bool decode = false, - const std::set &extensions = {}, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API CelebA(const std::string &dataset_dir, const std::string &usage, + const Sampler *sampler, bool decode = false, + const std::set &extensions = {}, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, decode, SetStringToChar(extensions), cache); } @@ -1255,17 +1255,17 @@ inline std::shared_ptr CelebA(const std::string &dataset_dir, con /// \param[in] extensions Set of file extensions to be included in the dataset (default={}). /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the CelebADataset. -inline std::shared_ptr CelebA(const std::string &dataset_dir, const std::string &usage, - const std::reference_wrapper sampler, bool decode = false, - const std::set &extensions = {}, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API CelebA(const std::string &dataset_dir, const std::string &usage, + const std::reference_wrapper sampler, bool decode = false, + const std::set &extensions = {}, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, decode, SetStringToChar(extensions), cache); } /// \class Cifar10Dataset /// \brief A source dataset for reading and parsing Cifar10 dataset. -class Cifar10Dataset : public Dataset { +class MS_API Cifar10Dataset : public Dataset { public: /// \brief Constructor of Cifar10Dataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -1318,10 +1318,10 @@ class Cifar10Dataset : public Dataset { /// /* Note: In CIFAR10 dataset, each data dictionary owns keys "image" and "label" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr Cifar10( - const std::string &dataset_dir, const std::string &usage = "all", - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +Cifar10(const std::string &dataset_dir, const std::string &usage = "all", + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } @@ -1332,9 +1332,9 @@ inline std::shared_ptr Cifar10( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the Cifar10Dataset. -inline std::shared_ptr Cifar10(const std::string &dataset_dir, const std::string &usage, - const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Cifar10(const std::string &dataset_dir, const std::string &usage, + const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } @@ -1345,15 +1345,15 @@ inline std::shared_ptr Cifar10(const std::string &dataset_dir, c /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the Cifar10Dataset. -inline std::shared_ptr Cifar10(const std::string &dataset_dir, const std::string &usage, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Cifar10(const std::string &dataset_dir, const std::string &usage, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } /// \class Cifar100Dataset /// \brief A source dataset for reading and parsing Cifar100 dataset. -class Cifar100Dataset : public Dataset { +class MS_API Cifar100Dataset : public Dataset { public: /// \brief Constructor of Cifar100Dataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -1406,10 +1406,10 @@ class Cifar100Dataset : public Dataset { /// /* Note: In CIFAR100 dataset, each dictionary has 3 keys: "image", "fine_label" and "coarse_label" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr Cifar100( - const std::string &dataset_dir, const std::string &usage = "all", - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +Cifar100(const std::string &dataset_dir, const std::string &usage = "all", + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } @@ -1420,9 +1420,9 @@ inline std::shared_ptr Cifar100( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the Cifar100Dataset. -inline std::shared_ptr Cifar100(const std::string &dataset_dir, const std::string &usage, - const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Cifar100(const std::string &dataset_dir, const std::string &usage, + const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } @@ -1433,15 +1433,15 @@ inline std::shared_ptr Cifar100(const std::string &dataset_dir, /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the Cifar100Dataset. -inline std::shared_ptr Cifar100(const std::string &dataset_dir, const std::string &usage, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Cifar100(const std::string &dataset_dir, const std::string &usage, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } /// \class CityscapesDataset /// \brief A source dataset for reading and parsing Cityscapes dataset. -class CityscapesDataset : public Dataset { +class MS_API CityscapesDataset : public Dataset { public: /// \brief Constructor of CityscapesDataset. /// \param[in] dataset_dir The dataset dir to be read. @@ -1521,7 +1521,7 @@ class CityscapesDataset : public Dataset { /// /* Note: In Cityscapes dataset, each data dictionary owns keys "image" and "task" */ /// auto task = row["task"]; /// \endcode -inline std::shared_ptr Cityscapes( +inline std::shared_ptr MS_API Cityscapes( const std::string &dataset_dir, const std::string &usage, const std::string &quality_mode, const std::string &task, bool decode = false, const std::shared_ptr &sampler = std::make_shared(), const std::shared_ptr &cache = nullptr) { @@ -1542,10 +1542,10 @@ inline std::shared_ptr Cityscapes( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current CityscapesDataset. -inline std::shared_ptr Cityscapes(const std::string &dataset_dir, const std::string &usage, - const std::string &quality_mode, const std::string &task, - bool decode, const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Cityscapes(const std::string &dataset_dir, const std::string &usage, + const std::string &quality_mode, const std::string &task, + bool decode, const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), StringToChar(quality_mode), StringToChar(task), decode, sampler, cache); } @@ -1563,17 +1563,17 @@ inline std::shared_ptr Cityscapes(const std::string &dataset_ /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current CityscapesDataset. -inline std::shared_ptr Cityscapes(const std::string &dataset_dir, const std::string &usage, - const std::string &quality_mode, const std::string &task, - bool decode, const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Cityscapes(const std::string &dataset_dir, const std::string &usage, + const std::string &quality_mode, const std::string &task, + bool decode, const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), StringToChar(quality_mode), StringToChar(task), decode, sampler, cache); } /// \class CLUEDataset /// \brief A source dataset for reading and parsing CLUE dataset. -class CLUEDataset : public Dataset { +class MS_API CLUEDataset : public Dataset { public: /// \brief Constructor of CLUEDataset. /// \param[in] dataset_files List of files to be read to search for a pattern of files. The list @@ -1630,18 +1630,18 @@ class CLUEDataset : public Dataset { /// /// auto text = row["sentence1"]; /// \endcode -inline std::shared_ptr CLUE(const std::vector &dataset_files, - const std::string &task = "AFQMC", const std::string &usage = "train", - int64_t num_samples = 0, ShuffleMode shuffle = ShuffleMode::kGlobal, - int32_t num_shards = 1, int32_t shard_id = 0, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API CLUE(const std::vector &dataset_files, + const std::string &task = "AFQMC", const std::string &usage = "train", + int64_t num_samples = 0, ShuffleMode shuffle = ShuffleMode::kGlobal, + int32_t num_shards = 1, int32_t shard_id = 0, + const std::shared_ptr &cache = nullptr) { return std::make_shared(VectorStringToChar(dataset_files), StringToChar(task), StringToChar(usage), num_samples, shuffle, num_shards, shard_id, cache); } /// \class CocoDataset /// \brief A source dataset for reading and parsing Coco dataset. -class CocoDataset : public Dataset { +class MS_API CocoDataset : public Dataset { public: /// \brief Constructor of CocoDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -1717,11 +1717,10 @@ class CocoDataset : public Dataset { /// /* Note: In COCO dataset, each dictionary has keys "image" and "annotation" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr Coco(const std::string &dataset_dir, const std::string &annotation_file, - const std::string &task = "Detection", const bool &decode = false, - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr, - const bool &extra_metadata = false) { +inline std::shared_ptr MS_API +Coco(const std::string &dataset_dir, const std::string &annotation_file, const std::string &task = "Detection", + const bool &decode = false, const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr, const bool &extra_metadata = false) { return std::make_shared(StringToChar(dataset_dir), StringToChar(annotation_file), StringToChar(task), decode, sampler, cache, extra_metadata); } @@ -1743,10 +1742,10 @@ inline std::shared_ptr Coco(const std::string &dataset_dir, const s /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \param[in] extra_metadata Flag to add extra meta-data to row. (default=false). /// \return Shared pointer to the CocoDataset. -inline std::shared_ptr Coco(const std::string &dataset_dir, const std::string &annotation_file, - const std::string &task, const bool &decode, const Sampler *sampler, - const std::shared_ptr &cache = nullptr, - const bool &extra_metadata = false) { +inline std::shared_ptr MS_API Coco(const std::string &dataset_dir, const std::string &annotation_file, + const std::string &task, const bool &decode, const Sampler *sampler, + const std::shared_ptr &cache = nullptr, + const bool &extra_metadata = false) { return std::make_shared(StringToChar(dataset_dir), StringToChar(annotation_file), StringToChar(task), decode, sampler, cache, extra_metadata); } @@ -1768,18 +1767,18 @@ inline std::shared_ptr Coco(const std::string &dataset_dir, const s /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \param[in] extra_metadata Flag to add extra meta-data to row. (default=false). /// \return Shared pointer to the CocoDataset. -inline std::shared_ptr Coco(const std::string &dataset_dir, const std::string &annotation_file, - const std::string &task, const bool &decode, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr, - const bool &extra_metadata = false) { +inline std::shared_ptr MS_API Coco(const std::string &dataset_dir, const std::string &annotation_file, + const std::string &task, const bool &decode, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr, + const bool &extra_metadata = false) { return std::make_shared(StringToChar(dataset_dir), StringToChar(annotation_file), StringToChar(task), decode, sampler, cache, extra_metadata); } /// \class CSVDataset /// \brief A source dataset that reads and parses comma-separated values (CSV) datasets. -class CSVDataset : public Dataset { +class MS_API CSVDataset : public Dataset { public: /// \brief Constructor of CSVDataset. /// \param[in] dataset_files List of files to be read to search for a pattern of files. The list @@ -1845,11 +1844,12 @@ class CSVDataset : public Dataset { /// /* Note: As we defined before, the dataset has column "col1", "col2", "col3" and "col4" */ /// auto col1 = row["col1"]; /// \endcode -inline std::shared_ptr CSV(const std::vector &dataset_files, char field_delim = ',', - const std::vector> &column_defaults = {}, - const std::vector &column_names = {}, int64_t num_samples = 0, - ShuffleMode shuffle = ShuffleMode::kGlobal, int32_t num_shards = 1, - int32_t shard_id = 0, const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API CSV(const std::vector &dataset_files, char field_delim = ',', + const std::vector> &column_defaults = {}, + const std::vector &column_names = {}, + int64_t num_samples = 0, ShuffleMode shuffle = ShuffleMode::kGlobal, + int32_t num_shards = 1, int32_t shard_id = 0, + const std::shared_ptr &cache = nullptr) { return std::make_shared(VectorStringToChar(dataset_files), field_delim, column_defaults, VectorStringToChar(column_names), num_samples, shuffle, num_shards, shard_id, cache); @@ -1857,7 +1857,7 @@ inline std::shared_ptr CSV(const std::vector &dataset_f /// \class DBpediaDataset /// \brief A source dataset for reading and parsing DBpedia dataset. -class DBpediaDataset : public Dataset { +class MS_API DBpediaDataset : public Dataset { public: /// \brief Constructor of DBpediaDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -1895,17 +1895,18 @@ class DBpediaDataset : public Dataset { /// specified only when num_shards is also specified (Default = 0). /// \param[in] cache Tensor cache to use (default=nullptr, which means no cache is used). /// \return Shared pointer to the DBpediaDataset -inline std::shared_ptr DBpedia(const std::string &dataset_dir, const std::string &usage = "all", - int64_t num_samples = 0, ShuffleMode shuffle = ShuffleMode::kGlobal, - int32_t num_shards = 1, int32_t shard_id = 0, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API DBpedia(const std::string &dataset_dir, const std::string &usage = "all", + int64_t num_samples = 0, + ShuffleMode shuffle = ShuffleMode::kGlobal, + int32_t num_shards = 1, int32_t shard_id = 0, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), num_samples, shuffle, num_shards, shard_id, cache); } /// \class DIV2KDataset /// \brief A source dataset for reading and parsing DIV2K dataset. -class DIV2KDataset : public Dataset { +class MS_API DIV2KDataset : public Dataset { public: /// \brief Constructor of DIV2KDataset. /// \param[in] dataset_dir The dataset dir to be read. @@ -1976,10 +1977,10 @@ class DIV2KDataset : public Dataset { /// /* Note: In DIV2K dataset, each dictionary has keys "hr_image" and "lr_image" */ /// auto hr_image = row["hr_image"]; /// \endcode -inline std::shared_ptr DIV2K(const std::string &dataset_dir, const std::string &usage, - const std::string &downgrade, int32_t scale, bool decode = false, - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +DIV2K(const std::string &dataset_dir, const std::string &usage, const std::string &downgrade, int32_t scale, + bool decode = false, const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), StringToChar(downgrade), scale, decode, sampler, cache); } @@ -1995,10 +1996,10 @@ inline std::shared_ptr DIV2K(const std::string &dataset_dir, const /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the current DIV2KDataset. -inline std::shared_ptr DIV2K(const std::string &dataset_dir, const std::string &usage, - const std::string &downgrade, int32_t scale, bool decode, - const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API DIV2K(const std::string &dataset_dir, const std::string &usage, + const std::string &downgrade, int32_t scale, bool decode, + const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), StringToChar(downgrade), scale, decode, sampler, cache); } @@ -2014,17 +2015,17 @@ inline std::shared_ptr DIV2K(const std::string &dataset_dir, const /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the current DIV2KDataset. -inline std::shared_ptr DIV2K(const std::string &dataset_dir, const std::string &usage, - const std::string &downgrade, int32_t scale, bool decode, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API DIV2K(const std::string &dataset_dir, const std::string &usage, + const std::string &downgrade, int32_t scale, bool decode, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), StringToChar(downgrade), scale, decode, sampler, cache); } /// \class EMnistDataset /// \brief A source dataset for reading and parsing EMnist dataset. -class EMnistDataset : public Dataset { +class MS_API EMnistDataset : public Dataset { public: /// \brief Constructor of EMnistDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -2085,10 +2086,10 @@ class EMnistDataset : public Dataset { /// /* Note: In EMNIST dataset dataset, each dictionary has keys "image" and "label" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr EMnist( - const std::string &dataset_dir, const std::string &name, const std::string &usage = "all", - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +EMnist(const std::string &dataset_dir, const std::string &name, const std::string &usage = "all", + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(name), StringToChar(usage), sampler, cache); } @@ -2101,9 +2102,9 @@ inline std::shared_ptr EMnist( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current EMnistDataset. -inline std::shared_ptr EMnist(const std::string &dataset_dir, const std::string &usage, - const std::string &name, const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API EMnist(const std::string &dataset_dir, const std::string &usage, + const std::string &name, const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(name), StringToChar(usage), sampler, cache); } @@ -2116,16 +2117,17 @@ inline std::shared_ptr EMnist(const std::string &dataset_dir, con /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current EMnistDataset. -inline std::shared_ptr EMnist(const std::string &dataset_dir, const std::string &name, - const std::string &usage, const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_APIEMnist(const std::string &dataset_dir, const std::string &name, + const std::string &usage, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(name), StringToChar(usage), sampler, cache); } /// \class FakeImageDataset /// \brief A source dataset for generating fake images. -class FakeImageDataset : public Dataset { +class MS_API FakeImageDataset : public Dataset { public: /// \brief Constructor of FakeImageDataset. /// \param[in] num_images The number of images to generate, which must be positive. @@ -2175,10 +2177,10 @@ class FakeImageDataset : public Dataset { /// given, a `RandomSampler` will be used to randomly iterate the entire dataset (default = RandomSampler()). /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the current FakeDataset. -inline std::shared_ptr FakeImage( - int32_t num_images = 1000, const std::vector &image_size = {224, 224, 3}, int32_t num_classes = 10, - int32_t base_seed = 0, const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +FakeImage(int32_t num_images = 1000, const std::vector &image_size = {224, 224, 3}, int32_t num_classes = 10, + int32_t base_seed = 0, const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(num_images, image_size, num_classes, base_seed, sampler, cache); } @@ -2191,9 +2193,10 @@ inline std::shared_ptr FakeImage( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the current FakeImageDataset. -inline std::shared_ptr FakeImage(int32_t num_images, const std::vector &image_size, - int32_t num_classes, int32_t base_seed, const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API FakeImage(int32_t num_images, const std::vector &image_size, + int32_t num_classes, int32_t base_seed, + const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(num_images, image_size, num_classes, base_seed, sampler, cache); } @@ -2206,16 +2209,16 @@ inline std::shared_ptr FakeImage(int32_t num_images, const std /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the current FakeImageDataset. -inline std::shared_ptr FakeImage(int32_t num_images, const std::vector &image_size, - int32_t num_classes, int32_t base_seed, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API FakeImage(int32_t num_images, const std::vector &image_size, + int32_t num_classes, int32_t base_seed, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(num_images, image_size, num_classes, base_seed, sampler, cache); } /// \class FashionMnistDataset /// \brief A source dataset that reads and parses FASHION-MNIST dataset. -class FashionMnistDataset : public Dataset { +class MS_API FashionMnistDataset : public Dataset { public: /// \brief Constructor of FashionMnistDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -2255,10 +2258,10 @@ class FashionMnistDataset : public Dataset { /// given, a `RandomSampler` will be used to randomly iterate the entire dataset (default = RandomSampler()). /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the FashionMnistDataset. -inline std::shared_ptr FashionMnist( - const std::string &dataset_dir, const std::string &usage = "all", - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +FashionMnist(const std::string &dataset_dir, const std::string &usage = "all", + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } @@ -2269,9 +2272,9 @@ inline std::shared_ptr FashionMnist( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the FashionMnistDataset. -inline std::shared_ptr FashionMnist(const std::string &dataset_dir, const std::string &usage, - const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API FashionMnist(const std::string &dataset_dir, + const std::string &usage, const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } @@ -2282,15 +2285,16 @@ inline std::shared_ptr FashionMnist(const std::string &data /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the FashionMnistDataset. -inline std::shared_ptr FashionMnist(const std::string &dataset_dir, const std::string &usage, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API FashionMnist(const std::string &dataset_dir, + const std::string &usage, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } /// \class FlickrDataset /// \brief A source dataset for reading and parsing Flickr dataset. -class FlickrDataset : public Dataset { +class MS_API FlickrDataset : public Dataset { public: /// \brief Constructor of FlickrDataset. /// \param[in] dataset_dir The dataset dir to be read @@ -2348,10 +2352,10 @@ class FlickrDataset : public Dataset { /// /* Note: In FLICKR dataset, each dictionary has keys "image" and "annotation" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr Flickr( - const std::string &dataset_dir, const std::string &annotation_file, bool decode = false, - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +Flickr(const std::string &dataset_dir, const std::string &annotation_file, bool decode = false, + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(annotation_file), decode, sampler, cache); } @@ -2364,9 +2368,9 @@ inline std::shared_ptr Flickr( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current FlickrDataset -inline std::shared_ptr Flickr(const std::string &dataset_dir, const std::string &annotation_file, - bool decode, const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Flickr(const std::string &dataset_dir, const std::string &annotation_file, + bool decode, const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(annotation_file), decode, sampler, cache); } @@ -2379,16 +2383,16 @@ inline std::shared_ptr Flickr(const std::string &dataset_dir, con /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current FlickrDataset -inline std::shared_ptr Flickr(const std::string &dataset_dir, const std::string &annotation_file, - bool decode, const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Flickr(const std::string &dataset_dir, const std::string &annotation_file, + bool decode, const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(annotation_file), decode, sampler, cache); } /// \class ImageFolderDataset /// \brief A source dataset that reads images from a tree of directories. -class ImageFolderDataset : public Dataset { +class MS_API ImageFolderDataset : public Dataset { public: /// \brief Constructor of ImageFolderDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -2457,11 +2461,11 @@ class ImageFolderDataset : public Dataset { /// /* Note: In ImageFolder dataset, each data dictionary has keys "image" and "label" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr ImageFolder( - const std::string &dataset_dir, bool decode = false, - const std::shared_ptr &sampler = std::make_shared(), - const std::set &extensions = {}, const std::map &class_indexing = {}, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +ImageFolder(const std::string &dataset_dir, bool decode = false, + const std::shared_ptr &sampler = std::make_shared(), + const std::set &extensions = {}, const std::map &class_indexing = {}, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), decode, sampler, SetStringToChar(extensions), MapStringToChar(class_indexing), cache); } @@ -2477,11 +2481,11 @@ inline std::shared_ptr ImageFolder( /// \param[in] class_indexing a class name to label map. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the ImageFolderDataset. -inline std::shared_ptr ImageFolder(const std::string &dataset_dir, bool decode, - const Sampler *sampler, - const std::set &extensions = {}, - const std::map &class_indexing = {}, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API ImageFolder(const std::string &dataset_dir, bool decode, + const Sampler *sampler, + const std::set &extensions = {}, + const std::map &class_indexing = {}, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), decode, sampler, SetStringToChar(extensions), MapStringToChar(class_indexing), cache); } @@ -2497,18 +2501,18 @@ inline std::shared_ptr ImageFolder(const std::string &datase /// \param[in] class_indexing a class name to label map. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the ImageFolderDataset. -inline std::shared_ptr ImageFolder(const std::string &dataset_dir, bool decode, - const std::reference_wrapper sampler, - const std::set &extensions = {}, - const std::map &class_indexing = {}, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API ImageFolder(const std::string &dataset_dir, bool decode, + const std::reference_wrapper sampler, + const std::set &extensions = {}, + const std::map &class_indexing = {}, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), decode, sampler, SetStringToChar(extensions), MapStringToChar(class_indexing), cache); } /// \class LJSpeechDataset /// \brief A source dataset for reading and parsing LJSpeech dataset. -class LJSpeechDataset : public Dataset { +class MS_API LJSpeechDataset : public Dataset { public: /// \brief Constructor of LJSpeechDataset. /// \param[in] dataset_file The dataset file to be read. @@ -2544,9 +2548,9 @@ class LJSpeechDataset : public Dataset { /// given, a `RandomSampler` will be used to randomly iterate the entire dataset (default = RandomSampler()). /// \param[in] cache Tensor cache to use. (default=nullptr, which means no cache is used). /// \return Shared pointer to the current Dataset. -inline std::shared_ptr LJSpeech( - const std::string &dataset_dir, const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +LJSpeech(const std::string &dataset_dir, const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), sampler, cache); } @@ -2557,8 +2561,8 @@ inline std::shared_ptr LJSpeech( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr, which means no cache is used). /// \return Shared pointer to the current Dataset. -inline std::shared_ptr LJSpeech(const std::string &dataset_dir, Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API LJSpeech(const std::string &dataset_dir, Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), sampler, cache); } @@ -2569,15 +2573,15 @@ inline std::shared_ptr LJSpeech(const std::string &dataset_dir, /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr, which means no cache is used). /// \return Shared pointer to the current Dataset. -inline std::shared_ptr LJSpeech(const std::string &dataset_dir, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API LJSpeech(const std::string &dataset_dir, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), sampler, cache); } /// \class ManifestDataset /// \brief A source dataset for reading and parsing Manifest dataset. -class ManifestDataset : public Dataset { +class MS_API ManifestDataset : public Dataset { public: /// \brief Constructor of ManifestDataset. /// \param[in] dataset_file The dataset file to be read. @@ -2646,11 +2650,11 @@ class ManifestDataset : public Dataset { /// /* Note: In Manifest dataset, each data dictionary has keys "image" and "label" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr Manifest( - const std::string &dataset_file, const std::string &usage = "train", - const std::shared_ptr &sampler = std::make_shared(), - const std::map &class_indexing = {}, bool decode = false, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +Manifest(const std::string &dataset_file, const std::string &usage = "train", + const std::shared_ptr &sampler = std::make_shared(), + const std::map &class_indexing = {}, bool decode = false, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_file), StringToChar(usage), sampler, MapStringToChar(class_indexing), decode, cache); } @@ -2665,11 +2669,11 @@ inline std::shared_ptr Manifest( /// \param[in] decode Decode the images after reading (default=false). /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the ManifestDataset. -inline std::shared_ptr Manifest(const std::string &dataset_file, const std::string &usage, - const Sampler *sampler, - const std::map &class_indexing = {}, - bool decode = false, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Manifest(const std::string &dataset_file, const std::string &usage, + const Sampler *sampler, + const std::map &class_indexing = {}, + bool decode = false, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_file), StringToChar(usage), sampler, MapStringToChar(class_indexing), decode, cache); } @@ -2684,18 +2688,18 @@ inline std::shared_ptr Manifest(const std::string &dataset_file /// \param[in] decode Decode the images after reading (default=false). /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the ManifestDataset. -inline std::shared_ptr Manifest(const std::string &dataset_file, const std::string &usage, - const std::reference_wrapper sampler, - const std::map &class_indexing = {}, - bool decode = false, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Manifest(const std::string &dataset_file, const std::string &usage, + const std::reference_wrapper sampler, + const std::map &class_indexing = {}, + bool decode = false, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_file), StringToChar(usage), sampler, MapStringToChar(class_indexing), decode, cache); } /// \class MindDataDataset /// \brief A source dataset for reading and parsing MindRecord dataset. -class MindDataDataset : public Dataset { +class MS_API MindDataDataset : public Dataset { public: /// \brief Constructor of MindDataDataset. /// \param[in] dataset_file File name of one component of a mindrecord source. Other files with identical source @@ -2854,11 +2858,11 @@ class MindDataDataset : public Dataset { /// /* Note: As we defined before, each data dictionary owns keys "data", "file_name" and "label" */ /// auto data = row["data"]; /// \endcode -inline std::shared_ptr MindData( - const std::string &dataset_file, const std::vector &columns_list = {}, - const std::shared_ptr &sampler = std::make_shared(), nlohmann::json *padded_sample = nullptr, - int64_t num_padded = 0, ShuffleMode shuffle_mode = ShuffleMode::kGlobal, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +MindData(const std::string &dataset_file, const std::vector &columns_list = {}, + const std::shared_ptr &sampler = std::make_shared(), + nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0, + ShuffleMode shuffle_mode = ShuffleMode::kGlobal, const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_file), VectorStringToChar(columns_list), sampler, padded_sample, num_padded, shuffle_mode, cache); } @@ -2879,11 +2883,12 @@ inline std::shared_ptr MindData( /// ShuffleMode::kInfile - Shuffle samples in file. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the MindDataDataset. -inline std::shared_ptr MindData(const std::string &dataset_file, - const std::vector &columns_list, const Sampler *sampler, - nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0, - ShuffleMode shuffle_mode = ShuffleMode::kGlobal, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API MindData(const std::string &dataset_file, + const std::vector &columns_list, + const Sampler *sampler, nlohmann::json *padded_sample = nullptr, + int64_t num_padded = 0, + ShuffleMode shuffle_mode = ShuffleMode::kGlobal, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_file), VectorStringToChar(columns_list), sampler, padded_sample, num_padded, shuffle_mode, cache); } @@ -2903,12 +2908,12 @@ inline std::shared_ptr MindData(const std::string &dataset_file /// ShuffleMode::kInfile - Shuffle samples in file. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the MindDataDataset. -inline std::shared_ptr MindData(const std::string &dataset_file, - const std::vector &columns_list, - const std::reference_wrapper sampler, - nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0, - ShuffleMode shuffle_mode = ShuffleMode::kGlobal, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API MindData(const std::string &dataset_file, + const std::vector &columns_list, + const std::reference_wrapper sampler, + nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0, + ShuffleMode shuffle_mode = ShuffleMode::kGlobal, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_file), VectorStringToChar(columns_list), sampler, padded_sample, num_padded, shuffle_mode, cache); } @@ -2946,11 +2951,11 @@ inline std::shared_ptr MindData(const std::string &dataset_file /// /* Note: As we defined before, each data dictionary owns keys "data", "file_name" and "label" */ /// auto data = row["data"]; /// \endcode -inline std::shared_ptr MindData( - const std::vector &dataset_files, const std::vector &columns_list = {}, - const std::shared_ptr &sampler = std::make_shared(), nlohmann::json *padded_sample = nullptr, - int64_t num_padded = 0, ShuffleMode shuffle_mode = ShuffleMode::kGlobal, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +MindData(const std::vector &dataset_files, const std::vector &columns_list = {}, + const std::shared_ptr &sampler = std::make_shared(), + nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0, + ShuffleMode shuffle_mode = ShuffleMode::kGlobal, const std::shared_ptr &cache = nullptr) { return std::make_shared(VectorStringToChar(dataset_files), VectorStringToChar(columns_list), sampler, padded_sample, num_padded, shuffle_mode, cache); } @@ -2970,11 +2975,12 @@ inline std::shared_ptr MindData( /// ShuffleMode::kInfile - Shuffle data within each file. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the MindDataDataset. -inline std::shared_ptr MindData(const std::vector &dataset_files, - const std::vector &columns_list, const Sampler *sampler, - nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0, - ShuffleMode shuffle_mode = ShuffleMode::kGlobal, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API MindData(const std::vector &dataset_files, + const std::vector &columns_list, + const Sampler *sampler, nlohmann::json *padded_sample = nullptr, + int64_t num_padded = 0, + ShuffleMode shuffle_mode = ShuffleMode::kGlobal, + const std::shared_ptr &cache = nullptr) { return std::make_shared(VectorStringToChar(dataset_files), VectorStringToChar(columns_list), sampler, padded_sample, num_padded, shuffle_mode, cache); } @@ -2994,19 +3000,19 @@ inline std::shared_ptr MindData(const std::vector /// ShuffleMode::kInfile - Shuffle samples in file. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the MindDataDataset. -inline std::shared_ptr MindData(const std::vector &dataset_files, - const std::vector &columns_list, - const std::reference_wrapper sampler, - nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0, - ShuffleMode shuffle_mode = ShuffleMode::kGlobal, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API MindData(const std::vector &dataset_files, + const std::vector &columns_list, + const std::reference_wrapper sampler, + nlohmann::json *padded_sample = nullptr, int64_t num_padded = 0, + ShuffleMode shuffle_mode = ShuffleMode::kGlobal, + const std::shared_ptr &cache = nullptr) { return std::make_shared(VectorStringToChar(dataset_files), VectorStringToChar(columns_list), sampler, padded_sample, num_padded, shuffle_mode, cache); } /// \class MnistDataset /// \brief A source dataset for reading and parsing MNIST dataset. -class MnistDataset : public Dataset { +class MS_API MnistDataset : public Dataset { public: /// \brief Constructor of MnistDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -3059,9 +3065,10 @@ class MnistDataset : public Dataset { /// /* Note: In MNIST dataset, each dictionary has keys "image" and "label" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr Mnist(const std::string &dataset_dir, const std::string &usage = "all", - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +Mnist(const std::string &dataset_dir, const std::string &usage = "all", + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } @@ -3072,9 +3079,9 @@ inline std::shared_ptr Mnist(const std::string &dataset_dir, const /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the MnistDataset. -inline std::shared_ptr Mnist(const std::string &dataset_dir, const std::string &usage, - const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Mnist(const std::string &dataset_dir, const std::string &usage, + const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } @@ -3085,15 +3092,15 @@ inline std::shared_ptr Mnist(const std::string &dataset_dir, const /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the MnistDataset. -inline std::shared_ptr Mnist(const std::string &dataset_dir, const std::string &usage, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Mnist(const std::string &dataset_dir, const std::string &usage, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } /// \class PhotoTourDataset /// \brief A source dataset for reading and parsing PhotoTour dataset. -class PhotoTourDataset : public Dataset { +class MS_API PhotoTourDataset : public Dataset { public: /// \brief Constructor of PhotoTourDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -3143,10 +3150,10 @@ class PhotoTourDataset : public Dataset { /// be used to randomly iterate the entire dataset (default = RandomSampler()). /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the current PhotoTourDataset. -inline std::shared_ptr PhotoTour( - const std::string &dataset_dir, const std::string &name, const std::string &usage = "train", - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +PhotoTour(const std::string &dataset_dir, const std::string &name, const std::string &usage = "train", + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(name), StringToChar(usage), sampler, cache); } @@ -3161,9 +3168,9 @@ inline std::shared_ptr PhotoTour( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the current PhotoTourDataset. -inline std::shared_ptr PhotoTour(const std::string &dataset_dir, const std::string &name, - const std::string &usage, const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API PhotoTour(const std::string &dataset_dir, const std::string &name, + const std::string &usage, const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(name), StringToChar(usage), sampler, cache); } @@ -3178,17 +3185,17 @@ inline std::shared_ptr PhotoTour(const std::string &dataset_di /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the current PhotoTourDataset. -inline std::shared_ptr PhotoTour(const std::string &dataset_dir, const std::string &name, - const std::string &usage, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API PhotoTour(const std::string &dataset_dir, const std::string &name, + const std::string &usage, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(name), StringToChar(usage), sampler, cache); } /// \class Places365Dataset /// \brief A source dataset that reads and parses Places365 dataset. -class Places365Dataset : public Dataset { +class MS_API Places365Dataset : public Dataset { public: /// \brief Constructor of Places365Dataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -3237,10 +3244,10 @@ class Places365Dataset : public Dataset { /// be used to randomly iterate the entire dataset (default = RandomSampler()). /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current Places365Dataset. -inline std::shared_ptr Places365( - const std::string &dataset_dir, const std::string &usage = "train-standard", const bool small = false, - const bool decode = true, const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +Places365(const std::string &dataset_dir, const std::string &usage = "train-standard", const bool small = false, + const bool decode = true, const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), small, decode, sampler, cache); } @@ -3254,9 +3261,9 @@ inline std::shared_ptr Places365( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current Places365Dataset. -inline std::shared_ptr Places365(const std::string &dataset_dir, const std::string &usage, - const bool small, const bool decode, const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Places365(const std::string &dataset_dir, const std::string &usage, + const bool small, const bool decode, const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), small, decode, sampler, cache); } @@ -3270,17 +3277,17 @@ inline std::shared_ptr Places365(const std::string &dataset_di /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current Places365Dataset. -inline std::shared_ptr Places365(const std::string &dataset_dir, const std::string &usage, - const bool small, const bool decode, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Places365(const std::string &dataset_dir, const std::string &usage, + const bool small, const bool decode, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), small, decode, sampler, cache); } /// \class QMnistDataset /// \brief A source dataset that reads and parses QMNIST dataset. -class QMnistDataset : public Dataset { +class MS_API QMnistDataset : public Dataset { public: /// \brief Constructor of QMnistDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -3341,10 +3348,10 @@ class QMnistDataset : public Dataset { /// /* Note: In QMNIST dataset, each dictionary has keys "image" and "label" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr QMnist( - const std::string &dataset_dir, const std::string &usage = "all", bool compat = true, - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +QMnist(const std::string &dataset_dir, const std::string &usage = "all", bool compat = true, + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), compat, sampler, cache); } @@ -3356,9 +3363,9 @@ inline std::shared_ptr QMnist( /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the QMnistDataset. -inline std::shared_ptr QMnist(const std::string &dataset_dir, const std::string &usage, bool compat, - const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API QMnist(const std::string &dataset_dir, const std::string &usage, + bool compat, const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), compat, sampler, cache); } @@ -3370,9 +3377,9 @@ inline std::shared_ptr QMnist(const std::string &dataset_dir, con /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the QMnistDataset. -inline std::shared_ptr QMnist(const std::string &dataset_dir, const std::string &usage, bool compat, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API QMnist(const std::string &dataset_dir, const std::string &usage, + bool compat, const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), compat, sampler, cache); } @@ -3381,14 +3388,14 @@ inline std::shared_ptr QMnist(const std::string &dataset_dir, con /// \param[in] datasets1 Shared pointer to the first dataset to be concatenated. /// \param[in] datasets2 Shared pointer to the second dataset to be concatenated. /// \return Shared pointer to the current Dataset. -inline std::shared_ptr operator+(const std::shared_ptr &datasets1, - const std::shared_ptr &datasets2) { +inline std::shared_ptr MS_API operator+(const std::shared_ptr &datasets1, + const std::shared_ptr &datasets2) { return std::make_shared(std::vector({datasets1, datasets2})); } /// \class RandomDataDataset /// \brief A source dataset that generates random data. -class RandomDataDataset : public Dataset { +class MS_API RandomDataDataset : public Dataset { public: /// \brief Constructor of RandomDataDataset. /// \param[in] total_rows Number of rows for the dataset to generate (default=0, number of rows is random). @@ -3433,9 +3440,9 @@ class RandomDataDataset : public Dataset { /// auto column1 = row["column1"]; /// \endcode template > -std::shared_ptr RandomData(const int32_t &total_rows = 0, const T &schema = nullptr, - const std::vector &columns_list = {}, - const std::shared_ptr &cache = nullptr) { +std::shared_ptr MS_API RandomData(const int32_t &total_rows = 0, const T &schema = nullptr, + const std::vector &columns_list = {}, + const std::shared_ptr &cache = nullptr) { std::shared_ptr ds; if constexpr (std::is_same::value || std::is_same>::value) { std::shared_ptr schema_obj = schema; @@ -3449,7 +3456,7 @@ std::shared_ptr RandomData(const int32_t &total_rows = 0, con /// \class SBUDataset /// \brief A source dataset that reads and parses SBU dataset. -class SBUDataset : public Dataset { +class MS_API SBUDataset : public Dataset { public: /// \brief Constructor of SBUDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -3502,9 +3509,10 @@ class SBUDataset : public Dataset { /// /* Note: In SBU dataset, each dictionary has keys "image" and "caption" */ /// auto caption = row["caption"]; /// \endcode -inline std::shared_ptr SBU(const std::string &dataset_dir, bool decode = false, - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +SBU(const std::string &dataset_dir, bool decode = false, + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), decode, sampler, cache); } @@ -3515,8 +3523,8 @@ inline std::shared_ptr SBU(const std::string &dataset_dir, bool deco /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the current SBUDataset. -inline std::shared_ptr SBU(const std::string &dataset_dir, bool decode, const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API SBU(const std::string &dataset_dir, bool decode, const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), decode, sampler, cache); } @@ -3527,15 +3535,15 @@ inline std::shared_ptr SBU(const std::string &dataset_dir, bool deco /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \return Shared pointer to the current SBUDataset. -inline std::shared_ptr SBU(const std::string &dataset_dir, bool decode, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API SBU(const std::string &dataset_dir, bool decode, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), decode, sampler, cache); } /// \class TextFileDataset /// \brief A source dataset that reads and parses datasets stored on disk in text format. -class TextFileDataset : public Dataset { +class MS_API TextFileDataset : public Dataset { public: /// \brief Constructor of TextFileDataset. /// \param[in] dataset_files List of files to be read to search for a pattern of files. The list @@ -3588,17 +3596,18 @@ class TextFileDataset : public Dataset { /// /* Note: In TextFile dataset, each dictionary has key "text" */ /// auto text = row["text"]; /// \endcode -inline std::shared_ptr TextFile(const std::vector &dataset_files, int64_t num_samples = 0, - ShuffleMode shuffle = ShuffleMode::kGlobal, int32_t num_shards = 1, - int32_t shard_id = 0, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API TextFile(const std::vector &dataset_files, + int64_t num_samples = 0, + ShuffleMode shuffle = ShuffleMode::kGlobal, + int32_t num_shards = 1, int32_t shard_id = 0, + const std::shared_ptr &cache = nullptr) { return std::make_shared(VectorStringToChar(dataset_files), num_samples, shuffle, num_shards, shard_id, cache); } /// \class TFRecordDataset /// \brief A source dataset for reading and parsing datasets stored on disk in TFData format. -class TFRecordDataset : public Dataset { +class MS_API TFRecordDataset : public Dataset { public: /// \brief Constructor of TFRecordDataset. /// \param[in] dataset_files List of files to be read to search for a pattern of files. The list @@ -3694,11 +3703,13 @@ class TFRecordDataset : public Dataset { /// auto image = row["image"]; /// \endcode template > -std::shared_ptr TFRecord(const std::vector &dataset_files, const T &schema = nullptr, - const std::vector &columns_list = {}, int64_t num_samples = 0, - ShuffleMode shuffle = ShuffleMode::kGlobal, int32_t num_shards = 1, - int32_t shard_id = 0, bool shard_equal_rows = false, - const std::shared_ptr &cache = nullptr) { +std::shared_ptr MS_API TFRecord(const std::vector &dataset_files, + const T &schema = nullptr, + const std::vector &columns_list = {}, + int64_t num_samples = 0, ShuffleMode shuffle = ShuffleMode::kGlobal, + int32_t num_shards = 1, int32_t shard_id = 0, + bool shard_equal_rows = false, + const std::shared_ptr &cache = nullptr) { std::shared_ptr ds = nullptr; if constexpr (std::is_same::value || std::is_same>::value) { std::shared_ptr schema_obj = schema; @@ -3723,7 +3734,7 @@ std::shared_ptr TFRecord(const std::vector &datase /// \class USPSDataset /// \brief A source dataset that reads and parses USPS datasets. -class USPSDataset : public Dataset { +class MS_API USPSDataset : public Dataset { public: /// \brief Constructor of USPSDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -3775,17 +3786,17 @@ class USPSDataset : public Dataset { /// /* Note: In USPS dataset, each dictionary has keys "image" and "label" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr USPS(const std::string &dataset_dir, const std::string &usage = "all", - int64_t num_samples = 0, ShuffleMode shuffle = ShuffleMode::kGlobal, - int32_t num_shards = 1, int32_t shard_id = 0, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API USPS(const std::string &dataset_dir, const std::string &usage = "all", + int64_t num_samples = 0, ShuffleMode shuffle = ShuffleMode::kGlobal, + int32_t num_shards = 1, int32_t shard_id = 0, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), num_samples, shuffle, num_shards, shard_id, cache); } /// \class VOCDataset /// \brief A source dataset for reading and parsing VOC dataset. -class VOCDataset : public Dataset { +class MS_API VOCDataset : public Dataset { public: /// \brief Constructor of VOCDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -3863,12 +3874,11 @@ class VOCDataset : public Dataset { /// /* Note: In VOC dataset, if task='Detection', each dictionary has keys "image" and "annotation" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr VOC(const std::string &dataset_dir, const std::string &task = "Segmentation", - const std::string &usage = "train", - const std::map &class_indexing = {}, bool decode = false, - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr, - bool extra_metadata = false) { +inline std::shared_ptr MS_API +VOC(const std::string &dataset_dir, const std::string &task = "Segmentation", const std::string &usage = "train", + const std::map &class_indexing = {}, bool decode = false, + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr, bool extra_metadata = false) { return std::make_shared(StringToChar(dataset_dir), StringToChar(task), StringToChar(usage), MapStringToChar(class_indexing), decode, sampler, cache, extra_metadata); } @@ -3887,11 +3897,12 @@ inline std::shared_ptr VOC(const std::string &dataset_dir, const std /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \param[in] extra_metadata Flag to add extra meta-data to row (default=false). /// \return Shared pointer to the VOCDataset. -inline std::shared_ptr VOC(const std::string &dataset_dir, const std::string &task, - const std::string &usage, const std::map &class_indexing, - bool decode, const Sampler *sampler, - const std::shared_ptr &cache = nullptr, - bool extra_metadata = false) { +inline std::shared_ptr MS_API VOC(const std::string &dataset_dir, const std::string &task, + const std::string &usage, + const std::map &class_indexing, bool decode, + const Sampler *sampler, + const std::shared_ptr &cache = nullptr, + bool extra_metadata = false) { return std::make_shared(StringToChar(dataset_dir), StringToChar(task), StringToChar(usage), MapStringToChar(class_indexing), decode, sampler, cache, extra_metadata); } @@ -3910,18 +3921,19 @@ inline std::shared_ptr VOC(const std::string &dataset_dir, const std /// \param[in] cache Tensor cache to use (default=nullptr which means no cache is used). /// \param[in] extra_metadata Flag to add extra meta-data to row (default=false). /// \return Shared pointer to the VOCDataset. -inline std::shared_ptr VOC(const std::string &dataset_dir, const std::string &task, - const std::string &usage, const std::map &class_indexing, - bool decode, const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr, - bool extra_metadata = false) { +inline std::shared_ptr MS_API VOC(const std::string &dataset_dir, const std::string &task, + const std::string &usage, + const std::map &class_indexing, bool decode, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr, + bool extra_metadata = false) { return std::make_shared(StringToChar(dataset_dir), StringToChar(task), StringToChar(usage), MapStringToChar(class_indexing), decode, sampler, cache, extra_metadata); } /// \class YesNoDataset. /// \brief A source dataset for reading and parsing YesNo dataset. -class YesNoDataset : public Dataset { +class MS_API YesNoDataset : public Dataset { public: /// \brief Constructor of YesNoDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -3956,9 +3968,9 @@ class YesNoDataset : public Dataset { /// given, a `RandomSampler` will be used to randomly iterate the entire dataset (default = RandomSampler()). /// \param[in] cache Tensor cache to use (default=nullptr, which means no cache is used). /// \return Shared pointer to the current Dataset. -inline std::shared_ptr YesNo(const std::string &dataset_dir, - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +YesNo(const std::string &dataset_dir, const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), sampler, cache); } @@ -3968,8 +3980,8 @@ inline std::shared_ptr YesNo(const std::string &dataset_dir, /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr, which means no cache is used). /// \return Shared pointer to the current Dataset. -inline std::shared_ptr YesNo(const std::string &dataset_dir, Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API YesNo(const std::string &dataset_dir, Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), sampler, cache); } @@ -3979,9 +3991,9 @@ inline std::shared_ptr YesNo(const std::string &dataset_dir, Sampl /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use (default=nullptr, which means no cache is used). /// \return Shared pointer to the current Dataset. -inline std::shared_ptr YesNo(const std::string &dataset_dir, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API YesNo(const std::string &dataset_dir, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), sampler, cache); } @@ -3997,11 +4009,11 @@ inline std::shared_ptr YesNo(const std::string &dataset_dir, /// \param[in] num_connections optional number of connections (default=12). /// \param[in] prefetch_sz optional prefetch size (default=20). /// \return Shared pointer to DatasetCache. If error, nullptr is returned. -std::shared_ptr CreateDatasetCacheCharIF(session_id_type id, uint64_t mem_sz, bool spill, - std::optional> hostname = std::nullopt, - std::optional port = std::nullopt, - std::optional num_connections = std::nullopt, - std::optional prefetch_sz = std::nullopt); +std::shared_ptr MS_API CreateDatasetCacheCharIF(session_id_type id, uint64_t mem_sz, bool spill, + std::optional> hostname = std::nullopt, + std::optional port = std::nullopt, + std::optional num_connections = std::nullopt, + std::optional prefetch_sz = std::nullopt); /// \brief Function the create a cache to be attached to a dataset. /// \param[in] id A user assigned session id for the current pipeline. @@ -4025,11 +4037,11 @@ std::shared_ptr CreateDatasetCacheCharIF(session_id_type id, uint6 /// /* Create iterator to read dataset */ /// std::shared_ptr iter = ds->CreateIterator(); /// \endcode -inline std::shared_ptr CreateDatasetCache(session_id_type id, uint64_t mem_sz, bool spill, - std::optional hostname = std::nullopt, - std::optional port = std::nullopt, - std::optional num_connections = std::nullopt, - std::optional prefetch_sz = std::nullopt) { +inline std::shared_ptr MS_API CreateDatasetCache(session_id_type id, uint64_t mem_sz, bool spill, + std::optional hostname = std::nullopt, + std::optional port = std::nullopt, + std::optional num_connections = std::nullopt, + std::optional prefetch_sz = std::nullopt) { std::optional> hostname_c = std::nullopt; if (hostname != std::nullopt) { hostname_c = std::vector(hostname->begin(), hostname->end()); @@ -4041,7 +4053,7 @@ inline std::shared_ptr CreateDatasetCache(session_id_type id, uint /// \note Applies zip to the dataset. /// \param[in] datasets List of shared pointers to the datasets that we want to zip. /// \return Shared pointer to the ZipDataset. -inline std::shared_ptr Zip(const std::vector> &datasets) { +inline std::shared_ptr MS_API Zip(const std::vector> &datasets) { return std::make_shared(datasets); } } // namespace dataset diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h b/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h index 74a59a3f8b5..8adc9dfab80 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/execute.h @@ -30,7 +30,7 @@ namespace mindspore { namespace dataset { class DeviceResource; // class to run tensor operations in eager mode -class Execute { +class MS_API Execute { public: /// \brief Constructor. /// \param[in] op TensorOperation to be applied in Eager mode, it accepts operation in type of shared pointer. diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/iterator.h b/mindspore/ccsrc/minddata/dataset/include/dataset/iterator.h index d9aa4ab95da..b08e291c2b3 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/iterator.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/iterator.h @@ -45,7 +45,7 @@ using MSTensorMapChar = std::map, mindspore::MSTensor>; using MSTensorVec = std::vector; // Abstract class for iterating over the dataset. -class Iterator { +class MS_API Iterator { public: /// \brief Constructor. Iterator(); @@ -146,7 +146,7 @@ class Iterator { IteratorConsumer *consumer_; }; -class PullIterator : public Iterator { +class MS_API PullIterator : public Iterator { public: /// \brief Constructor. PullIterator(); diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/samplers.h b/mindspore/ccsrc/minddata/dataset/include/dataset/samplers.h index 9a13e30375b..d80abb005ef 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/samplers.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/samplers.h @@ -20,6 +20,8 @@ #include #include +#include "include/api/types.h" + namespace mindspore { namespace dataset { @@ -29,7 +31,7 @@ class SamplerObj; // Abstract class to represent a sampler in the data pipeline. /// \class Sampler samplers.h /// \brief An abstract base class to represent a sampler in the data pipeline. -class Sampler : std::enable_shared_from_this { +class MS_API Sampler : std::enable_shared_from_this { friend class AlbumDataset; friend class CelebADataset; friend class Cifar10Dataset; @@ -81,7 +83,7 @@ class Sampler : std::enable_shared_from_this { /// \brief A class to represent a Distributed Sampler in the data pipeline. /// \note A Sampler that accesses a shard of the dataset. -class DistributedSampler final : public Sampler { +class MS_API DistributedSampler final : public Sampler { friend std::shared_ptr SelectSampler(int64_t, bool, int32_t, int32_t); public: @@ -123,7 +125,7 @@ class DistributedSampler final : public Sampler { /// \brief A class to represent a PK Sampler in the data pipeline. /// \note Samples K elements for each P class in the dataset. /// This will sample all classes. -class PKSampler final : public Sampler { +class MS_API PKSampler final : public Sampler { friend std::shared_ptr SelectSampler(int64_t, bool, int32_t, int32_t); public: @@ -155,7 +157,7 @@ class PKSampler final : public Sampler { /// \brief A class to represent a Random Sampler in the data pipeline. /// \note Samples the elements randomly. -class RandomSampler final : public Sampler { +class MS_API RandomSampler final : public Sampler { friend std::shared_ptr SelectSampler(int64_t, bool, int32_t, int32_t); public: @@ -185,7 +187,7 @@ class RandomSampler final : public Sampler { /// \brief A class to represent a Sequential Sampler in the data pipeline. /// \note Samples the dataset elements sequentially, same as not having a sampler. -class SequentialSampler final : public Sampler { +class MS_API SequentialSampler final : public Sampler { friend std::shared_ptr SelectSampler(int64_t, bool, int32_t, int32_t); public: @@ -215,7 +217,7 @@ class SequentialSampler final : public Sampler { /// \brief A class to represent a Subset Sampler in the data pipeline. /// \note Samples the elements from a sequence of indices. -class SubsetSampler : public Sampler { +class MS_API SubsetSampler : public Sampler { friend std::shared_ptr SelectSampler(int64_t, bool, int32_t, int32_t); public: @@ -244,7 +246,7 @@ class SubsetSampler : public Sampler { /// \brief A class to represent a Subset Random Sampler in the data pipeline. /// \note Samples the elements randomly from a sequence of indices. -class SubsetRandomSampler final : public SubsetSampler { +class MS_API SubsetRandomSampler final : public SubsetSampler { friend std::shared_ptr SelectSampler(int64_t, bool, int32_t, int32_t); public: @@ -271,7 +273,7 @@ class SubsetRandomSampler final : public SubsetSampler { /// \brief A class to represent a Weighted Random Sampler in the data pipeline. /// \note Samples the elements from [0, len(weights) - 1] randomly with the given /// weights (probabilities). -class WeightedRandomSampler final : public Sampler { +class MS_API WeightedRandomSampler final : public Sampler { friend std::shared_ptr SelectSampler(int64_t, bool, int32_t, int32_t); public: diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/text.h b/mindspore/ccsrc/minddata/dataset/include/dataset/text.h index a84e66c6fbb..baea18563c1 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/text.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/text.h @@ -41,7 +41,7 @@ namespace text { #ifndef _WIN32 /// \brief Tokenize a scalar tensor of UTF-8 string by specific rules. /// \note BasicTokenizer is not supported on the Windows platform yet. -class BasicTokenizer final : public TensorTransform { +class MS_API BasicTokenizer final : public TensorTransform { public: /// \brief Constructor. /// \param[in] lower_case If true, apply CaseFold, NormalizeUTF8 (NFD mode) and RegexReplace operations to @@ -81,7 +81,7 @@ class BasicTokenizer final : public TensorTransform { /// \brief A tokenizer used for Bert text process. /// \note BertTokenizer is not supported on the Windows platform yet. -class BertTokenizer final : public TensorTransform { +class MS_API BertTokenizer final : public TensorTransform { public: /// \brief Constructor. /// \param[in] vocab A Vocab object. @@ -153,7 +153,7 @@ class BertTokenizer final : public TensorTransform { }; /// \brief Apply case fold operation on UTF-8 string tensors. -class CaseFold final : public TensorTransform { +class MS_API CaseFold final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -179,7 +179,7 @@ class CaseFold final : public TensorTransform { /// \brief Tokenize a Chinese string into words based on the dictionary. /// \note The integrity of the HMMSegment algorithm and MPSegment algorithm files must be confirmed. -class JiebaTokenizer final : public TensorTransform { +class MS_API JiebaTokenizer final : public TensorTransform { public: /// \brief Constructor. /// \param[in] hmm_path Dictionary file is used by the HMMSegment algorithm. The dictionary can be obtained on the @@ -291,7 +291,7 @@ class JiebaTokenizer final : public TensorTransform { }; /// \brief Look up a word into an id according to the input vocabulary table. -class Lookup final : public TensorTransform { +class MS_API Lookup final : public TensorTransform { public: /// \brief Constructor. /// \param[in] vocab a Vocab object. @@ -345,7 +345,7 @@ class Lookup final : public TensorTransform { }; /// \brief Generate n-gram from a 1-D string Tensor. -class Ngram final : public TensorTransform { +class MS_API Ngram final : public TensorTransform { public: /// \brief Constructor. /// \param[in] ngrams ngrams is a vector of positive integers. For example, if ngrams={4, 3}, then the result @@ -396,7 +396,7 @@ class Ngram final : public TensorTransform { #ifndef _WIN32 /// \brief Apply normalize operation to UTF-8 string tensors. -class NormalizeUTF8 final : public TensorTransform { +class MS_API NormalizeUTF8 final : public TensorTransform { public: /// \brief Constructor. /// \param[in] normalize_form Valid values can be any of [NormalizeForm::kNone,NormalizeForm::kNfc, @@ -432,7 +432,7 @@ class NormalizeUTF8 final : public TensorTransform { }; /// \brief Replace a UTF-8 string tensor with 'replace' according to regular expression 'pattern'. -class RegexReplace final : public TensorTransform { +class MS_API RegexReplace final : public TensorTransform { public: /// \brief Constructor. /// \param[in] pattern The regex expression patterns. @@ -472,7 +472,7 @@ class RegexReplace final : public TensorTransform { }; /// \brief Tokenize a scalar tensor of UTF-8 string by the regex expression pattern. -class RegexTokenizer final : public TensorTransform { +class MS_API RegexTokenizer final : public TensorTransform { public: /// \brief Constructor. /// \param[in] delim_pattern The pattern of regex delimiters. @@ -510,7 +510,7 @@ class RegexTokenizer final : public TensorTransform { #endif /// \brief Tokenize a scalar token or a 1-D token to tokens by sentencepiece. -class SentencePieceTokenizer final : public TensorTransform { +class MS_API SentencePieceTokenizer final : public TensorTransform { public: /// \brief Constructor. /// \param[in] vocab a SentencePieceVocab object. @@ -566,7 +566,7 @@ class SentencePieceTokenizer final : public TensorTransform { /// \brief Construct a tensor from data (only 1-D for now), where each element in the dimension /// axis is a slice of data starting at the corresponding position, with a specified width. -class SlidingWindow final : public TensorTransform { +class MS_API SlidingWindow final : public TensorTransform { public: /// \brief Constructor. /// \param[in] width The width of the window. It must be an integer and greater than zero. @@ -601,7 +601,7 @@ class SlidingWindow final : public TensorTransform { /// https://en.cppreference.com/w/cpp/string/basic_string/stof, /// https://en.cppreference.com/w/cpp/string/basic_string/stoul, /// except that any strings which represent negative numbers cannot be cast to an unsigned integer type. -class ToNumber final : public TensorTransform { +class MS_API ToNumber final : public TensorTransform { public: /// \brief Constructor. /// \param[in] data_type mindspore::DataType of the tensor to be cast to. Must be a numeric type, excluding bool. @@ -630,7 +630,7 @@ class ToNumber final : public TensorTransform { }; /// \brief Truncate a pair of rank-1 tensors such that the total length is less than max_length. -class TruncateSequencePair final : public TensorTransform { +class MS_API TruncateSequencePair final : public TensorTransform { public: /// \brief Constructor. /// \param[in] max_length Maximum length required. @@ -659,7 +659,7 @@ class TruncateSequencePair final : public TensorTransform { }; /// \brief Tokenize a scalar tensor of UTF-8 string to Unicode characters. -class UnicodeCharTokenizer final : public TensorTransform { +class MS_API UnicodeCharTokenizer final : public TensorTransform { public: /// \brief Constructor. /// \param[in] with_offsets whether to output offsets of tokens (default=false). @@ -688,7 +688,7 @@ class UnicodeCharTokenizer final : public TensorTransform { }; /// \brief Tokenize scalar token or 1-D tokens to 1-D sub-word tokens. -class WordpieceTokenizer final : public TensorTransform { +class MS_API WordpieceTokenizer final : public TensorTransform { public: /// \brief Constructor. /// \param[in] vocab A Vocab object. @@ -734,7 +734,7 @@ class WordpieceTokenizer final : public TensorTransform { #ifndef _WIN32 /// \brief Tokenize a scalar tensor of UTF-8 string on Unicode script boundaries. -class UnicodeScriptTokenizer final : public TensorTransform { +class MS_API UnicodeScriptTokenizer final : public TensorTransform { public: /// \brief Constructor. /// \param[in] keep_whitespace whether to emit whitespace tokens (default=false). @@ -764,7 +764,7 @@ class UnicodeScriptTokenizer final : public TensorTransform { }; /// \brief Tokenize a scalar tensor of UTF-8 string on ICU4C defined whitespaces. -class WhitespaceTokenizer final : public TensorTransform { +class MS_API WhitespaceTokenizer final : public TensorTransform { public: /// \brief Constructor. /// \param[in] with_offsets whether to output offsets of tokens (default=false). diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h b/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h index b1f365341c6..3fcaddeb036 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/transforms.h @@ -48,7 +48,7 @@ class UniformAugment; // Abstract class to represent a tensor transform operation in the data pipeline. /// \class TensorTransform transforms.h /// \brief A base class to represent a tensor transform operation in the data pipeline. -class TensorTransform : public std::enable_shared_from_this { +class MS_API TensorTransform : public std::enable_shared_from_this { friend class Dataset; friend class Execute; friend class transforms::Compose; @@ -77,7 +77,7 @@ class TensorTransform : public std::enable_shared_from_this { }; /// \brief Slice object used in SliceOption. -class Slice { +class MS_API Slice { public: /// \brief Constructor, with start, stop and step default to 0. Slice() : start_(0), stop_(0), step_(0) {} @@ -104,7 +104,7 @@ class Slice { }; /// \brief SliceOption used in Slice TensorTransform. -class SliceOption { +class MS_API SliceOption { public: /// \param[in] all Slice the whole dimension explicit SliceOption(bool all) : all_(all) {} @@ -128,7 +128,7 @@ class SliceOption { namespace transforms { /// \brief Compose a list of transforms into a single transform. -class Compose final : public TensorTransform { +class MS_API Compose final : public TensorTransform { public: /// \brief Constructor. /// \param[in] transforms A vector of raw pointers to TensorTransform objects to be applied. @@ -191,7 +191,7 @@ class Compose final : public TensorTransform { }; /// \brief Concatenate all tensors into a single tensor. -class Concatenate final : public TensorTransform { +class MS_API Concatenate final : public TensorTransform { public: /// \brief Constructor. /// \param[in] axis Concatenate the tensors along given axis, only support 0 or -1 so far (default=0). @@ -225,7 +225,7 @@ class Concatenate final : public TensorTransform { /// \brief Duplicate the input tensor to a new output tensor. /// The input tensor is carried over to the output list. -class Duplicate final : public TensorTransform { +class MS_API Duplicate final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -251,7 +251,7 @@ class Duplicate final : public TensorTransform { /// \brief Fill all elements in the tensor with the specified value. /// The output tensor will have the same shape and type as the input tensor. -class Fill final : public TensorTransform { +class MS_API Fill final : public TensorTransform { public: /// \brief Constructor. /// \param[in] fill_value Scalar value to fill the tensor with. @@ -284,7 +284,7 @@ class Fill final : public TensorTransform { /// \brief Mask content of the input tensor with the given predicate. /// Any element of the tensor that matches the predicate will be evaluated to True, otherwise False. -class Mask final : public TensorTransform { +class MS_API Mask final : public TensorTransform { public: /// \brief Constructor. /// \param[in] op One of the relational operators: EQ, NE LT, GT, LE or GE. @@ -319,7 +319,7 @@ class Mask final : public TensorTransform { }; /// \brief Convert the labels into OneHot format. -class OneHot final : public TensorTransform { +class MS_API OneHot final : public TensorTransform { public: /// \brief Constructor. /// \param[in] num_classes number of classes. @@ -349,7 +349,7 @@ class OneHot final : public TensorTransform { }; /// \brief Pad input tensor according to pad_shape -class PadEnd final : public TensorTransform { +class MS_API PadEnd final : public TensorTransform { public: /// \brief Constructor. /// \param[in] pad_shape List of integers representing the shape needed, need to have same rank with input tensor. @@ -382,7 +382,7 @@ class PadEnd final : public TensorTransform { }; /// \brief Randomly perform a series of transforms with a given probability. -class RandomApply final : public TensorTransform { +class MS_API RandomApply final : public TensorTransform { public: /// \brief Constructor. /// \param[in] transforms A vector of raw pointers to TensorTransform objects to be applied. @@ -448,7 +448,7 @@ class RandomApply final : public TensorTransform { }; /// \brief Randomly select one transform from a list of transforms to perform on the input tensor. -class RandomChoice final : public TensorTransform { +class MS_API RandomChoice final : public TensorTransform { public: /// \brief Constructor. /// \param[in] transforms A vector of raw pointers to TensorTransform objects to be applied. @@ -513,7 +513,7 @@ class RandomChoice final : public TensorTransform { /// \brief Extract a tensor out using the given n slices. /// The functionality of Slice is similar to the feature of indexing of NumPy. /// (Currently only rank-1 tensors are supported). -class Slice final : public TensorTransform { +class MS_API Slice final : public TensorTransform { public: /// \brief Constructor. /// \param[in] slice_input Vector of SliceOption. @@ -543,7 +543,7 @@ class Slice final : public TensorTransform { }; /// \brief Cast the MindSpore data type of a tensor to another. -class TypeCast final : public TensorTransform { +class MS_API TypeCast final : public TensorTransform { public: /// \brief Constructor. /// \param[in] data_type mindspore::DataType to be cast to. @@ -573,7 +573,7 @@ class TypeCast final : public TensorTransform { /// \brief Return an output tensor that contains all the unique elements of the input tensor in /// the same order as they appear in the input tensor. -class Unique final : public TensorTransform { +class MS_API Unique final : public TensorTransform { public: /// \brief Constructor. /// \par Example diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h b/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h index 1d18943c17f..f00921e38ee 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/vision.h @@ -39,7 +39,7 @@ namespace vision { /// \brief AdjustGamma TensorTransform. /// \note Apply gamma correction on input image. -class AdjustGamma final : public TensorTransform { +class MS_API AdjustGamma final : public TensorTransform { public: /// \brief Constructor. /// \param[in] gamma Non negative real number, which makes the output image pixel value @@ -71,7 +71,7 @@ class AdjustGamma final : public TensorTransform { }; /// \brief Apply AutoAugment data augmentation method. -class AutoAugment final : public TensorTransform { +class MS_API AutoAugment final : public TensorTransform { public: /// \brief Constructor. /// \param[in] policy An enum for the data auto augmentation policy (default=AutoAugmentPolicy::kImageNet). @@ -111,7 +111,7 @@ class AutoAugment final : public TensorTransform { }; /// \brief Apply automatic contrast on the input image. -class AutoContrast final : public TensorTransform { +class MS_API AutoContrast final : public TensorTransform { public: /// \brief Constructor. /// \param[in] cutoff Percent of pixels to cut off from the histogram, the valid range of cutoff value is 0 to 50. @@ -143,7 +143,7 @@ class AutoContrast final : public TensorTransform { /// \brief BoundingBoxAugment TensorTransform. /// \note Apply a given image transform on a random selection of bounding box regions of a given image. -class BoundingBoxAugment final : public TensorTransform { +class MS_API BoundingBoxAugment final : public TensorTransform { public: /// \brief Constructor. /// \param[in] transform Raw pointer to the TensorTransform operation. @@ -204,7 +204,7 @@ class BoundingBoxAugment final : public TensorTransform { }; /// \brief Change the color space of the image. -class ConvertColor final : public TensorTransform { +class MS_API ConvertColor final : public TensorTransform { public: /// \brief Constructor. /// \param[in] convert_mode The mode of image channel conversion. @@ -232,7 +232,7 @@ class ConvertColor final : public TensorTransform { /// \brief Mask a random section of each image with the corresponding part of another randomly /// selected image in that batch. -class CutMixBatch final : public TensorTransform { +class MS_API CutMixBatch final : public TensorTransform { public: /// \brief Constructor. /// \param[in] image_batch_format The format of the batch. @@ -261,7 +261,7 @@ class CutMixBatch final : public TensorTransform { }; /// \brief Randomly cut (mask) out a given number of square patches from the input image. -class CutOut final : public TensorTransform { +class MS_API CutOut final : public TensorTransform { public: /// \brief Constructor. /// \param[in] length Integer representing the side length of each square patch. @@ -289,7 +289,7 @@ class CutOut final : public TensorTransform { }; /// \brief Apply histogram equalization on the input image. -class Equalize final : public TensorTransform { +class MS_API Equalize final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -311,7 +311,7 @@ class Equalize final : public TensorTransform { }; /// \brief Flip the input image horizontally. -class HorizontalFlip final : public TensorTransform { +class MS_API HorizontalFlip final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -333,7 +333,7 @@ class HorizontalFlip final : public TensorTransform { }; /// \brief Transpose the input image; shape (H, W, C) to shape (C, H, W). -class HWC2CHW final : public TensorTransform { +class MS_API HWC2CHW final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -355,7 +355,7 @@ class HWC2CHW final : public TensorTransform { }; /// \brief Apply invert on the input image in RGB mode. -class Invert final : public TensorTransform { +class MS_API Invert final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -378,7 +378,7 @@ class Invert final : public TensorTransform { /// \brief Apply MixUp transformation on an input batch of images and labels. The labels must be in /// one-hot format and Batch must be called before calling this function. -class MixUpBatch final : public TensorTransform { +class MS_API MixUpBatch final : public TensorTransform { public: /// \brief Constructor. /// \param[in] alpha hyperparameter of beta distribution (default = 1.0). @@ -406,7 +406,7 @@ class MixUpBatch final : public TensorTransform { /// \brief Normalize the input image with respect to mean and standard deviation and pads an extra /// channel with value zero. -class NormalizePad final : public TensorTransform { +class MS_API NormalizePad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] mean A vector of mean values for each channel, with respect to channel order. @@ -444,7 +444,7 @@ class NormalizePad final : public TensorTransform { }; /// \brief Pad the image according to padding parameters. -class Pad final : public TensorTransform { +class MS_API Pad final : public TensorTransform { public: /// \brief Constructor. /// \param[in] padding A vector representing the number of pixels to pad the image. @@ -490,7 +490,7 @@ class Pad final : public TensorTransform { }; /// \brief Automatically adjust the contrast of the image with a given probability. -class RandomAutoContrast final : public TensorTransform { +class MS_API RandomAutoContrast final : public TensorTransform { public: /// \brief Constructor. /// \param[in] cutoff Percent of the lightest and darkest pixels to be cut off from @@ -525,7 +525,7 @@ class RandomAutoContrast final : public TensorTransform { }; /// \brief Randomly adjust the sharpness of the input image with a given probability. -class RandomAdjustSharpness final : public TensorTransform { +class MS_API RandomAdjustSharpness final : public TensorTransform { public: /// \brief Constructor. /// \param[in] degree A float representing sharpness adjustment degree, which must be non negative. @@ -559,7 +559,7 @@ class RandomAdjustSharpness final : public TensorTransform { /// \brief Blend an image with its grayscale version with random weights /// t and 1 - t generated from a given range. If the range is trivial /// then the weights are determinate and t equals to the bound of the interval. -class RandomColor final : public TensorTransform { +class MS_API RandomColor final : public TensorTransform { public: /// \brief Constructor. /// \param[in] t_lb Lower bound random weights. @@ -590,7 +590,7 @@ class RandomColor final : public TensorTransform { }; /// \brief Randomly adjust the brightness, contrast, saturation, and hue of the input image. -class RandomColorAdjust final : public TensorTransform { +class MS_API RandomColorAdjust final : public TensorTransform { public: /// \brief Constructor. /// \param[in] brightness Brightness adjustment factor. Must be a vector of one or two values @@ -629,7 +629,7 @@ class RandomColorAdjust final : public TensorTransform { }; /// \brief Crop the input image at a random location. -class RandomCrop final : public TensorTransform { +class MS_API RandomCrop final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the cropped image. @@ -681,7 +681,7 @@ class RandomCrop final : public TensorTransform { }; /// \brief Equivalent to RandomResizedCrop TensorTransform, but crop the image before decoding. -class RandomCropDecodeResize final : public TensorTransform { +class MS_API RandomCropDecodeResize final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the cropped image. @@ -728,7 +728,7 @@ class RandomCropDecodeResize final : public TensorTransform { /// \brief Crop the input image at a random location and adjust bounding boxes accordingly. /// If the cropped area is out of bbox, the returned bbox will be empty. -class RandomCropWithBBox final : public TensorTransform { +class MS_API RandomCropWithBBox final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the cropped image. @@ -778,7 +778,7 @@ class RandomCropWithBBox final : public TensorTransform { }; /// \brief Randomly apply histogram equalization on the input image with a given probability. -class RandomEqualize final : public TensorTransform { +class MS_API RandomEqualize final : public TensorTransform { public: /// \brief Constructor. /// \param[in] prob A float representing the probability of equalization, which @@ -809,7 +809,7 @@ class RandomEqualize final : public TensorTransform { }; /// \brief Randomly flip the input image horizontally with a given probability. -class RandomHorizontalFlip final : public TensorTransform { +class MS_API RandomHorizontalFlip final : public TensorTransform { public: /// \brief Constructor. /// \param[in] prob A float representing the probability of flip. @@ -839,7 +839,7 @@ class RandomHorizontalFlip final : public TensorTransform { }; /// \brief Randomly flip the input image horizontally with a given probability and adjust bounding boxes accordingly. -class RandomHorizontalFlipWithBBox final : public TensorTransform { +class MS_API RandomHorizontalFlipWithBBox final : public TensorTransform { public: /// \brief Constructor. /// \param[in] prob A float representing the probability of flip. @@ -868,7 +868,7 @@ class RandomHorizontalFlipWithBBox final : public TensorTransform { }; /// \brief Randomly invert the input image with a given probability. -class RandomInvert final : public TensorTransform { +class MS_API RandomInvert final : public TensorTransform { public: /// \brief Constructor. /// \param[in] prob A float representing the probability of the image being inverted, which @@ -899,7 +899,7 @@ class RandomInvert final : public TensorTransform { }; /// \brief Add AlexNet-style PCA-based noise to an image. -class RandomLighting final : public TensorTransform { +class MS_API RandomLighting final : public TensorTransform { public: /// \brief Constructor. /// \param[in] alpha A float representing the intensity of the image (default=0.05). @@ -929,7 +929,7 @@ class RandomLighting final : public TensorTransform { }; /// \brief Reduce the number of bits for each color channel randomly. -class RandomPosterize final : public TensorTransform { +class MS_API RandomPosterize final : public TensorTransform { public: /// \brief Constructor. /// \param[in] bit_range Range of random posterize to compress image. @@ -960,7 +960,7 @@ class RandomPosterize final : public TensorTransform { }; /// \brief Resize the input image using a randomly selected interpolation mode. -class RandomResize final : public TensorTransform { +class MS_API RandomResize final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the resized image. @@ -993,7 +993,7 @@ class RandomResize final : public TensorTransform { /// \brief Resize the input image using a randomly selected interpolation mode and adjust /// bounding boxes accordingly. -class RandomResizeWithBBox final : public TensorTransform { +class MS_API RandomResizeWithBBox final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the resized image. @@ -1024,7 +1024,7 @@ class RandomResizeWithBBox final : public TensorTransform { }; /// \brief Crop the input image to a random size and aspect ratio. -class RandomResizedCrop final : public TensorTransform { +class MS_API RandomResizedCrop final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the cropped image. @@ -1072,7 +1072,7 @@ class RandomResizedCrop final : public TensorTransform { /// \brief Crop the input image to a random size and aspect ratio. /// If cropped area is out of bbox, the return bbox will be empty. -class RandomResizedCropWithBBox final : public TensorTransform { +class MS_API RandomResizedCropWithBBox final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the cropped image. @@ -1117,7 +1117,7 @@ class RandomResizedCropWithBBox final : public TensorTransform { }; /// \brief Rotate the image according to parameters. -class RandomRotation final : public TensorTransform { +class MS_API RandomRotation final : public TensorTransform { public: /// \brief Constructor. /// \param[in] degrees A float vector of size 2, representing the starting and ending degrees. @@ -1163,7 +1163,7 @@ class RandomRotation final : public TensorTransform { /// (operation, prob), where operation is a TensorTransform operation and prob is the probability that this /// operation will be applied. Once a sub-policy is selected, each operation within the sub-policy with be /// applied in sequence according to its probability. -class RandomSelectSubpolicy final : public TensorTransform { +class MS_API RandomSelectSubpolicy final : public TensorTransform { public: /// \brief Constructor. /// \param[in] policy Vector of sub-policies to choose from, in which the TensorTransform objects are raw pointers. @@ -1234,7 +1234,7 @@ class RandomSelectSubpolicy final : public TensorTransform { }; /// \brief Adjust the sharpness of the input image by a fixed or random degree. -class RandomSharpness final : public TensorTransform { +class MS_API RandomSharpness final : public TensorTransform { public: /// \brief Constructor. /// \param[in] degrees A float vector of size 2, representing the range of random sharpness @@ -1266,7 +1266,7 @@ class RandomSharpness final : public TensorTransform { }; /// \brief Invert pixels randomly within a specified range. -class RandomSolarize final : public TensorTransform { +class MS_API RandomSolarize final : public TensorTransform { public: /// \brief Constructor. /// \param[in] threshold A vector with two elements specifying the pixel range to invert. @@ -1298,7 +1298,7 @@ class RandomSolarize final : public TensorTransform { }; /// \brief Randomly flip the input image vertically with a given probability. -class RandomVerticalFlip final : public TensorTransform { +class MS_API RandomVerticalFlip final : public TensorTransform { public: /// \brief Constructor. /// \param[in] prob A float representing the probability of flip. @@ -1328,7 +1328,7 @@ class RandomVerticalFlip final : public TensorTransform { }; /// \brief Randomly flip the input image vertically with a given probability and adjust bounding boxes accordingly. -class RandomVerticalFlipWithBBox final : public TensorTransform { +class MS_API RandomVerticalFlipWithBBox final : public TensorTransform { public: /// \brief Constructor. /// \param[in] prob A float representing the probability of flip. @@ -1357,7 +1357,7 @@ class RandomVerticalFlipWithBBox final : public TensorTransform { }; /// \brief Rescale the pixel value of input image. -class Rescale final : public TensorTransform { +class MS_API Rescale final : public TensorTransform { public: /// \brief Constructor. /// \param[in] rescale Rescale factor. @@ -1388,7 +1388,7 @@ class Rescale final : public TensorTransform { }; /// \brief Resize the input image to the given size and adjust bounding boxes accordingly. -class ResizeWithBBox final : public TensorTransform { +class MS_API ResizeWithBBox final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size The output size of the resized image. @@ -1425,7 +1425,7 @@ class ResizeWithBBox final : public TensorTransform { }; /// \brief Change the format of input tensor from 4-channel RGBA to 3-channel BGR. -class RGBA2BGR final : public TensorTransform { +class MS_API RGBA2BGR final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -1450,7 +1450,7 @@ class RGBA2BGR final : public TensorTransform { }; /// \brief Change the input 4 channel RGBA tensor to 3 channel RGB. -class RGBA2RGB final : public TensorTransform { +class MS_API RGBA2RGB final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -1475,7 +1475,7 @@ class RGBA2RGB final : public TensorTransform { }; /// \note Slice the tensor to multiple patches in horizontal and vertical directions. -class SlicePatches final : public TensorTransform { +class MS_API SlicePatches final : public TensorTransform { public: /// \brief Constructor. /// \param[in] num_height The number of patches in vertical direction (default=1). @@ -1516,7 +1516,7 @@ class SlicePatches final : public TensorTransform { /// The input image size should be in range [32*32, 8192*8192]. /// The zoom-out and zoom-in multiples of the image length and width should be in the range [1/32, 16]. /// Only images with an even resolution can be output. The output of odd resolution is not supported. -class SoftDvppDecodeRandomCropResizeJpeg final : public TensorTransform { +class MS_API SoftDvppDecodeRandomCropResizeJpeg final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the resized image. @@ -1561,7 +1561,7 @@ class SoftDvppDecodeRandomCropResizeJpeg final : public TensorTransform { /// and the input image size should be in range [32*32, 8192*8192]. /// The zoom-out and zoom-in multiples of the image length and width should be in the range [1/32, 16]. /// Only images with an even resolution can be output. The output of odd resolution is not supported. -class SoftDvppDecodeResizeJpeg final : public TensorTransform { +class MS_API SoftDvppDecodeResizeJpeg final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the resized image. @@ -1592,7 +1592,7 @@ class SoftDvppDecodeResizeJpeg final : public TensorTransform { }; /// \brief Swap the red and blue channels of the input image. -class SwapRedBlue final : public TensorTransform { +class MS_API SwapRedBlue final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -1617,7 +1617,7 @@ class SwapRedBlue final : public TensorTransform { }; /// \brief Randomly perform transformations, as selected from input transform list, on the input tensor. -class UniformAugment final : public TensorTransform { +class MS_API UniformAugment final : public TensorTransform { public: /// \brief Constructor. /// \param[in] transforms Raw pointer to vector of TensorTransform operations. @@ -1684,7 +1684,7 @@ class UniformAugment final : public TensorTransform { }; /// \brief Flip the input image vertically. -class VerticalFlip final : public TensorTransform { +class MS_API VerticalFlip final : public TensorTransform { public: /// \brief Constructor. /// \par Example diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h b/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h index a4edab34c7a..1ee40c95772 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/vision_ascend.h @@ -36,7 +36,7 @@ namespace vision { /// \brief Decode and resize JPEG image using the hardware algorithm of /// Ascend series chip DVPP module. -class DvppDecodeResizeJpeg final : public TensorTransform { +class MS_API DvppDecodeResizeJpeg final : public TensorTransform { public: /// \brief Constructor. /// \param[in] resize Parameter vector of two integers for each dimension, with respect to H,W order. @@ -68,7 +68,7 @@ class DvppDecodeResizeJpeg final : public TensorTransform { /// \brief Decode, resize and crop JPEG image using the hardware algorithm of /// Ascend series chip DVPP module. -class DvppDecodeResizeCropJpeg final : public TensorTransform { +class MS_API DvppDecodeResizeCropJpeg final : public TensorTransform { public: /// \brief Constructor. /// \param[in] crop Parameter vector of two integers for each dimension after final crop, with respect to H,W order. @@ -101,7 +101,7 @@ class DvppDecodeResizeCropJpeg final : public TensorTransform { /// \brief Decode PNG image using the hardware algorithm of /// Ascend series chip DVPP module. -class DvppDecodePng final : public TensorTransform { +class MS_API DvppDecodePng final : public TensorTransform { public: /// \brief Constructor. /// \par Example diff --git a/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h b/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h index ce89732667d..102f34849d8 100644 --- a/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h +++ b/mindspore/ccsrc/minddata/dataset/include/dataset/vision_lite.h @@ -36,7 +36,7 @@ namespace vision { class RotateOperation; /// \brief Apply affine transform on the input image. -class Affine final : public TensorTransform { +class MS_API Affine final : public TensorTransform { public: /// \brief Constructor. /// \param[in] degrees The degrees to rotate the image. @@ -80,7 +80,7 @@ class Affine final : public TensorTransform { }; /// \brief Crop the input image at the center to the given size. -class CenterCrop final : public TensorTransform { +class MS_API CenterCrop final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the cropped image. @@ -114,7 +114,7 @@ class CenterCrop final : public TensorTransform { }; /// \brief Crop an image based on location and crop size. -class Crop final : public TensorTransform { +class MS_API Crop final : public TensorTransform { public: /// \brief Constructor. /// \param[in] coordinates Starting location of crop. Must be a vector of two values, in the form of {x_coor, y_coor}. @@ -147,7 +147,7 @@ class Crop final : public TensorTransform { }; /// \brief Decode the input image in RGB mode. -class Decode final : public TensorTransform { +class MS_API Decode final : public TensorTransform { public: /// \brief Constructor. /// \param[in] rgb A boolean indicating whether to decode the image in RGB mode or not. @@ -178,7 +178,7 @@ class Decode final : public TensorTransform { }; /// \brief Blur the input image with the specified Gaussian kernel. -class GaussianBlur final : public TensorTransform { +class MS_API GaussianBlur final : public TensorTransform { public: /// \brief Constructor. /// \param[in] kernel_size A vector of Gaussian kernel size for width and height. The value must be positive and odd. @@ -210,7 +210,7 @@ class GaussianBlur final : public TensorTransform { }; /// \brief Normalize the input image with respect to mean and standard deviation. -class Normalize final : public TensorTransform { +class MS_API Normalize final : public TensorTransform { public: /// \brief Constructor. /// \param[in] mean A vector of mean values for each channel, with respect to channel order. @@ -245,7 +245,7 @@ class Normalize final : public TensorTransform { }; /// \brief Apply a Random Affine transformation on the input image in RGB or Greyscale mode. -class RandomAffine final : public TensorTransform { +class MS_API RandomAffine final : public TensorTransform { public: /// \brief Constructor. /// \param[in] degrees A float vector of size 2, representing the starting and ending degree. @@ -296,7 +296,7 @@ class RandomAffine final : public TensorTransform { }; /// \brief Resize the input image to the given size. -class Resize final : public TensorTransform { +class MS_API Resize final : public TensorTransform { public: /// \brief Constructor. /// \param[in] size A vector representing the output size of the resized image. @@ -336,7 +336,7 @@ class Resize final : public TensorTransform { }; /// \brief Keep the original picture ratio and fills the rest. -class ResizePreserveAR final : public TensorTransform { +class MS_API ResizePreserveAR final : public TensorTransform { public: /// \brief Constructor. /// \param[in] height The height of image output value after resizing. @@ -377,7 +377,7 @@ class ResizePreserveAR final : public TensorTransform { /// \brief RGB2BGR TensorTransform. /// \notes Convert the format of input image from RGB to BGR. -class RGB2BGR final : public TensorTransform { +class MS_API RGB2BGR final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -404,7 +404,7 @@ class RGB2BGR final : public TensorTransform { /// \brief RGB2GRAY TensorTransform. /// \note Convert RGB image or color image to grayscale image. /// \brief Convert a RGB image or color image to a grayscale one. -class RGB2GRAY final : public TensorTransform { +class MS_API RGB2GRAY final : public TensorTransform { public: /// \brief Constructor. /// \par Example @@ -429,7 +429,7 @@ class RGB2GRAY final : public TensorTransform { }; /// \brief Rotate the input image according to parameters. -class Rotate final : public TensorTransform { +class MS_API Rotate final : public TensorTransform { public: /// \brief Constructor. /// \note This api is only used in Lite, the interpolation mode is bilinear. diff --git a/mindspore/ccsrc/minddata/dataset/liteapi/include/datasets.h b/mindspore/ccsrc/minddata/dataset/liteapi/include/datasets.h index 9a8d89710ac..fb38a2f94d6 100644 --- a/mindspore/ccsrc/minddata/dataset/liteapi/include/datasets.h +++ b/mindspore/ccsrc/minddata/dataset/liteapi/include/datasets.h @@ -63,7 +63,7 @@ class DSCallback; /// \class Dataset datasets.h /// \brief A base class to represent a dataset in the data pipeline. -class Dataset : public std::enable_shared_from_this { +class MS_API Dataset : public std::enable_shared_from_this { public: // need friend class so they can access the children_ field friend class Iterator; @@ -388,7 +388,7 @@ class Dataset : public std::enable_shared_from_this { bool SaveCharIF(const std::vector &dataset_path, int32_t num_files, const std::vector &dataset_type); }; -class SchemaObj { +class MS_API SchemaObj { public: /// \brief Constructor explicit SchemaObj(const std::string &schema_file = "") : SchemaObj(StringToChar(schema_file)) {} @@ -490,13 +490,13 @@ class SchemaObj { std::shared_ptr data_; }; -class BatchDataset : public Dataset { +class MS_API BatchDataset : public Dataset { public: BatchDataset(std::shared_ptr input, int32_t batch_size, bool drop_remainder = false); ~BatchDataset() = default; }; -class MapDataset : public Dataset { +class MS_API MapDataset : public Dataset { public: MapDataset(std::shared_ptr input, std::vector> operations, const std::vector> &input_columns, const std::vector> &output_columns, @@ -505,13 +505,13 @@ class MapDataset : public Dataset { ~MapDataset() = default; }; -class ProjectDataset : public Dataset { +class MS_API ProjectDataset : public Dataset { public: ProjectDataset(std::shared_ptr input, const std::vector> &columns); ~ProjectDataset() = default; }; -class ShuffleDataset : public Dataset { +class MS_API ShuffleDataset : public Dataset { public: ShuffleDataset(std::shared_ptr input, int32_t buffer_size); ~ShuffleDataset() = default; @@ -522,16 +522,16 @@ class ShuffleDataset : public Dataset { /// \note The reason for using this API is that std::string will be constrained by the /// compiler option '_GLIBCXX_USE_CXX11_ABI' while char is free of this restriction. /// \return Shared pointer to the current schema. -std::shared_ptr SchemaCharIF(const std::vector &schema_file); +std::shared_ptr MS_API SchemaCharIF(const std::vector &schema_file); /// \brief Function to create a SchemaObj. /// \param[in] schema_file Path of schema file. /// \return Shared pointer to the current schema. -inline std::shared_ptr Schema(const std::string &schema_file = "") { +inline std::shared_ptr MS_API Schema(const std::string &schema_file = "") { return SchemaCharIF(StringToChar(schema_file)); } -class AlbumDataset : public Dataset { +class MS_API AlbumDataset : public Dataset { public: /// \brief Constructor of AlbumDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -599,10 +599,10 @@ class AlbumDataset : public Dataset { /// /* Note: As we defined before, each data dictionary owns keys "image", "label" and "id" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr Album(const std::string &dataset_dir, const std::string &data_schema, - const std::vector &column_names = {}, bool decode = false, - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +Album(const std::string &dataset_dir, const std::string &data_schema, const std::vector &column_names = {}, + bool decode = false, const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(data_schema), VectorStringToChar(column_names), decode, sampler, cache); } @@ -615,10 +615,10 @@ inline std::shared_ptr Album(const std::string &dataset_dir, const /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current Dataset -inline std::shared_ptr Album(const std::string &dataset_dir, const std::string &data_schema, - const std::vector &column_names, bool decode, - const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Album(const std::string &dataset_dir, const std::string &data_schema, + const std::vector &column_names, bool decode, + const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(data_schema), VectorStringToChar(column_names), decode, sampler, cache); } @@ -631,15 +631,15 @@ inline std::shared_ptr Album(const std::string &dataset_dir, const /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current Dataset -inline std::shared_ptr Album(const std::string &dataset_dir, const std::string &data_schema, - const std::vector &column_names, bool decode, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Album(const std::string &dataset_dir, const std::string &data_schema, + const std::vector &column_names, bool decode, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(data_schema), VectorStringToChar(column_names), decode, sampler, cache); } -class MnistDataset : public Dataset { +class MS_API MnistDataset : public Dataset { public: /// \brief Constructor of MnistDataset. /// \param[in] dataset_dir Path to the root directory that contains the dataset. @@ -692,9 +692,10 @@ class MnistDataset : public Dataset { /// /* Note: In MNIST dataset, each dictionary has keys "image" and "label" */ /// auto image = row["image"]; /// \endcode -inline std::shared_ptr Mnist(const std::string &dataset_dir, const std::string &usage = "all", - const std::shared_ptr &sampler = std::make_shared(), - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API +Mnist(const std::string &dataset_dir, const std::string &usage = "all", + const std::shared_ptr &sampler = std::make_shared(), + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } @@ -705,9 +706,9 @@ inline std::shared_ptr Mnist(const std::string &dataset_dir, const /// \param[in] sampler Raw pointer to a sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current MnistDataset -inline std::shared_ptr Mnist(const std::string &dataset_dir, const std::string &usage, - const Sampler *sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Mnist(const std::string &dataset_dir, const std::string &usage, + const Sampler *sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } @@ -718,9 +719,9 @@ inline std::shared_ptr Mnist(const std::string &dataset_dir, const /// \param[in] sampler Sampler object used to choose samples from the dataset. /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). /// \return Shared pointer to the current MnistDataset -inline std::shared_ptr Mnist(const std::string &dataset_dir, const std::string &usage, - const std::reference_wrapper sampler, - const std::shared_ptr &cache = nullptr) { +inline std::shared_ptr MS_API Mnist(const std::string &dataset_dir, const std::string &usage, + const std::reference_wrapper sampler, + const std::shared_ptr &cache = nullptr) { return std::make_shared(StringToChar(dataset_dir), StringToChar(usage), sampler, cache); } } // namespace dataset