Make Parse() as protected
This commit is contained in:
parent
a5af03f8ca
commit
ccefa8b32e
|
|
@ -104,7 +104,13 @@ Status MapNode::ValidateParams() {
|
|||
RETURN_STATUS_SYNTAX_ERROR(err_msg);
|
||||
}
|
||||
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()) {
|
||||
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
|
||||
/// \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
|
||||
/// operation as input. The size of this list must match the number of
|
||||
/// 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);
|
||||
}
|
||||
|
||||
/// \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,
|
||||
const std::vector<std::string> &input_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);
|
||||
}
|
||||
|
||||
/// \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,
|
||||
const std::vector<std::string> &input_columns = {},
|
||||
const std::vector<std::string> &output_columns = {},
|
||||
|
|
|
|||
|
|
@ -59,6 +59,7 @@ class BasicTokenizer : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~BasicTokenizer() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -99,6 +100,7 @@ class BertTokenizer : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~BertTokenizer() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -125,6 +127,7 @@ class CaseFold : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~CaseFold() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
//// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -151,12 +154,13 @@ class JiebaTokenizer : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~JiebaTokenizer() = default;
|
||||
|
||||
Status AddWord(const std::string &word, int64_t freq = 0);
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
||||
Status AddWord(const std::string &word, int64_t freq = 0);
|
||||
|
||||
private:
|
||||
std::string hmm_path_;
|
||||
std::string mp_path_;
|
||||
|
|
@ -180,6 +184,7 @@ class Lookup : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~Lookup() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -208,6 +213,7 @@ class Ngram : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~Ngram() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -238,6 +244,7 @@ class NormalizeUTF8 : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~NormalizeUTF8() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -259,6 +266,7 @@ class RegexReplace : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~RegexReplace() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -283,6 +291,7 @@ class RegexTokenizer : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~RegexTokenizer() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -311,6 +320,7 @@ class SentencePieceTokenizer : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~SentencePieceTokenizer() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -335,6 +345,7 @@ class SlidingWindow : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~SlidingWindow() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -358,6 +369,7 @@ class ToNumber : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~ToNumber() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -376,6 +388,7 @@ class TruncateSequencePair : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~TruncateSequencePair() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -394,6 +407,7 @@ class UnicodeCharTokenizer : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~UnicodeCharTokenizer() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -414,6 +428,7 @@ class UnicodeScriptTokenizer : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~UnicodeScriptTokenizer() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -433,6 +448,7 @@ class WhitespaceTokenizer : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~WhitespaceTokenizer() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
|
|||
|
|
@ -30,10 +30,32 @@ namespace dataset {
|
|||
|
||||
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.
|
||||
/// \class TensorTransform transforms.h
|
||||
/// \brief A base class to represent a tensor transform operation in the data pipeline.
|
||||
class TensorTransform : public std::enable_shared_from_this<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:
|
||||
/// \brief Constructor
|
||||
TensorTransform() {}
|
||||
|
|
@ -41,6 +63,7 @@ class TensorTransform : public std::enable_shared_from_this<TensorTransform> {
|
|||
/// \brief Destructor
|
||||
~TensorTransform() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Pure virtual function to convert a TensorTransform class into a IR TensorOperation object.
|
||||
/// \return shared pointer to the newly created TensorOperation.
|
||||
virtual std::shared_ptr<TensorOperation> Parse() = 0;
|
||||
|
|
@ -59,14 +82,19 @@ namespace transforms {
|
|||
class Compose : public TensorTransform {
|
||||
public:
|
||||
/// \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);
|
||||
/// \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);
|
||||
/// \brief Constructor.
|
||||
/// \param[in] transforms A vector of TensorTransform objects to be applied.
|
||||
explicit Compose(const std::vector<std::reference_wrapper<TensorTransform>> &transforms);
|
||||
|
||||
/// \brief Destructor
|
||||
~Compose() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -86,6 +114,7 @@ class Duplicate : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~Duplicate() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -102,6 +131,7 @@ class OneHot : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~OneHot() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -115,15 +145,22 @@ class OneHot : public TensorTransform {
|
|||
class RandomApply : public TensorTransform {
|
||||
public:
|
||||
/// \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)
|
||||
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);
|
||||
/// \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);
|
||||
|
||||
/// \brief Destructor
|
||||
~RandomApply() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -138,14 +175,19 @@ class RandomApply : public TensorTransform {
|
|||
class RandomChoice : public TensorTransform {
|
||||
public:
|
||||
/// \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);
|
||||
/// \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);
|
||||
/// \brief Constructor.
|
||||
/// \param[in] transforms A vector of TensorTransform objects to be applied.
|
||||
explicit RandomChoice(const std::vector<std::reference_wrapper<TensorTransform>> &transforms);
|
||||
|
||||
/// \brief Destructor
|
||||
~RandomChoice() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -165,6 +207,7 @@ class TypeCast : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~TypeCast() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -184,6 +227,7 @@ class Unique : public TensorTransform {
|
|||
/// \brief Destructor
|
||||
~Unique() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class AutoContrast : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~AutoContrast() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -78,6 +79,7 @@ class BoundingBoxAugment : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~BoundingBoxAugment() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -101,6 +103,7 @@ class CutMixBatch : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~CutMixBatch() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -123,6 +126,7 @@ class CutOut : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~CutOut() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -142,6 +146,7 @@ class Equalize : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~Equalize() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -157,6 +162,7 @@ class HWC2CHW : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~HWC2CHW() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -172,6 +178,7 @@ class Invert : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~Invert() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -189,6 +196,7 @@ class MixUpBatch : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~MixUpBatch() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -215,6 +223,7 @@ class NormalizePad : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~NormalizePad() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -252,6 +261,7 @@ class Pad : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~Pad() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -275,6 +285,7 @@ class RandomColor : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomColor() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -304,6 +315,7 @@ class RandomColorAdjust : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomColorAdjust() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -341,6 +353,7 @@ class RandomCrop : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomCrop() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -376,6 +389,7 @@ class RandomCropDecodeResize : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomCropDecodeResize() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -416,6 +430,7 @@ class RandomCropWithBBox : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomCropWithBBox() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -439,6 +454,7 @@ class RandomHorizontalFlip : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomHorizontalFlip() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -458,6 +474,7 @@ class RandomHorizontalFlipWithBBox : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomHorizontalFlipWithBBox() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -477,6 +494,7 @@ class RandomPosterize : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomPosterize() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -498,6 +516,7 @@ class RandomResize : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomResize() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -520,6 +539,7 @@ class RandomResizeWithBBox : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomResizeWithBBox() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -550,6 +570,7 @@ class RandomResizedCrop : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomResizedCrop() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -584,6 +605,7 @@ class RandomResizedCropWithBBox : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomResizedCropWithBBox() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -615,6 +637,7 @@ class RandomRotation : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomRotation() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -650,6 +673,7 @@ class RandomSelectSubpolicy : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomSelectSubpolicy() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -670,6 +694,7 @@ class RandomSharpness : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomSharpness() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -690,6 +715,7 @@ class RandomSolarize : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomSolarize() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -709,6 +735,7 @@ class RandomVerticalFlip : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomVerticalFlip() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -728,6 +755,7 @@ class RandomVerticalFlipWithBBox : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RandomVerticalFlipWithBBox() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -748,6 +776,7 @@ class Rescale : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~Rescale() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -771,6 +800,7 @@ class ResizeWithBBox : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~ResizeWithBBox() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -790,6 +820,7 @@ class RGBA2BGR : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RGBA2BGR() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -805,6 +836,7 @@ class RGBA2RGB : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~RGBA2RGB() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -828,6 +860,7 @@ class SoftDvppDecodeRandomCropResizeJpeg : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~SoftDvppDecodeRandomCropResizeJpeg() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -859,6 +892,7 @@ class SoftDvppDecodeResizeJpeg : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~SoftDvppDecodeResizeJpeg() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -877,6 +911,7 @@ class SwapRedBlue : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~SwapRedBlue() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -904,6 +939,7 @@ class UniformAugment : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~UniformAugment() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ class DvppDecodeResizeJpeg : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~DvppDecodeResizeJpeg() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -67,6 +68,7 @@ class DvppDecodeResizeCropJpeg : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~DvppDecodeResizeCropJpeg() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -86,6 +88,7 @@ class DvppDecodePng : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~DvppDecodePng() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ class CenterCrop : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~CenterCrop() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -107,6 +108,7 @@ class Crop : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~Crop() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -127,6 +129,7 @@ class Decode : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~Decode() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -151,6 +154,7 @@ class Normalize : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~Normalize() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -218,6 +222,7 @@ class Resize : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~Resize() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
@ -239,6 +244,7 @@ class Rotate : public TensorTransform {
|
|||
/// \brief Destructor.
|
||||
~Rotate() = default;
|
||||
|
||||
protected:
|
||||
/// \brief Function to convert TensorTransform object into a TensorOperation object.
|
||||
/// \return Shared pointer to TensorOperation object.
|
||||
std::shared_ptr<TensorOperation> Parse() override;
|
||||
|
|
|
|||
|
|
@ -997,6 +997,25 @@ TEST_F(MindDataTestPipeline, TestMapDuplicateColumnFail) {
|
|||
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) {
|
||||
MS_LOG(INFO) << "Doing MindDataTestPipeline.TestProjectMapAutoInjection";
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,9 @@ TEST_F(MindDataTestOptimizationPass, MindDataTestTensorFusionPassPreBuiltTensorO
|
|||
MS_LOG(INFO) << "Doing MindDataTestOptimizationPass-MindDataTestTensorFusionPassPreBuiltTensorOperation.";
|
||||
std::string folder_path = datasets_root_path_ + "/testPK/data/";
|
||||
// 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::string> op_name = {"image"};
|
||||
std::shared_ptr<DatasetNode> root = ImageFolder(folder_path, false)->IRNode();
|
||||
|
|
|
|||
Loading…
Reference in New Issue