MCPcopy Create free account
hub / github.com/ARM-software/armnn / MakeRandomTensor

Function MakeRandomTensor

include/armnnTestUtils/TensorHelpers.hpp:224–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

222
223template <typename T>
224std::vector<T> MakeRandomTensor(const armnn::TensorInfo& tensorInfo,
225 unsigned int seed,
226 float min = -10.0f,
227 float max = 10.0f)
228{
229 std::mt19937 gen(seed);
230 std::uniform_real_distribution<float> dist(min, max);
231
232 std::vector<float> init(tensorInfo.GetNumElements());
233 for (unsigned int i = 0; i < init.size(); i++)
234 {
235 init[i] = dist(gen);
236 }
237
238 const float qScale = tensorInfo.GetQuantizationScale();
239 const int32_t qOffset = tensorInfo.GetQuantizationOffset();
240
241 return armnnUtils::QuantizedVector<T>(init, qScale, qOffset);
242}

Callers

nothing calls this directly

Calls 4

GetNumElementsMethod · 0.45
sizeMethod · 0.45
GetQuantizationScaleMethod · 0.45
GetQuantizationOffsetMethod · 0.45

Tested by

no test coverage detected