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
{{ message }}
Repository navigation
Commit ad64232
Browse filesBrowse the repository at this point in the historyBrowse files
Stop overwriting external constants that a method returns
A model that returns one of its constants (a buffer or a parameter)
gives zeros at run time when it is exported with
external_constants=True. There is no error. The same model with its
constants kept inside the .pte file returns the right values.
MethodMeta decides whether an output is memory planned by looking for
an allocation or an inline data buffer. A constant stored in a .ptd
file has neither, so it looks like an output with no storage. The
Python bindings then give that output a new zero-filled buffer, and
set_output_data_ptr replaces the constant's data pointer with it. From
then on every read of the constant sees zeros, including operators that
use it to compute other outputs.
Treat a tensor whose data lives in an external file as memory planned,
the same way inline constants already are. One helper now computes this
for inputs, outputs and attributes, and the C++ and Objective-C header
documentation now says that constants count as memory planned.
Callers can see this change for external constants only. Inline
constants already behaved this way:
- TensorInfo::is_memory_planned() now returns true for an output or an
attribute that is an external constant. The Python, Swift and
JavaScript bindings show this value.
- Method::set_output_data_ptr and Module::set_output on such an output
now return InvalidState, instead of silently replacing the constant's
data.
Add a Python test that returns a buffer, and a sum that uses it, from a
program exported with external constants. It checks that the buffer
output reports is_memory_planned() and that both outputs stay right
over 2 runs. A C++ test checks that the external constant attributes of
an existing test program report is_memory_planned().
0 commit comments