Compute Library  18.05
dequantization_layer.cl File Reference
#include "helpers.h"

Go to the source code of this file.

Functions

__kernel void dequantization_layer (__global uchar *input_ptr, uint input_stride_x, uint input_step_x, uint input_stride_y, uint input_step_y, uint input_stride_z, uint input_step_z, uint input_offset_first_element_in_bytes, __global uchar *output_ptr, uint output_stride_x, uint output_step_x, uint output_stride_y, uint output_step_y, uint output_stride_z, uint output_step_z, uint output_offset_first_element_in_bytes, __global uchar *min_max_ptr, uint min_max_stride_x, uint min_max_step_x, uint min_max_offset_first_element_in_bytes)
 This performs the dequantization of 8-bit unsigned integers to floating point. More...
 

Function Documentation

__kernel void dequantization_layer ( __global uchar *  input_ptr,
uint  input_stride_x,
uint  input_step_x,
uint  input_stride_y,
uint  input_step_y,
uint  input_stride_z,
uint  input_step_z,
uint  input_offset_first_element_in_bytes,
__global uchar *  output_ptr,
uint  output_stride_x,
uint  output_step_x,
uint  output_stride_y,
uint  output_step_y,
uint  output_stride_z,
uint  output_step_z,
uint  output_offset_first_element_in_bytes,
__global uchar *  min_max_ptr,
uint  min_max_stride_x,
uint  min_max_step_x,
uint  min_max_offset_first_element_in_bytes 
)

This performs the dequantization of 8-bit unsigned integers to floating point.

Parameters
[in]input_ptrPointer to the source image. Supported data types: QS8/QS16/F16/F32
[in]input_stride_xStride of the source image in X dimension (in bytes)
[in]input_step_xinput_stride_x * number of elements along X processed per workitem(in bytes)
[in]input_stride_yStride of the source image in Y dimension (in bytes)
[in]input_step_yinput_stride_y * number of elements along Y processed per workitem(in bytes)
[in]input_stride_zStride of the source tensor in Z dimension (in bytes)
[in]input_step_zinput_stride_z * number of elements along Z processed per workitem(in bytes)
[in]input_offset_first_element_in_bytesThe offset of the first element in the source image
[out]output_ptrPointer to the destination image. Supported data types: same as input_ptr
[in]output_stride_xStride of the destination image in X dimension (in bytes)
[in]output_step_xoutput_stride_x * number of elements along X processed per workitem(in bytes)
[in]output_stride_yStride of the destination image in Y dimension (in bytes)
[in]output_step_youtput_stride_y * number of elements along Y processed per workitem(in bytes)
[in]output_stride_zStride of the source tensor in Z dimension (in bytes)
[in]output_step_zoutput_stride_z * number of elements along Z processed per workitem(in bytes)
[in]output_offset_first_element_in_bytesThe offset of the first element in the destination image
[in]min_max_ptrPointer to the min/max vector. Minimum value in position 0, maximum value in position 1. Suppported data types: F32.
[in]min_max_stride_xStride of the min/max vector in X dimension (in bytes)
[in]min_max_step_xmin_max_stride_x * number of elements along X processed per workitem(in bytes)
[in]min_max_offset_first_element_in_bytesThe offset of the first element in the min/max vector

Definition at line 49 of file dequantization_layer.cl.

References CONVERT_TO_TENSOR3D_STRUCT, CONVERT_TO_VECTOR_STRUCT, Vector::ptr, Tensor3D::ptr, arm_compute::test::validation::scale, and arm_compute::wrapper::vmin().

53 {
54  // Get pixels pointer
55  Tensor3D input = CONVERT_TO_TENSOR3D_STRUCT(input);
56  Tensor3D output = CONVERT_TO_TENSOR3D_STRUCT(output);
57  Vector min_max = CONVERT_TO_VECTOR_STRUCT(min_max);
58 
59  // min_max_value.s0 = min, min_max_value.s1 = max
60  const float2 min_max_value = vload2(0, (__global float *)min_max.ptr);
61 
62  const float4 vmin = (float4)min_max_value.s0;
63  const float4 scale = (float4)((min_max_value.s1 - min_max_value.s0) / 255.0f);
64 
65  // Load data
66  const uchar4 data = vload4(0, (__global uchar *)input.ptr);
67 
68  // Dequantize
69  const float4 res = convert_float4(data) * scale + vmin;
70 
71  // Store result
72  vstore4(res, 0, (__global float *)output.ptr);
73 }
Structure to hold Vector information.
Definition: helpers.h:134
#define CONVERT_TO_TENSOR3D_STRUCT(name)
Definition: helpers.h:119
#define CONVERT_TO_VECTOR_STRUCT(name)
Definition: helpers.h:98
Structure to hold 3D tensor information.
Definition: helpers.h:151
uint8x8_t vmin(const uint8x8_t &a, const uint8x8_t &b)
Definition: min.h:39
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:136
__global uchar * ptr
Pointer to the starting postion of the buffer.
Definition: helpers.h:153