You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Changes to allow the export of functions with no user input. (pytorch#8031)
### Summary
This is a set of changes that I have been using to get executorch
working with Multiple Entrypoints with shared state.
This is related to: pytorch#8030
### Issue & Changes
Currently trying to export a function:
```python
def init():
self.shared_state.fill_(0)
```
Will fail, because in to_edge in exir in the program.py the lifted
constants are assumed to be placed before the first user input. This
causes weird behavior when there are no user inputs. I changed it to
place the lifted constant after the last buffer, if there are no user
inputs to place before. However, this relies on my understanding of the
implicit layout of the graph inputs.
At the same time later in the after the memory planning phase of
to_executorch, it validates that memory planning was correct based on
whether the `graph_input_allocated` flag is set, this only applies to
user inputs, of which we have none, so it errors out. I added a check to
bypass this error if there are no user inputs, but I honestly do not
understand enough of the validation check to know if that is
appropriate.
### Comments
In the current executorch with no support for shared state, this case
does not make sense, but pytorch#8030 is my attempt at adding that capability.
and having initialization methods that init the buffers from constants
is useful, especially since their initail state is undefined.
Currently this is not ready, I have no tests/ and have my random notes
in the commit as comments, and other than validating that it worked as I
was working on the shared state export have not done anything in
depth....
But I kind-of want feedback if my solution seems correct, or if I am
missing something. Particularly regarding my understanding of
placeholder ordering and signature logic, and whether bypassing the
graph_input_allocated validation is appropriate.
Out of all the changes I had to make for shared state, this is the one I
am least sure about.
cc @JacobSzwejbka@angelayi
0 commit comments