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

Function expand_grads

imperative/src/test/backward_graph.cpp:36–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34
35template <typename T, typename U>
36T expand_grads(const U& mask, const T& outputs) {
37 T ret(mask.size());
38 for (size_t i = 0, j = 0; i < mask.size(); ++i) {
39 if (mask[i]) {
40 ret[i] = outputs[j++];
41 }
42 }
43 return ret;
44}
45
46template <typename T>
47T prepare_optimized_backward_inputs(

Callers 1

TESTFunction · 0.85

Calls 1

sizeMethod · 0.45

Tested by

no test coverage detected