# DataLoader -- an API to wrap datasets from other machine learning frameworks

**URL:** <https://discuss.tvm.apache.org/t/dataloader-an-api-to-wrap-datasets-from-other-machine-learning-frameworks/9498>\
**Category:** RFC\
**Created:** [March 24, 2021, 12:17am UTC](https://discuss.tvm.apache.org/t/dataloader-an-api-to-wrap-datasets-from-other-machine-learning-frameworks/9498 "2021-03-24T00:17:52Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![electriclilies](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/electriclilies/32/1971_2.png) [@electriclilies](https://discuss.tvm.apache.org/u/electriclilies)\
**Post date:** [March 29, 2021, 7:56pm UTC](https://discuss.tvm.apache.org/t/dataloader-an-api-to-wrap-datasets-from-other-machine-learning-frameworks/9498/9 "2021-03-29T19:56:13Z")

</div>

@altanh Thanks for the input. I think you’re right, knowledge of the layout is not required, and I can remove that.

With regard to your concern about the list of ndarrays – the ndarrays in the list are meant to be batched (I should make this clearer in the documentation, though). The intention is to allow DataLoaders to be used with relay mods that take more than one input. So if we have a list that is` [ndarray1, ndarray2]`, `ndarray1` is the first input to the relay mod, and `ndarary2 `is the second. For a mod that takes batched inputs, the list would look like this: `[ndarray1]`, where `ndarray1` has dimensions `(batch_size, ...)`.

Then running the graph runtime module would look something like this:

```auto
for data in dataloader:
     for i, inp in enumerate(data):
           graphmodule.set_input(i, inp)

graphmodule.run()

```

With regard to whether the batch size is necessary – one of the algorithms that is commonly used to pick scales and zero points uses batch size because it calculates an average across batches. (I guess an interesting and related question here is how we would use this calibration method with BERT, since it doesn’t have batch size). I thought it was cleaner to package the batch size with the data coming into the function rather than requiring a user to figure out what it is and pass it in directly.

And additionally, anytime you are doing averaging or trying to calculate accuracy, having the batch size easily available without having to slice it out of your tensor with an index calculated based on what the layout is is useful.

But, for non-batched data, I agree that it doesn’t make sense to have the batch size. I’m not sure what the best solution is here. One option is that the DataLoader could have subclass called BatchedDataLoader that has the batch\_size property. I’m open to other suggestions, though.

---

_[View the full topic](https://discuss.tvm.apache.org/t/dataloader-an-api-to-wrap-datasets-from-other-machine-learning-frameworks/9498)._
