Changes to allow the export of functions with no user input. (#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: #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 #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
N
Nicholas Long committed
8d4ba1d0d48fb838788f5dbb02afbf62a0926957
Parent: 37265a1
Committed by GitHub <noreply@github.com>
on 3/17/2025, 4:49:46 PM