MCPcopy Create free account
hub / github.com/KnowingNothing/MatmulTutorial / random_fill

Function random_fill

include/common.h:283–289  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

281
282template <class DType>
283void random_fill(DType* tensor, std::vector<int> shape) {
284 int length =
285 std::accumulate(shape.begin(), shape.end(), 1, std::multiplies<int>());
286 for (int i = 0; i < length; ++i) {
287 tensor[i] = (DType)((rand() % 1000 * 1 / 100 % 10 - 5.0));
288 }
289}
290
291template <class DType>
292void arange_fill(DType* tensor, std::vector<int> shape, int bound = 1024) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected