MCPcopy Create free account
hub / github.com/MegEngine/MegCC / IsAvailable

Method IsAvailable

compiler/lib/KernelGen/GeneralIntrinsic/Relayout.cpp:27–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25}
26
27bool RelayoutKernel::IsAvailable(TContext* context) const {
28 auto dtype_str = context->getAttrOprand("operand:0").dtype;
29 int32_t type_size = Utils::get_dtype_size(dtype_str);
30 bool ok_dtype = (context->getAttrOprand("operand:0").dtype ==
31 context->getAttrOprand("operand:1").dtype) &&
32 (type_size == 1 || type_size == 2 || type_size == 4);
33 std::vector<size_t> shape_in = context->getAttrOprand("operand:0").shape;
34 std::vector<size_t> shape_out = context->getAttrOprand("operand:0").shape;
35 bool ok_shape = shape_in.size() == shape_out.size();
36 for (size_t i = 0; ok_shape && i < shape_in.size(); ++i) {
37 ok_shape = ok_shape && shape_in.at(i) == shape_out.at(i);
38 }
39 return ok_dtype && ok_shape;
40}
41
42//! kernel gen
43std::string RelayoutKernel::GetKernelSymbol(TContext* context) const {

Callers

nothing calls this directly

Calls 2

get_dtype_sizeFunction · 0.85
getAttrOprandMethod · 0.80

Tested by

no test coverage detected