#pragma once #include #include #include #include #include inline void hip_check( hipError_t err, std::source_location loc = std::source_location::current()) { if (err != hipSuccess) { throw std::runtime_error( std::string(hipGetErrorString(err)) + " at " + loc.file_name() + ":" + std::to_string(loc.line())); } } struct PyramidLevel { int width = 0, height = 0; float4* color_smax = nullptr; // rgb = color, a = s_max float4* tensor = nullptr; // x=E, y=F, z=G, w=unused }; struct Pyramid { std::vector levels; // 0 = finest, back() = coarsest }; struct Params { float radius = 5.0f; float alpha = 1.0f; // eccentricity tuning int num_sectors = 8; float q = 8.0f; float tau_w = 0.02f; float p_s = 0.5f; float p_d = 1.25f; float tau_v = 0.1f; }; PyramidLevel make_level(int width, int height); void free_level(PyramidLevel& lvl); Pyramid make_pyramid(int base_width, int base_height, int num_levels); void destroy_pyramid(Pyramid& pyr); void build_pyramid (Pyramid& pyr); void compute_tensor(Pyramid& pyr, const Params& p); void smooth_tensor (Pyramid& pyr, const Params& p); void run_pipeline (Pyramid& pyr, const Params& p);