MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / DatasetBaseIterator

Class DatasetBaseIterator

tensorflow/core/framework/dataset.h:788–919  ·  view source on GitHub ↗

Represents an iterator that is associated with a particular dataset.

Source from the content-addressed store, hash-verified

786
787// Represents an iterator that is associated with a particular dataset.
788class DatasetBaseIterator : public IteratorBase {
789 public:
790 struct BaseParams {
791 // Owns one reference on the shared dataset object.
792 const DatasetBase* dataset;
793
794 // Identifies the sequence of iterators leading up to this iterator.
795 const string prefix;
796 };
797
798 explicit DatasetBaseIterator(const BaseParams& params) : params_(params) {
799 params_.dataset->Ref();
800 }
801
802 ~DatasetBaseIterator() override { params_.dataset->Unref(); }
803
804 const DataTypeVector& output_dtypes() const override {
805 return params_.dataset->output_dtypes();
806 }
807
808 const std::vector<PartialTensorShape>& output_shapes() const override {
809 return params_.dataset->output_shapes();
810 }
811
812 // The sequence of iterators leading up to this iterator.
813 const string& prefix() const override { return params_.prefix; }
814
815 // Returns a name to be used for the TraceMe event.
816 //
817 // NOTE: TraceMe support passing key value pairs of "arguments" using the
818 // following format "name#arg_1=value_,...,arg_n=value_n".
819 virtual string BuildTraceMeName() { return params_.prefix; }
820
821 Status GetNext(IteratorContext* ctx, std::vector<Tensor>* out_tensors,
822 bool* end_of_sequence) final;
823
824 Status Save(SerializationContext* ctx, IteratorStateWriter* writer) final {
825 TF_RETURN_IF_ERROR(params_.dataset->CheckExternalState());
826 return IteratorBase::Save(ctx, writer);
827 }
828
829 protected:
830 // Internal implementation of GetNext that is wrapped in tracing logic.
831 virtual Status GetNextInternal(IteratorContext* ctx,
832 std::vector<Tensor>* out_tensors,
833 bool* end_of_sequence) = 0;
834
835 string full_name(const string& name) const {
836 return strings::StrCat(params_.prefix, ":", name);
837 }
838
839 // By default we model iterators using an unknown node, which acts as
840 // pass-through with respect to performance modeling.
841 std::shared_ptr<model::Node> CreateNode(
842 IteratorContext* ctx, model::Node::Args args) const override {
843 return model::MakeUnknownNode(std::move(args));
844 }
845

Callers

nothing calls this directly

Calls 2

output_dtypesMethod · 0.45
output_shapesMethod · 0.45

Tested by

no test coverage detected