Check bias tensor ID in XNNPACK delegate
Verify that bias tensor ID in CONV_2D, DEPTHWISE_CONV_2D, and FULLY_CONNECTED nodes is non-negative. If the check fails, interpret it as missing bias input, and reject delegating the node without any out-of-bound access. PiperOrigin-RevId: 342050053 Change-Id: Ia2e53b552f44aaf86a1028eeaa6ae2bb29edd052
This commit is contained in:
parent
0a65354842
commit
c1b46f8df4
@ -1231,7 +1231,14 @@ class Subgraph {
|
||||
logging_context, filter_tensor, node->inputs->data[1], node_index));
|
||||
}
|
||||
|
||||
const TfLiteTensor& bias_tensor = tensors[node->inputs->data[2]];
|
||||
const int bias_tensor_id = node->inputs->data[2];
|
||||
if (bias_tensor_id < 0) {
|
||||
TF_LITE_MAYBE_KERNEL_LOG(logging_context,
|
||||
"unsupported CONV_2D node #%d without bias",
|
||||
node_index);
|
||||
return kTfLiteError;
|
||||
}
|
||||
const TfLiteTensor& bias_tensor = tensors[bias_tensor_id];
|
||||
TF_LITE_ENSURE_STATUS(CheckTensorFloatType(
|
||||
logging_context, bias_tensor, node->inputs->data[2], node_index));
|
||||
TF_LITE_ENSURE_STATUS(CheckTensorShape(logging_context, bias_tensor, 1,
|
||||
@ -1319,7 +1326,14 @@ class Subgraph {
|
||||
logging_context, filter_tensor, node->inputs->data[1], node_index));
|
||||
}
|
||||
|
||||
const TfLiteTensor& bias_tensor = tensors[node->inputs->data[2]];
|
||||
const int bias_tensor_id = node->inputs->data[2];
|
||||
if (bias_tensor_id < 0) {
|
||||
TF_LITE_MAYBE_KERNEL_LOG(
|
||||
logging_context,
|
||||
"unsupported DEPTHWISE_CONV_2D node #%d without bias", node_index);
|
||||
return kTfLiteError;
|
||||
}
|
||||
const TfLiteTensor& bias_tensor = tensors[bias_tensor_id];
|
||||
TF_LITE_ENSURE_STATUS(CheckTensorFloatType(
|
||||
logging_context, filter_tensor, node->inputs->data[2], node_index));
|
||||
TF_LITE_ENSURE_STATUS(CheckTensorShape(logging_context, bias_tensor, 1,
|
||||
@ -1503,7 +1517,14 @@ class Subgraph {
|
||||
logging_context, filter_tensor, node->inputs->data[1], node_index));
|
||||
}
|
||||
|
||||
const TfLiteTensor& bias_tensor = tensors[node->inputs->data[2]];
|
||||
const int bias_tensor_id = node->inputs->data[2];
|
||||
if (bias_tensor_id < 0) {
|
||||
TF_LITE_MAYBE_KERNEL_LOG(
|
||||
logging_context, "unsupported FULLY_CONNECTED node #%d without bias",
|
||||
node_index);
|
||||
return kTfLiteError;
|
||||
}
|
||||
const TfLiteTensor& bias_tensor = tensors[bias_tensor_id];
|
||||
TF_LITE_ENSURE_STATUS(CheckTensorFloatType(
|
||||
logging_context, filter_tensor, node->inputs->data[2], node_index));
|
||||
TF_LITE_ENSURE_STATUS(CheckTensorShape(logging_context, bias_tensor, 1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user