getattr
does not support default parameter when jitted
#56909
Comments
Hi, I want to work on this issue. |
Assigned it to you! Let me know if you need help |
Can I try to work on this or any other "gud first issue"? The others I saw had pending pull requests that were not resolved. |
Hi, I am already working on this. |
Hi @narang99, Thanks for offering to contribute! I just marked a few more issues as "good firs issue", feel free look through them and comment on one or two that you find interesting. Happy to discuss them with you if needed. |
Hi @gmagogsfm, I'm new to pytorch, so was going through a couple of "good first issue" labels to see if I can work on some of them. More specifically for this issue, I noticed the use of |
Hi @aaditya-panik, Thanks for the question. TorchScript compiles a PyTorch program into an archive, which can be loaded into Python-free environment for execution, so |
I am working on this, as a way to get myself familiar with TorchScript codebase. |
So my plan for fixing this is to first verify that the number of args is 2 or 3 and then replace this line: so that the IR returned is some sort of IF expression, essentially: attribute not found with the given name ? default val param for attr : obj->attr(apply.range(), method, name) Is this the right plan? Please comment. |
I too thought along these lines. Here's what I could manage to write. Been busy with other work to validate if this is the way to go |
actually, the right syntax tree to emit is a prim::If node with two blocks, one for True one for False something like this: ` Graph: graph(%x : Tensor): |
The builtin
getattr
function has a third optional parameter calleddefault
, returned if the key fetched does not exist. However, the IR emitter does not support this third parameter and supports only the 2 arguments version:https://github.com/pytorch/pytorch/blob/master/torch/csrc/jit/frontend/ir_emitter.cpp#L2858-L2859
To Reproduce
Steps to reproduce the behavior:
getattr
with 3 argumentsError log
Expected behavior
Environment
cc @gmagogsfm
The text was updated successfully, but these errors were encountered: