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

Method exec

dnn/src/cambricon/argmxx/opr_impl.cpp:76–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

74}
75
76void ArgmaxForwardImpl::exec(
77 _megdnn_tensor_in src, _megdnn_tensor_out dst, _megdnn_workspace workspace) {
78 check_exec(src.layout, dst.layout, workspace.size);
79 auto _handle = cnnl_handle(this->handle());
80 ArgmxxCnnlDescs descs(src.layout, dst.layout, param().axis);
81 auto ws_bundle = make_bundle(src.layout, dst.layout);
82 ws_bundle.set(workspace.raw_ptr);
83
84 void* target_src = src.raw_ptr();
85 if (!src.layout.is_contiguous()) {
86 TensorLayout dst;
87 dst = src.layout;
88 dst.init_contiguous_stride();
89 CnnlTensorDescriptor dst_desc;
90 dst_desc.set(dst);
91 cnnl_check(cnnlCopy(
92 _handle, descs.src_desc.desc(), src.raw_ptr(), dst_desc.desc(),
93 ws_bundle.get(2)));
94 target_src = ws_bundle.get(2);
95 }
96
97 switch (src.layout.dtype.enumv()) {
98#define cb(t) \
99 case DTypeTrait<t>::enumv: \
100 do { \
101 using ct = DTypeTrait<t>::ctype; \
102 dispatch_argmax_with_ctype<ct>( \
103 _handle, static_cast<ct*>(target_src), dst.ptr<int32_t>(), \
104 ws_bundle, descs); \
105 return; \
106 } while (0);
107 cb(::megdnn::dtype::Float32);
108 DNN_INC_FLOAT16(cb(::megdnn::dtype::Float16));
109 MEGDNN_FOREACH_COMPUTING_DTYPE_INT(cb);
110 default:
111 megdnn_throw("unsupported dtype in cambricon ArgmaxImpl");
112 }
113}
114
115} // namespace cambricon
116} // namespace megdnn

Callers

nothing calls this directly

Calls 12

cnnl_handleFunction · 0.85
make_bundleFunction · 0.85
paramFunction · 0.50
cbFunction · 0.50
handleMethod · 0.45
setMethod · 0.45
raw_ptrMethod · 0.45
is_contiguousMethod · 0.45
descMethod · 0.45
getMethod · 0.45
enumvMethod · 0.45

Tested by

no test coverage detected