From c8b187ffa4ef4b56912df4a927ee287bfca0f3bf Mon Sep 17 00:00:00 2001 From: Satya Jandhyala Date: Sat, 17 Aug 2024 13:02:18 -0700 Subject: [PATCH] Added a test case with zero-size pastKey/pastValue inputs that requires presentKey/presentValue outputs. --- .../test/data/ops/multihead-attention.jsonc | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/js/web/test/data/ops/multihead-attention.jsonc b/js/web/test/data/ops/multihead-attention.jsonc index ed937a22c0b84..9ae866327b3f2 100644 --- a/js/web/test/data/ops/multihead-attention.jsonc +++ b/js/web/test/data/ops/multihead-attention.jsonc @@ -1073,5 +1073,80 @@ ] } ] + }, + { + "name": "MultiHeadAttention Basic, one head and head-size=1 with empty pastKey, pastValue inputs and optional presentKey, presentValue outputs", + "operator": "MultiHeadAttention", + "opset": { "domain": "com.microsoft", "version": 1 }, + "attributes": [{ "name": "num_heads", "data": 1, "type": "int" }], + "cases": [ + { + "name": "T[0]", + "inputs": [ + // Q + { + "data": [1], + "dims": [1, 1, 1], + "type": "float32" + }, + // K + { + "data": [2], + "dims": [1, 1, 1], + "type": "float32" + }, + // V + { + "data": [3], + "dims": [1, 1, 1], + "type": "float32" + }, + // Bias + { + "data": null, + "type": "float32" + }, + // Mask + { + "data": null, + "type": "int32" + }, + // AttentionBias + { + "data": null, + "type": "float32" + }, + // PastKey + { + "data": [], + "dims": [1, 1, 0, 1], + "type": "float32" + }, + // PastValue + { + "data": [], + "dims": [1, 1, 0, 1], + "type": "float32" + } + ], + "outputs": [ + { + "data": [3], + "dims": [1, 1, 1], + "type": "float32" + }, + { + "data": [2], + "dims": [1, 1, 1, 1], + "type": "float32" + }, + { + "data": [3], + "dims": [1, 1, 1, 1], + "type": "float32" + } + ] + } + ] } ]