17#include "../KernelGenerator.h"
18#include "../Validator.h"
26void Validator::visit(
const ir::operation::InstanceNorm &) {
_supported =
true; }
28void KernelGenerator::visit(
const ir::operation::InstanceNorm &node)
30 const auto ofm_index{node.getOutputs().at(0)};
35 auto ofm_tensor = _tensor_reg->getAclTensor(ofm_index);
36 auto ifm_tensor = _tensor_reg->getAclTensor(ifm_index);
37 auto epsilon = node.param().epsilon;
38 auto activation = node.param().activation;
40 if (!_ctx.
at(gamma_index).isConstant() || !_ctx.
at(beta_index).isConstant())
41 throw std::runtime_error{
"Non-constant gamma or beta for acl_cl backend InstanceNorm"};
43 auto gamma = _ctx.
at(gamma_index).asScalar<
float>();
44 auto beta = _ctx.
at(beta_index).asScalar<
float>();
45 auto fn = acl_common::generateLayer<arm_compute::CLInstanceNormalizationLayer>(
46 ifm_tensor->handle(), ofm_tensor->handle(), gamma, beta, epsilon);
49 acl_common::AclActivationBuilder<::arm_compute::ICLTensor, ::arm_compute::CLActivationLayer,
50 acl_common::AclFunction>;
52 _return_fn = std::make_unique<exec::FunctionSequence>(
54 ActivationBuilder::generate(activation, ofm_tensor->handle()));
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