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

Method canonize_params

dnn/src/common/matrix_inverse.cpp:22–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20}
21
22void MatrixInverse::canonize_params(
23 const TensorLayout& layout, size_t* batch, size_t* n) {
24 megdnn_assert(
25 layout.ndim >= 2 && layout[layout.ndim - 2] == layout[layout.ndim - 1],
26 "MatrixInverse: input must be batches of square matrices, but with input "
27 "layout: %s",
28 layout.to_string().c_str());
29 if (!layout.is_empty()) {
30 megdnn_assert(
31 layout.is_contiguous(),
32 "MatrixInverse: input must be contiguous, but with input layout: %s",
33 layout.to_string().c_str());
34 }
35 megdnn_assert(
36 DNN_FLOAT16_SELECT(layout.dtype == dtype::Float16(), false) ||
37 layout.dtype == dtype::Float32(),
38 "MatrixInverse only supports f16 & f32");
39 if (batch) {
40 *batch = 1;
41 for (size_t i = 0; i < layout.ndim - 2; ++i) {
42 *batch *= layout[i];
43 }
44 }
45 if (n) {
46 *n = layout[layout.ndim - 1];
47 }
48}
49
50void MatrixInverse::check_exec(
51 const TensorLayout& src, const TensorLayout& dst, _megdnn_workspace workspace,

Callers

nothing calls this directly

Calls 3

to_stringMethod · 0.45
is_emptyMethod · 0.45
is_contiguousMethod · 0.45

Tested by

no test coverage detected