#include "tensorflow/lite/kernels/internal/utils/sparsity_format_converter.h"
#include <algorithm>
#include <cstdint>
#include <utility>
#include <vector>
#include "Eigen/Core"
#include "tensorflow/lite/c/c_api_types.h"
#include "tensorflow/lite/c/common.h"
namespace tflite {
namespace internal {
namespace sparsity {
namespace {
uint64_t GetFlattenedIndex(const std::vector<int>& indices,
const std::vector<int>& shape) { … }
std::vector<int> TfLiteIntArrayToVector(const TfLiteIntArray* int_array) { … }
}
template <typename T>
FormatConverter<T>::FormatConverter(
const std::vector<int>& shape, const std::vector<int>& traversal_order,
const std::vector<TfLiteDimensionType>& format,
const std::vector<int>& block_size, const std::vector<int>& block_map)
: … { … }
template <typename T>
TfLiteStatus FormatConverter<T>::DenseToSparse(const T* src_data) { … }
template <typename T>
FormatConverter<T>::FormatConverter(
const std::vector<int>& shape, const std::vector<int>& traversal_order,
const std::vector<TfLiteDimensionType>& format,
const std::vector<int>& dense_size,
const std::vector<std::vector<int>>& segments,
const std::vector<std::vector<int>>& indices,
const std::vector<int>& block_map) { … }
template <typename T>
FormatConverter<T>::FormatConverter(const std::vector<int>& shape,
const TfLiteSparsity& sparsity) { … }
template <typename T>
void FormatConverter<T>::InitSparseToDenseConverter(
std::vector<int> shape, std::vector<int> traversal_order,
std::vector<TfLiteDimensionType> format, std::vector<int> dense_size,
std::vector<std::vector<int>> segments,
std::vector<std::vector<int>> indices, std::vector<int> block_map) { … }
template <typename T>
void FormatConverter<T>::Populate(const T* src_data, std::vector<int> indices,
int level, int prev_idx, int* src_data_ptr,
T* dest_data) { … }
template <typename T>
TfLiteStatus FormatConverter<T>::SparseToDense(const T* src_data) { … }
template <typename T>
TfLiteStatus FormatConverter<T>::SparseToDense(const T* src_data,
const size_t dest_size,
T* dest_data,
TfLiteContext* context) { … }
template <typename T>
bool FormatConverter<T>::IsZero(const T val) { … }
template class FormatConverter<int32_t>;
template class FormatConverter<int8_t>;
template class FormatConverter<float>;
template class FormatConverter<Eigen::half>;
}
}
}