MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / GenerateRandomTensor

Function GenerateRandomTensor

tensorflow/lite/testing/generate_testspec.h:51–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49// random_func returns the generated random element at given index.
50template <typename T>
51std::vector<T> GenerateRandomTensor(const std::vector<int>& shape,
52 const std::function<T(int)>& random_func) {
53 int64_t num_elements = 1;
54 for (const int dim : shape) {
55 num_elements *= dim;
56 }
57
58 std::vector<T> result(num_elements);
59 for (int i = 0; i < num_elements; i++) {
60 result[i] = random_func(i);
61 }
62 return result;
63}
64
65} // namespace testing
66} // namespace tflite

Callers 1

GenerateCsvFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected