| @@ -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_)); | ||||
| @@ -281,8 +281,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 | ||||
| @@ -309,6 +309,22 @@ class Dataset : public std::enable_shared_from_this<Dataset> { | |||||
| project_columns, cache, callbacks); | project_columns, cache, 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 = {}, | ||||
| @@ -324,6 +340,22 @@ class Dataset : public std::enable_shared_from_this<Dataset> { | |||||
| project_columns, cache, callbacks); | project_columns, cache, 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 = {}, | ||||
| @@ -59,6 +59,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; | ||||
| @@ -99,6 +100,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; | ||||
| @@ -125,6 +127,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; | ||||
| @@ -151,12 +154,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: | ||||
| std::string hmm_path_; | std::string hmm_path_; | ||||
| std::string mp_path_; | std::string mp_path_; | ||||
| @@ -180,6 +184,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; | ||||
| @@ -208,6 +213,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; | ||||
| @@ -238,6 +244,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; | ||||
| @@ -259,6 +266,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; | ||||
| @@ -283,6 +291,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; | ||||
| @@ -311,6 +320,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; | ||||
| @@ -335,6 +345,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; | ||||
| @@ -358,6 +369,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; | ||||
| @@ -376,6 +388,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; | ||||
| @@ -394,6 +407,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; | ||||
| @@ -414,6 +428,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; | ||||
| @@ -433,6 +448,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; | ||||
| @@ -30,10 +30,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() {} | ||||
| @@ -41,6 +63,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; | ||||
| @@ -59,14 +82,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; | ||||
| @@ -86,6 +114,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; | ||||
| @@ -102,6 +131,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; | ||||
| @@ -115,15 +145,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; | ||||
| @@ -138,14 +175,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; | ||||
| @@ -165,6 +207,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; | ||||
| @@ -184,6 +227,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; | ||||
| @@ -47,6 +47,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; | ||||
| @@ -78,6 +79,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; | ||||
| @@ -101,6 +103,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; | ||||
| @@ -215,6 +223,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; | ||||
| @@ -252,6 +261,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; | ||||
| @@ -275,6 +285,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; | ||||
| @@ -304,6 +315,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; | ||||
| @@ -376,6 +389,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; | ||||
| @@ -416,6 +430,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; | ||||
| @@ -439,6 +454,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; | ||||
| @@ -458,6 +474,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; | ||||
| @@ -477,6 +494,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; | ||||
| @@ -498,6 +516,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; | ||||
| @@ -520,6 +539,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; | ||||
| @@ -550,6 +570,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; | ||||
| @@ -584,6 +605,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; | ||||
| @@ -615,6 +637,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; | ||||
| @@ -650,6 +673,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; | ||||
| @@ -670,6 +694,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; | ||||
| @@ -690,6 +715,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; | ||||
| @@ -709,6 +735,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; | ||||
| @@ -728,6 +755,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; | ||||
| @@ -748,6 +776,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; | ||||
| @@ -771,6 +800,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; | ||||
| @@ -790,6 +820,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; | ||||
| @@ -805,6 +836,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; | ||||
| @@ -828,6 +860,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; | ||||
| @@ -859,6 +892,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; | ||||
| @@ -877,6 +911,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; | ||||
| @@ -904,6 +939,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; | ||||
| @@ -47,6 +47,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; | ||||
| @@ -67,6 +68,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; | ||||
| @@ -86,6 +88,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; | ||||
| @@ -83,6 +83,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; | ||||
| @@ -107,6 +108,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; | ||||
| @@ -127,6 +129,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; | ||||
| @@ -151,6 +154,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; | ||||
| @@ -218,6 +222,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; | ||||
| @@ -239,6 +244,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(); | ||||