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

Function initRandom

tests/unittests/unittest_utils.h:148–154  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146
147template<typename T>
148void initRandom(T* ptr, size_t size, float minval, float maxval) {
149 for (size_t i = 0; i < size; ++i) {
150 float val = static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
151 val *= (maxval - minval);
152 ptr[i] = static_cast<T>(minval + val);
153 }
154}
155
156void initRandomInt(int* ptr, size_t size, int minval, int maxval) {
157 assert(minval < maxval);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected