بنقرة واحدة
paddle-style-default-device
Implement PaddlePaddle-style lazy GPU default device in C++ core, all languages inherit
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
القائمة
Implement PaddlePaddle-style lazy GPU default device in C++ core, all languages inherit
التثبيت باستخدام Codex أو Claude انسخ هذا Prompt والصقه في Codex أو Claude أو مساعد آخر ليراجع صفحة Skill ويثبّتها لك.
استنادا إلى تصنيف SOC المهني
Add device information query functions through HAL → ins:: API → language bindings
Add --device all/--timer/--info CLI flags to demos across all languages for competition scoring
Add composite signal operators using existing primitives (no dedicated backend kernels needed)
How to port a cusignal Python/CUDA module to ins::signal C++ using Insight7 primitives and HAL
Profile and optimize binding language (Lua/Julia/Python) demo performance to match or exceed C++ baseline
busted loads _insight.so from ~/.luarocks/lib first, not build/ — must copy .so after rebuild
| name | paddle-style-default-device |
| description | Implement PaddlePaddle-style lazy GPU default device in C++ core, all languages inherit |
| source | auto-skill |
| extracted_at | 2026-06-05T14:22:08.096Z |
Problem: PaddlePaddle defaults to GPU when available, CPU otherwise. Insight7 should match this behavior.
Implementation (in src/core/place.cpp):
namespace {
thread_local Place g_default_device = CPUPlace();
thread_local bool g_device_explicitly_set = false;
}
Place get_device() {
// Lazy: first call checks if GPU is available
if (!g_device_explicitly_set && g_default_device.kind() == DeviceKind::CPU) {
if (is_device_available(DeviceKind::GPU)) {
g_default_device = GPUPlace(0);
}
}
return g_default_device;
}
void set_device(const Place &place) {
g_default_device = place;
g_device_explicitly_set = true; // User's choice is honored
}
Key design:
g_device_explicitly_set flag ensures set_device(CPUPlace()) is honoredis_device_available(DeviceKind::GPU) handles ALL backends (cuda/npu/rocm/...)Binding requirements:
set_device and get_devicecreation.py MUST call get_device() at call time, NOT at module load time:
# ❌ WRONG — evaluated once at import
m.def("zeros", &zeros, py::arg("place") = get_device());
# ✅ CORRECT — evaluated at each call
def zeros(shape, dtype, place=None):
if place is None:
return _native_zeros(shape, dtype, get_device())
set_device(CPUPlace()) in setup (conftest.py for Python, setup block for Lua/busted)Why: PaddlePaddle does this in _current_expected_place_() — checks is_compiled_with_cuda() + get_cuda_device_count(). Insight7's HAL abstraction makes it simpler: one is_device_available() check.