- 
                Notifications
    You must be signed in to change notification settings 
- Fork 706
[executorch][core] NamedDataMap interface #7763
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
          
     Merged
      
      
    
  
     Merged
                    Changes from 5 commits
      Commits
    
    
            Show all changes
          
          
            6 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      c81d8cf
              
                [executorch][core] NamedDataMap interface
              
              
                lucylq 907d9f2
              
                Update on "[executorch][core] NamedDataMap interface"
              
              
                lucylq 93c0fb6
              
                Update on "[executorch][core] NamedDataMap interface"
              
              
                lucylq d2089a0
              
                Update on "[executorch][core] NamedDataMap interface"
              
              
                lucylq 61d6a8b
              
                Update on "[executorch][core] NamedDataMap interface"
              
              
                lucylq 3fd73a1
              
                Update on "[executorch][core] NamedDataMap interface"
              
              
                lucylq File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| /* | ||
| * Copyright (c) Meta Platforms, Inc. and affiliates. | ||
| * All rights reserved. | ||
| * | ||
| * This source code is licensed under the BSD-style license found in the | ||
| * LICENSE file in the root directory of this source tree. | ||
| */ | ||
|  | ||
| #pragma once | ||
|  | ||
| #include <executorch/runtime/core/exec_aten/exec_aten.h> | ||
| #include <executorch/runtime/core/freeable_buffer.h> | ||
| #include <executorch/runtime/core/result.h> | ||
| #include <executorch/runtime/core/span.h> | ||
| #include <executorch/runtime/core/tensor_layout.h> | ||
| #include <executorch/runtime/platform/compiler.h> | ||
|  | ||
| namespace executorch { | ||
| namespace runtime { | ||
|  | ||
| /** | ||
| * Interface to access and retrieve data via name. | ||
| * See executorch/extension/flat_tensor/ for an example. | ||
| */ | ||
| class ET_EXPERIMENTAL NamedDataMap { | ||
| public: | ||
| virtual ~NamedDataMap() = default; | ||
| /** | ||
| * Get tensor metadata by fully qualified name (FQN). | ||
| * | ||
| * @param fqn Fully qualified name of the tensor. | ||
| * @return Result containing TensorLayout with tensor metadata. | ||
| */ | ||
| ET_NODISCARD virtual Result<const executorch::runtime::TensorLayout> | ||
| get_metadata(const char* fqn) const = 0; | ||
| /** | ||
| * Get tensor data by fully qualified name (FQN). | ||
| * | ||
| * @param fqn Fully qualified name of the tensor. | ||
| * @return Result containing a FreeableBuffer with the tensor data. | ||
| */ | ||
| ET_NODISCARD virtual Result<FreeableBuffer> get_data( | ||
| const char* fqn) const = 0; | ||
|  | ||
| /** | ||
| * Loads data corresponding to the fqn into the provided buffer. | ||
|         
                  lucylq marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| * | ||
| * @param fqn Fully qualified name of the tensor. | ||
| * @param size The number of bytes to load. Use `get_metadata` to retrieve the | ||
| * size of the tensor for a given fqn. | ||
| * @param buffer The buffer to load the data into. Must point to at least | ||
| * `size` bytes of memory. | ||
| * @return Result containing the number of bytes written on success. | ||
|         
                  lucylq marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
| */ | ||
| ET_NODISCARD virtual Result<size_t> | ||
| load_data_into(const char* fqn, size_t size, void* buffer) const = 0; | ||
|         
                  lucylq marked this conversation as resolved.
              Outdated
          
            Show resolved
            Hide resolved | ||
|  | ||
| /** | ||
| * Get the number of keys in the NamedDataMap. | ||
| * | ||
| * @return Result containing the number of keys. | ||
| */ | ||
| ET_NODISCARD virtual Result<size_t> get_num_keys() const = 0; | ||
|         
                  lucylq marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| /** | ||
| * Get the key at the given index. | ||
| * | ||
| * @param index The index of the key to retrieve. | ||
| * @return Result containing the key at the given index. Note: the returned | ||
| * pointer is only valid for the lifetime of the DataMap. | ||
| */ | ||
| ET_NODISCARD virtual Result<const char*> get_key(size_t index) const = 0; | ||
| }; | ||
|         
                  lucylq marked this conversation as resolved.
              Show resolved
            Hide resolved | ||
|  | ||
| } // namespace runtime | ||
| } // namespace executorch | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.