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

Method setup

tests/benchmark/fixtures/ScaleFixture.h:44–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42{
43public:
44 void setup(TensorShape shape,
45 DataType data_type,
46 DataLayout data_layout,
47 InterpolationPolicy policy,
48 BorderMode border_mode,
49 SamplingPolicy sampling_policy)
50 {
51 constexpr float max_width = 8192.0f;
52 constexpr float max_height = 6384.0f;
53
54 // Change shape in case of NHWC.
55 if (data_layout == DataLayout::NHWC)
56 {
57 permute(shape, PermutationVector(2U, 0U, 1U));
58 }
59
60 std::mt19937 generator(library->seed());
61 std::uniform_real_distribution<float> distribution_float(0.25f, 3.0f);
62 float scale_x = distribution_float(generator);
63 float scale_y = distribution_float(generator);
64
65 scale_x = ((shape.x() * scale_x) > max_width) ? (max_width / shape.x()) : scale_x;
66 scale_y = ((shape.y() * scale_y) > max_height) ? (max_height / shape.y()) : scale_y;
67
68 std::uniform_int_distribution<uint8_t> distribution_u8(0, 255);
69 uint8_t constant_border_value = static_cast<uint8_t>(distribution_u8(generator));
70
71 const int idx_width = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
72 const int idx_height = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
73
74 TensorShape shape_scaled(shape);
75 shape_scaled.set(idx_width, shape[idx_width] * scale_x);
76 shape_scaled.set(idx_height, shape[idx_height] * scale_y);
77
78 // Create tensors
79 src = create_tensor<TensorType>(shape, data_type);
80 dst = create_tensor<TensorType>(shape_scaled, data_type);
81
82 // Create and configure function
83 scale_func.configure(&src, &dst,
84 ScaleKernelInfo{policy, border_mode, constant_border_value, sampling_policy, false});
85
86 // Allocate tensors
87 src.allocator()->allocate();
88 dst.allocator()->allocate();
89 }
90
91 void run()
92 {

Callers

nothing calls this directly

Calls 8

seedMethod · 0.80
permuteFunction · 0.50
xMethod · 0.45
yMethod · 0.45
setMethod · 0.45
configureMethod · 0.45
allocateMethod · 0.45
allocatorMethod · 0.45

Tested by

no test coverage detected