提交 84c8b85d 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!3452 [MD] Gets rid of uncessary print calls

Merge pull request !3452 from nhussain/refactor_name_function
......@@ -121,6 +121,10 @@ class BarrierOp : public PipelineOp {
// @param show_all - if it should print everything
void Print(std::ostream &out, bool show_all) const override;
// Op name getter
// @return Name of the current Op
std::string Name() const override { return kBarrierOp; }
// Provide stream operator for displaying it
friend std::ostream &operator<<(std::ostream &out, const BarrierOp &bo) {
bo.Print(out, false);
......
......@@ -136,7 +136,7 @@ Status BatchOp::operator()() {
void BatchOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <BatchOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
ParallelOp::Print(out, show_all);
......
......@@ -200,7 +200,7 @@ class BatchOp : public ParallelOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "BatchOp"; }
std::string Name() const override { return kBatchOp; }
// batch the rows in src table then put it to dest table
// @param const std::unique_ptr<TensorQTable> *src - table that has the rows for batching
......
......@@ -107,8 +107,6 @@ Status BucketBatchByLengthOp::EoeReceived(int32_t) {
return Status::OK();
}
void BucketBatchByLengthOp::Print(std::ostream &out, bool show_all) const { out << "BucketBatchByLengthOp\n"; }
Status BucketBatchByLengthOp::operator()() {
TaskManager::FindMe()->Post();
......
......@@ -109,10 +109,7 @@ class BucketBatchByLengthOp : public PipelineOp {
// @return Status - The error code returned
Status EoeReceived(int32_t) override;
// A print method typically used for debugging
// @param out - The output stream to write output to
// @param show_all - A bool to control if you want to show all info or just a summary
void Print(std::ostream &out, bool show_all) const override;
std::string Name() const override { return kBucketBatchByLengthOp; }
// << Stream output operator overload
// @notes This allows you to write the debug print info using stream operators
......
......@@ -157,6 +157,8 @@ class BuildSentencePieceVocabOp : public PipelineOp {
Status Reset() override { RETURN_STATUS_UNEXPECTED("Reset shouldn't be called in BuildSentencePieceVocabOp"); }
std::string Name() const override { return kBuildSentencePieceVocabOp; }
// build the input params for sentence api
std::unordered_map<std::string, std::string> BuildParams();
......
......@@ -208,7 +208,7 @@ BuildVocabOp::Builder::Builder()
// A print method typically used for debugging
void BuildVocabOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <BuildVocabOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
ParallelOp::Print(out, show_all);
......
......@@ -135,6 +135,7 @@ class BuildVocabOp : public ParallelOp {
/// \param[out] out The output stream to write output to
/// \param[in] show_all A bool to control if you want to show all info or just a summary
void Print(std::ostream &out, bool show_all) const override;
std::string Name() const override { return kBuildVocabOp; }
/// \briefStream output operator overload
/// \notes This allows you to write the debug print info using stream operators
......
......@@ -59,6 +59,9 @@ class CacheBase : public ParallelOp {
/// \param show_all A bool to control if you want to show all info or just a summary
void Print(std::ostream &out, bool show_all) const override;
/// \brief Gives a name to the class, typically used for debugging
std::string Name() const override { return kCacheBase; }
/// \brief << Stream output operator overload
/// \notes This allows you to write the debug print info using stream operators
/// \param out reference to the output stream being overloaded
......
......@@ -100,7 +100,7 @@ class CacheLookupOp : public CacheBase, public Sampler {
Status GetNextSample(std::unique_ptr<DataBuffer> *out_buffer) override;
void Print(std::ostream &out, bool show_all) const override;
bool AllowCacheMiss() override { return true; }
std::string Name() const override { return "CacheLookupOp"; }
std::string Name() const override { return kCacheLookupOp; }
/// \brief Base-class override for NodePass visitor acceptor
/// \param[in] p The node to visit
......
......@@ -30,7 +30,7 @@ namespace dataset {
CacheMergeOp::~CacheMergeOp() = default;
void CacheMergeOp::Print(std::ostream &out, bool show_all)
const { // Always show the id and name as first line regardless if this is summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <CacheMergeOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
ParallelOp::Print(out, show_all);
......
......@@ -140,6 +140,8 @@ class CacheMergeOp : public ParallelOp {
std::shared_ptr<CacheClient> cache_client, const std::shared_ptr<Sampler> &sampler);
~CacheMergeOp();
void Print(std::ostream &out, bool show_all) const override;
std::string Name() const override { return kCacheMergeOp; }
friend std::ostream &operator<<(std::ostream &out, const CacheMergeOp &mo) {
mo.Print(out, false);
return out;
......
......@@ -140,7 +140,7 @@ class CacheOp : public CacheBase, public RandomAccessOp {
/// \brief Base-class override for handling cases if we allow cache miss
bool AllowCacheMiss() override { return false; }
/// \brief Base-class override for the name of this operator
std::string Name() const override { return "CacheOp"; }
std::string Name() const override { return kCacheOp; }
/// \brief A public wrapper for creating the cache through the client
/// \param[in] cache_crc The crc that identifies the cache
/// \see cache_pass.cc
......
......@@ -43,7 +43,7 @@ ConcatOp::ConcatOp(int32_t op_connector_size) : PipelineOp(op_connector_size), c
// A function that prints info about the Operator
void ConcatOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this is summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <ConcatOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
PipelineOp::Print(out, show_all);
......
......@@ -77,7 +77,7 @@ class ConcatOp : public PipelineOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "ConcatOp"; }
std::string Name() const override { return kConcatOp; }
// Private function for computing the assignment of the column name map.
// @return - Status
......
......@@ -239,6 +239,8 @@ void DatasetOp::Print(std::ostream &out, bool show_all) const {
if (sampler_) {
sampler_->Print(out, show_all);
}
} else {
out << Name() << std::endl;
}
}
......
......@@ -28,6 +28,31 @@
namespace mindspore {
namespace dataset {
constexpr char kBarrierOp[] = "BarrierOp";
constexpr char kBatchOp[] = "BatchOp";
constexpr char kBucketBatchByLengthOp[] = "BucketBatchByLengthOp";
constexpr char kBuildSentencePieceVocabOp[] = "BuildSentencePieceVocabOp";
constexpr char kBuildVocabOp[] = "BuildVocabOp";
constexpr char kCacheBase[] = "CacheBase";
constexpr char kCacheLookupOp[] = "CacheLookupOp";
constexpr char kCacheMergeOp[] = "CacheMergeOp";
constexpr char kCacheOp[] = "CacheOp";
constexpr char kConcatOp[] = "ConcatOp";
constexpr char kDatasetOp[] = "DatasetOp";
constexpr char kDeviceQueueOp[] = "DeviceQueueOp";
constexpr char kEpochCtrlOp[] = "EpochCtrlOp";
constexpr char kFilterOp[] = "FilterOp";
constexpr char kMapOp[] = "MapOp";
constexpr char kParallelOp[] = "ParallelOp";
constexpr char kPipelineOp[] = "PipelineOp";
constexpr char kProjectOp[] = "ProjectOp";
constexpr char kRenameOp[] = "RenameOp";
constexpr char kRepeatOp[] = "RepeatOp";
constexpr char kShuffleOp[] = "ShuffleOp";
constexpr char kSkipOp[] = "SkipOp";
constexpr char kTakeOp[] = "TakeOp";
constexpr char kZipOp[] = "ZipOp";
// Forward declare
class ExecutionTree;
......@@ -292,7 +317,7 @@ class DatasetOp : public std::enable_shared_from_this<DatasetOp> {
/// Op name getter
/// \return Name of the current Op
virtual std::string Name() const { return "DatasetOp"; }
virtual std::string Name() const = 0;
/// Execution Tree getter
/// \return Pointer to the ExecutionTree the current op belongs to, no ownership
......
......@@ -308,7 +308,7 @@ Status DeviceQueueOp::SendDataToCPU() {
void DeviceQueueOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <DeviceQueueOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
PipelineOp::Print(out, show_all);
......
......@@ -146,7 +146,7 @@ class DeviceQueueOp : public PipelineOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "DeviceQueueOp"; }
std::string Name() const override { return kDeviceQueueOp; }
private:
// Name: checkExceptions(DataBuffer);
......
......@@ -43,7 +43,7 @@ EpochCtrlOp::~EpochCtrlOp() {}
// A print method typically used for debugging
void EpochCtrlOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <EpochCtrlOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
PipelineOp::Print(out, show_all);
......
......@@ -52,6 +52,7 @@ class EpochCtrlOp : public RepeatOp {
// @param out - The output stream to write output to
// @param show_all - A bool to control if you want to show all info or just a summary
void Print(std::ostream &out, bool show_all) const override;
std::string Name() const override { return kEpochCtrlOp; }
// This function returns the buffer that is at the top of our output connector. The caller is
// typically our parent node, when the parent is asking us to provide the next buffer of data.
......
......@@ -91,7 +91,7 @@ Status FilterOp::ValidateInColumns(const std::vector<std::string> *input_columns
// A print method typically used for debugging.
void FilterOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <FilterOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
ParallelOp::Print(out, show_all);
......
......@@ -129,7 +129,7 @@ class FilterOp : public ParallelOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "FilterOp"; }
std::string Name() const override { return kFilterOp; }
private:
// predicate_func python callable which returns a boolean value.
......
......@@ -84,7 +84,7 @@ int32_t MapOp::num_consumers() const {
// A print method typically used for debugging
void MapOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <MapOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
ParallelOp::Print(out, show_all);
......
......@@ -179,7 +179,7 @@ class MapOp : public ParallelOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "MapOp"; }
std::string Name() const override { return kMapOp; }
// List of tensor ops getter/setter
// @Return the vector of tensor ops by non-const reference
......
......@@ -17,6 +17,7 @@
#define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_DATASETOPS_PARALLEL_OP_H_
#include <memory>
#include <string>
#include <vector>
#include "minddata/dataset/core/constants.h"
#include "minddata/dataset/engine/datasetops/dataset_op.h"
......@@ -54,6 +55,7 @@ class ParallelOp : public DatasetOp {
// @param out - The output stream to write output to
// @param show_all - A bool to control if you want to show all info or just a summary
void Print(std::ostream &out, bool show_all) const override;
std::string Name() const override { return kParallelOp; }
// << Stream output operator overload
// @notes This allows you to write the debug print info using stream operators
......
......@@ -17,6 +17,7 @@
#define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_DATASETOPS_PIPELINE_OP_H_
#include <memory>
#include <string>
#include <vector>
#include "minddata/dataset/engine/datasetops/dataset_op.h"
......@@ -42,6 +43,7 @@ class PipelineOp : public DatasetOp {
// @param out - The output stream to write output to
// @param show_all - A bool to control if you want to show all info or just a summary
void Print(std::ostream &out, bool show_all) const override;
std::string Name() const override { return kPipelineOp; }
// << Stream output operator overload
// @notes This allows you to write the debug print info using stream operators
......
......@@ -52,7 +52,7 @@ ProjectOp::ProjectOp(const std::vector<std::string> &columns_to_project)
void ProjectOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <ProjectOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
PipelineOp::Print(out, show_all);
......
......@@ -109,7 +109,7 @@ class ProjectOp : public PipelineOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "ProjectOp"; }
std::string Name() const override { return kProjectOp; }
private:
std::vector<std::string> columns_to_project_;
......
......@@ -142,7 +142,7 @@ Status RenameOp::ComputeColMap() {
void RenameOp::Print(std::ostream &out, // In: The output stream to print to
bool show_all) const { // In: T/F if it should print everything
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <RenameOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
PipelineOp::Print(out, show_all);
......
......@@ -118,7 +118,7 @@ class RenameOp : public PipelineOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "RenameOp"; }
std::string Name() const override { return kRenameOp; }
protected:
// Rename core functionality
......
......@@ -54,7 +54,7 @@ RepeatOp::~RepeatOp() {}
// A print method typically used for debugging
void RepeatOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <RepeatOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
PipelineOp::Print(out, show_all);
......
......@@ -129,7 +129,7 @@ class RepeatOp : public PipelineOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "RepeatOp"; }
std::string Name() const override { return kRepeatOp; }
// \brief Adds an operator to the repeat ops list of tracked leaf/eoe nodes
// \param[in] eoe_op The input leaf/eoe operator to add to the list
......
......@@ -101,7 +101,7 @@ Status ShuffleOp::SelfReset() {
// A print method typically used for debugging
void ShuffleOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <ShuffleOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
PipelineOp::Print(out, show_all);
......
......@@ -163,7 +163,7 @@ class ShuffleOp : public PipelineOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "ShuffleOp"; }
std::string Name() const override { return kShuffleOp; }
private:
// Private function to add a new row to the shuffle buffer.
......
......@@ -59,7 +59,7 @@ SkipOp::~SkipOp() {}
// A print method typically used for debugging
void SkipOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <SkipOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
PipelineOp::Print(out, show_all);
......
......@@ -82,7 +82,7 @@ class SkipOp : public PipelineOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "SkipOp"; }
std::string Name() const override { return kSkipOp; }
private:
int32_t max_skips_; // The number of skips that the user requested
......
......@@ -54,7 +54,7 @@ TakeOp::TakeOp(int32_t count, int32_t op_connector_size)
// A print method typically used for debugging
void TakeOp::Print(std::ostream &out, bool show_all) const {
// Always show the id and name as first line regardless if this summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <TakeOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
PipelineOp::Print(out, show_all);
......
......@@ -86,7 +86,7 @@ class TakeOp : public PipelineOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "TakeOp"; }
std::string Name() const override { return kTakeOp; }
private:
int32_t max_takes_; // The number of takes that the user requested
......
......@@ -209,7 +209,7 @@ Status ZipOp::drainPipeline() {
void ZipOp::Print(std::ostream &out, // In: The output stream to print to
bool show_all) const { // In: T/F if it should print everything
// Always show the id and name as first line regardless if this is summary or detailed print
out << "(" << std::setw(2) << operator_id_ << ") <ZipOp>:";
out << "(" << std::setw(2) << operator_id_ << ") <" << Name() << ">:";
if (!show_all) {
// Call the super class for displaying any common 1-liner info
PipelineOp::Print(out, show_all);
......
......@@ -112,7 +112,7 @@ class ZipOp : public PipelineOp {
// Op name getter
// @return Name of the current Op
std::string Name() const override { return "ZipOp"; }
std::string Name() const override { return kZipOp; }
private:
// Handles preprocessing of the main loop, used when starting new epoch
......
......@@ -40,7 +40,6 @@ class ConcatenateOp : public TensorOp {
/// Print method to see which tensor Op this is.
/// @param std::ostream &out - output stream object.
void Print(std::ostream &out) const override { out << "ConcatenateOp"; }
/// Compute method allowing multiple tensors as inputs
/// @param TensorRow &input - input tensor rows
......
......@@ -32,8 +32,6 @@ class DuplicateOp : public TensorOp {
~DuplicateOp() override = default;
void Print(std::ostream &out) const override { out << "DuplicateOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
uint32_t NumOutput() override { return 2; }
......
......@@ -31,7 +31,6 @@ class FillOp : public TensorOp {
explicit FillOp(std::shared_ptr<Tensor> value) : fill_value_(value) {}
~FillOp() override = default;
void Print(std::ostream &out) const override { out << "FillOp"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
......
......@@ -37,8 +37,6 @@ class MaskOp : public TensorOp {
~MaskOp() override = default;
void Print(std::ostream &out) const override { out << "MaskOp"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
Status OutputType(const std::vector<DataType> &inputs, std::vector<DataType> &outputs) override;
......
......@@ -31,8 +31,6 @@ class OneHotOp : public TensorOp {
~OneHotOp() override = default;
void Print(std::ostream &out) const override { out << "OneHotOp"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
......
......@@ -32,8 +32,6 @@ class PadEndOp : public TensorOp {
~PadEndOp() override = default;
void Print(std::ostream &out) const override { out << "PadEndOp"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
......
......@@ -67,8 +67,6 @@ class SliceOp : public TensorOp {
~SliceOp() override = default;
void Print(std::ostream &out) const override { out << "SliceOp"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
std::string Name() const override { return kSliceOp; }
......
......@@ -39,8 +39,6 @@ class ToFloat16Op : public TensorOp {
// @return Status - The error code return
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
void Print(std::ostream &out) const override { out << "ToFloat16Op"; }
Status OutputType(const std::vector<DataType> &inputs, std::vector<DataType> &outputs) override;
std::string Name() const override { return kToFloat16Op; }
......
......@@ -39,7 +39,6 @@ class TypeCastOp : public TensorOp {
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
void Print(std::ostream &out) const override { out << "TypeCastOp"; }
Status OutputType(const std::vector<DataType> &inputs, std::vector<DataType> &outputs) override;
std::string Name() const override { return kTypeCastOp; }
......
......@@ -45,8 +45,6 @@ class AutoContrastOp : public TensorOp {
return out;
}
void Print(std::ostream &out) const override { out << Name(); }
std::string Name() const override { return kAutoContrastOp; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
......
......@@ -47,8 +47,6 @@ class BoundingBoxAugmentOp : public TensorOp {
return out;
}
void Print(std::ostream &out) const override { out << "BoundingBoxAugmentOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
std::string Name() const override { return kBoundingBoxAugmentOp; }
......
......@@ -37,7 +37,6 @@ class DecodeOp : public TensorOp {
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
void Print(std::ostream &out) const override { out << "DecodeOp"; }
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
Status OutputType(const std::vector<DataType> &inputs, std::vector<DataType> &outputs) override;
......
......@@ -32,9 +32,6 @@ class EqualizeOp : public TensorOp {
EqualizeOp() {}
~EqualizeOp() = default;
// Description: A function that prints info about the node
void Print(std::ostream &out) const override { out << Name(); }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
std::string Name() const override { return kEqualizeOp; }
......
......@@ -28,8 +28,6 @@ namespace mindspore {
namespace dataset {
class HwcToChwOp : public TensorOp {
public:
void Print(std::ostream &out) const override { out << "HwcToChw"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
......
......@@ -31,9 +31,6 @@ class InvertOp : public TensorOp {
InvertOp() {}
~InvertOp() = default;
// Description: A function that prints info about the node
void Print(std::ostream &out) const override { out << Name(); }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
std::string Name() const override { return kInvertOp; }
......
......@@ -49,8 +49,6 @@ class PadOp : public TensorOp {
~PadOp() override = default;
void Print(std::ostream &out) const override { out << "PadOp: "; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
......
......@@ -47,10 +47,6 @@ class RandomColorAdjustOp : public TensorOp {
~RandomColorAdjustOp() override = default;
// Print function for RandomJitter.
// @param out output stream to print to.
void Print(std::ostream &out) const override { out << "RandomColorAdjustOp: "; }
// Overrides the base class compute function.
// Calls multiple transform functions in ImageUtils, this function takes an input tensor.
// and transforms its data using openCV, the output memory is manipulated to contain the result.
......
......@@ -40,8 +40,7 @@ class RandomCropDecodeResizeOp : public RandomCropAndResizeOp {
~RandomCropDecodeResizeOp() override = default;
void Print(std::ostream &out) const override {
out << "RandomCropDecodeResize: " << RandomCropAndResizeOp::target_height_ << " "
<< RandomCropAndResizeOp::target_width_;
out << Name() << ": " << RandomCropAndResizeOp::target_height_ << " " << RandomCropAndResizeOp::target_width_;
}
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
......
......@@ -52,7 +52,7 @@ class RandomCropOp : public TensorOp {
~RandomCropOp() override = default;
void Print(std::ostream &out) const override { out << "RandomCropOp: " << crop_height_ << " " << crop_width_; }
void Print(std::ostream &out) const override { out << Name() << ": " << crop_height_ << " " << crop_width_; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
......
......@@ -38,7 +38,7 @@ class RandomCropWithBBoxOp : public RandomCropOp {
~RandomCropWithBBoxOp() override = default;
void Print(std::ostream &out) const override {
out << "RandomCropWithBBoxOp: " << RandomCropOp::crop_height_ << " " << RandomCropOp::crop_width_;
out << Name() << ": " << RandomCropOp::crop_height_ << " " << RandomCropOp::crop_width_;
}
Status Compute(const TensorRow &input, TensorRow *output) override;
......
......@@ -44,8 +44,6 @@ class RandomHorizontalFlipOp : public TensorOp {
return out;
}
void Print(std::ostream &out) const override { out << "RandomHorizontalFlipOp"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
std::string Name() const override { return kRandomHorizontalFlipOp; }
......
......@@ -45,8 +45,6 @@ class RandomHorizontalFlipWithBBoxOp : public TensorOp {
return out;
}
void Print(std::ostream &out) const override { out << "RandomHorizontalFlipWithBBoxOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
std::string Name() const override { return kRandomHorizontalFlipWithBBoxOp; }
......
......@@ -40,9 +40,7 @@ class RandomResizeOp : public ResizeOp {
~RandomResizeOp() = default;
// Description: A function that prints info about the node
void Print(std::ostream &out) const override {
out << "RandomResizeOp: " << ResizeOp::size1_ << " " << ResizeOp::size2_;
}
void Print(std::ostream &out) const override { out << Name() << ": " << ResizeOp::size1_ << " " << ResizeOp::size2_; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
......
......@@ -42,7 +42,7 @@ class RandomResizeWithBBoxOp : public ResizeWithBBoxOp {
// Description: A function that prints info about the node
void Print(std::ostream &out) const override {
out << "RandomResizeWithBBoxOp: " << ResizeWithBBoxOp::size1_ << " " << ResizeWithBBoxOp::size2_;
out << Name() << ": " << ResizeWithBBoxOp::size1_ << " " << ResizeWithBBoxOp::size2_;
}
Status Compute(const TensorRow &input, TensorRow *output) override;
......
......@@ -58,10 +58,6 @@ class RandomRotationOp : public TensorOp {
~RandomRotationOp() override = default;
// Print function for RandomRotation
// @param out output stream to print to
void Print(std::ostream &out) const override { out << "RandomRotationOp: "; }
// Overrides the base class compute function
// Calls the rotate function in ImageUtils, this function takes an input tensor
// and transforms its data using openCV, the output memory is manipulated to contain the result
......
......@@ -38,8 +38,6 @@ class RandomVerticalFlipOp : public TensorOp {
~RandomVerticalFlipOp() override = default;
void Print(std::ostream &out) const override { out << "RandomVerticalFlipOp"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
std::string Name() const override { return kRandomVerticalFlipOp; }
......
......@@ -39,8 +39,6 @@ class RandomVerticalFlipWithBBoxOp : public TensorOp {
~RandomVerticalFlipWithBBoxOp() override = default;
void Print(std::ostream &out) const override { out << "RandomVerticalFlipWithBBoxOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
std::string Name() const override { return kRandomVerticalFlipWithBBoxOp; }
......
......@@ -33,7 +33,7 @@ class RescaleOp : public TensorOp {
~RescaleOp() override = default;
void Print(std::ostream &out) const override {
out << "RescaleOp: shift: " << shift_ << ", Rescale: " << rescale_ << std::endl;
out << Name() << ": shift: " << shift_ << ", Rescale: " << rescale_ << std::endl;
}
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
......
......@@ -22,6 +22,5 @@ namespace mindspore {
namespace dataset {
const int32_t ResizeBilinearOp::kDefWidth = 0;
void ResizeBilinearOp::Print(std::ostream &out) const { out << "ResizeBilinearOp: "; }
} // namespace dataset
} // namespace mindspore
......@@ -48,10 +48,6 @@ class ResizeBilinearOp : public ResizeOp {
// Description: Destructor
~ResizeBilinearOp() = default;
// Name: Print()
// Description: A function that prints info about the node
void Print(std::ostream &out) const override;
std::string Name() const override { return kResizeBilinearOp; }
};
} // namespace dataset
......
......@@ -50,7 +50,7 @@ class ResizeOp : public TensorOp {
~ResizeOp() override = default;
void Print(std::ostream &out) const override { out << "ResizeOp: " << size1_ << " " << size2_; }
void Print(std::ostream &out) const override { out << Name() << ": " << size1_ << " " << size2_; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
......
......@@ -34,7 +34,7 @@ class ResizeWithBBoxOp : public ResizeOp {
~ResizeWithBBoxOp() override = default;
void Print(std::ostream &out) const override { out << "ResizeWithBBoxOp: " << size1_ << " " << size2_; }
void Print(std::ostream &out) const override { out << Name() << ": " << size1_ << " " << size2_; }
Status Compute(const TensorRow &input, TensorRow *output) override;
......
......@@ -40,7 +40,7 @@ class UniformAugOp : public TensorOp {
// Destructor
~UniformAugOp() override = default;
void Print(std::ostream &out) const override { out << "UniformAugOp:: number of ops " << num_ops_; }
void Print(std::ostream &out) const override { out << Name() << ":: number of ops " << num_ops_; }
// Overrides the base class compute function
// @return Status - The error code return
......
......@@ -31,8 +31,6 @@ class NoOp : public TensorOp {
return Status::OK();
}
void Print(std::ostream &out) const override { out << "NoOp"; };
std::string Name() const override { return kNoOp; }
};
} // namespace dataset
......
......@@ -48,8 +48,6 @@ Status TensorOp::Compute(const TensorRow &input, TensorRow *output) {
"Is this TensorOp oneToOne? If no, please implement this Compute() in the derived class.");
}
void TensorOp::Print(std::ostream &out) const { out << "TensorOp" << std::endl; }
Status TensorOp::OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) {
if (inputs.size() != NumInput())
return Status(StatusCode::kUnexpectedError,
......
......@@ -86,6 +86,9 @@
namespace mindspore {
namespace dataset {
// base class
constexpr char kTensorOp[] = "TensorOp";
// image
constexpr char kAutoContrastOp[] = "AutoContrastOp";
constexpr char kBoundingBoxAugmentOp[] = "BoundingBoxAugmentOp";
......@@ -142,7 +145,7 @@ constexpr char kRandomSelectSubpolicyOp[] = "RandomSelectSubpolicyOp";
constexpr char kSentencepieceTokenizerOp[] = "SentencepieceTokenizerOp";
// data
constexpr char kConcatenateOp[] = "kConcatenateOp";
constexpr char kConcatenateOp[] = "ConcatenateOp";
constexpr char kDuplicateOp[] = "DuplicateOp";
constexpr char kFillOp[] = "FillOp";
constexpr char kMaskOp[] = "MaskOp";
......@@ -165,7 +168,7 @@ class TensorOp {
// A function that prints info about the tensor operation
// @param out
virtual void Print(std::ostream &out) const;
virtual void Print(std::ostream &out) const { out << Name() << std::endl; }
// Provide stream operator for displaying it
// @param output stream
......
......@@ -45,8 +45,6 @@ class BasicTokenizerOp : public TensorOp {
~BasicTokenizerOp() override = default;
void Print(std::ostream &out) const override { out << "BasicTokenizerOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
protected:
......
......@@ -42,8 +42,6 @@ class BertTokenizerOp : public TensorOp {
~BertTokenizerOp() override = default;
void Print(std::ostream &out) const override { out << "BertTokenizerOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
std::string Name() const override { return kBertTokenizerOp; }
......
......@@ -31,8 +31,6 @@ class CaseFoldOp : public TensorOp {
~CaseFoldOp() override = default;
void Print(std::ostream &out) const override { out << "CaseFoldOp"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
std::string Name() const override { return kCaseFoldOp; }
......
......@@ -46,8 +46,7 @@ class JiebaTokenizerOp : public TensorOp {
~JiebaTokenizerOp() override = default;
void Print(std::ostream &out) const override {
out << "JiebaTokenizerOp: " << jieba_mode_ << "hmm_model_path_ " << hmm_model_path_ << "mp_dict_path_"
<< mp_dict_path_;
out << Name() << ": " << jieba_mode_ << "hmm_model_path_ " << hmm_model_path_ << "mp_dict_path_" << mp_dict_path_;
}
Status Compute(const TensorRow &input, TensorRow *output) override;
......
......@@ -39,8 +39,6 @@ class NormalizeUTF8Op : public TensorOp {
~NormalizeUTF8Op() override = default;
void Print(std::ostream &out) const override { out << "NormalizeUTF8Op"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
std::string Name() const override { return kNormalizeUTF8Op; }
......
......@@ -38,8 +38,6 @@ class RegexReplaceOp : public TensorOp {
~RegexReplaceOp() override = default;
void Print(std::ostream &out) const override { out << "RegexReplaceOp"; }
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
std::string Name() const override { return kRegexReplaceOp; }
......
......@@ -43,8 +43,6 @@ class RegexTokenizerOp : public TensorOp {
~RegexTokenizerOp() override = default;
void Print(std::ostream &out) const override { out << "RegexTokenizerOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
protected:
......
......@@ -45,7 +45,7 @@ class SentencePieceTokenizerOp : public TensorOp {
Status GetModelRealPath(const std::string &model_path, const std::string &filename);
void Print(std::ostream &out) const override {
out << "SentencePieceTokenizerOp out_type = " << out_type_ << " load_type = " << load_type_;
out << Name() << " out_type = " << out_type_ << " load_type = " << load_type_;
}
Status Compute(const std::shared_ptr<Tensor> &input, std::shared_ptr<Tensor> *output) override;
......
......@@ -52,10 +52,6 @@ class SlidingWindowOp : public TensorOp {
/// \return Status return code
Status OutputShape(const std::vector<TensorShape> &inputs, std::vector<TensorShape> &outputs) override;
/// \brief Print args for debugging.
/// \param[in] out - std::ostream &out.
void Print(std::ostream &out) const override { out << "SliceWindowOp"; }
/// \brief Print name of op.
std::string Name() const override { return kSlidingWindowOp; }
......
......@@ -36,8 +36,6 @@ class TruncateSequencePairOp : public TensorOp {
~TruncateSequencePairOp() override = default;
void Print(std::ostream &out) const override { out << "TruncateSequencePairOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
std::string Name() const override { return kTruncateSequencePairOp; }
......
......@@ -33,8 +33,6 @@ class UnicodeCharTokenizerOp : public TensorOp {
~UnicodeCharTokenizerOp() override = default;
void Print(std::ostream &out) const override { out << "UnicodeCharTokenizerOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
std::string Name() const override { return kUnicodeCharTokenizerOp; }
......
......@@ -36,8 +36,6 @@ class UnicodeScriptTokenizerOp : public TensorOp {
~UnicodeScriptTokenizerOp() override = default;
void Print(std::ostream &out) const override { out << "UnicodeScriptTokenizerOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
std::string Name() const override { return kUnicodeScriptTokenizerOp; }
......
......@@ -33,8 +33,6 @@ class WhitespaceTokenizerOp : public TensorOp {
~WhitespaceTokenizerOp() override = default;
void Print(std::ostream &out) const override { out << "WhitespaceTokenizerOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
std::string Name() const override { return kWhitespaceTokenizerOp; }
......
......@@ -44,8 +44,6 @@ class WordpieceTokenizerOp : public TensorOp {
~WordpieceTokenizerOp() override = default;
void Print(std::ostream &out) const override { out << "WordpieceTokenizerOp"; }
Status Compute(const TensorRow &input, TensorRow *output) override;
protected:
......
......@@ -78,7 +78,10 @@ std::shared_ptr<de::ExecutionTree> Build(std::vector<std::shared_ptr<de::Dataset
TEST_F(MindDataTestBatchOp, TestSimpleBatch) {
std::string schema_file = datasets_root_path_ + "/testBatchDataset/test.data";
bool success = false;
auto tree = Build({TFReader(schema_file), Batch(12)});
const std::shared_ptr<de::BatchOp> &op = Batch(12);
EXPECT_EQ(op->Name(), "BatchOp");
auto tree = Build({TFReader(schema_file), op});
tree->Prepare();
Status rc = tree->Launch();
if (rc.IsError()) {
......
......@@ -55,13 +55,5 @@ TEST_F(MindDataTestConcatenateOp, TestOp) {
ASSERT_TRUE(output->type() == expected->type());
MS_LOG(DEBUG) << *output << std::endl;
MS_LOG(DEBUG) << *expected << std::endl;
ASSERT_TRUE(*output == *expected);
// std::vector<TensorShape> inputs = {TensorShape({3})};
// std::vector<TensorShape> outputs = {};
// s = op->OutputShape(inputs, outputs);
// EXPECT_TRUE(s.IsOk());
// ASSERT_TRUE(outputs[0] == TensorShape{6});
// MS_LOG(INFO) << "MindDataTestConcatenateOp-TestOp end.";
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册