24.02.1
|
Go to the documentation of this file.
43 const std::map<ComparisonOperation, std::string> supported_comparison_ops = {
50 const ITensorInfo &input2,
51 const ITensorInfo &output,
63 if (output.total_size() > 0)
67 "Wrong shape for output");
84 return std::make_pair(Status{}, win);
118 const std::string &operation_name = supported_comparison_ops.at(operation);
125 std::set<std::string> build_opts;
128 build_opts.emplace(
"-DVEC_SIZE_LEFTOVER=" +
136 build_opts.emplace(
"-DOP=" + operation_name);
137 build_opts.emplace(
"-DOP_NAME=" +
lower_string(operation_name));
143 build_opts.emplace(
"-DIS_QUANTIZED");
154 ICLKernel::configure_internal(win_config.second);
190 bool can_collapse =
true;
197 can_collapse = (in_shape1[d] == in_shape2[d]);
201 bool has_collapsed =
false;
209 Window slice_input1 =
slice.broadcast_if_dimension_le_one(in_shape1_collapsed);
210 Window slice_input2 =
slice.broadcast_if_dimension_le_one(in_shape2_collapsed);
214 unsigned int idx = 0;
std::string to_string(T &&value)
Convert integer and float values to string.
@ LessEqual
Less equal comparison ( )
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
@ Equal
Equal comparison ( )
@ Greater
Greater comparison ( )
std::string lower_string(const std::string &val)
Lower a given string.
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
virtual size_t element_size() const =0
Element size in bytes calculated as data_size() * num_channels()
Window collapse_if_possible(const Window &full_window, size_t first, size_t last, bool *has_collapsed=nullptr) const
Collapse the dimensions between first and last if possible.
Interface for OpenCL tensor.
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
void configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, ComparisonOperation operation)
Set the inputs and output tensors.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
@ Less
Less comparison ( )
#define ARM_COMPUTE_ERROR_THROW_ON(status)
CLComparisonKernel()
Default constructor.
ComparisonOperation
Supported comparison operations.
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, ComparisonOperation operation)
Static function to check if given info will lead to a valid configuration of CLComparisonKernel.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
size_t total_size() const
Collapses all dimensions to a single linear total size.
@ U8
unsigned 8-bit number
#define ARM_COMPUTE_RETURN_ERROR_ON_F16_UNSUPPORTED(tensor)
bool have_different_dimensions(const Dimensions< T > &dim1, const Dimensions< T > &dim2, unsigned int upper_dim)
cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set< std::string > &build_opts=std::set< std::string >())
Creates an opencl kernel using a compile context.
@ NotEqual
NotEqual comparison ( )
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
std::string float_to_string_with_full_precision(float val)
Create a string with the float in full precision.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *src, ITensorInfo *dst)
UniformQuantizationInfo uniform() const
Return per layer quantization info.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
virtual QuantizationInfo quantization_info() const =0
Get the quantization settings (scale and offset) of the tensor.
Window first_slice_window_3D() const
First 3D slice of the window.
const Window & window() const
The maximum window the kernel can be executed on.
const std::string & string_from_data_layout(DataLayout dl)
Convert a data layout identity into a string.
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
void add_3D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
Describe a multidimensional execution window.
@ ELEMENTWISE
Elementwise CL kernel type.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Copyright (c) 2017-2024 Arm Limited.
unsigned int adjust_vec_size(unsigned int vec_size, size_t dim0)
Returns the adjusted vector size in case it is less than the input's first dimension,...
static constexpr size_t DimZ
Alias for dimension 2 also known as Z dimension.
@ GreaterEqual
Greater equal comparison ( )
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
bool is_data_type_quantized(DataType dt)
Check if a given data type is of quantized type.
Store the tensor's metadata.
static TensorShape broadcast_shape(const Shapes &...shapes)
If shapes are broadcast compatible, return the broadcasted shape.
@ UNKNOWN
Unknown data type.
TensorShape collapsed_from(size_t start) const
Return a copy with collapsed dimensions starting from a given point.
unsigned int num_dimensions() const
Returns the effective dimensionality of the tensor.
unsigned int num_elems_processed_per_iteration
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint=CLKernelLibrary::get().default_ndrange(), bool use_dummy_work_items=false)
Add the kernel to the command queue with the given window.