-
Notifications
You must be signed in to change notification settings - Fork 749
Add flat tensor to cmake #8332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add flat tensor to cmake #8332
Conversation
To indicate if a tensor is external to the PTE file or not. Currently, we can also use the existence of 'fqn' to determine if a tensor is external or not. I think it's better to have a specific location field as fqn may be required for cases besides external tensor storage. Differential Revision: [D66523171](https://our.internmc.facebook.com/intern/diff/D66523171/) [ghstack-poisoned]
Emit FQNs for external tensors. In the emitter, store external tensors as:
```
// list of unique tensors
external_constants_buffer: List[bytes]
// map of {constant_tag: {fqn: index into external_constant_buffer}}
// constant_tag: may want to save multiple external constant files; group them together via the tag.
// {fqn: index}; there may be multiple fqns pointing to the same data buffer. This is for deduplication.
external_constants_map: [Dict[str, Dict[str, int]]
```
Differential Revision: [D66523226](https://our.internmc.facebook.com/intern/diff/D66523226/)
[ghstack-poisoned]
…l file - Add config 'external_constants' to ExecutorchBackendConfig. - When set to True, run the 'external_constants_pass' - This tags all constants as external, and moves them into a separate buffer to be serialized outside of the PTE file. Note: users can write their own passes to tag weights to specific files / multiple files. TODO: write example pass and test for the case where we have two constant files. Differential Revision: [D66560903](https://our.internmc.facebook.com/intern/diff/D66560903/) [ghstack-poisoned]
Introduce data serialization interface. Differential Revision: [D65947145](https://our.internmc.facebook.com/intern/diff/D65947145/) [ghstack-poisoned]
…tion interface" Introduce data serialization interface. Differential Revision: [D65947145](https://our.internmc.facebook.com/intern/diff/D65947145/) [ghstack-poisoned]
Introduce data serialization interface. Differential Revision: [D65947145](https://our.internmc.facebook.com/intern/diff/D65947145/) [ghstack-poisoned]
For usage in extension/flat_tensor/serialize. Differential Revision: [D66854756](https://our.internmc.facebook.com/intern/diff/D66854756/) [ghstack-poisoned]
1. Move schema files under flat_tensor/serialize 2. Add targets to generate schema files Differential Revision: [D66903492](https://our.internmc.facebook.com/intern/diff/D66903492/) [ghstack-poisoned]
Serialize a flat tensor file. The resulting file looks like: Header with - flatbuffer offset and size - segment data offset and size Flatbuffer Tensor data (in segment) Differential Revision: [D66374253](https://our.internmc.facebook.com/intern/diff/D66374253/) [ghstack-poisoned]
More comprehensive testing for flat tensor serialization. Differential Revision: [D67007821](https://our.internmc.facebook.com/intern/diff/D67007821/) [ghstack-poisoned]
Introduce top-level serialization file that calls: - serialize_pte_binary for PTE file - FlatTensor.serialize_tensors for PTD files. Differential Revision: [D66523267](https://our.internmc.facebook.com/intern/diff/D66523267/) [ghstack-poisoned]
…files." Introduce top-level serialization file that calls: - serialize_pte_binary for PTE file - FlatTensor.serialize_tensors for PTD files. Differential Revision: [D66523267](https://our.internmc.facebook.com/intern/diff/D66523267/) [ghstack-poisoned]
Introduce top-level serialization file that calls: - serialize_pte_binary for PTE file - FlatTensor.serialize_tensors for PTD files. Differential Revision: [D66523267](https://our.internmc.facebook.com/intern/diff/D66523267/) [ghstack-poisoned]
…files." Introduce top-level serialization file that calls: - serialize_pte_binary for PTE file - FlatTensor.serialize_tensors for PTD files. Differential Revision: [D66523267](https://our.internmc.facebook.com/intern/diff/D66523267/) [ghstack-poisoned]
Introduce top-level serialization file that calls: - serialize_pte_binary for PTE file - FlatTensor.serialize_tensors for PTD files. Differential Revision: [D66523267](https://our.internmc.facebook.com/intern/diff/D66523267/) [ghstack-poisoned]
…files." Introduce top-level serialization file that calls: - serialize_pte_binary for PTE file - FlatTensor.serialize_tensors for PTD files. Differential Revision: [D66523267](https://our.internmc.facebook.com/intern/diff/D66523267/) [ghstack-poisoned]
Introduce top-level serialization file that calls: - serialize_pte_binary for PTE file - FlatTensor.serialize_tensors for PTD files. Differential Revision: [D66523267](https://our.internmc.facebook.com/intern/diff/D66523267/) [ghstack-poisoned]
…files." Introduce top-level serialization file that calls: - serialize_pte_binary for PTE file - FlatTensor.serialize_tensors for PTD files. Differential Revision: [D66523267](https://our.internmc.facebook.com/intern/diff/D66523267/) [ghstack-poisoned]
Introduce top-level serialization file that calls: - serialize_pte_binary for PTE file - FlatTensor.serialize_tensors for PTD files. Differential Revision: [D66523267](https://our.internmc.facebook.com/intern/diff/D66523267/) [ghstack-poisoned]
Introduce TensorLayout class, used to describe external tensors. Currently contains: - scalar_type - sizes - dim_order Differential Revision: [D67048723](https://our.internmc.facebook.com/intern/diff/D67048723/) [ghstack-poisoned]
Add NamedDataMap interface to runtime. Differential Revision: [D66834552](https://our.internmc.facebook.com/intern/diff/D66834552/) [ghstack-poisoned]
Add NamedDataMap interface to runtime. Differential Revision: [D66834552](https://our.internmc.facebook.com/intern/diff/D66834552/) [ghstack-poisoned]
Add NamedDataMap interface to runtime. Differential Revision: [D66834552](https://our.internmc.facebook.com/intern/diff/D66834552/) [ghstack-poisoned]
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
…tation"
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
…tation"
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
…tation"
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
…tation"
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
…tation"
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
DataMap implementation that
* Loads a flat_tensor file
* Populates a map with {fqn: tensor} and {fqn: TensorLayout}.
* Makes tensor information available via the named_data_map.h interface.
For now, DataMap doesn't store the DataLoader.
- If/when tensors are in their own segments, DataMap should also store a DataLoader.
Differential Revision: [D67064580](https://our.internmc.facebook.com/intern/diff/D67064580/)
[ghstack-poisoned]
Add NamedDataMap as an arg to: - Method - load_method - parseTensor Use NamedDataMap to resolve external tensors in parseTensor. Test that the PTE + PTD file run well inside method_test. Differential Revision: [D67127327](https://our.internmc.facebook.com/intern/diff/D67127327/) [ghstack-poisoned]
…method load" Add NamedDataMap as an arg to: - Method - load_method - parseTensor Use NamedDataMap to resolve external tensors in parseTensor. Test that the PTE + PTD file run well inside method_test. Differential Revision: [D67127327](https://our.internmc.facebook.com/intern/diff/D67127327/) [ghstack-poisoned]
Add NamedDataMap as an arg to: - Method - load_method - parseTensor Use NamedDataMap to resolve external tensors in parseTensor. Test that the PTE + PTD file run well inside method_test. Differential Revision: [D67127327](https://our.internmc.facebook.com/intern/diff/D67127327/) [ghstack-poisoned]
…method load" Add NamedDataMap as an arg to: - Method - load_method - parseTensor Use NamedDataMap to resolve external tensors in parseTensor. Test that the PTE + PTD file run well inside method_test. Differential Revision: [D67127327](https://our.internmc.facebook.com/intern/diff/D67127327/) [ghstack-poisoned]
Add NamedDataMap as an arg to: - Method - load_method - parseTensor Use NamedDataMap to resolve external tensors in parseTensor. Test that the PTE + PTD file run well inside method_test. Differential Revision: [D67127327](https://our.internmc.facebook.com/intern/diff/D67127327/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/8332
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 2 Cancelled JobsAs of commit 03569f7 with merge base 8ee637e ( NEW FAILURE - The following job has failed:
CANCELLED JOBS - The following jobs were cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
d62d1b4 to
17fe113
Compare
17fe113 to
03569f7
Compare
Summary
Add flat tensor to cmake
Test plan