Merge pull request #46215 from ddavis-2015:LeakyRelu-pr1
PiperOrigin-RevId: 351451889 Change-Id: I533ab24ccc2a0f89f978c57874d378fa14336cc2
This commit is contained in:
commit
4c7e5af62a
@ -253,6 +253,10 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type,
|
||||
return ParsePool(op, error_reporter, allocator, builtin_data);
|
||||
}
|
||||
|
||||
case BuiltinOperator_LEAKY_RELU: {
|
||||
return ParseLeakyRelu(op, error_reporter, allocator, builtin_data);
|
||||
}
|
||||
|
||||
case BuiltinOperator_LESS: {
|
||||
return ParseLess(op, error_reporter, allocator, builtin_data);
|
||||
}
|
||||
@ -682,16 +686,6 @@ TfLiteStatus ParseOpDataTfLite(const Operator* op, BuiltinOperator op_type,
|
||||
*builtin_data = params.release();
|
||||
return kTfLiteOk;
|
||||
}
|
||||
case BuiltinOperator_LEAKY_RELU: {
|
||||
auto params = safe_allocator.Allocate<TfLiteLeakyReluParams>();
|
||||
TF_LITE_ENSURE(error_reporter, params != nullptr);
|
||||
if (const auto* leaky_relu_params =
|
||||
op->builtin_options_as_LeakyReluOptions()) {
|
||||
params->alpha = leaky_relu_params->alpha();
|
||||
}
|
||||
*builtin_data = params.release();
|
||||
return kTfLiteOk;
|
||||
}
|
||||
case BuiltinOperator_MIRROR_PAD: {
|
||||
auto params = safe_allocator.Allocate<TfLiteMirrorPaddingParams>();
|
||||
TF_LITE_ENSURE(error_reporter, params != nullptr);
|
||||
@ -1266,6 +1260,22 @@ TfLiteStatus ParseL2Normalization(const Operator* op,
|
||||
return kTfLiteOk;
|
||||
}
|
||||
|
||||
TfLiteStatus ParseLeakyRelu(const Operator* op, ErrorReporter* error_reporter,
|
||||
BuiltinDataAllocator* allocator,
|
||||
void** builtin_data) {
|
||||
CheckParsePointerParams(op, error_reporter, allocator, builtin_data);
|
||||
|
||||
SafeBuiltinDataAllocator safe_allocator(allocator);
|
||||
auto params = safe_allocator.Allocate<TfLiteLeakyReluParams>();
|
||||
TF_LITE_ENSURE(error_reporter, params != nullptr);
|
||||
if (const auto* leaky_relu_params =
|
||||
op->builtin_options_as_LeakyReluOptions()) {
|
||||
params->alpha = leaky_relu_params->alpha();
|
||||
}
|
||||
*builtin_data = params.release();
|
||||
return kTfLiteOk;
|
||||
}
|
||||
|
||||
// We have this parse function instead of directly returning kTfLiteOk from the
|
||||
// switch-case in ParseOpData because this function is used as part of the
|
||||
// selective registration for the OpResolver implementation in micro.
|
||||
|
@ -155,6 +155,10 @@ TfLiteStatus ParseL2Normalization(const Operator* op,
|
||||
BuiltinDataAllocator* allocator,
|
||||
void** builtin_data);
|
||||
|
||||
TfLiteStatus ParseLeakyRelu(const Operator* op, ErrorReporter* error_reporter,
|
||||
BuiltinDataAllocator* allocator,
|
||||
void** builtin_data);
|
||||
|
||||
TfLiteStatus ParseLess(const Operator* op, ErrorReporter* error_reporter,
|
||||
BuiltinDataAllocator* allocator, void** builtin_data);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user