MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / configure

Method configure

src/gpu/cl/kernels/ClDequantizeKernel.cpp:81–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79}
80
81void ClDequantizeKernel::configure(const CLCompileContext &compile_context, ITensorInfo *src, ITensorInfo *dst)
82{
83 ARM_COMPUTE_ERROR_ON_NULLPTR(src, dst);
84
85 // Output tensor auto initialization if not yet initialized
86 auto_init_if_empty(*dst, src->tensor_shape(), 1, DataType::F32);
87
88 auto padding_info = get_padding_info({src, dst});
89
90 ARM_COMPUTE_ERROR_THROW_ON(validate_arguments(src, dst));
91
92 const int vec_size_x = 16 / dst->element_size();
93 const int output_width_x = dst->tensor_shape().x();
94 const bool multi_access_x = (output_width_x / vec_size_x > 0);
95
96 const bool is_quantized_per_channel = is_data_type_quantized_per_channel(src->data_type());
97 std::string kernel_name = "dequantization_layer";
98
99 // Create kernel
100 CLBuildOptions build_opts;
101 if (!is_quantized_per_channel)
102 {
103 const UniformQuantizationInfo qinfo = src->quantization_info().uniform();
104 const int qoffset = is_data_type_quantized_asymmetric(src->data_type()) ? qinfo.offset : 0;
105 build_opts.add_option("-DSCALE=" + float_to_string_with_full_precision(qinfo.scale));
106 build_opts.add_option("-DOFFSET=" + support::cpp11::to_string(qoffset));
107 }
108 else
109 {
110 kernel_name += "_per_channel";
111 kernel_name += src->data_layout() == DataLayout::NCHW ? "_nchw" : "_nhwc";
112 }
113
114 build_opts.add_option("-DVEC_SIZE=" + support::cpp11::to_string(vec_size_x));
115 build_opts.add_option("-DDATA_TYPE_SRC=" + get_cl_type_from_data_type(src->data_type()));
116 build_opts.add_option("-DDATA_TYPE_DST=" + get_cl_type_from_data_type(dst->data_type()));
117 build_opts.add_option_if(multi_access_x, "-DLAST_ACCESSED_X=" + support::cpp11::to_string(
118 std::max<int>(output_width_x - vec_size_x, 0)));
119
120 // Create kernel name
121 _kernel = create_kernel(compile_context, kernel_name, build_opts.options());
122
123 // Configure kernel window
124 Window win = calculate_max_window(*dst);
125 if (multi_access_x)
126 {
127 win.set(Window::DimX,
128 Window::Dimension(win.x().start(), ceil_to_multiple(win.x().end(), vec_size_x), vec_size_x));
129 }
130 ICLKernel::configure_internal(win);
131
132 ARM_COMPUTE_ERROR_ON(has_padding_changed(padding_info));
133}
134
135Status ClDequantizeKernel::validate(const ITensorInfo *src, const ITensorInfo *dst)
136{

Callers

nothing calls this directly

Calls 15

auto_init_if_emptyFunction · 0.85
get_padding_infoFunction · 0.85
create_kernelFunction · 0.85
ceil_to_multipleFunction · 0.85
has_padding_changedFunction · 0.85
add_option_ifMethod · 0.80
validate_argumentsFunction · 0.70
to_stringFunction · 0.50

Tested by

no test coverage detected