# Round-tripping objects through the FFI

**URL:** <https://discuss.tvm.apache.org/t/round-tripping-objects-through-the-ffi/8440>\
**Category:** Development\
**Created:** [November 11, 2020, 1:09pm UTC](https://discuss.tvm.apache.org/t/round-tripping-objects-through-the-ffi/8440 "2020-11-11T13:09:57Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![t-vi](https://discuss.tvm.apache.org/user_avatar/discuss.tvm.apache.org/t-vi/32/1148_2.png) [@t-vi](https://discuss.tvm.apache.org/u/t-vi)\
**Post date:** [November 11, 2020, 1:48pm UTC](https://discuss.tvm.apache.org/t/round-tripping-objects-through-the-ffi/8440/3 "2020-11-11T13:48:04Z")

</div>

The difficulty with the map is that you need to pass the map around or make it global state. My usecase is the PyTorch frontend (which could be made object-oriented instead of made purely functional to keep track of the map and prelude which is currently kept track of by indirection). Concretely tracking types:

> <https://github.com/apache/tvm/pull/6900>
>
> Currently, the PyTorch frontend will use the vanilla TVM type inference pass to …get the types.
> Combined with the incremental nature of translating the graph, this makes for quadratic (in the graph size) runtime.
> This patch runs type inference on a subgraph (starting from the things that has types) instead. It is a bit hacky though because it essentially tries to implement in-place modification where TVM does not foresee it.
> 
> For converting Huggingface BERT, this patch gives a ~10x increase in the speed of conversion (from 31 seconds to just below 3), so it is solving a very real and quite bad problem.

The case is even more delicate as I’m close to (but not quite, probably) wanting checked\_type as the attribute.

---

_[View the full topic](https://discuss.tvm.apache.org/t/round-tripping-objects-through-the-ffi/8440)._
