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

Method alloc_cnnl_workspace

dnn/src/cambricon/elemwise/opr_impl.cpp:871–889  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

869} // anonymous namespace
870
871WorkspaceBundle ElemwiseForwardImpl::alloc_cnnl_workspace(
872 const TensorNDArray& src, const TensorND& dst) {
873 TensorLayoutArray src_layouts(src.size());
874 std::transform(
875 src.begin(), src.end(), src_layouts.begin(),
876 [](const TensorND& tensor) { return tensor.layout; });
877 auto mode = m_param.mode;
878 auto handle = concrete_handle(this->handle());
879 int nr_operands = src.size();
880 if (nr_operands == 1) { // unary mode
881 return get_unary_ws(handle, src_layouts, dst.layout, mode);
882 } else if (nr_operands == 2) { // binary mode
883 return get_binary_ws(handle, src_layouts, dst.layout, mode);
884 } else if (nr_operands == 3) {
885 return get_ternary_ws(handle, src_layouts, dst.layout, mode);
886 } else {
887 megdnn_throw("elemwise unsupport mode");
888 }
889}
890
891void ElemwiseForwardImpl::free_cnnl_workspace(const WorkspaceBundle& wk_bundle) {
892 concrete_handle(handle())->free(wk_bundle.ptr());

Callers

nothing calls this directly

Calls 8

get_unary_wsFunction · 0.85
get_binary_wsFunction · 0.85
get_ternary_wsFunction · 0.85
concrete_handleFunction · 0.50
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
handleMethod · 0.45

Tested by

no test coverage detected