Browse Source

dataset: Specify Sampler and TensorTransform C++ API classes as final

tags/v1.2.0-rc1
Cathy Wong 5 years ago
parent
commit
71ad3bb808
8 changed files with 78 additions and 79 deletions
  1. +6
    -6
      mindspore/ccsrc/minddata/dataset/include/samplers.h
  2. +16
    -16
      mindspore/ccsrc/minddata/dataset/include/text.h
  3. +7
    -7
      mindspore/ccsrc/minddata/dataset/include/transforms.h
  4. +36
    -36
      mindspore/ccsrc/minddata/dataset/include/vision.h
  5. +3
    -3
      mindspore/ccsrc/minddata/dataset/include/vision_ascend.h
  6. +8
    -8
      mindspore/ccsrc/minddata/dataset/include/vision_lite.h
  7. +2
    -2
      tests/ut/cpp/dataset/c_api_samplers_test.cc
  8. +0
    -1
      tests/ut/cpp/dataset/execute_test.cc

+ 6
- 6
mindspore/ccsrc/minddata/dataset/include/samplers.h View File

@@ -68,7 +68,7 @@ class Sampler : std::enable_shared_from_this<Sampler> {

/// \brief A class to represent a Distributed Sampler in the data pipeline.
/// \notes A Sampler that accesses a shard of the dataset.
class DistributedSampler : public Sampler {
class DistributedSampler final : public Sampler {
friend std::shared_ptr<SamplerObj> SelectSampler(int64_t, bool, int32_t, int32_t);

public:
@@ -104,7 +104,7 @@ class DistributedSampler : public Sampler {
/// \brief A class to represent a PK Sampler in the data pipeline.
/// \notes Samples K elements for each P class in the dataset.
/// This will sample all classes.
class PKSampler : public Sampler {
class PKSampler final : public Sampler {
friend std::shared_ptr<SamplerObj> SelectSampler(int64_t, bool, int32_t, int32_t);

public:
@@ -130,7 +130,7 @@ class PKSampler : public Sampler {

/// \brief A class to represent a Random Sampler in the data pipeline.
/// \notes Samples the elements randomly.
class RandomSampler : public Sampler {
class RandomSampler final : public Sampler {
friend std::shared_ptr<SamplerObj> SelectSampler(int64_t, bool, int32_t, int32_t);

public:
@@ -154,7 +154,7 @@ class RandomSampler : public Sampler {

/// \brief A class to represent a Sequential Sampler in the data pipeline.
/// \notes Samples the dataset elements sequentially, same as not having a sampler.
class SequentialSampler : public Sampler {
class SequentialSampler final : public Sampler {
friend std::shared_ptr<SamplerObj> SelectSampler(int64_t, bool, int32_t, int32_t);

public:
@@ -201,7 +201,7 @@ class SubsetSampler : public Sampler {

/// \brief A class to represent a Subset Random Sampler in the data pipeline.
/// \notes Samples the elements randomly from a sequence of indices.
class SubsetRandomSampler : public SubsetSampler {
class SubsetRandomSampler final : public SubsetSampler {
friend std::shared_ptr<SamplerObj> SelectSampler(int64_t, bool, int32_t, int32_t);

public:
@@ -222,7 +222,7 @@ class SubsetRandomSampler : public SubsetSampler {
/// \brief A class to represent a Weighted Random Sampler in the data pipeline.
/// \notes Samples the elements from [0, len(weights) - 1] randomly with the given
/// weights (probabilities).
class WeightedRandomSampler : public Sampler {
class WeightedRandomSampler final : public Sampler {
friend std::shared_ptr<SamplerObj> SelectSampler(int64_t, bool, int32_t, int32_t);

public:


+ 16
- 16
mindspore/ccsrc/minddata/dataset/include/text.h View File

@@ -41,7 +41,7 @@ namespace text {
#ifndef _WIN32
/// \brief Tokenize a scalar tensor of UTF-8 string by specific rules.
/// \notes BasicTokenizer is not supported on Windows platform yet.
class BasicTokenizer : public TensorTransform {
class BasicTokenizer final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] lower_case If true, apply CaseFold, NormalizeUTF8(NFD mode), RegexReplace operation on input text to
@@ -72,7 +72,7 @@ class BasicTokenizer : public TensorTransform {

/// \brief Tokenizer used for Bert text process.
/// \notes BertTokenizer is not supported on Windows platform yet.
class BertTokenizer : public TensorTransform {
class BertTokenizer final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] vocab A Vocab object.
@@ -117,7 +117,7 @@ class BertTokenizer : public TensorTransform {

/// \brief Apply case fold operation on UTF-8 string tensor.
/// \return Shared pointer to the current TensorOperation.
class CaseFold : public TensorTransform {
class CaseFold final : public TensorTransform {
public:
/// \brief Constructor.
CaseFold();
@@ -134,7 +134,7 @@ class CaseFold : public TensorTransform {

/// \brief Tokenize Chinese string into words based on dictionary.
/// \notes The integrity of the HMMSEgment algorithm and MPSegment algorithm files must be confirmed.
class JiebaTokenizer : public TensorTransform {
class JiebaTokenizer final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] hmm_path Dictionary file is used by HMMSegment algorithm. The dictionary can be obtained on the
@@ -169,7 +169,7 @@ class JiebaTokenizer : public TensorTransform {
};

/// \brief Look up a word into an id according to the input vocabulary table.
class Lookup : public TensorTransform {
class Lookup final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] vocab a Vocab object.
@@ -198,7 +198,7 @@ class Lookup : public TensorTransform {
};

/// \brief TensorOp to generate n-gram from a 1-D string Tensor.
class Ngram : public TensorTransform {
class 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
@@ -231,7 +231,7 @@ class Ngram : public TensorTransform {

#ifndef _WIN32
/// \brief Apply normalize operation on UTF-8 string tensor.
class NormalizeUTF8 : public TensorTransform {
class NormalizeUTF8 final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] normalize_form Valid values can be any of [NormalizeForm::kNone,NormalizeForm::kNfc,
@@ -259,7 +259,7 @@ class NormalizeUTF8 : public TensorTransform {
};

/// \brief Replace UTF-8 string tensor with 'replace' according to regular expression 'pattern'.
class RegexReplace : public TensorTransform {
class RegexReplace final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] pattern The regex expression patterns.
@@ -285,7 +285,7 @@ class RegexReplace : public TensorTransform {
};

/// \brief Tokenize a scalar tensor of UTF-8 string by regex expression pattern.
class RegexTokenizer : public TensorTransform {
class RegexTokenizer final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] delim_pattern The pattern of regex delimiters.
@@ -314,7 +314,7 @@ class RegexTokenizer : public TensorTransform {
#endif

/// \brief Tokenize scalar token or 1-D tokens to tokens by sentencepiece.
class SentencePieceTokenizer : public TensorTransform {
class SentencePieceTokenizer final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] vocab a SentencePieceVocab object.
@@ -345,7 +345,7 @@ class SentencePieceTokenizer : public TensorTransform {

/// \brief TensorOp to 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 : public TensorTransform {
class SlidingWindow final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] width The width of the window. It must be an integer and greater than zero.
@@ -371,7 +371,7 @@ class SlidingWindow : 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 : public TensorTransform {
class ToNumber final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] data_type of the tensor to be casted to. Must be a numeric type.
@@ -393,7 +393,7 @@ class ToNumber : public TensorTransform {
};

/// \brief Truncate a pair of rank-1 tensors such that the total length is less than max_length.
class TruncateSequencePair : public TensorTransform {
class TruncateSequencePair final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] max_length Maximum length required.
@@ -413,7 +413,7 @@ class TruncateSequencePair : public TensorTransform {
};

/// \brief Tokenize a scalar tensor of UTF-8 string to Unicode characters.
class UnicodeCharTokenizer : public TensorTransform {
class UnicodeCharTokenizer final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] with_offsets If or not output offsets of tokens (default=false).
@@ -434,7 +434,7 @@ class UnicodeCharTokenizer : public TensorTransform {

#ifndef _WIN32
/// \brief Tokenize a scalar tensor of UTF-8 string on Unicode script boundaries.
class UnicodeScriptTokenizer : public TensorTransform {
class UnicodeScriptTokenizer final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] keep_whitespace If or not emit whitespace tokens (default=false).
@@ -455,7 +455,7 @@ class UnicodeScriptTokenizer : public TensorTransform {
};

/// \brief Tokenize a scalar tensor of UTF-8 string on ICU4C defined whitespaces.
class WhitespaceTokenizer : public TensorTransform {
class WhitespaceTokenizer final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] with_offsets If or not output offsets of tokens (default=false).


+ 7
- 7
mindspore/ccsrc/minddata/dataset/include/transforms.h View File

@@ -80,7 +80,7 @@ namespace transforms {

/// \brief Compose Op.
/// \notes Compose a list of transforms into a single transform.
class Compose : public TensorTransform {
class Compose final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] transforms A vector of raw pointers to TensorTransform objects to be applied.
@@ -108,7 +108,7 @@ class Compose : public TensorTransform {
/// \brief Duplicate Op.
/// \notes Duplicate the input tensor to a new output tensor.
/// The input tensor is carried over to the output list.
class Duplicate : public TensorTransform {
class Duplicate final : public TensorTransform {
public:
/// \brief Constructor.
Duplicate();
@@ -124,7 +124,7 @@ class Duplicate : public TensorTransform {

/// \brief OneHot Op.
/// \notes Convert the labels into OneHot format.
class OneHot : public TensorTransform {
class OneHot final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] num_classes number of classes.
@@ -145,7 +145,7 @@ class OneHot : public TensorTransform {

/// \brief RandomApply Op.
/// \notes Randomly perform a series of transforms with a given probability.
class RandomApply : public TensorTransform {
class RandomApply final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] transforms A vector of raw pointers to TensorTransform objects to be applied.
@@ -175,7 +175,7 @@ class RandomApply : public TensorTransform {

/// \brief RandomChoice Op.
/// \notes Randomly selects one transform from a list of transforms to perform operation.
class RandomChoice : public TensorTransform {
class RandomChoice final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] transforms A vector of raw pointers to TensorTransform objects to be applied.
@@ -202,7 +202,7 @@ class RandomChoice : public TensorTransform {

/// \brief TypeCast Op.
/// \notes Tensor operation to cast to a given MindSpore data type.
class TypeCast : public TensorTransform {
class TypeCast final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] data_type mindspore.dtype to be cast to.
@@ -226,7 +226,7 @@ class TypeCast : public TensorTransform {
/// \brief Unique Op.
/// \notes Return an output tensor containing all the unique elements of the input tensor in
/// the same order that they occur in the input tensor.
class Unique : public TensorTransform {
class Unique final : public TensorTransform {
public:
/// \brief Constructor.
Unique();


+ 36
- 36
mindspore/ccsrc/minddata/dataset/include/vision.h View File

@@ -38,7 +38,7 @@ class TensorOperation;
namespace vision {
/// \brief AutoContrast TensorTransform.
/// \notes Apply automatic contrast on input image.
class AutoContrast : public TensorTransform {
class 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 100.
@@ -60,7 +60,7 @@ class AutoContrast : public TensorTransform {

/// \brief BoundingBoxAugment TensorTransform.
/// \notes Apply a given image transform on a random selection of bounding box regions of a given image.
class BoundingBoxAugment : public TensorTransform {
class BoundingBoxAugment final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] transform Raw pointer to a TensorTransform operation.
@@ -93,7 +93,7 @@ class BoundingBoxAugment : public TensorTransform {
/// \brief Constructor to apply CutMix on a batch of images
/// \notes Masks a random section of each image with the corresponding part of another randomly
/// selected image in that batch
class CutMixBatch : public TensorTransform {
class CutMixBatch final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] image_batch_format The format of the batch
@@ -116,7 +116,7 @@ class CutMixBatch : public TensorTransform {

/// \brief CutOut TensorOp
/// \notes Randomly cut (mask) out a given number of square patches from the input image
class CutOut : public TensorTransform {
class CutOut final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] length Integer representing the side length of each square patch
@@ -138,7 +138,7 @@ class CutOut : public TensorTransform {

/// \brief Equalize TensorTransform.
/// \notes Apply histogram equalization on input image.
class Equalize : public TensorTransform {
class Equalize final : public TensorTransform {
public:
/// \brief Constructor.
Equalize();
@@ -154,7 +154,7 @@ class Equalize : public TensorTransform {

/// \brief HwcToChw TensorTransform.
/// \notes Transpose the input image; shape (H, W, C) to shape (C, H, W).
class HWC2CHW : public TensorTransform {
class HWC2CHW final : public TensorTransform {
public:
/// \brief Constructor.
HWC2CHW();
@@ -170,7 +170,7 @@ class HWC2CHW : public TensorTransform {

/// \brief Invert TensorTransform.
/// \notes Apply invert on input image in RGB mode.
class Invert : public TensorTransform {
class Invert final : public TensorTransform {
public:
/// \brief Constructor.
Invert();
@@ -187,7 +187,7 @@ class Invert : public TensorTransform {
/// \brief MixUpBatch TensorTransform.
/// \notes 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 : public TensorTransform {
class MixUpBatch final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] alpha hyperparameter of beta distribution (default = 1.0)
@@ -209,7 +209,7 @@ class MixUpBatch : public TensorTransform {
/// \brief NormalizePad TensorTransform.
/// \notes Normalize the input image with respect to mean and standard deviation and pad an extra
/// channel with value zero.
class NormalizePad : public TensorTransform {
class NormalizePad final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] mean A vector of mean values for each channel, w.r.t channel order.
@@ -239,7 +239,7 @@ class NormalizePad : public TensorTransform {

/// \brief Pad TensorOp
/// \notes Pads the image according to padding parameters
class Pad : public TensorTransform {
class Pad final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] padding A vector representing the number of pixels to pad the image
@@ -277,7 +277,7 @@ class Pad : public TensorTransform {
/// \brief Blends 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 the bound of the interval
class RandomColor : public TensorTransform {
class RandomColor final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] t_lb Lower bound on the range of random weights
@@ -299,7 +299,7 @@ class RandomColor : public TensorTransform {

/// \brief RandomColorAdjust TensorTransform.
/// \brief Randomly adjust the brightness, contrast, saturation, and hue of the input image
class RandomColorAdjust : public TensorTransform {
class RandomColorAdjust final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] brightness Brightness adjustment factor. Must be a vector of one or two values
@@ -329,7 +329,7 @@ class RandomColorAdjust : public TensorTransform {

/// \brief RandomCrop TensorTransform.
/// \notes Crop the input image at a random location.
class RandomCrop : public TensorTransform {
class RandomCrop final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the cropped image.
@@ -365,7 +365,7 @@ class RandomCrop : public TensorTransform {

/// \brief RandomCropDecodeResize TensorTransform.
/// \notes Equivalent to RandomResizedCrop, but crops before decodes.
class RandomCropDecodeResize : public TensorTransform {
class RandomCropDecodeResize final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the cropped image.
@@ -398,7 +398,7 @@ class RandomCropDecodeResize : public TensorTransform {

/// \brief RandomCropWithBBox TensorTransform.
/// \notes Crop the input image at a random location and adjust bounding boxes accordingly.
class RandomCropWithBBox : public TensorTransform {
class RandomCropWithBBox final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the cropped image.
@@ -436,7 +436,7 @@ class RandomCropWithBBox : public TensorTransform {

/// \brief RandomHorizontalFlip TensorTransform.
/// \notes Tensor operation to perform random horizontal flip.
class RandomHorizontalFlip : public TensorTransform {
class RandomHorizontalFlip final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] prob A float representing the probability of flip.
@@ -457,7 +457,7 @@ class RandomHorizontalFlip : public TensorTransform {

/// \brief RandomHorizontalFlipWithBBox TensorTransform.
/// \notes Flip the input image horizontally, randomly with a given probability and adjust bounding boxes accordingly.
class RandomHorizontalFlipWithBBox : public TensorTransform {
class RandomHorizontalFlipWithBBox final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] prob A float representing the probability of flip.
@@ -478,7 +478,7 @@ class RandomHorizontalFlipWithBBox : public TensorTransform {

/// \brief RandomPosterize TensorTransform.
/// \notes Tensor operation to perform random posterize.
class RandomPosterize : public TensorTransform {
class RandomPosterize final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] bit_range - uint8_t vector representing the minimum and maximum bit in range. (Default={4, 8})
@@ -500,7 +500,7 @@ class RandomPosterize : public TensorTransform {
/// \brief RandomResize TensorTransform.
/// \notes Resize the input image using a randomly selected interpolation mode.
// the same image aspect ratio. If size has 2 values, it should be (height, width).
class RandomResize : public TensorTransform {
class RandomResize final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the resized image.
@@ -523,7 +523,7 @@ class RandomResize : public TensorTransform {
/// \brief RandomResizeWithBBox TensorTransform.
/// \notes Resize the input image using a randomly selected interpolation mode and adjust
/// bounding boxes accordingly.
class RandomResizeWithBBox : public TensorTransform {
class RandomResizeWithBBox final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the resized image.
@@ -546,7 +546,7 @@ class RandomResizeWithBBox : public TensorTransform {

/// \brief RandomResizedCrop TensorTransform.
/// \notes Crop the input image to a random size and aspect ratio.
class RandomResizedCrop : public TensorTransform {
class RandomResizedCrop final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the cropped image.
@@ -578,7 +578,7 @@ class RandomResizedCrop : public TensorTransform {

/// \brief RandomResizedCropWithBBox TensorTransform.
/// \notes Crop the input image to a random size and aspect ratio.
class RandomResizedCropWithBBox : public TensorTransform {
class RandomResizedCropWithBBox final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the cropped image.
@@ -610,7 +610,7 @@ class RandomResizedCropWithBBox : public TensorTransform {

/// \brief RandomRotation TensorOp
/// \notes Rotates the image according to parameters
class RandomRotation : public TensorTransform {
class RandomRotation final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] degrees A float vector of size, representing the starting and ending degree
@@ -642,7 +642,7 @@ class RandomRotation : public TensorTransform {
/// (op, prob), where op is a TensorTransform operation and prob is the probability that this op will be applied.
/// Once a sub-policy is selected, each op within the sub-policy with be applied in sequence according to its
/// probability.
class RandomSelectSubpolicy : public TensorTransform {
class 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
@@ -672,7 +672,7 @@ class RandomSelectSubpolicy : public TensorTransform {

/// \brief RandomSharpness TensorTransform.
/// \notes Tensor operation to perform random sharpness.
class RandomSharpness : public TensorTransform {
class RandomSharpness final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] degrees A float vector of size 2, representing the starting and ending degree to uniformly
@@ -695,7 +695,7 @@ class RandomSharpness : public TensorTransform {
/// \brief RandomSolarize TensorTransform.
/// \notes Invert pixels randomly within specified range. If min=max, it is a single fixed magnitude operation
/// to inverts all pixel above that threshold
class RandomSolarize : public TensorTransform {
class RandomSolarize final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] threshold A vector with two elements specifying the pixel range to invert.
@@ -716,7 +716,7 @@ class RandomSolarize : public TensorTransform {

/// \brief RandomVerticalFlip TensorTransform.
/// \notes Tensor operation to perform random vertical flip.
class RandomVerticalFlip : public TensorTransform {
class RandomVerticalFlip final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] prob A float representing the probability of flip.
@@ -737,7 +737,7 @@ class RandomVerticalFlip : public TensorTransform {

/// \brief RandomVerticalFlipWithBBox TensorTransform.
/// \notes Flip the input image vertically, randomly with a given probability and adjust bounding boxes accordingly.
class RandomVerticalFlipWithBBox : public TensorTransform {
class RandomVerticalFlipWithBBox final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] prob A float representing the probability of flip.
@@ -758,7 +758,7 @@ class RandomVerticalFlipWithBBox : public TensorTransform {

/// \brief RescaleOperation TensorTransform.
/// \notes Tensor operation to rescale the input image.
class Rescale : public TensorTransform {
class Rescale final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] rescale Rescale factor.
@@ -780,7 +780,7 @@ class Rescale : public TensorTransform {

/// \brief ResizeWithBBox TensorTransform.
/// \notes Resize the input image to the given size and adjust bounding boxes accordingly.
class ResizeWithBBox : public TensorTransform {
class ResizeWithBBox final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size The output size of the resized image.
@@ -804,7 +804,7 @@ class ResizeWithBBox : public TensorTransform {

/// \brief RgbaToBgr TensorTransform.
/// \notes Changes the input 4 channel RGBA tensor to 3 channel BGR.
class RGBA2BGR : public TensorTransform {
class RGBA2BGR final : public TensorTransform {
public:
/// \brief Constructor.
RGBA2BGR();
@@ -820,7 +820,7 @@ class RGBA2BGR : public TensorTransform {

/// \brief RgbaToRgb TensorTransform.
/// \notes Changes the input 4 channel RGBA tensor to 3 channel RGB.
class RGBA2RGB : public TensorTransform {
class RGBA2RGB final : public TensorTransform {
public:
/// \brief Constructor.
RGBA2RGB();
@@ -840,7 +840,7 @@ class RGBA2RGB : 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 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 : public TensorTransform {
class SoftDvppDecodeRandomCropResizeJpeg final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the resized image.
@@ -877,7 +877,7 @@ class SoftDvppDecodeRandomCropResizeJpeg : 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 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 : public TensorTransform {
class SoftDvppDecodeResizeJpeg final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the resized image.
@@ -900,7 +900,7 @@ class SoftDvppDecodeResizeJpeg : public TensorTransform {

/// \brief SwapRedBlue TensorOp
/// \notes Swaps the red and blue channels in image
class SwapRedBlue : public TensorTransform {
class SwapRedBlue final : public TensorTransform {
public:
/// \brief Constructor.
SwapRedBlue();
@@ -916,7 +916,7 @@ class SwapRedBlue : public TensorTransform {

/// \brief UniformAugment TensorTransform.
/// \notes Tensor operation to perform randomly selected augmentation.
class UniformAugment : public TensorTransform {
class UniformAugment final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] transforms Raw pointer to vector of TensorTransform operations.


+ 3
- 3
mindspore/ccsrc/minddata/dataset/include/vision_ascend.h View File

@@ -34,7 +34,7 @@ namespace vision {

/* ##################################### API class ###########################################*/

class DvppDecodeResizeJpeg : public TensorTransform {
class DvppDecodeResizeJpeg final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] resize A vector of int value for each dimension, w.r.t H,W order.
@@ -55,7 +55,7 @@ class DvppDecodeResizeJpeg : public TensorTransform {
std::shared_ptr<Data> data_;
};

class DvppDecodeResizeCropJpeg : public TensorTransform {
class DvppDecodeResizeCropJpeg final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] crop A vector of int value for each dimension after final crop, w.r.t H,W order.
@@ -77,7 +77,7 @@ class DvppDecodeResizeCropJpeg : public TensorTransform {
std::shared_ptr<Data> data_;
};

class DvppDecodePng : public TensorTransform {
class DvppDecodePng final : public TensorTransform {
public:
/// \brief Constructor.
DvppDecodePng();


+ 8
- 8
mindspore/ccsrc/minddata/dataset/include/vision_lite.h View File

@@ -37,7 +37,7 @@ class RotateOperation;

/// \brief Affine TensorTransform.
/// \notes Apply affine transform on input image.
class Affine : public TensorTransform {
class Affine final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] degrees The degrees to rotate the image by
@@ -68,7 +68,7 @@ class Affine : public TensorTransform {

/// \brief CenterCrop TensorTransform.
/// \notes Crops the input image at the center to the given size.
class CenterCrop : public TensorTransform {
class CenterCrop final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the cropped image.
@@ -93,7 +93,7 @@ class CenterCrop : public TensorTransform {

/// \brief Crop TensorTransform.
/// \notes Crop an image based on location and crop size
class Crop : public TensorTransform {
class 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}
@@ -117,7 +117,7 @@ class Crop : public TensorTransform {

/// \brief Decode TensorTransform.
/// \notes Decode the input image in RGB mode.
class Decode : public TensorTransform {
class Decode final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] rgb A boolean of whether to decode in RGB mode or not.
@@ -140,7 +140,7 @@ class Decode : public TensorTransform {

/// \brief Normalize TensorTransform.
/// \notes Normalize the input image with respect to mean and standard deviation.
class Normalize : public TensorTransform {
class Normalize final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] mean A vector of mean values for each channel, w.r.t channel order.
@@ -166,7 +166,7 @@ class Normalize : public TensorTransform {

/// \brief RandomAffine TensorTransform.
/// \notes Applies a Random Affine transformation on input image in RGB or Greyscale mode.
class RandomAffine : public TensorTransform {
class RandomAffine final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] degrees A float vector of size 2, representing the starting and ending degree
@@ -204,7 +204,7 @@ class RandomAffine : public TensorTransform {

/// \brief Resize TensorTransform.
/// \notes Resize the input image to the given size.
class Resize : public TensorTransform {
class Resize final : public TensorTransform {
public:
/// \brief Constructor.
/// \param[in] size A vector representing the output size of the resized image.
@@ -230,7 +230,7 @@ class Resize : public TensorTransform {

/// \brief Rotate TensorTransform.
/// \notes Rotate the input image using a specified angle id.
class Rotate : public TensorTransform {
class Rotate final : public TensorTransform {
public:
/// \brief Constructor.
Rotate();


+ 2
- 2
tests/ut/cpp/dataset/c_api_samplers_test.cc View File

@@ -149,7 +149,7 @@ TEST_F(MindDataTestPipeline, TestDistributedSamplerSuccess2) {
// Test basic setting of distributed_sampler

// num_shards=4, shard_id=0, shuffle=false, num_samplers=0, seed=0, offset=-1, even_dist=true
Sampler *sampler = new DistributedSampler(4, 0, false, 0, 0, -1, true);
auto sampler(new DistributedSampler(4, 0, false, 0, 0, -1, true));
// Note that with new, we have to explicitly delete the allocated object as shown below.
// Note: No need to check for output after calling API class constructor

@@ -232,7 +232,7 @@ TEST_F(MindDataTestPipeline, TestDistributedSamplerFail2) {

// num_shards=4, shard_id=0, shuffle=false, num_samplers=0, seed=0, offset=5, even_dist=true
// offset=5 which is greater than num_shards=4 --> will fail later
Sampler *sampler = new DistributedSampler(4, 0, false, 0, 0, 5, false);
auto sampler(new DistributedSampler(4, 0, false, 0, 0, 5, false));
// Note that with new, we have to explicitly delete the allocated object as shown below.
// Note: No need to check for output after calling API class constructor



+ 0
- 1
tests/ut/cpp/dataset/execute_test.cc View File

@@ -173,7 +173,6 @@ TEST_F(MindDataTestExecute, TestTransformInput3) {
TEST_F(MindDataTestExecute, TestTransformInputSequential) {
MS_LOG(INFO) << "Doing MindDataTestExecute-TestTransformInputSequential.";
// Test Execute with transform op input using API constructors, with auto pointers;
// Note that with auto and new, we have to explicitly delete the allocated object as shown below.
// Apply 2 transformations sequentially, including single non-vector Transform op input

// Read image, construct MSTensor from dataset tensor


Loading…
Cancel
Save