Open Enigmatisms opened 1 year ago
I meet this problem too T_T. May I ask if there are any ways to bypass this issue now? Can we write the member function outter and pass the struct into this function?
I guess currently only way is to use procedural programming with first argument being the struct...
I guess currently only way is to use procedural programming with first argument being the struct...
May i ask if this is data oriented programming? The struct is considered as a group of data without function.
It's been a long time. By the way I bypassed this issue by opting for newer python version.
So... what's the cause of this problem? As far as I can recall, it's caused by struct name aliasing? But I don't see anything related to this in my minimal reproduction code.
Judging from the discussion you have above, it seems that it is caused by struct nesting, and the member functions of the inner struct are stripped?
It's been a long time. By the way I bypassed this issue by opting for newer python version.
So... what's the cause of this problem? As far as I can recall, it's caused by struct name aliasing? But I don't see anything related to this in my minimal reproduction code.
Judging from the discussion you have above, it seems that it is caused by struct nesting, and the member functions of the inner struct are stripped?
Could you please explain how you can bypass this issue by newer python version? Because I think maybe taichi is not related to the version of python? I think that it is caused by struct nesting, nesting in taichi and paralleling is complex.
Since I have two systems (one windows and one ubuntu) on my laptop, I found that the behavior of my code was different, even if I have the same version of Taichi. I did some experiments back then, and found that 3.8- (not all of them, 3.7.8 seemed fine, if I recall it correctly) would run into this issue. I tried again this code just now:
Python 3.7.5 with Taichi 1.4.1: Error
Python 3.9+ with Taichi 1.4.1: passed
And..., is struct nesting such a big problem? I used a lot in my project, like: BSDF.py. The outtermost struct is BSDF, containing a struct Medium, which contains, further, a dataclass struct called PhaseFunction. The code works fine.
thanks a lot!! My code was run on python 3.8.10 and it was bad. Could you please offer your exact python version?
Mine is 3.9.13, but my ubuntu is 3.8+. This is weird...
Mine is 3.9.13, but my ubuntu is 3.8+. This is weird...
yes... My code will be pushed into some projects which require other envrioment... So i try to use procedural programming mentioned by @bobcao3. Thanks a lot for ur explaination and @bobcao3 !
Calling nested struct member function Calling the function of a struct from the parent struct will fail and lead to "AttributeError: 'Structxx' object has no attribute 'xxx'"
To Reproduce First, I know this issue looks like #6917 or #6737 but it's different. I saw there was a pr in #6917. I ran through the code, and also found the updated version of struct initialization. Yet I got a exception. I create a small example snippet to reproduce:
The code is run by (say we create a file called
test.py
):python3 test.py
Log/Screenshots The exception thrown:
I have tested this behavior on Win11 / Ubuntu 20.04, with python 3.7.1 and 3.7.5, taichi 1.3.0 (after that fixing PR) and 1.4.1. It looks like on win11, llvm version is 15.0.1 while on linux it is 15.0.4. They all throw the same exception. I tried to print the
__struct_method
field when initializing the struct, everything seems fine to me. I just got no clue why this would happen.Additional comments