From: @tina_mengting_zhang Reviewed-by: Signed-off-by:tags/v1.2.0-rc1
| @@ -104,7 +104,13 @@ Status MapNode::ValidateParams() { | |||||
| RETURN_STATUS_SYNTAX_ERROR(err_msg); | RETURN_STATUS_SYNTAX_ERROR(err_msg); | ||||
| } | } | ||||
| for (const auto &op : operations_) { | for (const auto &op : operations_) { | ||||
| RETURN_IF_NOT_OK(op->ValidateParams()); | |||||
| if (op == nullptr) { | |||||
| std::string err_msg = "MapNode: operation must not be nullptr."; | |||||
| MS_LOG(ERROR) << err_msg; | |||||
| RETURN_STATUS_SYNTAX_ERROR(err_msg); | |||||
| } else { | |||||
| RETURN_IF_NOT_OK(op->ValidateParams()); | |||||
| } | |||||
| } | } | ||||
| if (!input_columns_.empty()) { | if (!input_columns_.empty()) { | ||||
| RETURN_IF_NOT_OK(ValidateDatasetColumnParam("MapNode", "input_columns", input_columns_)); | RETURN_IF_NOT_OK(ValidateDatasetColumnParam("MapNode", "input_columns", input_columns_)); | ||||
| @@ -297,8 +297,8 @@ class Dataset : public std::enable_shared_from_this<Dataset> { | |||||
| /// \brief Function to create a MapDataset | /// \brief Function to create a MapDataset | ||||
| /// \notes Applies each operation in operations to this dataset | /// \notes Applies each operation in operations to this dataset | ||||
| /// \param[in] operations Vector of operations to be applied on the dataset. Operations are | |||||
| /// applied in the order they appear in this list | |||||
| /// \param[in] operations Vector of raw pointers to TensorTransform objects to be applied on the dataset. Operations | |||||
| /// are applied in the order they appear in this list | |||||
| /// \param[in] input_columns Vector of the names of the columns that will be passed to the first | /// \param[in] input_columns Vector of the names of the columns that will be passed to the first | ||||
| /// operation as input. The size of this list must match the number of | /// operation as input. The size of this list must match the number of | ||||
| /// input columns expected by the first operator. The default input_columns | /// input columns expected by the first operator. The default input_columns | ||||
| @@ -326,6 +326,22 @@ class Dataset : public std::enable_shared_from_this<Dataset> { | |||||
| callbacks); | callbacks); | ||||
| } | } | ||||
| /// \brief Function to create a MapDataset | |||||
| /// \notes Applies each operation in operations to this dataset | |||||
| /// \param[in] operations Vector of shared pointers to TensorTransform objects to be applied on the dataset. | |||||
| /// Operations are applied in the order they appear in this list | |||||
| /// \param[in] input_columns Vector of the names of the columns that will be passed to the first | |||||
| /// operation as input. The size of this list must match the number of | |||||
| /// input columns expected by the first operator. The default input_columns | |||||
| /// is the first column | |||||
| /// \param[in] output_columns Vector of names assigned to the columns outputted by the last operation | |||||
| /// This parameter is mandatory if len(input_columns) != len(output_columns) | |||||
| /// The size of this list must match the number of output columns of the | |||||
| /// last operation. The default output_columns will have the same | |||||
| /// name as the input columns, i.e., the columns will be replaced | |||||
| /// \param[in] project_columns A list of column names to project | |||||
| /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). | |||||
| /// \return Shared pointer to the current MapDataset | |||||
| std::shared_ptr<MapDataset> Map(std::vector<std::shared_ptr<TensorTransform>> operations, | std::shared_ptr<MapDataset> Map(std::vector<std::shared_ptr<TensorTransform>> operations, | ||||
| const std::vector<std::string> &input_columns = {}, | const std::vector<std::string> &input_columns = {}, | ||||
| const std::vector<std::string> &output_columns = {}, | const std::vector<std::string> &output_columns = {}, | ||||
| @@ -342,6 +358,22 @@ class Dataset : public std::enable_shared_from_this<Dataset> { | |||||
| callbacks); | callbacks); | ||||
| } | } | ||||
| /// \brief Function to create a MapDataset | |||||
| /// \notes Applies each operation in operations to this dataset | |||||
| /// \param[in] operations Vector of TensorTransform objects to be applied on the dataset. Operations are applied in | |||||
| /// the order they appear in this list | |||||
| /// \param[in] input_columns Vector of the names of the columns that will be passed to the first | |||||
| /// operation as input. The size of this list must match the number of | |||||
| /// input columns expected by the first operator. The default input_columns | |||||
| /// is the first column | |||||
| /// \param[in] output_columns Vector of names assigned to the columns outputted by the last operation | |||||
| /// This parameter is mandatory if len(input_columns) != len(output_columns) | |||||
| /// The size of this list must match the number of output columns of the | |||||
| /// last operation. The default output_columns will have the same | |||||
| /// name as the input columns, i.e., the columns will be replaced | |||||
| /// \param[in] project_columns A list of column names to project | |||||
| /// \param[in] cache Tensor cache to use. (default=nullptr which means no cache is used). | |||||
| /// \return Shared pointer to the current MapDataset | |||||
| std::shared_ptr<MapDataset> Map(const std::vector<std::reference_wrapper<TensorTransform>> operations, | std::shared_ptr<MapDataset> Map(const std::vector<std::reference_wrapper<TensorTransform>> operations, | ||||
| const std::vector<std::string> &input_columns = {}, | const std::vector<std::string> &input_columns = {}, | ||||
| const std::vector<std::string> &output_columns = {}, | const std::vector<std::string> &output_columns = {}, | ||||
| @@ -60,6 +60,7 @@ class BasicTokenizer : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~BasicTokenizer() = default; | ~BasicTokenizer() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -104,6 +105,7 @@ class BertTokenizer : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~BertTokenizer() = default; | ~BertTokenizer() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -123,6 +125,7 @@ class CaseFold : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~CaseFold() = default; | ~CaseFold() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| //// \return Shared pointer to TensorOperation object. | //// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -153,12 +156,13 @@ class JiebaTokenizer : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~JiebaTokenizer() = default; | ~JiebaTokenizer() = default; | ||||
| Status AddWord(const std::string &word, int64_t freq = 0); | |||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| Status AddWord(const std::string &word, int64_t freq = 0); | |||||
| private: | private: | ||||
| struct Data; | struct Data; | ||||
| std::shared_ptr<Data> data_; | std::shared_ptr<Data> data_; | ||||
| @@ -183,6 +187,7 @@ class Lookup : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~Lookup() = default; | ~Lookup() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -214,6 +219,7 @@ class Ngram : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~Ngram() = default; | ~Ngram() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -242,6 +248,7 @@ class NormalizeUTF8 : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~NormalizeUTF8() = default; | ~NormalizeUTF8() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -267,6 +274,7 @@ class RegexReplace : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~RegexReplace() = default; | ~RegexReplace() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -294,6 +302,7 @@ class RegexTokenizer : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~RegexTokenizer() = default; | ~RegexTokenizer() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -324,6 +333,7 @@ class SentencePieceTokenizer : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~SentencePieceTokenizer() = default; | ~SentencePieceTokenizer() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -346,6 +356,7 @@ class SlidingWindow : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~SlidingWindow() = default; | ~SlidingWindow() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -371,6 +382,7 @@ class ToNumber : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~ToNumber() = default; | ~ToNumber() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -390,6 +402,7 @@ class TruncateSequencePair : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~TruncateSequencePair() = default; | ~TruncateSequencePair() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -409,6 +422,7 @@ class UnicodeCharTokenizer : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~UnicodeCharTokenizer() = default; | ~UnicodeCharTokenizer() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -430,6 +444,7 @@ class UnicodeScriptTokenizer : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~UnicodeScriptTokenizer() = default; | ~UnicodeScriptTokenizer() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -449,6 +464,7 @@ class WhitespaceTokenizer : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~WhitespaceTokenizer() = default; | ~WhitespaceTokenizer() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -31,10 +31,32 @@ namespace dataset { | |||||
| class TensorOperation; | class TensorOperation; | ||||
| // We need the following two groups of forward declaration to friend the class in class TensorTransform. | |||||
| namespace transforms { | |||||
| class Compose; | |||||
| class RandomApply; | |||||
| class RandomChoice; | |||||
| } // namespace transforms | |||||
| namespace vision { | |||||
| class BoundingBoxAugment; | |||||
| class RandomSelectSubpolicy; | |||||
| class UniformAugment; | |||||
| } // namespace vision | |||||
| // Abstract class to represent a tensor transform operation in the data pipeline. | // Abstract class to represent a tensor transform operation in the data pipeline. | ||||
| /// \class TensorTransform transforms.h | /// \class TensorTransform transforms.h | ||||
| /// \brief A base class to represent a tensor transform operation in the data pipeline. | /// \brief A base class to represent a tensor transform operation in the data pipeline. | ||||
| class TensorTransform : public std::enable_shared_from_this<TensorTransform> { | class TensorTransform : public std::enable_shared_from_this<TensorTransform> { | ||||
| friend class Dataset; | |||||
| friend class Execute; | |||||
| friend class transforms::Compose; | |||||
| friend class transforms::RandomApply; | |||||
| friend class transforms::RandomChoice; | |||||
| friend class vision::BoundingBoxAugment; | |||||
| friend class vision::RandomSelectSubpolicy; | |||||
| friend class vision::UniformAugment; | |||||
| public: | public: | ||||
| /// \brief Constructor | /// \brief Constructor | ||||
| TensorTransform() {} | TensorTransform() {} | ||||
| @@ -42,6 +64,7 @@ class TensorTransform : public std::enable_shared_from_this<TensorTransform> { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~TensorTransform() = default; | ~TensorTransform() = default; | ||||
| protected: | |||||
| /// \brief Pure virtual function to convert a TensorTransform class into a IR TensorOperation object. | /// \brief Pure virtual function to convert a TensorTransform class into a IR TensorOperation object. | ||||
| /// \return shared pointer to the newly created TensorOperation. | /// \return shared pointer to the newly created TensorOperation. | ||||
| virtual std::shared_ptr<TensorOperation> Parse() = 0; | virtual std::shared_ptr<TensorOperation> Parse() = 0; | ||||
| @@ -60,14 +83,19 @@ namespace transforms { | |||||
| class Compose : public TensorTransform { | class Compose : public TensorTransform { | ||||
| public: | public: | ||||
| /// \brief Constructor. | /// \brief Constructor. | ||||
| /// \param[in] transforms A vector of transformations to be applied. | |||||
| /// \param[in] transforms A vector of raw pointers to TensorTransform objects to be applied. | |||||
| explicit Compose(const std::vector<TensorTransform *> &transforms); | explicit Compose(const std::vector<TensorTransform *> &transforms); | ||||
| /// \brief Constructor. | |||||
| /// \param[in] transforms A vector of shared pointers to TensorTransform objects to be applied. | |||||
| explicit Compose(const std::vector<std::shared_ptr<TensorTransform>> &transforms); | explicit Compose(const std::vector<std::shared_ptr<TensorTransform>> &transforms); | ||||
| /// \brief Constructor. | |||||
| /// \param[in] transforms A vector of TensorTransform objects to be applied. | |||||
| explicit Compose(const std::vector<std::reference_wrapper<TensorTransform>> &transforms); | explicit Compose(const std::vector<std::reference_wrapper<TensorTransform>> &transforms); | ||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~Compose() = default; | ~Compose() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -88,6 +116,7 @@ class Duplicate : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~Duplicate() = default; | ~Duplicate() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -104,6 +133,7 @@ class OneHot : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~OneHot() = default; | ~OneHot() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -118,15 +148,22 @@ class OneHot : public TensorTransform { | |||||
| class RandomApply : public TensorTransform { | class RandomApply : public TensorTransform { | ||||
| public: | public: | ||||
| /// \brief Constructor. | /// \brief Constructor. | ||||
| /// \param[in] transforms A vector of transformations to be applied. | |||||
| /// \param[in] transforms A vector of raw pointers to TensorTransform objects to be applied. | |||||
| /// \param[in] prob The probability to apply the transformation list (default=0.5) | /// \param[in] prob The probability to apply the transformation list (default=0.5) | ||||
| explicit RandomApply(const std::vector<TensorTransform *> &transforms, double prob = 0.5); | explicit RandomApply(const std::vector<TensorTransform *> &transforms, double prob = 0.5); | ||||
| /// \brief Constructor. | |||||
| /// \param[in] transforms A vector of shared pointers to TensorTransform objects to be applied. | |||||
| /// \param[in] prob The probability to apply the transformation list (default=0.5) | |||||
| explicit RandomApply(const std::vector<std::shared_ptr<TensorTransform>> &transforms, double prob = 0.5); | explicit RandomApply(const std::vector<std::shared_ptr<TensorTransform>> &transforms, double prob = 0.5); | ||||
| /// \brief Constructor. | |||||
| /// \param[in] transforms A vector of TensorTransform objects to be applied. | |||||
| /// \param[in] prob The probability to apply the transformation list (default=0.5) | |||||
| explicit RandomApply(const std::vector<std::reference_wrapper<TensorTransform>> &transforms, double prob = 0.5); | explicit RandomApply(const std::vector<std::reference_wrapper<TensorTransform>> &transforms, double prob = 0.5); | ||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~RandomApply() = default; | ~RandomApply() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -141,14 +178,19 @@ class RandomApply : public TensorTransform { | |||||
| class RandomChoice : public TensorTransform { | class RandomChoice : public TensorTransform { | ||||
| public: | public: | ||||
| /// \brief Constructor. | /// \brief Constructor. | ||||
| /// \param[in] transforms A vector of transformations to be chosen from to apply. | |||||
| /// \param[in] transforms A vector of raw pointers to TensorTransform objects to be applied. | |||||
| explicit RandomChoice(const std::vector<TensorTransform *> &transforms); | explicit RandomChoice(const std::vector<TensorTransform *> &transforms); | ||||
| /// \brief Constructor. | |||||
| /// \param[in] transforms A vector of shared pointers to TensorTransform objects to be applied. | |||||
| explicit RandomChoice(const std::vector<std::shared_ptr<TensorTransform>> &transforms); | explicit RandomChoice(const std::vector<std::shared_ptr<TensorTransform>> &transforms); | ||||
| /// \brief Constructor. | |||||
| /// \param[in] transforms A vector of TensorTransform objects to be applied. | |||||
| explicit RandomChoice(const std::vector<std::reference_wrapper<TensorTransform>> &transforms); | explicit RandomChoice(const std::vector<std::reference_wrapper<TensorTransform>> &transforms); | ||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~RandomChoice() = default; | ~RandomChoice() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -171,6 +213,7 @@ class TypeCast : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~TypeCast() = default; | ~TypeCast() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -191,6 +234,7 @@ class Unique : public TensorTransform { | |||||
| /// \brief Destructor | /// \brief Destructor | ||||
| ~Unique() = default; | ~Unique() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -48,6 +48,7 @@ class AutoContrast : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~AutoContrast() = default; | ~AutoContrast() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -79,6 +80,7 @@ class BoundingBoxAugment : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~BoundingBoxAugment() = default; | ~BoundingBoxAugment() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -102,6 +104,7 @@ class CutMixBatch : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~CutMixBatch() = default; | ~CutMixBatch() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -123,6 +126,7 @@ class CutOut : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~CutOut() = default; | ~CutOut() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -142,6 +146,7 @@ class Equalize : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~Equalize() = default; | ~Equalize() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -157,6 +162,7 @@ class HWC2CHW : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~HWC2CHW() = default; | ~HWC2CHW() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -172,6 +178,7 @@ class Invert : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~Invert() = default; | ~Invert() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -189,6 +196,7 @@ class MixUpBatch : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~MixUpBatch() = default; | ~MixUpBatch() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -219,6 +227,7 @@ class NormalizePad : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~NormalizePad() = default; | ~NormalizePad() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -255,6 +264,7 @@ class Pad : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~Pad() = default; | ~Pad() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -277,6 +287,7 @@ class RandomColor : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomColor() = default; | ~RandomColor() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -306,6 +317,7 @@ class RandomColorAdjust : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomColorAdjust() = default; | ~RandomColorAdjust() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -341,6 +353,7 @@ class RandomCrop : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomCrop() = default; | ~RandomCrop() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -373,6 +386,7 @@ class RandomCropDecodeResize : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomCropDecodeResize() = default; | ~RandomCropDecodeResize() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -410,6 +424,7 @@ class RandomCropWithBBox : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomCropWithBBox() = default; | ~RandomCropWithBBox() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -430,6 +445,7 @@ class RandomHorizontalFlip : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomHorizontalFlip() = default; | ~RandomHorizontalFlip() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -450,6 +466,7 @@ class RandomHorizontalFlipWithBBox : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomHorizontalFlipWithBBox() = default; | ~RandomHorizontalFlipWithBBox() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -470,6 +487,7 @@ class RandomPosterize : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomPosterize() = default; | ~RandomPosterize() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -492,6 +510,7 @@ class RandomResize : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomResize() = default; | ~RandomResize() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -515,6 +534,7 @@ class RandomResizeWithBBox : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomResizeWithBBox() = default; | ~RandomResizeWithBBox() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -546,6 +566,7 @@ class RandomResizedCrop : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomResizedCrop() = default; | ~RandomResizedCrop() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -577,6 +598,7 @@ class RandomResizedCropWithBBox : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomResizedCropWithBBox() = default; | ~RandomResizedCropWithBBox() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -605,6 +627,7 @@ class RandomRotation : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomRotation() = default; | ~RandomRotation() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -637,6 +660,7 @@ class RandomSelectSubpolicy : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomSelectSubpolicy() = default; | ~RandomSelectSubpolicy() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -658,6 +682,7 @@ class RandomSharpness : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomSharpness() = default; | ~RandomSharpness() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -679,6 +704,7 @@ class RandomSolarize : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomSolarize() = default; | ~RandomSolarize() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -699,6 +725,7 @@ class RandomVerticalFlip : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomVerticalFlip() = default; | ~RandomVerticalFlip() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -719,6 +746,7 @@ class RandomVerticalFlipWithBBox : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RandomVerticalFlipWithBBox() = default; | ~RandomVerticalFlipWithBBox() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -740,6 +768,7 @@ class Rescale : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~Rescale() = default; | ~Rescale() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -763,6 +792,7 @@ class ResizeWithBBox : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~ResizeWithBBox() = default; | ~ResizeWithBBox() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -782,6 +812,7 @@ class RGBA2BGR : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RGBA2BGR() = default; | ~RGBA2BGR() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -797,6 +828,7 @@ class RGBA2RGB : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~RGBA2RGB() = default; | ~RGBA2RGB() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -820,6 +852,7 @@ class SoftDvppDecodeRandomCropResizeJpeg : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~SoftDvppDecodeRandomCropResizeJpeg() = default; | ~SoftDvppDecodeRandomCropResizeJpeg() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -849,6 +882,7 @@ class SoftDvppDecodeResizeJpeg : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~SoftDvppDecodeResizeJpeg() = default; | ~SoftDvppDecodeResizeJpeg() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -868,6 +902,7 @@ class SwapRedBlue : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~SwapRedBlue() = default; | ~SwapRedBlue() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -895,6 +930,7 @@ class UniformAugment : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~UniformAugment() = default; | ~UniformAugment() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -43,6 +43,7 @@ class DvppDecodeResizeJpeg : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~DvppDecodeResizeJpeg() = default; | ~DvppDecodeResizeJpeg() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -64,6 +65,7 @@ class DvppDecodeResizeCropJpeg : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~DvppDecodeResizeCropJpeg() = default; | ~DvppDecodeResizeCropJpeg() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -83,6 +85,7 @@ class DvppDecodePng : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~DvppDecodePng() = default; | ~DvppDecodePng() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -79,6 +79,7 @@ class CenterCrop : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~CenterCrop() = default; | ~CenterCrop() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -104,6 +105,7 @@ class Crop : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~Crop() = default; | ~Crop() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -124,6 +126,7 @@ class Decode : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~Decode() = default; | ~Decode() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -149,6 +152,7 @@ class Normalize : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~Normalize() = default; | ~Normalize() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -212,6 +216,7 @@ class Resize : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~Resize() = default; | ~Resize() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -233,6 +238,7 @@ class Rotate : public TensorTransform { | |||||
| /// \brief Destructor. | /// \brief Destructor. | ||||
| ~Rotate() = default; | ~Rotate() = default; | ||||
| protected: | |||||
| /// \brief Function to convert TensorTransform object into a TensorOperation object. | /// \brief Function to convert TensorTransform object into a TensorOperation object. | ||||
| /// \return Shared pointer to TensorOperation object. | /// \return Shared pointer to TensorOperation object. | ||||
| std::shared_ptr<TensorOperation> Parse() override; | std::shared_ptr<TensorOperation> Parse() override; | ||||
| @@ -997,6 +997,25 @@ TEST_F(MindDataTestPipeline, TestMapDuplicateColumnFail) { | |||||
| EXPECT_EQ(iter3, nullptr); | EXPECT_EQ(iter3, nullptr); | ||||
| } | } | ||||
| TEST_F(MindDataTestPipeline, TestMapNullOperation) { | |||||
| MS_LOG(INFO) << "Doing MindDataTestPipeline-TestMapNullOperation."; | |||||
| // Create an ImageFolder Dataset | |||||
| std::string folder_path = datasets_root_path_ + "/testPK/data/"; | |||||
| std::shared_ptr<Dataset> ds = ImageFolder(folder_path, true, std::make_shared<RandomSampler>(false, 10)); | |||||
| EXPECT_NE(ds, nullptr); | |||||
| // Create a Map operation on ds | |||||
| std::shared_ptr<TensorTransform> operation = nullptr; | |||||
| auto ds1 = ds->Map({operation}, {"image"}, {}, {}); | |||||
| EXPECT_NE(ds1, nullptr); | |||||
| // Create an iterator over the result of the above dataset | |||||
| std::shared_ptr<Iterator> iter1 = ds1->CreateIterator(); | |||||
| // Expect failure: Operation is nullptr | |||||
| EXPECT_EQ(iter1, nullptr); | |||||
| } | |||||
| TEST_F(MindDataTestPipeline, TestProjectMapAutoInjection) { | TEST_F(MindDataTestPipeline, TestProjectMapAutoInjection) { | ||||
| MS_LOG(INFO) << "Doing MindDataTestPipeline.TestProjectMapAutoInjection"; | MS_LOG(INFO) << "Doing MindDataTestPipeline.TestProjectMapAutoInjection"; | ||||
| @@ -91,8 +91,9 @@ TEST_F(MindDataTestOptimizationPass, MindDataTestTensorFusionPassPreBuiltTensorO | |||||
| MS_LOG(INFO) << "Doing MindDataTestOptimizationPass-MindDataTestTensorFusionPassPreBuiltTensorOperation."; | MS_LOG(INFO) << "Doing MindDataTestOptimizationPass-MindDataTestTensorFusionPassPreBuiltTensorOperation."; | ||||
| std::string folder_path = datasets_root_path_ + "/testPK/data/"; | std::string folder_path = datasets_root_path_ + "/testPK/data/"; | ||||
| // make prebuilt tensor operation | // make prebuilt tensor operation | ||||
| auto decode = std::make_shared<transforms::PreBuiltOperation>(vision::Decode().Parse()->Build()); | |||||
| auto resize = std::make_shared<transforms::PreBuiltOperation>(vision::RandomResizedCrop({100}).Parse()->Build()); | |||||
| auto decode = std::make_shared<transforms::PreBuiltOperation>(vision::DecodeOperation(true).Build()); | |||||
| auto resize = std::make_shared<transforms::PreBuiltOperation>( | |||||
| vision::RandomResizedCropOperation({100}, {0.5}, {0.1}, InterpolationMode::kNearestNeighbour, 5).Build()); | |||||
| std::vector<std::shared_ptr<TensorOperation>> op_list = {decode, resize}; | std::vector<std::shared_ptr<TensorOperation>> op_list = {decode, resize}; | ||||
| std::vector<std::string> op_name = {"image"}; | std::vector<std::string> op_name = {"image"}; | ||||
| std::shared_ptr<DatasetNode> root = ImageFolder(folder_path, false)->IRNode(); | std::shared_ptr<DatasetNode> root = ImageFolder(folder_path, false)->IRNode(); | ||||