Does TVM Relay support STRING?

When converting a TF saved model to TVM so, I realized that the constant node’s STRING tensor has been converted into a uint32 tensor. The value is exactly the index mapping to the STRING tensor’s string list, per parsing TF pbtxt file.

How can we keep the constant node’s STRING info in the TVM module? It seems the NDArray can’t store the STRING dtype, which only supports so-called “object” dtype. The STRING information seems get lost. Is there any workaround about this issue? Otherwise we have to store the STRING map in TF before relay build and then do an index mapping after inference, which is non-trivial. I figure it is a common issue for all the frontend(s).

BTW, will this feature be supported in Relax IR in the future? Thanks a lot.

I’m sure that the STRING map was stored in tensorflow const node.

Per code: python/tvm/relay/frontend/tensorflow2.py In function convert_const_node(), it seems the object dtype is converted into uint8? Some information get lost here? def convert_const_node(node, shape):

Hi @wenxian, AFAIK, Relay’s type system and ADT do not support String currently, cc Relay experts: @masahi @mbs-octoml.

In Relax, we have introduced an ObjectType, which serves as a general type whose runtime representations can be any tvm::runtime::Object such as String, Array, Integer, etc. It can be used in your case where you have a tvm::runtime::Array<tvm::runtime::String> in your model, from the Relax AST pov, it can be represented as a relax.Var with the generic type ObjectType.

We have seen a lot of demand and use cases for representing constant POD values such as int/float/string at the graph-level IR, so we plan to support them directly in Relax. Here are some discussions we had: https://github.com/tlc-pack/relax/pull/135#issuecomment-1113497183.

Thanks for your reply. Yuchen.