You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/05/03 17:26:39 UTC

[GitHub] haojin2 commented on a change in pull request #10533: [MXNET-314] Support Integer Type parsing in CSVIter

haojin2 commented on a change in pull request #10533: [MXNET-314] Support Integer Type parsing in CSVIter
URL: https://github.com/apache/incubator-mxnet/pull/10533#discussion_r185878246
 
 

 ##########
 File path: src/io/iter_csv.cc
 ##########
 @@ -54,27 +57,90 @@ struct CSVIterParam : public dmlc::Parameter<CSVIterParam> {
     index_t shape1[] = {1};
     DMLC_DECLARE_FIELD(label_shape).set_default(TShape(shape1, shape1 + 1))
         .describe("The shape of one label.");
+    DMLC_DECLARE_FIELD(dtype)
+      .add_enum("float32", mshadow::kFloat32)
+      .add_enum("int32", mshadow::kInt32)
+      .set_default(dmlc::optional<int>())
+      .describe("Output data type. ``None`` means no change.");
   }
 };
 
-class CSVIter: public IIterator<DataInst> {
+class CSVIterBase: public IIterator<DataInst> {
  public:
-  CSVIter() {
+  CSVIterBase() {
     out_.data.resize(2);
   }
-  virtual ~CSVIter() {}
+  virtual ~CSVIterBase() {}
+
+  // initialize iterator loads data in
+  virtual void Init(const std::vector<std::pair<std::string, std::string> >& kwargs) = 0;
+  /*! \brief reset the iterator */
+  virtual void BeforeFirst(void) = 0;
+  /*! \brief move to next item */
+  virtual bool Next(void) = 0;
+  /*! \brief get current data */
+  virtual const DataInst &Value(void) const {
+    return out_;
+  }
+
+ protected:
+  CSVIterParam param_;
+
+  DataInst out_;
+
+  // internal instance counter
+  unsigned inst_counter_{0};
+  // at end
+  bool end_{false};
 
+  // label parser
+  size_t label_ptr_{0}, label_size_{0};
+  size_t data_ptr_{0}, data_size_{0};
+};
+
+class CSVIterInt: public CSVIterBase {
 
 Review comment:
   This may not be possible as this is a user-facing class.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services