MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / binary_op

Function binary_op

external/ggml/src/ggml-cpu/binary-ops.cpp:146–168  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144// TODO: Use the 'traits' lookup table (for type conversion fns), instead of a mass of 'if' conditions with long templates
145template <float (*op)(float, float)>
146static void binary_op(const ggml_compute_params * params, ggml_tensor * dst) {
147 const ggml_tensor * src0 = dst->src[0];
148 const ggml_tensor * src1 = dst->src[1];
149
150 /* */ if (src0->type == GGML_TYPE_F32 && src1->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_F32) { // all f32
151 apply_binary_op<op, float, float, float>(params, dst);
152 } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_F16 && dst->type == GGML_TYPE_F16) { // all f16
153 apply_binary_op<op, ggml_fp16_t, ggml_fp16_t, ggml_fp16_t>(params, dst);
154 } else if (src0->type == GGML_TYPE_BF16 && src1->type == GGML_TYPE_BF16 && dst->type == GGML_TYPE_BF16) { // all bf16
155 apply_binary_op<op, ggml_bf16_t, ggml_bf16_t, ggml_bf16_t>(params, dst);
156 } else if (src0->type == GGML_TYPE_BF16 && src1->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_BF16) {
157 apply_binary_op<op, ggml_bf16_t, float, ggml_bf16_t>(params, dst);
158 } else if (src0->type == GGML_TYPE_BF16 && src1->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_F32) {
159 apply_binary_op<op, ggml_bf16_t, float, float>(params, dst);
160 } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_F16) {
161 apply_binary_op<op, ggml_fp16_t, float, ggml_fp16_t>(params, dst);
162 } else if (src0->type == GGML_TYPE_F16 && src1->type == GGML_TYPE_F32 && dst->type == GGML_TYPE_F32) {
163 apply_binary_op<op, ggml_fp16_t, float, float>(params, dst);
164 } else {
165 GGML_ABORT("%s: unsupported types: dst: %s, src0: %s, src1: %s\n", __func__,
166 ggml_type_name(dst->type), ggml_type_name(src0->type), ggml_type_name(src1->type));
167 }
168}
169
170void ggml_compute_forward_add_non_quantized(const ggml_compute_params * params, ggml_tensor * dst) {
171 binary_op<op_add>(params, dst);

Callers 3

ggml_cann_binary_opFunction · 0.85
operator()Method · 0.85
operator()Method · 0.85

Calls 1

ggml_type_nameFunction · 0.85

Tested by

no test coverage detected