Merge pull request #38869 from wwwind:16x8_versioning
PiperOrigin-RevId: 310154090 Change-Id: Ie8f8a7623f87a2268e25c03c5499b686516f4ad2
This commit is contained in:
commit
6b809d9f44
@ -52,10 +52,10 @@ BuiltinOpResolver::BuiltinOpResolver() {
|
||||
AddBuiltin(BuiltinOperator_L2_POOL_2D, Register_L2_POOL_2D());
|
||||
AddBuiltin(BuiltinOperator_CONV_2D, Register_CONV_2D(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 3);
|
||||
/* max_version = */ 4);
|
||||
AddBuiltin(BuiltinOperator_DEPTHWISE_CONV_2D, Register_DEPTHWISE_CONV_2D(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 3);
|
||||
/* max_version = */ 5);
|
||||
AddBuiltin(BuiltinOperator_SVDF, Register_SVDF(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 3);
|
||||
@ -77,15 +77,15 @@ BuiltinOpResolver::BuiltinOpResolver() {
|
||||
Register_EMBEDDING_LOOKUP_SPARSE());
|
||||
AddBuiltin(BuiltinOperator_FULLY_CONNECTED, Register_FULLY_CONNECTED(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 6);
|
||||
/* max_version = */ 7);
|
||||
AddBuiltin(BuiltinOperator_LSH_PROJECTION, Register_LSH_PROJECTION());
|
||||
AddBuiltin(BuiltinOperator_HASHTABLE_LOOKUP, Register_HASHTABLE_LOOKUP());
|
||||
AddBuiltin(BuiltinOperator_SOFTMAX, Register_SOFTMAX(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 2);
|
||||
/* max_version = */ 3);
|
||||
AddBuiltin(BuiltinOperator_CONCATENATION, Register_CONCATENATION(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 2);
|
||||
/* max_version = */ 3);
|
||||
AddBuiltin(BuiltinOperator_ADD, Register_ADD(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 2);
|
||||
@ -96,7 +96,7 @@ BuiltinOpResolver::BuiltinOpResolver() {
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 3);
|
||||
AddBuiltin(BuiltinOperator_MUL, Register_MUL(), /* min_version = */ 1,
|
||||
/* max_version = */ 3);
|
||||
/* max_version = */ 4);
|
||||
AddBuiltin(BuiltinOperator_L2_NORMALIZATION, Register_L2_NORMALIZATION(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 2);
|
||||
@ -142,8 +142,9 @@ BuiltinOpResolver::BuiltinOpResolver() {
|
||||
AddBuiltin(BuiltinOperator_SUB, Register_SUB(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 3);
|
||||
AddBuiltin(BuiltinOperator_SPLIT, Register_SPLIT(), /* min_version = */ 1,
|
||||
/* max_version = */ 3);
|
||||
AddBuiltin(BuiltinOperator_SPLIT, Register_SPLIT(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 4);
|
||||
AddBuiltin(BuiltinOperator_SPLIT_V, Register_SPLIT_V(),
|
||||
/* min_version = */ 1,
|
||||
/* max_version = */ 2);
|
||||
|
@ -45,9 +45,12 @@ string GetMinimumRuntimeVersionForModel(const Model& model) {
|
||||
{{OperatorType::kConv, 1}, "1.5.0"},
|
||||
{{OperatorType::kConv, 2}, "1.14.0"},
|
||||
{{OperatorType::kConv, 3}, "1.14.0"},
|
||||
{{OperatorType::kConv, 4}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kDepthwiseConv, 1}, "1.5.0"},
|
||||
{{OperatorType::kDepthwiseConv, 2}, "1.12.0"},
|
||||
{{OperatorType::kDepthwiseConv, 3}, "1.14.0"},
|
||||
{{OperatorType::kDepthwiseConv, 4}, "1.14.0"},
|
||||
{{OperatorType::kDepthwiseConv, 5}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kAdd, 1}, "1.5.0"},
|
||||
{{OperatorType::kAdd, 2}, "1.14.0"},
|
||||
{{OperatorType::kAddN, 1}, "1.14.0"},
|
||||
@ -62,6 +65,7 @@ string GetMinimumRuntimeVersionForModel(const Model& model) {
|
||||
{{OperatorType::kCast, 1}, "1.5.0"},
|
||||
{{OperatorType::kConcatenation, 1}, "1.5.0"},
|
||||
{{OperatorType::kConcatenation, 2}, "1.14.0"},
|
||||
{{OperatorType::kConcatenation, 3}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kDepthToSpace, 1}, "2.1.0"},
|
||||
{{OperatorType::kFakeQuant, 1}, "1.5.0"},
|
||||
{{OperatorType::kFakeQuant, 2}, "1.10.0"},
|
||||
@ -71,6 +75,7 @@ string GetMinimumRuntimeVersionForModel(const Model& model) {
|
||||
{{OperatorType::kFullyConnected, 4}, "1.14.0"},
|
||||
{{OperatorType::kFullyConnected, 5}, "2.0.0"},
|
||||
{{OperatorType::kFullyConnected, 6}, "2.1.0"},
|
||||
{{OperatorType::kFullyConnected, 7}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kGather, 1}, "1.6.0"},
|
||||
{{OperatorType::kGather, 2}, "1.14.0"},
|
||||
{{OperatorType::kGather, 3}, "1.15.0"},
|
||||
@ -89,12 +94,14 @@ string GetMinimumRuntimeVersionForModel(const Model& model) {
|
||||
{{OperatorType::kMaximum, 1}, "1.14.0"},
|
||||
{{OperatorType::kMaximum, 2}, "1.14.0"},
|
||||
{{OperatorType::kMaximum, 3}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kMaximum, 4}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kMinimum, 1}, "1.14.0"},
|
||||
{{OperatorType::kMinimum, 2}, "1.14.0"},
|
||||
{{OperatorType::kMinimum, 3}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kMul, 1}, "1.5.0"},
|
||||
{{OperatorType::kMul, 2}, "1.14.0"},
|
||||
{{OperatorType::kMul, 3}, "1.15.0"},
|
||||
{{OperatorType::kMul, 4}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kPad, 1}, "1.5.0"},
|
||||
{{OperatorType::kPad, 2}, "1.14.0"},
|
||||
{{OperatorType::kTile, 1}, "1.10.1"},
|
||||
@ -104,6 +111,7 @@ string GetMinimumRuntimeVersionForModel(const Model& model) {
|
||||
{{OperatorType::kReshape, 1}, "1.5.0"},
|
||||
{{OperatorType::kSoftmax, 1}, "1.5.0"},
|
||||
{{OperatorType::kSoftmax, 2}, "1.14.0"},
|
||||
{{OperatorType::kSoftmax, 3}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kSpaceToDepth, 1}, "1.5.0"},
|
||||
{{OperatorType::kSpaceToDepth, 2}, "1.14.0"},
|
||||
{{OperatorType::kTranspose, 1}, "1.6.0"},
|
||||
@ -138,6 +146,7 @@ string GetMinimumRuntimeVersionForModel(const Model& model) {
|
||||
{{OperatorType::kSplit, 1}, "1.5.0"},
|
||||
{{OperatorType::kSplit, 2}, "1.14.0"},
|
||||
{{OperatorType::kSplit, 3}, "1.14.0"},
|
||||
{{OperatorType::kSplit, 4}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kSplitV, 2}, kPendingReleaseOpVersion},
|
||||
{{OperatorType::kStridedSlice, 1}, "1.6.0"},
|
||||
{{OperatorType::kStridedSlice, 2}, "1.14.0"},
|
||||
|
@ -53,6 +53,14 @@ inline bool HaveSameShapes(const SubGraph* subgraph, const Operator* op,
|
||||
int GetBuiltinOperatorVersion(const OpSignature& op_sig) {
|
||||
switch (op_sig.op) {
|
||||
case BuiltinOperator_CONV_2D:
|
||||
// If the op has signed int16 op_sig.inputs and op_sig.outputs, its
|
||||
// version 4.
|
||||
if (op_sig.input_types.at(0) == TensorType_INT16 &&
|
||||
op_sig.input_types.at(1) == TensorType_INT16 &&
|
||||
op_sig.output_types.at(1) == TensorType_INT16) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
// If the op has signed int8 op_sig.inputs and op_sig.outputs, its
|
||||
// version 3.
|
||||
if (op_sig.input_types.at(0) == TensorType_INT8 &&
|
||||
@ -70,6 +78,13 @@ int GetBuiltinOperatorVersion(const OpSignature& op_sig) {
|
||||
return 1;
|
||||
|
||||
case BuiltinOperator_DEPTHWISE_CONV_2D:
|
||||
// If the op accepts int16, we return version 5.
|
||||
if (op_sig.input_types.at(0) == TensorType_INT16 &&
|
||||
op_sig.input_types.at(1) == TensorType_INT16 &&
|
||||
op_sig.output_types.at(1) == TensorType_INT16) {
|
||||
return 5;
|
||||
}
|
||||
|
||||
// If the op is a signed int8 hybrid operation, we need to return
|
||||
// version 4.
|
||||
if (op_sig.input_types.at(0) == TensorType_FLOAT32 &&
|
||||
@ -105,6 +120,14 @@ int GetBuiltinOperatorVersion(const OpSignature& op_sig) {
|
||||
// | Hybrid | 3 | 3 |
|
||||
// | Quantized Int8 | 4 | 4 |
|
||||
// +-----------------+--------------------+--------------------------+
|
||||
|
||||
// Int16 fully fixed point kernel is at version 7.
|
||||
if (op_sig.input_types.at(0) == TensorType_INT16 &&
|
||||
op_sig.input_types.at(1) == TensorType_INT16 &&
|
||||
op_sig.output_types.at(0) == TensorType_INT16) {
|
||||
return 7;
|
||||
}
|
||||
|
||||
// 2 op_sig.inputs (no bias) use case is supported starting from
|
||||
// version 6.
|
||||
if (op_sig.input_types.size() == 2) {
|
||||
@ -161,6 +184,10 @@ int GetBuiltinOperatorVersion(const OpSignature& op_sig) {
|
||||
return 1;
|
||||
|
||||
case BuiltinOperator_MUL:
|
||||
// Version 4 supports int16 inputs
|
||||
if (op_sig.input_types.at(0) == TensorType_INT16) {
|
||||
return 4;
|
||||
}
|
||||
// Version 3 supports have a rescale value greater than or equal to 1.
|
||||
if (op_sig.options.mul.input1_scale != 0 &&
|
||||
op_sig.options.mul.input2_scale != 0 &&
|
||||
@ -237,6 +264,10 @@ int GetBuiltinOperatorVersion(const OpSignature& op_sig) {
|
||||
return 1;
|
||||
|
||||
case BuiltinOperator_SPLIT:
|
||||
// If the op take in16 input, it is version 4.
|
||||
if (op_sig.input_types.at(1) == TensorType_INT16) {
|
||||
return 4;
|
||||
}
|
||||
// If the op take int8 input, it is version 2, for int32 it's version 3.
|
||||
// The input tensor is at index 1 not 0, 0 is the axis.
|
||||
if (op_sig.input_types.at(1) == TensorType_INT32) {
|
||||
@ -427,11 +458,20 @@ int GetBuiltinOperatorVersion(const OpSignature& op_sig) {
|
||||
}
|
||||
return 1;
|
||||
|
||||
case BuiltinOperator_ADD:
|
||||
case BuiltinOperator_CONCATENATION:
|
||||
case BuiltinOperator_SOFTMAX:
|
||||
// In case of int16 inputs, the version is 3.
|
||||
if (op_sig.input_types.at(0) == TensorType_INT16) {
|
||||
return 3;
|
||||
}
|
||||
if (op_sig.input_types.at(0) == TensorType_INT8) {
|
||||
return 2;
|
||||
}
|
||||
return 1;
|
||||
|
||||
case BuiltinOperator_ADD:
|
||||
case BuiltinOperator_PAD:
|
||||
case BuiltinOperator_PADV2:
|
||||
case BuiltinOperator_SOFTMAX:
|
||||
case BuiltinOperator_SPACE_TO_DEPTH:
|
||||
case BuiltinOperator_SPLIT_V:
|
||||
case BuiltinOperator_MEAN:
|
||||
|
Loading…
Reference in New Issue
Block a user