Skip to content

Conversation

@tqchen
Copy link
Member

@tqchen tqchen commented Aug 2, 2025

This PR introduces small string support to the FFI system. When the string length fit into the space in TVMFFIAny (aka len(str) <= 7). We directly store the string content into the TVMFFIAny content instead of creating a Object. This change will likely speedup small string access.

Some implications:

  • Always check for kTVMFFISmallStr code as well as kTVMFFIStr
  • Always check for kTVMFFISmallBytes when checking kTVMFFIBytes
  • Avoid using details::StringObj, instead, always use any.as()
  • Always set any.padding to 0 for other values (in compiler and runtime) to enable fast cmp

This PR introduces small string support to the FFI system.
When the string length fit into the space in TVMFFIAny (aka len(str) <= 7).
We directly store the string content into the TVMFFIAny content instead of creating a Object.
This change will likely speedup small string access.

Some implications:

- Always check for kTVMFFISmallStr code as well as kTVMFFIStr
- Always check for kTVMFFISmallBytes when checking kTVMFFIBytes
- Avoid using details::StringObj, instead, always use any.as<String>()
- Always set any.padding to 0 for other values (in compiler and runtime) to enable fast cmp
@Hzfengsy Hzfengsy merged commit fe36bb9 into apache:main Aug 4, 2025
13 checks passed
ShiboXing pushed a commit to ShiboXing/tvm that referenced this pull request Aug 10, 2025
tqchen added a commit to tqchen/tvm that referenced this pull request Sep 13, 2025
tqchen added a commit to tqchen/tvm that referenced this pull request Sep 13, 2025
tqchen added a commit to tqchen/tvm that referenced this pull request Sep 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants