!9340 Rename SamplerRT Print() to SamplerPrint()

From: @lixiachen
Reviewed-by: @nsyca,@mikef
Signed-off-by: @nsyca
This commit is contained in:
mindspore-ci-bot 2020-12-03 23:15:58 +08:00 committed by Gitee
commit 6ec8b97963
19 changed files with 34 additions and 25 deletions

View File

@ -89,6 +89,14 @@ Status CacheLookupOp::HandshakeRandomAccessOp(const RandomAccessOp *op) {
}
Status CacheLookupOp::InitSampler() { return SamplerRT::InitSampler(); }
void CacheLookupOp::Print(std::ostream &out, bool show_all) const { CacheBase::Print(out, show_all); }
void CacheLookupOp::SamplerPrint(std::ostream &out, bool show_all) const {
out << "\nSampler: CacheLookupOp";
if (show_all) {
// Call the super class for displaying any common detailed info
SamplerRT::SamplerPrint(out, show_all);
// Then add our own info if any
}
}
Status CacheLookupOp::GetNextSample(std::unique_ptr<DataBuffer> *out_buffer) {
std::vector<row_id_type> cache_miss;
RETURN_IF_NOT_OK(keys_miss_->Pop(0, &cache_miss));

View File

@ -99,6 +99,7 @@ class CacheLookupOp : public CacheBase, public SamplerRT {
Status InitSampler() override;
Status GetNextSample(std::unique_ptr<DataBuffer> *out_buffer) override;
void Print(std::ostream &out, bool show_all) const override;
void SamplerPrint(std::ostream &out, bool show_all) const override;
bool AllowCacheMiss() override { return true; }
std::string Name() const override { return kCacheLookupOp; }

View File

@ -252,7 +252,7 @@ void DatasetOp::Print(std::ostream &out, bool show_all) const {
<< "\nNumber repeats per epoch : " << op_num_repeats_per_epoch_;
if (sampler_) {
out << "\nSampler:\n";
sampler_->Print(out, show_all);
sampler_->SamplerPrint(out, show_all);
}
}
}

View File

@ -170,10 +170,10 @@ int64_t DistributedSamplerRT::CalculateNumSamples(int64_t num_rows) {
return std::ceil(num_samples * 1.0 / num_devices_);
}
void DistributedSamplerRT::Print(std::ostream &out, bool show_all) const {
void DistributedSamplerRT::SamplerPrint(std::ostream &out, bool show_all) const {
out << "\nSampler: DistributedSampler";
if (show_all) {
SamplerRT::Print(out, show_all);
SamplerRT::SamplerPrint(out, show_all);
out << "\nseed: " << seed_ << "\ndevice_id: " << device_id_ << "\nnum_devices: " << num_devices_
<< "\nshuffle: " << shuffle_;
}

View File

@ -70,7 +70,7 @@ class DistributedSamplerRT : public SamplerRT {
/// \return int64_t Calculated number of samples
int64_t CalculateNumSamples(int64_t num_rows) override;
void Print(std::ostream &out, bool show_all) const override;
void SamplerPrint(std::ostream &out, bool show_all) const override;
private:
int64_t cnt_; // number of samples that have already been filled in to buffer

View File

@ -116,11 +116,11 @@ Status PKSamplerRT::HandshakeRandomAccessOp(const RandomAccessOp *op) {
return Status::OK();
}
void PKSamplerRT::Print(std::ostream &out, bool show_all) const {
void PKSamplerRT::SamplerPrint(std::ostream &out, bool show_all) const {
out << "\nSampler: PKSampler";
if (show_all) {
// Call the super class for displaying any common detailed info
SamplerRT::Print(out, show_all);
SamplerRT::SamplerPrint(out, show_all);
// Then add our own info if any
}
}

View File

@ -59,7 +59,7 @@ class PKSamplerRT : public SamplerRT { // NOT YET FINISHED
// Printer for debugging purposes.
// @param out - output stream to write to
// @param show_all - bool to show detailed vs summary
void Print(std::ostream &out, bool show_all) const override;
void SamplerPrint(std::ostream &out, bool show_all) const override;
private:
bool shuffle_;

View File

@ -106,11 +106,11 @@ Status PythonSamplerRT::ResetSampler() {
return Status::OK();
}
void PythonSamplerRT::Print(std::ostream &out, bool show_all) const {
void PythonSamplerRT::SamplerPrint(std::ostream &out, bool show_all) const {
out << "\nSampler: PythonSampler";
if (show_all) {
// Call the super class for displaying any common detailed info
SamplerRT::Print(out, show_all);
SamplerRT::SamplerPrint(out, show_all);
// Then add our own info if any
}
}

View File

@ -53,7 +53,7 @@ class PythonSamplerRT : public SamplerRT {
// Printer for debugging purposes.
// @param out - output stream to write to
// @param show_all - bool to show detailed vs summary
void Print(std::ostream &out, bool show_all) const override;
void SamplerPrint(std::ostream &out, bool show_all) const override;
private:
bool need_to_reset_; // Whether Reset() should be called before calling GetNextBuffer()

View File

@ -115,11 +115,11 @@ Status RandomSamplerRT::ResetSampler() {
return Status::OK();
}
void RandomSamplerRT::Print(std::ostream &out, bool show_all) const {
void RandomSamplerRT::SamplerPrint(std::ostream &out, bool show_all) const {
out << "\nSampler: RandomSampler";
if (show_all) {
// Call the super class for displaying any common detailed info
SamplerRT::Print(out, show_all);
SamplerRT::SamplerPrint(out, show_all);
// Then add our own info if any
}
}

View File

@ -50,7 +50,7 @@ class RandomSamplerRT : public SamplerRT {
// @return - The error code return
Status ResetSampler() override;
void Print(std::ostream &out, bool show_all) const override;
void SamplerPrint(std::ostream &out, bool show_all) const override;
private:
uint32_t seed_;

View File

@ -78,7 +78,7 @@ Status SamplerRT::CreateSamplerTensor(std::shared_ptr<Tensor> *sample_ids, int64
return Status::OK();
}
void SamplerRT::Print(std::ostream &out, bool show_all) const {
void SamplerRT::SamplerPrint(std::ostream &out, bool show_all) const {
// Sampler printing is usually only called in the show_all mode.
// Derived classes will display the name, then call back to this base
// for common info.

View File

@ -126,7 +126,7 @@ class SamplerRT {
// 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
virtual void Print(std::ostream &out, bool show_all) const;
virtual void SamplerPrint(std::ostream &out, bool show_all) const;
// << Stream output operator overload
// @notes This allows you to write the debug print info using stream operators
@ -134,7 +134,7 @@ class SamplerRT {
// @param sampler - reference to teh sampler to print
// @return - the output stream must be returned
friend std::ostream &operator<<(std::ostream &out, const SamplerRT &sampler) {
sampler.Print(out, false);
sampler.SamplerPrint(out, false);
return out;
}

View File

@ -97,11 +97,11 @@ Status SequentialSamplerRT::ResetSampler() {
return Status::OK();
}
void SequentialSamplerRT::Print(std::ostream &out, bool show_all) const {
void SequentialSamplerRT::SamplerPrint(std::ostream &out, bool show_all) const {
out << "\nSampler: SequentialSampler";
if (show_all) {
// Call the super class for displaying any common detailed info
SamplerRT::Print(out, show_all);
SamplerRT::SamplerPrint(out, show_all);
// Then add our own info
out << "\nStart index: " << start_index_;
}

View File

@ -52,7 +52,7 @@ class SequentialSamplerRT : public SamplerRT {
// Printer for debugging purposes.
// @param out - output stream to write to
// @param show_all - bool to show detailed vs summary
void Print(std::ostream &out, bool show_all) const override;
void SamplerPrint(std::ostream &out, bool show_all) const override;
private:
int64_t current_id_; // The id sequencer. Each new id increments from this

View File

@ -119,11 +119,11 @@ Status SubsetRandomSamplerRT::GetNextSample(std::unique_ptr<DataBuffer> *out_buf
return Status::OK();
}
void SubsetRandomSamplerRT::Print(std::ostream &out, bool show_all) const {
void SubsetRandomSamplerRT::SamplerPrint(std::ostream &out, bool show_all) const {
out << "\nSampler: SubsetRandomSampler";
if (show_all) {
// Call the super class for displaying any common detailed info
SamplerRT::Print(out, show_all);
SamplerRT::SamplerPrint(out, show_all);
// Then add our own info if any
}
}

View File

@ -54,7 +54,7 @@ class SubsetRandomSamplerRT : public SamplerRT {
// Printer for debugging purposes.
// @param out - output stream to write to
// @param show_all - bool to show detailed vs summary
void Print(std::ostream &out, bool show_all) const override;
void SamplerPrint(std::ostream &out, bool show_all) const override;
private:
// A list of indices (already randomized in constructor).

View File

@ -181,11 +181,11 @@ Status WeightedRandomSamplerRT::GetNextSample(std::unique_ptr<DataBuffer> *out_b
return Status::OK();
}
void WeightedRandomSamplerRT::Print(std::ostream &out, bool show_all) const {
void WeightedRandomSamplerRT::SamplerPrint(std::ostream &out, bool show_all) const {
out << "\nSampler: WeightedRandomSampler";
if (show_all) {
// Call the super class for displaying any common detailed info
SamplerRT::Print(out, show_all);
SamplerRT::SamplerPrint(out, show_all);
// Then add our own info if any
}
}

View File

@ -56,7 +56,7 @@ class WeightedRandomSamplerRT : public SamplerRT {
// Printer for debugging purposes.
// @param out - output stream to write to
// @param show_all - bool to show detailed vs summary
void Print(std::ostream &out, bool show_all) const override;
void SamplerPrint(std::ostream &out, bool show_all) const override;
private:
// A list of weights for each sample.