ethosu: Fix scalar ADD on U85

They added new registers tot he command stream, with a new bitfield
layout.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39611>
This commit is contained in:
Tomeu Vizoso 2026-03-22 17:49:30 +01:00 committed by Marge Bot
parent 818e1835d7
commit 2a6d181bc6
2 changed files with 40 additions and 7 deletions

View file

@ -539,16 +539,42 @@ emit_pooling(struct ethosu_subgraph *subgraph, struct ethosu_operation *operatio
emit_acc_format(subgraph, operation);
}
static void
emit_ifm2_precision(struct ethosu_subgraph *subgraph,
struct ethosu_operation *operation,
bool has_scalar)
{
struct ethosu_tensor *tensor = ethosu_find_tensor(subgraph, operation->ifm2.tensor_idx);
unsigned prec = 0;
prec |= NPU_SET_IFM2_PRECISION_ACTIVATION_TYPE(operation->ifm2.is_signed);
prec |= NPU_SET_IFM2_PRECISION_ACTIVATION_PRECISION(operation->ifm2.precision);
if (tensor->layout == ETHOSU_LAYOUT_NHCWB16)
prec |= NPU_SET_IFM2_PRECISION_ACTIVATION_FORMAT(1);
/* Vela: scalar → NONE(3), non-scalar → TILE2X2(0) */
if (has_scalar)
prec |= NPU_SET_IFM2_PRECISION_ACTIVATION_STORAGE(3);
EMIT0(NPU_SET_IFM2_PRECISION, prec);
}
static void
emit_ifm2(struct ethosu_subgraph *subgraph, struct ethosu_operation *operation, bool has_scalar)
{
if (!has_scalar) {
if (has_scalar) {
if (ethosu_is_u65(ethosu_screen(subgraph->base.context->screen)))
EMIT0(NPU_SET_IFM2_SCALAR, operation->ifm2.scalar);
else {
emit_ifm2_precision(subgraph, operation, true);
EMIT1(NPU_SET_OP_SCALAR, 0, operation->ifm2.scalar);
}
} else {
EMIT0(NPU_SET_IFM2_REGION, IO_REGION);
emit_addresses(subgraph, &operation->ifm2, NPU_SET_IFM2_BASE0, NPU_SET_IFM2_BASE1, NPU_SET_IFM2_BASE2, NPU_SET_IFM2_BASE3);
emit_tiles(subgraph, &operation->ifm2, NPU_SET_IFM2_HEIGHT0_M1, NPU_SET_IFM2_HEIGHT1_M1, NPU_SET_IFM2_WIDTH0_M1);
emit_strides(subgraph, &operation->ifm2, NPU_SET_IFM2_STRIDE_C, NPU_SET_IFM2_STRIDE_Y, NPU_SET_IFM2_STRIDE_X);
} else {
EMIT0(NPU_SET_IFM2_SCALAR, operation->ifm2.scalar);
}
EMIT0(NPU_SET_IFM2_ZERO_POINT, operation->ifm2.zero_point);
}

View file

@ -242,10 +242,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<bitfield name="param" low="0" high="15" type="uint"/>
</reg32>
<reg32 offset="0x185" name="NPU_SET_IFM2_PRECISION">
<bitfield name="reserved1" low="8" high="15" type="uint"/>
<bitfield name="format" low="6" high="7" type="uint"/>
<bitfield name="reserved0" low="4" high="5" type="uint"/>
<bitfield name="precision" low="0" high="3" type="uint"/>
<bitfield name="activation_storage" low="14" high="15" type="uint"/>
<bitfield name="reserved3" low="8" high="13" type="uint"/>
<bitfield name="activation_format" low="6" high="7" type="uint"/>
<bitfield name="reserved2" low="4" high="5" type="uint"/>
<bitfield name="activation_precision" low="2" high="3" type="uint"/>
<bitfield name="reserved1" low="1" high="1" type="uint"/>
<bitfield name="activation_type" low="0" high="0" type="uint"/>
</reg32>
<reg32 offset="0x189" name="NPU_SET_IFM2_ZERO_POINT">
<bitfield name="param" low="0" high="15" type="uint"/>
@ -379,6 +382,10 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
<bitfield name="param" low="2" high="17" type="uint"/>
<bitfield name="payload_size" low="0" high="1" type="uint"/>
</reg32>
<reg32 offset="0x39" name="NPU_SET_OP_SCALAR">
<bitfield name="param" low="2" high="17" type="uint"/>
<bitfield name="payload_size" low="0" high="1" type="uint"/>
</reg32>
<reg32 offset="0x80" name="NPU_SET_IFM2_BASE0">
<bitfield name="reserved0" low="2" high="17" type="uint"/>
<bitfield name="payload_size" low="0" high="1" type="uint"/>