MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / gen

Method gen

dnn/test/rocm/argmxx.cpp:14–31  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12class ArgmxxRNG final : public RNG {
13public:
14 void gen(const TensorND& tensor) override {
15 auto offset = tensor.layout.span().low_elem;
16 auto nr_elems = tensor.layout.span().dist_elem();
17
18#define cb(DType) \
19 if (tensor.layout.dtype == DType()) { \
20 using ctype = typename DTypeTrait<DType>::ctype; \
21 auto ptr = tensor.ptr<ctype>(); \
22 for (size_t i = 0; i < nr_elems; ++i) { \
23 ptr[offset + i] = i; \
24 } \
25 COMPAT_RANDOM(ptr + offset, ptr + offset + nr_elems); \
26 return; \
27 }
28 MEGDNN_FOREACH_COMPUTING_DTYPE_FLOAT(cb);
29#undef cb
30 megdnn_throw(ssprintf("Unsupported DType: %s", tensor.layout.dtype.name()));
31 }
32};
33
34template <typename Argmxx>

Callers

nothing calls this directly

Calls 3

spanMethod · 0.80
dist_elemMethod · 0.80
nameMethod · 0.45

Tested by

no test coverage detected