MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / GetSourceCode

Method GetSourceCode

paddle/cinn/backends/compiler.cc:351–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351std::string Compiler::GetSourceCode(const ir::Module& module) {
352 return target_.arch.Match(
353 [&](common::UnknownArch) -> std::string { CINN_NOT_IMPLEMENTED; },
354 [&](common::X86Arch) -> std::string { CINN_NOT_IMPLEMENTED; },
355 [&](common::ARMArch) -> std::string { CINN_NOT_IMPLEMENTED; },
356 [&](common::CustomDeviceArch) -> std::string {
357#ifdef CINN_WITH_CUSTOM_DEVICE
358 auto _host_module_device_module_ =
359 SplitDeviceAndHostModule(module); // NOLINT
360 auto& host_module = std::get<0>(_host_module_device_module_);
361 auto& device_module = std::get<1>(_host_module_device_module_);
362 custom_device::CodeGenCustomDevice codegen(target_);
363 auto source_code = codegen.Compile(device_module);
364 return source_code;
365#else
366 CINN_NOT_IMPLEMENTED
367#endif
368 },
369 [&](common::NVGPUArch) -> std::string {
370#ifdef CINN_WITH_CUDA
371 auto _host_module_device_module_ =
372 SplitDeviceAndHostModule(module); // NOLINT
373 auto& host_module = std::get<0>(_host_module_device_module_);
374 auto& device_module = std::get<1>(_host_module_device_module_);
375 CodeGenCudaDev codegen(target_);
376 auto source_code = codegen.Compile(device_module);
377 return source_code;
378#else
379 CINN_NOT_IMPLEMENTED
380#endif
381 },
382 [&](common::HygonDCUArchHIP) -> std::string {
383#ifdef CINN_WITH_HIP
384 auto _host_module_device_module_ =
385 SplitDeviceAndHostModule(module); // NOLINT
386 auto& host_module = std::get<0>(_host_module_device_module_);
387 auto& device_module = std::get<1>(_host_module_device_module_);
388 hip::CodeGenHipDevice codegen(target_);
389 auto source_code = codegen.Compile(device_module);
390 return source_code;
391#else
392 CINN_NOT_IMPLEMENTED
393#endif
394 },
395 [&](common::HygonDCUArchSYCL) -> std::string {
396#ifdef CINN_WITH_SYCL
397 auto _host_module_device_module_ =
398 SplitDeviceAndHostModule(module); // NOLINT
399 auto& host_module = std::get<0>(_host_module_device_module_);
400 auto& device_module = std::get<1>(_host_module_device_module_);
401 sycl::CodeGenSyclDevice codegen(target_);
402 auto source_code = codegen.Compile(device_module);
403 return source_code;
404#else
405 CINN_NOT_IMPLEMENTED
406#endif
407 });
408}

Callers

nothing calls this directly

Calls 3

SplitDeviceAndHostModuleFunction · 0.85
MatchMethod · 0.45
CompileMethod · 0.45

Tested by

no test coverage detected