MCPcopy Create free account
hub / github.com/NVIDIA/FasterTransformer / initRandom

Function initRandom

tests/unittests/gtest_utils.h:105–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

103
104template<typename T>
105void initRandom(T* ptr, size_t size, float minval, float maxval) {
106 for (size_t i = 0; i < size; ++i) {
107 float val = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
108 val *= (maxval - minval);
109 ptr[i] = static_cast<T>(minval + val);
110 }
111}
112
113void initRandomInt(int* ptr, size_t size, int minval, int maxval) {
114 assert(minval < maxval);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected