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

#include <CLNegKernel.h>

Collaboration diagram for arm_compute::CLNegKernel:

Public Member Functions

 CLNegKernel ()
 
 CLNegKernel (const CLNegKernel &)=delete
 
CLNegKerneloperator= (const CLNegKernel &)=delete
 
 CLNegKernel (CLNegKernel &&)=default
 
CLNegKerneloperator= (CLNegKernel &&)=default
 
void configure (const ICLTensor *input, ICLTensor *output)
 
void run (const Window &window, cl::CommandQueue &queue) override
 

Detailed Description

OpenCL kernel to perform a negation operation on tensor

Definition at line 51 of file CLNegKernel.h.

Constructor & Destructor Documentation

◆ CLNegKernel() [1/3]

CLNegKernel::CLNegKernel ( )

Default constructor

Definition at line 69 of file CLNegKernel.cpp.

69: _input(nullptr), _output(nullptr) {}

◆ CLNegKernel() [2/3]

arm_compute::CLNegKernel::CLNegKernel ( const CLNegKernel )
delete

Prevent instances of this class from being copied (As this class contains pointers).

◆ CLNegKernel() [3/3]

arm_compute::CLNegKernel::CLNegKernel ( CLNegKernel &&  )
default

Allow instances of this class to be moved

Member Function Documentation

◆ configure()

void CLNegKernel::configure ( const ICLTensor *  input,
ICLTensor *  output 
)

Initialize the kernel's input, output.

Parameters
[in]inputSource tensor.
[out]outputDestination tensor.

Definition at line 71 of file CLNegKernel.cpp.

72{
73
74 ARM_COMPUTE_ERROR_ON_NULLPTR(input, output);
75 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(input->info(), output->info()));
76
77 _input = input;
78 _output = output;
79
80 constexpr unsigned int num_elems_processed_per_iteration = 16;
81
82 // Create kernel
83 std::set<std::string> build_opts;
84 build_opts.emplace(("-DDATA_TYPE=" + get_cl_type_from_data_type(input->info()->data_type())));
85 build_opts.emplace(
86 ("-DVEC_SIZE=" + support::cpp11::to_string(num_elems_processed_per_iteration)));
87 _kernel =
88 static_cast<cl::Kernel>(CLKernelLibraryEx::get().create_kernel("neg_tensor", build_opts));
89
90 // Configure window
91 Window win = calculate_max_window(*input->info(), Steps(num_elems_processed_per_iteration));
92
93 AccessWindowHorizontal input_access(input->info(), 0, num_elems_processed_per_iteration);
94 AccessWindowHorizontal output_access(output->info(), 0, num_elems_processed_per_iteration);
95 update_window_and_padding(win, input_access, output_access);
96 output_access.set_valid_region(win, input->info()->valid_region());
97
98 ICLKernel::configure_internal(win);
99}
static CLKernelLibraryEx & get()
Get the KernelLibrary singleton.
Kernel create_kernel(const std::string &kernel_name, const StringSet &build_options_set={}) const
Create a kernel from the kernel library.

References arm_compute::CLKernelLibraryEx::create_kernel(), and arm_compute::CLKernelLibraryEx::get().

◆ operator=() [1/2]

CLNegKernel & arm_compute::CLNegKernel::operator= ( CLNegKernel &&  )
default

Allow instances of this class to be moved

◆ operator=() [2/2]

CLNegKernel & arm_compute::CLNegKernel::operator= ( const CLNegKernel )
delete

Prevent instances of this class from being copied (As this class contains pointers).

◆ run()

void CLNegKernel::run ( const Window &  window,
cl::CommandQueue &  queue 
)
override

Definition at line 101 of file CLNegKernel.cpp.

102{
103 ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(this);
104 ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(ICLKernel::window(), window);
105
106 Window collapsed = window.collapse_if_possible(ICLKernel::window(), Window::DimZ);
107 Window slice = collapsed.first_slice_window_3D();
108
109 do
110 {
111 unsigned int idx = 0;
112 add_3D_tensor_argument(idx, _input, slice);
113 add_3D_tensor_argument(idx, _output, slice);
114 enqueue(queue, *this, slice, lws_hint());
115 } while (collapsed.slide_window_slice_3D(slice));
116}

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


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