Repository navigation
[PERF] Avoid backtraces for type-key and dtype probes - #975
Merged
Merged
Conversation
cyx-6
force-pushed
the
codex/zihao-type-check-performance
branch
3 times, most recently
from
November 14, 2026 14:38
9ffd289 to
bb128ba
Compare
tqchen
reviewed
Nov 14, 2026
| * An error outside the parse, such as an unregistered custom type, is raised as | ||
| * TVMFFIDataTypeFromString raises it. | ||
| * \param str The string to convert. | ||
| * \param out The output DLDataType. |
| *scan = str.data() + 6; | ||
| TVM_FFI_ICHECK(str.data() == tmp); | ||
| if (**scan != '[') { | ||
| TVM_FFI_THROW(ValueError) << "expected opening brace after 'custom' type in" << str; |
Member
There was a problem hiding this comment.
add TVM_FFI_THROW_NO_BACKTRACE, keep private to file for now
cyx-6
force-pushed
the
codex/zihao-type-check-performance
branch
from
November 14, 2026 15:11
bb128ba to
e1b5548
Compare
tqchen
reviewed
Nov 14, 2026
| } | ||
|
|
||
| TVM_FFI_STATIC_INIT_BLOCK() { | ||
| reflection::GlobalDef().def("ffi.DataTypeParses", [](const String& str) { |
cyx-6
force-pushed
the
codex/zihao-type-check-performance
branch
2 times, most recently
from
November 14, 2026 15:24
4196403 to
e292404
Compare
tqchen
approved these changes
Nov 14, 2026
cyx-6
force-pushed
the
codex/zihao-type-check-performance
branch
from
November 14, 2026 15:38
e292404 to
7aecb09
Compare
tqchen
approved these changes
Nov 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type-key and dtype probes can capture expensive error backtraces for expected misses.
Query type keys without raising, and add
tvm_ffi.dtype.try_parse(text) -> dtype | None. It returns the parsed dtype directly on success and None for an invalid dtype string, avoiding a second parse after a successful probe. The registeredffi.DataTypeTryParsefunction returnsOptional<DLDataType>; there is no boolean can-parse API.Dtype parsing reuses ErrorBuilder through a file-local TVM_FFI_THROW_NO_BACKTRACE macro. Invalid dtype construction still raises ValueError with the existing message, without capturing a parser backtrace. Other errors propagate. No new C API or Cython wrapper is required.
Validation: editable C++/Cython build succeeded; dtype and object tests: 161 passed, 1 skipped. Type checking, Ruff, C++ formatting, and whitespace checks passed.