llvmlite assertion when using deferred type as typed dict values
See original GitHub issueimport numba as nb
from collections import OrderedDict
from numba import deferred_type, optional
from numba.experimental import jitclass
from numba import types
node_type = deferred_type()
@jitclass([
('parent', optional(node_type)),
('children', types.DictType(types.int32, node_type)),
])
class TreeNode(object):
def __init__(self, parent=None):
self.parent = parent
self.children = nb.typed.Dict.empty(types.int32, node_type)
node_type.define(TreeNode.class_type.instance_type)
t = TreeNode()
t2 = TreeNode(t2)
produces:
$ python repro.py
reducer_override for <class 'type'>
python: /opt/conda/conda-bld/llvmdev_1637166008009/work/lib/IR/DataLayout.cpp:713: llvm::Align llvm::DataLayout::getAlignment(llvm::Type*, bool) const: Assertion `Ty->isSized() && "Cannot getTypeInfo() on a type that is unsized!"' failed.
Aborted (core dumped)
This may be an llvmlite bug or a combination of Numba doing something bad and llvmlite not catching / handling it very well, but I’m just opening the issue with the initial reproducer to start tracking it.
Note: Edits made to the the reproducer so it can run to completion once the Numba issue is resolved (the initial revision tried to pass 1 as parent, when it should have been a tree node type).
To do:
- Create an llvmlite reproducer / issue and investigate whether the assertion failure can easily be prevented.
Issue Analytics
- State:
- Created a year ago
- Comments:12 (8 by maintainers)
Top Results From Across the Web
"Cannot getTypeInfo() on a type that is unsized!" error on ...
Dict variable that has deferred type as value type ... the workaround from llvmlite assertion when using deferred type as typed dict values...
Read more >How would you type hint Dict in Python with constant form but ...
one way of correctly type hinting would look like this: from typing import List, Dict, Union def some_func() -> List[Dict[str, Union[int, ...
Read more >Release Notes — Numba 0.50.1 documentation - PyData |
Issue with omitted type not recognized as literal value. PR #5517: Fix numba.typed.List extend for singleton and empty iterable.
Read more >Release 0.55.0rc1+0.gf2a673cd0.dirty-py3.7-linux-x86_64 ...
key and value types kv_ty = (types.int64, types.unicode_type). # A container class with: # * member 'd' holding a typed dictionary of int64 ......
Read more >Issues · numba/numba · GitHub - test.ocom.vn
NumPy aware dynamic Python compiler using LLVM. ... llvmlite assertion when using deferred type as typed dict values bug - ice Bugs: internal...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

The problem is that the context doesn’t ensure that the model for a deferred type has been defined prior to trying to get its actual size. The following hack:
allows the above code to run to completion, but may not be the right place to insert the fix.
Current failure happens on
llvmlite/bindings/targets.py::TargetData.get_pointee_abi_size. Below is the last five frames of the stacktrace:Assertion is triggered when Numba tries to get the size of the struct defined above: