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

Function ggml_compute_forward_repeat_f16

external/ggml/src/ggml-cpu/ops.cpp:1739–1784  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1737 for (int i2 = 0; i2 < nr2; i2++) {
1738 for (int k2 = 0; k2 < ne02; k2++) {
1739 for (int i1 = 0; i1 < nr1; i1++) {
1740 for (int k1 = 0; k1 < ne01; k1++) {
1741 for (int i0 = 0; i0 < nr0; i0++) {
1742 ggml_vec_cpy_f32(ne00,
1743 (float *) ((char *) dst->data + (i3*ne03 + k3)*nb3 + (i2*ne02 + k2)*nb2 + (i1*ne01 + k1)*nb1 + (i0*ne00)*nb0),
1744 (float *) ((char *) src0->data + ( k3)*nb03 + ( k2)*nb02 + ( k1)*nb01));
1745 }
1746 }
1747 }
1748 }
1749 }
1750 }
1751 }
1752}
1753
1754static void ggml_compute_forward_repeat_f16(
1755 const ggml_compute_params * params,
1756 ggml_tensor * dst) {
1757
1758 const ggml_tensor * src0 = dst->src[0];
1759
1760 if (params->ith != 0) {
1761 return;
1762 }
1763
1764 GGML_ASSERT(ggml_can_repeat(src0, dst));
1765
1766 GGML_TENSOR_UNARY_OP_LOCALS
1767
1768 // guaranteed to be an integer due to the check in ggml_can_repeat
1769 const int nr0 = (int)(ne0/ne00);
1770 const int nr1 = (int)(ne1/ne01);
1771 const int nr2 = (int)(ne2/ne02);
1772 const int nr3 = (int)(ne3/ne03);
1773
1774 // TODO: support for transposed / permuted tensors
1775 GGML_ASSERT(nb0 == sizeof(ggml_fp16_t));
1776 GGML_ASSERT(nb00 == sizeof(ggml_fp16_t));
1777
1778 // TODO: maybe this is not optimal?
1779 for (int i3 = 0; i3 < nr3; i3++) {
1780 for (int k3 = 0; k3 < ne03; k3++) {
1781 for (int i2 = 0; i2 < nr2; i2++) {
1782 for (int k2 = 0; k2 < ne02; k2++) {
1783 for (int i1 = 0; i1 < nr1; i1++) {
1784 for (int k1 = 0; k1 < ne01; k1++) {
1785 for (int i0 = 0; i0 < nr0; i0++) {
1786 ggml_fp16_t * y = (ggml_fp16_t *) ((char *) dst->data + (i3*ne03 + k3)*nb3 + (i2*ne02 + k2)*nb2 + (i1*ne01 + k1)*nb1 + (i0*ne00)*nb0);
1787 ggml_fp16_t * x = (ggml_fp16_t *) ((char *) src0->data + ( k3)*nb03 + ( k2)*nb02 + ( k1)*nb01);

Callers 1

Calls 1

ggml_can_repeatFunction · 0.85

Tested by

no test coverage detected