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

Method exec

dnn/src/naive/rnn/opr_impl.cpp:23–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21using rnn::RNNCellWeightWrapper;
22
23void RNNImpl::exec(
24 _megdnn_tensor_in input, _megdnn_tensor_in hx,
25 _megdnn_tensor_in flatten_weights, _megdnn_tensor_out output,
26 _megdnn_tensor_out hy, _megdnn_tensor_out reserve_space,
27 _megdnn_workspace workspace) {
28#if !MGE_BUILD_WITHOUT_NAIVE_EXEC
29 MIDOUT_BEGIN(megdnn_naive_rnn_fwd) {
30 auto _param = param();
31 size_t D = _param.bidirectional ? 2 : 1;
32 size_t num_layers = _param.num_layers;
33 size_t input_size = input.layout.shape[2];
34 std::vector<RNNCellWeightWrapper> cells;
35 size_t used_workspace_size = rnn::get_cells<RNNCellWeightWrapper>(
36 D, num_layers, input_size, _param.hidden_size, _param.bias, cells,
37 flatten_weights, workspace);
38
39 Workspace new_workspace(
40 workspace.raw_ptr + used_workspace_size,
41 workspace.size - used_workspace_size);
42 TensorNDArray states, states_new;
43 states.push_back(hx);
44 states_new.push_back(hy);
45 rnn::exec_internal<RNNCellWeightWrapper, RNNCellForward>(
46 cells, input, states, states_new, output, reserve_space, num_layers, D,
47 _param.nonlineMode, this->handle(), new_workspace);
48 }
49 MIDOUT_END();
50#else
51 __builtin_trap();
52#endif
53}
54
55size_t RNNImpl::get_workspace_in_bytes(
56 const TensorLayout& input, const TensorLayout& hx,

Callers 4

exec_internalFunction · 0.45
backward_exec_internalFunction · 0.45
backwardMethod · 0.45

Calls 8

get_cellsFunction · 0.85
WorkspaceClass · 0.85
dist_byteMethod · 0.80
spanMethod · 0.80
paramFunction · 0.50
push_backMethod · 0.45
raw_ptrMethod · 0.45
handleMethod · 0.45

Tested by

no test coverage detected