ONE - On-device Neural Engine
Loading...
Searching...
No Matches
arm_compute::NEInstanceNormalizationLayerEx Class Reference

#include <NEInstanceNormalizationLayerEx.h>

Collaboration diagram for arm_compute::NEInstanceNormalizationLayerEx:

Public Member Functions

 NEInstanceNormalizationLayerEx (std::shared_ptr< IMemoryManager > memory_manager=nullptr)
 
void configure (ITensor *input, ITensor *output, ITensor *gamma, ITensor *beta, float epsilon=1e-12f)
 
void run () override
 

Static Public Member Functions

static Status validate (const ITensorInfo *input, const ITensorInfo *output, const ITensorInfo *gamma=nullptr, const ITensorInfo *beta=nullptr, float epsilon=1e-12f)
 

Detailed Description

Basic function to perform a Instance normalization.

This function runs the following kernels:

  1. NEInstanceNormalizationLayerKernelEx

Definition at line 64 of file NEInstanceNormalizationLayerEx.h.

Constructor & Destructor Documentation

◆ NEInstanceNormalizationLayerEx()

arm_compute::NEInstanceNormalizationLayerEx::NEInstanceNormalizationLayerEx ( std::shared_ptr< IMemoryManager >  memory_manager = nullptr)

Constructor

Definition at line 48 of file NEInstanceNormalizationLayerEx.cpp.

50 : _memory_group(std::move(memory_manager)), _normalization_kernel(), _is_nchw(false),
51 _permute_input(), _permute_output(), _permuted_input(), _permuted_output()
52{
53}

Member Function Documentation

◆ configure()

void arm_compute::NEInstanceNormalizationLayerEx::configure ( ITensor *  input,
ITensor *  output,
ITensor *  gamma,
ITensor *  beta,
float  epsilon = 1e-12f 
)

Set the input and output tensors.

Parameters
[in,out]inputSource tensor. In case of output tensor = nullptr this tensor will store the result of the normalization. Data types supported: F16/F32. Data layout supported: NHWC, NCHW
[out]outputDestination tensor. Data types and data layouts supported: same as input.
[in]gamma(Optional) The scale scalar value applied to the normalized tensor. Defaults to 1.0
[in]beta(Optional) The offset scalar value applied to the normalized tensor. Defaults to 0.0
[in]epsilon(Optional) Lower bound value for the normalization. Defaults to 1e-12

Definition at line 55 of file NEInstanceNormalizationLayerEx.cpp.

57{
58 const DataLayout data_layout = input->info()->data_layout();
59
60 // Configure Kernels
61 _is_nchw = data_layout == DataLayout::NCHW;
62
63 if (!_is_nchw)
64 {
65 _memory_group.manage(&_permuted_input);
66 _memory_group.manage(&_permuted_output);
67
68 // Configure the function to transform the input tensor from NHWC -> NCHW
69 _permute_input.configure(input, &_permuted_input, PermutationVector(1U, 2U, 0U));
70 _permuted_input.info()->set_data_layout(DataLayout::NCHW);
71
72 _normalization_kernel.configure(&_permuted_input, &_permuted_output, gamma, beta, epsilon);
73 _permuted_output.info()->set_data_layout(DataLayout::NCHW);
74
75 _permute_output.configure(&_permuted_output, output != nullptr ? output : input,
76 PermutationVector(2U, 0U, 1U));
77 _permuted_input.allocator()->allocate();
78 _permuted_output.allocator()->allocate();
79 }
80 else
81 {
82 _normalization_kernel.configure(input, output, gamma, beta, epsilon);
83 }
84}
void configure(ITensor *input, ITensor *output, ITensor *gamma=nullptr, ITensor *beta=nullptr, float epsilon=1e-12f)

References arm_compute::NEInstanceNormalizationLayerKernelEx::configure().

◆ run()

void arm_compute::NEInstanceNormalizationLayerEx::run ( )
override

Definition at line 95 of file NEInstanceNormalizationLayerEx.cpp.

96{
97 MemoryGroupResourceScope scope_mg(_memory_group);
98
99 // Permute input
100 if (!_is_nchw)
101 {
102 _permute_input.run();
103 }
104
105 NEScheduler::get().schedule(&_normalization_kernel, Window::DimZ);
106
107 // Permute output
108 if (!_is_nchw)
109 {
110 _permute_output.run();
111 }
112}

Referenced by package.infer.session::inference().

◆ validate()

Status arm_compute::NEInstanceNormalizationLayerEx::validate ( const ITensorInfo *  input,
const ITensorInfo *  output,
const ITensorInfo *  gamma = nullptr,
const ITensorInfo *  beta = nullptr,
float  epsilon = 1e-12f 
)
static

Static function to check if given info will lead to a valid configuration of NEInstanceNormalizationLayer.

Parameters
[in]inputSource tensor info. Data types supported: F16/F32. Data layout supported: NHWC, NCHW
[in]outputDestination tensor info. Data types and data layouts supported: same as input.
[in]gamma(Optional) The scale scalar value applied to the normalized tensor. Defaults to 1.0
[in]beta(Optional) The offset scalar value applied to the normalized tensor. Defaults to 0.0
[in]epsilon(Optional) Lower bound value for the normalization. Defaults to 1e-12
Returns
a status

Definition at line 86 of file NEInstanceNormalizationLayerEx.cpp.

89{
91 &input->clone()->set_data_layout(DataLayout::NCHW),
92 &output->clone()->set_data_layout(DataLayout::NCHW), gamma, beta, epsilon);
93}
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const ITensorInfo *gamma=nullptr, const ITensorInfo *beta=nullptr, float epsilon=1e-12f)

References arm_compute::NEInstanceNormalizationLayerKernelEx::validate().


The documentation for this class was generated from the following files: