Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cpu
Submodule cpu deleted from 671493
1 change: 1 addition & 0 deletions cpu
1 change: 0 additions & 1 deletion cuda
Submodule cuda deleted from af3b6d
1 change: 1 addition & 0 deletions cuda
25 changes: 25 additions & 0 deletions reg_field.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -80,4 +80,29 @@ void field_kernel(
throw std::invalid_argument("unsupported device");
}

void field_relax(
DLTensor & sol ,
const DLTensor & hes ,
const DLTensor & grd ,
const double * voxel_size,
const double * absolute ,
const double * membrane ,
const double * bending ,
int8_t bound ,
int ndim ,
int nb_iter ,
int stream )
{
#ifdef FF_WITH_CUDA
if (IS_CUDA(sol))
return FF_CUDA::field_relax(sol, hes, grd, voxel_size, absolute, membrane, bending, bound, ndim, nb_iter, stream);
#endif
if (IS_CPU(sol))
return FF_CPU::field_relax(sol, hes, grd, voxel_size, absolute, membrane, bending, bound, ndim, nb_iter, stream);

if (IS_CUDA(sol))
throw std::invalid_argument("fastfields: built without CUDA support, cannot operate on CUDA tensors");
throw std::invalid_argument("unsupported device");
}

FF_NAMESPACE_END(FF)
28 changes: 28 additions & 0 deletions reg_field.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -106,6 +106,34 @@ void field_kernel(
int stream = 0
);

/**
* @brief In-place relaxation (Gauss-Seidel) sweeps solving `(H + L) x = g`.
*
* Refines the warm-started field `sol` towards the solution of the regularised
* system, where `H` is the per-voxel compact-symmetric Hessian (`hes`, packed
* `C*(C+1)/2` last axis), `L` the field regulariser (same per-channel penalties
* as `field_matvec`), and `g` the gradient (`grd`, `C` last axis). Runs
* `nb_iter` red-black sweeps and writes the refined solution back into `sol`.
*
* @param sol Field to refine, in/out (*batch, *spatial, C)
* @param hes Compact-symmetric Hessian (*batch, *spatial, C*(C+1)/2)
* @param grd Gradient (*batch, *spatial, C)
* @param nb_iter Number of relaxation iterations
*/
void field_relax(
DLTensor & sol ,
const DLTensor & hes ,
const DLTensor & grd ,
const double * voxel_size = nullptr,
const double * absolute = nullptr,
const double * membrane = nullptr,
const double * bending = nullptr,
int8_t bound = bound_t::DCT2,
int ndim = 1,
int nb_iter = 1,
int stream = 0
);

FF_NAMESPACE_END(FF)

#endif // FF_LIB_REG_FIELD
Loading