!3452 [MD] Gets rid of uncessary print calls

Merge pull request !3452 from nhussain/refactor_name_function
pull/3452/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit 84c8b85ddc

@ -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

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save