mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 15:58:05 +02:00
ethosu: Refactor ethosu_allocate_feature_map to return the new offset
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39611>
This commit is contained in:
parent
fc70406bdd
commit
42082266f0
4 changed files with 17 additions and 18 deletions
|
|
@ -397,12 +397,12 @@ emit_common(struct ethosu_subgraph *subgraph, struct ethosu_operation *operation
|
|||
static void
|
||||
emit_convolution(struct ethosu_subgraph *subgraph, struct ethosu_operation *operation)
|
||||
{
|
||||
ethosu_allocate_feature_map(subgraph, &operation->ifm);
|
||||
operation->ifm.tiles.addresses[0] = ethosu_allocate_feature_map(subgraph, operation->ifm.tensor_idx);
|
||||
operation->ifm.tiles.height_0 = operation->ifm.shape.height;
|
||||
operation->ifm.tiles.height_1 = operation->ifm.shape.height;
|
||||
operation->ifm.tiles.width_0 = operation->ifm.shape.width;
|
||||
|
||||
ethosu_allocate_feature_map(subgraph, &operation->ofm);
|
||||
operation->ofm.tiles.addresses[0] = ethosu_allocate_feature_map(subgraph, operation->ofm.tensor_idx);
|
||||
operation->ofm.tiles.height_0 = operation->ofm.shape.height;
|
||||
operation->ofm.tiles.height_1 = operation->ofm.shape.height;
|
||||
operation->ofm.tiles.width_0 = operation->ofm.shape.width;
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "ethosu_device.h"
|
||||
#include "ethosu_lower.h"
|
||||
#include "ethosu_coefs.h"
|
||||
#include "ethosu_ml.h"
|
||||
#include "ethosu_sched.h"
|
||||
|
||||
static bool
|
||||
|
|
@ -71,15 +72,15 @@ ethosu_find_first_consumer(const struct pipe_ml_operation *poperations,
|
|||
static void
|
||||
allocate_feature_maps(struct ethosu_subgraph *subgraph, struct ethosu_operation *operation)
|
||||
{
|
||||
ethosu_allocate_feature_map(subgraph, &operation->ifm);
|
||||
operation->ifm.tiles.height_0 = operation->ifm.shape.height;
|
||||
operation->ifm.tiles.height_1 = operation->ifm.shape.height;
|
||||
operation->ifm.tiles.width_0 = operation->ifm.shape.width;
|
||||
|
||||
ethosu_allocate_feature_map(subgraph, &operation->ofm);
|
||||
operation->ofm.tiles.addresses[0] = ethosu_allocate_feature_map(subgraph, operation->ofm.tensor_idx);
|
||||
operation->ofm.tiles.height_0 = operation->ofm.shape.height;
|
||||
operation->ofm.tiles.height_1 = operation->ofm.shape.height;
|
||||
operation->ofm.tiles.width_0 = operation->ofm.shape.width;
|
||||
|
||||
operation->ifm.tiles.addresses[0] = ethosu_allocate_feature_map(subgraph, operation->ifm.tensor_idx);
|
||||
operation->ifm.tiles.height_0 = operation->ifm.shape.height;
|
||||
operation->ifm.tiles.height_1 = operation->ifm.shape.height;
|
||||
operation->ifm.tiles.width_0 = operation->ifm.shape.width;
|
||||
}
|
||||
|
||||
static const struct pipe_ml_operation *
|
||||
|
|
@ -368,7 +369,7 @@ ethosu_lower_add(struct ethosu_subgraph *subgraph,
|
|||
|
||||
allocate_feature_maps(subgraph, operation);
|
||||
|
||||
ethosu_allocate_feature_map(subgraph, &operation->ifm2);
|
||||
operation->ifm2.tiles.addresses[0] = ethosu_allocate_feature_map(subgraph, operation->ifm2.tensor_idx);
|
||||
operation->ifm2.tiles.height_0 = operation->ifm2.shape.height;
|
||||
operation->ifm2.tiles.height_1 = operation->ifm2.shape.height;
|
||||
operation->ifm2.tiles.width_0 = operation->ifm2.shape.width;
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ ethosu_register_tensor(struct ethosu_subgraph *subgraph,
|
|||
util_dynarray_append(&subgraph->tensors, new_tensor);
|
||||
}
|
||||
|
||||
void
|
||||
ethosu_allocate_feature_map(struct ethosu_subgraph *subgraph, struct ethosu_feature_map *feature_map)
|
||||
unsigned
|
||||
ethosu_allocate_feature_map(struct ethosu_subgraph *subgraph, unsigned tensor_idx)
|
||||
{
|
||||
struct ethosu_tensor *tensor = ethosu_find_tensor(subgraph, feature_map->tensor_idx);
|
||||
struct ethosu_tensor *tensor = ethosu_find_tensor(subgraph, tensor_idx);
|
||||
unsigned size;
|
||||
|
||||
if (tensor->layout == ETHOSU_LAYOUT_NHWC) {
|
||||
|
|
@ -77,16 +77,14 @@ ethosu_allocate_feature_map(struct ethosu_subgraph *subgraph, struct ethosu_feat
|
|||
|
||||
assert(tensor);
|
||||
|
||||
if (tensor->size > 0) {
|
||||
feature_map->tiles.addresses[0] = tensor->offset;
|
||||
return;
|
||||
}
|
||||
if (tensor->size > 0)
|
||||
return tensor->offset;
|
||||
|
||||
tensor->offset = subgraph->io_used;
|
||||
tensor->size = size;
|
||||
subgraph->io_used += ALIGN_POT(size, 16);
|
||||
|
||||
feature_map->tiles.addresses[0] = tensor->offset;
|
||||
return tensor->offset;
|
||||
}
|
||||
|
||||
struct ethosu_tensor *
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ void ethosu_ml_subgraph_read_outputs(struct pipe_context *pcontext,
|
|||
void ethosu_ml_subgraph_destroy(struct pipe_context *context,
|
||||
struct pipe_ml_subgraph *psubgraph);
|
||||
|
||||
void ethosu_allocate_feature_map(struct ethosu_subgraph *subgraph, struct ethosu_feature_map *feature_map);
|
||||
unsigned ethosu_allocate_feature_map(struct ethosu_subgraph *subgraph, unsigned tensor_idx);
|
||||
|
||||
void ethosu_register_tensor(struct ethosu_subgraph *subgraph, const struct pipe_tensor *ptensor);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue