25 #ifndef GRAPH_VALIDATE_UTILS_H 26 #define GRAPH_VALIDATE_UTILS_H 54 static const std::map<std::string, ConvolutionPaddingMode> modes =
62 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED 67 #ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED 69 catch(
const std::out_of_range &)
71 throw std::invalid_argument(value);
99 throw std::invalid_argument(
"Unsupported padding mode format");
114 uint64_t range_low{ 0 };
115 uint64_t range_high{ 16 };
121 float absolute_tolerance{ -1.f };
122 float relative_tolerance{ -1.f };
123 float tolerance_number{ -1.f };
149 int depth_multiplier{ 1 };
151 int padding_top{ 0 };
152 int padding_bottom{ 0 };
153 int padding_left{ 0 };
154 int padding_right{ 0 };
155 int padding_stride_x{ 0 };
156 int padding_stride_y{ 0 };
173 int num_outputs{ 1 };
239 const std::set<arm_compute::graph::Target> supported_targets
245 const std::set<arm_compute::DataType> supported_data_types
255 target->
set_help(
"Target to execute on");
256 data_type->
set_help(
"Data type to use");
257 help->set_help(
"Show this help message");
258 absolute_tolerance->set_help(
"Absolute tolerance used for verification");
259 relative_tolerance->set_help(
"Absolute tolerance used for verification");
260 tolerance_number->set_help(
"Absolute tolerance used for verification");
296 os <<
"Data type : " << common_params.
data_type << std::endl;
337 if(!tensor.
npy.empty())
339 return std::make_unique<arm_compute::graph_utils::NumPyBinLoader>(tensor.
npy);
343 return std::make_unique<arm_compute::graph_utils::RandomAccessor>(lower, upper, seed);
348 template <
typename D>
358 : _params(
std::move(params))
364 if(_params.output.npy.empty())
371 create_tensors(src, weights, bias, tensor);
374 fill_tensor(src, 0, static_cast<D>(_params.input.range_low), static_cast<D>(_params.input.range_high));
375 fill_tensor(weights, 1, static_cast<D>(_params.weights.range_low), static_cast<D>(_params.weights.range_high));
376 fill_tensor(bias, 2, static_cast<TBias>(_params.input.range_low), static_cast<TBias>(_params.input.range_high));
460 std::mt19937 gen(seed);
461 std::uniform_int_distribution<uint8_t>
distribution(qasymm8_low, qasymm8_high);
481 std::mt19937 gen(seed);
482 std::uniform_int_distribution<int32_t>
distribution(static_cast<int32_t>(low), static_cast<uint32_t>(high));
503 std::mt19937 gen(seed);
504 std::uniform_real_distribution<float>
distribution(low, high);
525 std::mt19937 gen(seed);
526 std::uniform_real_distribution<float>
distribution(static_cast<half>(low), static_cast<half>(high));
540 virtual float relative_tolerance() = 0;
548 virtual float absolute_tolerance() = 0;
556 virtual float tolerance_number() = 0;
567 float user_relative_tolerance = _params.verification.relative_tolerance;
568 float user_absolute_tolerance = _params.verification.absolute_tolerance;
569 float user_tolerance_num = _params.verification.tolerance_number;
571 if(user_relative_tolerance == -1)
573 user_relative_tolerance = relative_tolerance();
576 if(user_absolute_tolerance == -1)
578 user_absolute_tolerance = absolute_tolerance();
581 if(user_tolerance_num == -1)
583 user_tolerance_num = tolerance_number();
602 template <
template <
typename D>
class VerifyAccessorT>
609 return std::make_unique<VerifyAccessorT<uint8_t>>(
614 return std::make_unique<VerifyAccessorT<half>>(
619 return std::make_unique<VerifyAccessorT<float>>(
627 template <
typename LayerT,
typename OptionsT,
template <
typename D>
class VerifyAccessorT>
636 virtual LayerT GraphFunctionLayer(
ExampleParams ¶ms) = 0;
642 OptionsT Options(parser);
644 parser.
parse(argc, argv);
648 Options.consume_common_parameters(params);
649 Options.consume_parameters(params);
657 Options.print_parameters(std::cout, params);
670 << GraphFunctionLayer(params)
695 #endif //GRAPH_VALIDATE_UTILS_H GraphValidateExample(std::string name)
int padding_top
Padding graph parameters.
bool access_tensor(ITensor &tensor) override
Interface to be implemented to access a given tensor.
PadStrideInfo calculate_convolution_padding(ExampleParams params)
Calculate stride information.
Arm® Neon™ capable target device.
Class describing the value of a pixel for any image format.
Graph configuration structure Device target types.
Class reprensenting an absolute tolerance value.
arm_compute::graph::ConvolutionMethod convolution_method
ToggleOption * help
show help message
ConvolutionParams convolution
uint8_t quantize_qasymm8(float value, const INFO_TYPE &qinfo, RoundingPolicy rounding_policy=RoundingPolicy::TO_NEAREST_UP)
Quantize a value given an unsigned 8-bit asymmetric quantization scheme.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
Structure holding all the common graph parameters.
void validate(ITensor &tensor, arm_compute::test::SimpleTensor< D > output)
Validate the output versus the reference.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
Implementation of an option that can be either true or false.
half_float::half half
16-bit floating point type
1 channel, 1 F32 per channel
DataType data_type() const override
Data type of the tensor.
CommonGraphValidateOptions command line options used to configure the graph examples.
inline ::std::ostream & operator<<(::std::ostream &os, ConvolutionPaddingMode Mode)
Formatted output of the ConvolutionPaddingMode type.
Structure holding all the graph Example parameters.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Fully connected layer info.
void consume_common_graph_parameters(CommonGraphValidateOptions &options, CommonParams &common_params)
Consumes the consume_common_graph_parameters graph options and creates a structure containing any inf...
Abstract ValidateExample class.
Includes all the Graph headers at once.
Class to parse command line arguments.
decltype(strategy::transforms) typedef type
Interface for CPU tensor.
void fill_tensor(arm_compute::test::SimpleTensor< uint8_t > &tensor, std::random_device::result_type seed, uint8_t low, uint8_t high)
Fill QASYMM tensor with Random values.
Structure holding all the input tensor graph parameters.
virtual void create_tensors(arm_compute::test::SimpleTensor< D > &src, arm_compute::test::SimpleTensor< D > &weights, arm_compute::test::SimpleTensor< TBias > &bias, ITensor &tensor)
Create reference tensors.
std::unique_ptr< graph::ITensorAccessor > get_accessor(const TensorParams &tensor, PixelValue lower, PixelValue upper, const std::random_device::result_type seed=0)
Generates appropriate accessor according to the specified graph parameters.
SimpleTensor< float > src
Copyright (c) 2017-2023 Arm Limited.
arm_compute::graph::Target target
1 channel, 1 F16 per channel
virtual TensorShape output_shape(ITensor &tensor)
Calculate reference output tensor shape.
std::string tolower(std::string string)
Convert string to lower case.
Quantization information.
const auto input_shape
Validate test suite is to test ARM_COMPUTE_RETURN_ON_* macros we use to check the validity of given a...
Accessor implementation for Tensor objects.
arm_compute::DataType data_type
Structure holding all the verification graph parameters.
void parse(int argc, char **argv)
Parses the command line arguments and updates the options accordingly.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
VerificationParams verification
Structure holding all the fully_connected layer graph parameters.
fill_tensor(input_to_input_weights, std::vector< uint8_t >{ 122, 130, 124, 134, 120, 122, 134, 134 })
void fill_tensor(arm_compute::test::SimpleTensor< float > &tensor, std::random_device::result_type seed, float low, float high)
Fill F32 tensor with Random values.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
CommonGraphValidateOptions(CommandLineParser &parser) noexcept
quantized, asymmetric fixed-point 8-bit number unsigned
DepthwiseConvolutionMethod
Supported Depthwise Convolution layer methods.
UniformQuantizationInfo uniform() const
Return per layer quantization info.
Structure holding all the graph Example parameters.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void fill_tensor(arm_compute::test::SimpleTensor< half > &tensor, std::random_device::result_type seed, half low, half high)
Fill F16 tensor with Random values.
virtual void print_parameters(::std::ostream &os, const ExampleParams &common_params)
Formatted output of the ExampleParams type.
Padding and stride information class.
validate(CLAccessor(output_state), expected_output)
void consume_common_parameters(CommonParams &common_params)
std::uniform_real_distribution< float > distribution(-5.f, 5.f)
const T & value() const
Get the option value.
std::unique_ptr< graph::ITensorAccessor > get_verify_accessor(ExampleParams params)
Generates appropriate convolution verify accessor.
Num samples, channels, height, width.
Tensor accessor interface.
TensorShape permute_shape(TensorShape tensor_shape, DataLayout in_data_layout, DataLayout out_data_layout)
Permutes a given tensor shape given the input and output data layout.
constexpr float tolerance_num
Tolerance number.
Simple tensor object that stores elements in a consecutive chunk of memory.
void fill_tensor(arm_compute::test::SimpleTensor< int32_t > &tensor, std::random_device::result_type seed, int32_t low, int32_t high)
Fill S32 tensor with Random values.
arm_compute::graph::DepthwiseConvolutionMethod depth_convolution_method
SimpleOption< float > * absolute_tolerance
Absolute tolerance used in verification.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
bool do_setup(int argc, char **argv) override
Setup the example.
void do_teardown() override
Teardown the example.
VerifyAccessor(ExampleParams ¶ms)
Constructor.
Graph example validation accessor class.
Class reprensenting a relative tolerance value.
const QuantizationInfo qinfo
EnumOption< arm_compute::graph::Target > * target
Graph execution target.
ConvolutionPaddingMode padding_mode
int num_elements() const override
Number of elements of the tensor.
ConvolutionMethod
Supported Convolution layer methods.
int num_threads
Number of threads to use (thread capable backends), if 0 the backend will auto-initialize, if -1 the backend will stay as it is.
SimpleOption< int > * threads
Number of threads option.
Default approach using internal heuristics.
CLTensor * tensor
Pointer to the auxiliary tensor.
Stream frontend class to construct simple graphs in a stream fashion.
void do_run() override
Run the example.
Default approach using internal heuristics.
bool is_set() const
Has a value been assigned to the option?
void print_help(const std::string &program_name) const
Prints a help message for all configured options.
inline ::std::istream & operator>>(::std::istream &stream, ConvolutionPaddingMode &Mode)
Stream Input operator for the ConvolutionPaddingMode type.
FrameworkParams common_params
QuantizationInfo quantization_info() const override
Quantization info in case of asymmetric quantized type.
EnumOption< arm_compute::DataType > * data_type
Graph data type.
const T & value() const
Get the selected value.
SimpleOption< float > * tolerance_number
Tolerance number used in verification.
DataType
Available data types.
arm_compute::graph::frontend::Stream graph
OpenCL capable target device.
arm_compute::DataLayout data_layout
DataLayout
[DataLayout enum definition]
Structure holding all the Convolution layer graph parameters.
typename std::conditional< std::is_same< typename std::decay< D >::type, uint8_t >::value, int32_t, D >::type TBias
void set_help(std::string help)
Set the help message for the option.
Status validate(const ITensorInfo *scores_in, const ITensorInfo *boxes_in, const ITensorInfo *batch_splits_in, const ITensorInfo *scores_out, const ITensorInfo *boxes_out, const ITensorInfo *classes, const ITensorInfo *batch_splits_out, const ITensorInfo *keeps, const ITensorInfo *keeps_size, const BoxNMSLimitInfo info)
PadStrideInfo calculate_same_pad(TensorShape input_shape, TensorShape weights_shape, PadStrideInfo conv_info, DataLayout data_layout=DataLayout::NCHW, const Size2D &dilation=Size2D(1u, 1u), const DimensionRoundingType &rounding_type=DimensionRoundingType::FLOOR)
Calculate padding requirements in case of SAME padding.
SimpleOption< float > * relative_tolerance
Relative tolerance used in verification.
QuantizationInfo quant_info