Skip to content

Commit

Permalink
Added implementation details
Browse files Browse the repository at this point in the history
  • Loading branch information
gkrivor authored Jun 4, 2024
1 parent 3ffac36 commit 985f3a8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/frontends/tensorflow_lite/src/sparsity_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ bool ov::frontend::tensorflow_lite::SparsityInfo::is_copyable() const {
}

// Unpacks sparse data. Supports only case when sparse tensor has only one sparse dimension [DENSE, ..., DENSE, SPARSE]
// TensorFlow Lite uses a specific format for storing sparse data (TACO):
// It uses three 1D arrays/1D tensors/vectors:
// values - stored in a model's buffers
// segments/postions - list of row's start positions
// indices - list of value indexes in a row (size is equal to values)
// Algorithm is next, and it should be easily modified later for 2D spare matrices (that's why it uses a 2D approach):
// 1. Get a first segment position, set idx = 0
// In a cycle
// 2. Get next segment position
// 3. Get an element_count by a difference between current segment position and last_segment position.
// If diff between last and current segment is 0 it means an empty row (contains only default values).
// In cycle for each element in a segment:
// 4. Caclulate a row_offset using idx-th index by indeces and element_size (fp16/fp32/etc...)
// 5. Put an idx-th value to a found target dest + row_offset
// 6. Move to a next row
template <typename T, typename U>
static void read_sparse_data(uint8_t* dest,
uint8_t* dest_end,
Expand Down

0 comments on commit 985f3a8

Please sign in to comment.