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

Function ggml_compute_forward_im2col_f16

ggml.c:11738–11818  ·  view source on GitHub ↗

src0: kernel [OC, IC, KH, KW] src1: image [N, IC, IH, IW] dst: result [N, OH, OW, IC*KH*KW]

Source from the content-addressed store, hash-verified

11736// src1: image [N, IC, IH, IW]
11737// dst: result [N, OH, OW, IC*KH*KW]
11738static void ggml_compute_forward_im2col_f16(
11739 const struct ggml_compute_params * params,
11740 const struct ggml_tensor * src0,
11741 const struct ggml_tensor * src1,
11742 struct ggml_tensor * dst) {
11743 GGML_ASSERT(src0->type == GGML_TYPE_F16);
11744 GGML_ASSERT(src1->type == GGML_TYPE_F32);
11745 GGML_ASSERT( dst->type == GGML_TYPE_F16);
11746
11747 int64_t t0 = ggml_perf_time_us();
11748 UNUSED(t0);
11749
11750 GGML_TENSOR_BINARY_OP_LOCALS;
11751
11752 const int32_t s0 = ((const int32_t *)(dst->op_params))[0];
11753 const int32_t s1 = ((const int32_t *)(dst->op_params))[1];
11754 const int32_t p0 = ((const int32_t *)(dst->op_params))[2];
11755 const int32_t p1 = ((const int32_t *)(dst->op_params))[3];
11756 const int32_t d0 = ((const int32_t *)(dst->op_params))[4];
11757 const int32_t d1 = ((const int32_t *)(dst->op_params))[5];
11758 const bool is_2D = ((const int32_t *)(dst->op_params))[6] == 1;
11759
11760 const int ith = params->ith;
11761 const int nth = params->nth;
11762
11763 const int64_t N = is_2D ? ne13 : ne12;
11764 const int64_t IC = is_2D ? ne12 : ne11;
11765 const int64_t IH = is_2D ? ne11 : 1;
11766 const int64_t IW = ne10;
11767
11768 const int64_t KH = is_2D ? ne01 : 1;
11769 const int64_t KW = ne00;
11770
11771 const int64_t OH = is_2D ? ne2 : 1;
11772 const int64_t OW = ne1;
11773
11774 int ofs0 = is_2D ? nb13 : nb12;
11775 int ofs1 = is_2D ? nb12 : nb11;
11776
11777 GGML_ASSERT(nb00 == sizeof(ggml_fp16_t));
11778 GGML_ASSERT(nb10 == sizeof(float));
11779
11780 if (params->type == GGML_TASK_INIT) {
11781 return;
11782 }
11783
11784 if (params->type == GGML_TASK_FINALIZE) {
11785 return;
11786 }
11787
11788 // im2col: [N, IC, IH, IW] => [N, OH, OW, IC*KH*KW]
11789 {
11790 ggml_fp16_t * const wdata = (ggml_fp16_t *) dst->data;
11791
11792 for (int64_t in = 0; in < N; in++) {
11793 for (int64_t ioh = 0; ioh < OH; ioh++) { // 1
11794 for (int64_t iow = 0; iow < OW; iow++) {
11795 for (int64_t iic = ith; iic < IC; iic += nth) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected