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

Function ggml_compute_forward_conv_transpose_2d

ggml.c:11843–11941  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11841// ggml_compute_forward_conv_transpose_2d
11842
11843static void ggml_compute_forward_conv_transpose_2d(
11844 const struct ggml_compute_params * params,
11845 const struct ggml_tensor * src0,
11846 const struct ggml_tensor * src1,
11847 struct ggml_tensor * dst) {
11848 GGML_ASSERT(src0->type == GGML_TYPE_F16);
11849 GGML_ASSERT(src1->type == GGML_TYPE_F32);
11850 GGML_ASSERT( dst->type == GGML_TYPE_F32);
11851
11852 int64_t t0 = ggml_perf_time_us();
11853 UNUSED(t0);
11854
11855 GGML_TENSOR_BINARY_OP_LOCALS
11856
11857 const int ith = params->ith;
11858 const int nth = params->nth;
11859
11860 const int nk = ne00*ne01*ne02*ne03;
11861
11862 GGML_ASSERT(nb00 == sizeof(ggml_fp16_t));
11863 GGML_ASSERT(nb10 == sizeof(float));
11864
11865 if (params->type == GGML_TASK_INIT) {
11866 memset(params->wdata, 0, params->wsize);
11867
11868 // permute kernel data (src0) from (Kw x Kh x Cout x Cin) to (Cin x Kw x Kh x Cout)
11869 {
11870 ggml_fp16_t * const wdata = (ggml_fp16_t *) params->wdata + 0;
11871
11872 for (int64_t i03 = 0; i03 < ne03; i03++) {
11873 for (int64_t i02 = 0; i02 < ne02; i02++) {
11874 const ggml_fp16_t * const src = (ggml_fp16_t *)((char *) src0->data + i03*nb03 + i02*nb02);
11875 ggml_fp16_t * dst_data = wdata + i02*ne01*ne00*ne03;
11876 for (int64_t i01 = 0; i01 < ne01; i01++) {
11877 for (int64_t i00 = 0; i00 < ne00; i00++) {
11878 dst_data[i01*ne00*ne03 + i00*ne03 + i03] = src[i01 * ne00 + i00];
11879 }
11880 }
11881 }
11882 }
11883 }
11884
11885 // permute source data (src1) from (Sw x Sh x Cin) to (Cin x Sw x Sh)
11886 {
11887 ggml_fp16_t * const wdata = (ggml_fp16_t *) params->wdata + nk;
11888 for (int i12 = 0; i12 < ne12; i12++) {
11889 for (int i11 = 0; i11 < ne11; i11++) {
11890 const float * const src = (float *)((char *) src1->data + i12*nb12 + i11*nb11);
11891 ggml_fp16_t * dst_data = wdata + i11*ne10*ne12;
11892 for (int i10 = 0; i10 < ne10; i10++) {
11893 dst_data[i10*ne12 + i12] = GGML_FP32_TO_FP16(src[i10]);
11894 }
11895 }
11896 }
11897 }
11898
11899 memset(dst->data, 0, ggml_nbytes(dst));
11900

Callers 1

ggml_compute_forwardFunction · 0.70

Calls 3

ggml_nbytesFunction · 0.70
ggml_get_op_params_i32Function · 0.70
ggml_vec_dot_f16Function · 0.70

Tested by

no test coverage detected