ggml : add comment
This commit is contained in:
parent
548e4e0daa
commit
0522dd930e
|
|
@ -2578,10 +2578,32 @@ extern "C" {
|
||||||
struct ggml_tensor * grad,
|
struct ggml_tensor * grad,
|
||||||
struct ggml_tensor * sgd_params); // alpha, weight decay
|
struct ggml_tensor * sgd_params); // alpha, weight decay
|
||||||
|
|
||||||
|
// build forward mutiple tensors and select one of them for computing
|
||||||
|
// this is useful for creating graphs that have constant topology but compute different things based on the input
|
||||||
|
// ref: https://github.com/ggml-org/llama.cpp/pull/18550
|
||||||
//
|
//
|
||||||
// automatic differentiation
|
// nodes:
|
||||||
|
// | - build forward into the graph but do not compute
|
||||||
|
// c - build forward into the graph and compute
|
||||||
|
//
|
||||||
|
// | | ... c ... |
|
||||||
|
// | | ... c ... |
|
||||||
|
// | | ... c ... |
|
||||||
|
// [0 1 ... idx ... n-1] <-- ggml_build_forward_select(..., n, idx)
|
||||||
|
// c
|
||||||
|
// c
|
||||||
|
//
|
||||||
|
// example:
|
||||||
|
// struct ggml_tensor * curs[3];
|
||||||
|
//
|
||||||
|
// curs[0] = compute0(...);
|
||||||
|
// curs[1] = compute1(...);
|
||||||
|
// curs[2] = compute2(...);
|
||||||
|
//
|
||||||
|
// int idx = select_branch(some_input);
|
||||||
|
//
|
||||||
|
// struct ggml_tensor * out = ggml_build_forward_select(cgraph, curs, 3, idx);
|
||||||
//
|
//
|
||||||
|
|
||||||
GGML_API struct ggml_tensor * ggml_build_forward_select(
|
GGML_API struct ggml_tensor * ggml_build_forward_select(
|
||||||
struct ggml_cgraph * cgraph,
|
struct ggml_cgraph * cgraph,
|
||||||
struct ggml_tensor ** tensors,
|
struct ggml_tensor ** tensors,
|
||||||
|
|
|
||||||
|
|
@ -6741,7 +6741,7 @@ static size_t ggml_visit_parents_graph(struct ggml_cgraph * cgraph, struct ggml_
|
||||||
// update the compute flag regardless
|
// update the compute flag regardless
|
||||||
for (int i = 0; i < GGML_MAX_SRC; ++i) {
|
for (int i = 0; i < GGML_MAX_SRC; ++i) {
|
||||||
struct ggml_tensor * src = node->src[i];
|
struct ggml_tensor * src = node->src[i];
|
||||||
if (src && (src->flags & GGML_TENSOR_FLAG_COMPUTE) == 0) {
|
if (src && ((src->flags & GGML_TENSOR_FLAG_COMPUTE) == 0)) {
|
||||||
ggml_visit_parents_graph(cgraph, src, true);
|
ggml_visit_parents_graph(cgraph, src, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue