Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft: [onert] support ReLU6 training #12395

Closed
wants to merge 2 commits into from

Conversation

zetwhite
Copy link
Contributor

@zetwhite zetwhite commented Jan 2, 2024

This draft is to support ReLU6 training feature.

  • Add ReLU6Grad cker
  • Extract fused activation gradient calculation part to reuse
  • Add Relu6 to EW activation layer

ONE-DCO-1.0-Signed-off-by: SeungHui Youn [email protected]

related : #12388

Comment on lines +40 to +42
grad_map.array() =
incoming_map.array() *
(0.0f < output_map.array() && output_map.array() < 6.0f).template cast<float>();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines +31 to +60
const IPortableTensor *getFusedActivationBackprop(const ir::Activation &activation,
const IPortableTensor *output,
const IPortableTensor *input_backprop,
IPortableTensor *output_backprop)
{
const IPortableTensor *res;

switch (activation)
{
case ir::Activation::NONE:
res = input_backprop;
break;
case ir::Activation::RELU:
nnfw::cker::train::ReLUGrad(getShape(output), getBuffer<float>(output),
getShape(input_backprop), getBuffer<float>(input_backprop),
getShape(output_backprop), getBuffer<float>(output_backprop));
res = output_backprop;
break;
case ir::Activation::RELU6:
nnfw::cker::train::ReLU6Grad(getShape(output), getBuffer<float>(output),
getShape(input_backprop), getBuffer<float>(input_backprop),
getShape(output_backprop), getBuffer<float>(output_backprop));
res = output_backprop;
break;
default:
throw std::runtime_error("Unsupported activation type yet");
}

return res;
}
Copy link
Contributor Author

@zetwhite zetwhite Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ragmani

While I was supporting relu6,
I found out that each layer(Convolution, FullyConnected and Pool for now) implements activation backpropagation on its own.

I'd like to extract fused activation's backpropagation part as OperationUtil to remove code duplication.

But before going on, I'd like to hear your opinion. Do you think it is fine?
( I'm a bit afraid that there's a reason it has the current implementation. )

Copy link
Contributor

@ragmani ragmani Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply. Perhaps, I missed your comment. It looks good to me.

Copy link
Contributor Author

@zetwhite zetwhite Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem!
I didn't ask again, because it wasn't in a hurry.

This draft is to support ReLU6 training feature.

 - Add ReLU6Grad cker
 - Extract fused activation gradient calculation part to reuse

ONE-DCO-1.0-Signed-off-by: SeungHui Youn <[email protected]>
@zetwhite
Copy link
Contributor Author

related code is all merged. so close this Draft :)

@zetwhite zetwhite closed this Jan 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DRAFT A draft issue or PR for sharing one's current working status and discussion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants