MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_clamp

Function ggml_clamp

ggml.c:5235–5258  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5233// ggml_clamp
5234
5235struct ggml_tensor * ggml_clamp(
5236 struct ggml_context * ctx,
5237 struct ggml_tensor * a,
5238 float min,
5239 float max) {
5240 bool is_node = false;
5241
5242 if (a->grad) {
5243 GGML_ASSERT(false); // TODO: implement backward
5244 is_node = true;
5245 }
5246
5247 // TODO: when implement backward, fix this:
5248 struct ggml_tensor * result = ggml_view_tensor(ctx, a);
5249
5250 float params[] = { min, max };
5251 ggml_set_op_params(result, params, sizeof(params));
5252
5253 result->op = GGML_OP_CLAMP;
5254 result->grad = is_node ? ggml_dup_tensor(ctx, result) : NULL;
5255 result->src[0] = a;
5256
5257 return result;
5258}
5259
5260// ggml_conv_1d
5261

Callers 1

build_mptMethod · 0.70

Calls 3

ggml_view_tensorFunction · 0.70
ggml_set_op_paramsFunction · 0.70
ggml_dup_tensorFunction · 0.70

Tested by

no test coverage detected