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

Method execute

src/jit/impl/tiny_opencl/compiler.cpp:52–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50 : m_source{std::move(source)}, m_name{std::move(name)}, m_is_debug{is_debug} {}
51
52void OpenCLExecutable::execute(JITExecutor* fusion_opr) {
53 auto&& cn = fusion_opr->comp_node();
54 auto& env = CompNodeEnv::from_comp_node(cn).opencl_env();
55 auto handle = mgb::opr::intl::get_megdnn_handle(cn);
56 auto mgr = env.opencl_mgr;
57 auto&& ctx = mgr->context();
58 auto& queue = mgr->command_queue();
59 auto&& kernel = megdnn::opencl::OpenCLKernel(handle);
60 auto& args = fusion_opr->args();
61
62 auto prop = megcore::opencl::OpenCLPropCache::instance().get(mgr->device());
63 bool is_adreno = prop->is_adreno();
64 bool is_mali = prop->is_mali();
65 auto max_work_group = static_cast<uint32_t>(prop->max_work_group_size());
66 mgb_assert(
67 prop->is_support_image(),
68 "code issue happened, OpenCL jit only support device with support image");
69
70 //! for debug
71 MGB_MARK_USED_VAR(ctx);
72 MGB_MARK_USED_VAR(queue);
73
74 size_t WGSX = 0;
75 size_t WGSY = 0;
76
77 //! create cl args
78 for (size_t i = 0; i < args.inputs.size(); i++) {
79 if (TensorFormat::Type::IMAGE2D_PACK4 == args.inputs[i].layout.format.type()) {
80 WGSX = std::max(
81 WGSX,
82 args.inputs[i]
83 .layout.format.as_impl<megdnn::Image2DPack4TensorFormat>()
84 .image_width(args.inputs[i].layout));
85 WGSY = std::max(
86 WGSY,
87 args.inputs[i]
88 .layout.format.as_impl<megdnn::Image2DPack4TensorFormat>()
89 .image_height(args.inputs[i].layout));
90 }
91 }
92 mgb_assert(WGSX > 0 && WGSY > 0, "invalid tensor for OpenCL jit");
93
94 if (m_is_debug) {
95 mgb_log_debug(
96 "OpenCLExecutable init input tensor array with size: %zu, init output "
97 "tensor array with size: %zu",
98 args.inputs.size(), args.outputs.size());
99 for (size_t i = 0; i < args.inputs.size(); i++) {
100 mgb_log_debug(
101 "input(%zu) dim: %zu %s", i, args.inputs[i].layout.ndim,
102 args.inputs[i].layout.to_string().c_str());
103 }
104 for (size_t i = 0; i < args.outputs.size(); i++) {
105 mgb_log_debug(
106 "output(%zu) dim: %zu %s", i, args.outputs[i].layout.ndim,
107 args.outputs[i].layout.to_string().c_str());
108 }
109 }

Callers

nothing calls this directly

Calls 15

maxFunction · 0.85
contextMethod · 0.80
argsMethod · 0.80
image_widthMethod · 0.80
image_heightMethod · 0.80
minFunction · 0.50
comp_nodeMethod · 0.45
getMethod · 0.45
deviceMethod · 0.45
sizeMethod · 0.45
typeMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected