17#include "../KernelGenerator.h"
18#include "../Validator.h"
27 acl_common::AclActivationBuilder<::arm_compute::ITensor, ::arm_compute::NEActivationLayer,
28 acl_common::AclFunction>;
30void Validator::visit(
const ir::operation::InstanceNorm &) {
_supported =
true; }
32void KernelGenerator::visit(
const ir::operation::InstanceNorm &node)
34 const auto ofm_index{node.getOutputs().at(0)};
39 auto ofm_tensor = _tensor_reg->getAclTensor(ofm_index);
40 auto ifm_tensor = _tensor_reg->getAclTensor(ifm_index);
41 auto epsilon = node.param().epsilon;
42 auto activation = node.param().activation;
44 if (!_ctx.
at(gamma_index).isConstant() || !_ctx.
at(beta_index).isConstant())
45 throw std::runtime_error{
"Non-constant gamma or beta for acl_neon backend InstanceNorm"};
47 auto gamma = _ctx.
at(gamma_index).asScalar<
float>();
48 auto beta = _ctx.
at(beta_index).asScalar<
float>();
49 auto fn = acl_common::generateLayer<arm_compute::NEInstanceNormalizationLayer>(
50 ifm_tensor->handle(), ofm_tensor->handle(), gamma, beta, epsilon);
52 _return_fn = std::make_unique<exec::FunctionSequence>(
static std::unique_ptr< exec::IFunction > generate(ir::Activation code, T_Tensor *ifm_alloc)
std::unique_ptr< exec::IFunction > _return_fn
const Object & at(const Index &index) const
Get the object that is associated with the given index.
std::unique_ptr< AclFunction > asAclFunction(std::unique_ptr<::arm_compute::IFunction > &&layer)
::onert::backend::acl_common::AclActivationBuilder< ::arm_compute::ITensor, ::arm_compute::NEActivationLayer, acl_common::AclFunction > ActivationBuilder