#include <assert.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "xnnpack.h"
#include "xnnpack/allocator.h"
#include "xnnpack/memory-planner.h"
#include "xnnpack/subgraph.h"
inline static bool value_lifecycle_overlap(const struct xnn_usage_record* a, const struct xnn_usage_record* b) { … }
static inline int cmp_value_usage_tensor_size(const void* a, const void* b) { … }
static void populate_value_lifecycle(const struct xnn_runtime* runtime, struct xnn_usage_record* usage) { … }
struct memory_block { … };
static inline int cmp_memory_block(const void* a, const void* b) { … }
static size_t find_value_alloc_offset(struct memory_block* live_mem_blocks,
size_t num_mem_blocks,
size_t to_alloc_size) { … }
void xnn_init_value_allocation_tracker(
struct xnn_value_allocation_tracker* tracker,
const struct xnn_runtime* runtime)
{ … }
void xnn_mark_tensor_as_reuse(struct xnn_value_allocation_tracker* tracker,
uint32_t value_id,
uint32_t reuse_value_id,
uint32_t new_last_node) { … }
void xnn_add_value_allocation_tracker(struct xnn_value_allocation_tracker* tracker,
uint32_t value_id,
size_t tensor_size) { … }
void xnn_add_operator_workspace_allocation_tracker(
struct xnn_value_allocation_tracker* tracker,
uint32_t operator_workspace_value_id,
size_t tensor_size,
uint32_t opdata_id)
{ … }
void xnn_plan_value_allocation_tracker(struct xnn_value_allocation_tracker* tracker) { … }