switch to default conv2d interface
This commit is contained in:
parent
4b1920e9e7
commit
1e568252b5
|
|
@ -1992,8 +1992,8 @@ extern "C" {
|
|||
int p0, // padding dimension 0
|
||||
int p1, // padding dimension 1
|
||||
int d0, // dilation dimension 0
|
||||
int d1,
|
||||
int layout); // dilation dimension 1
|
||||
int d1);
|
||||
// int layout); // for future
|
||||
|
||||
|
||||
GGML_API struct ggml_tensor * ggml_conv_3d_direct(
|
||||
|
|
|
|||
|
|
@ -4585,9 +4585,9 @@ struct ggml_tensor * ggml_conv_2d_implicitgemm(
|
|||
int p0, // padding dimension 0
|
||||
int p1, // padding dimension 1
|
||||
int d0, // dilation dimension 0
|
||||
int d1,
|
||||
int d1){
|
||||
// 0: NHWC, 1:NCHW
|
||||
int layout) {// dilation dimension 1
|
||||
// int layout) {
|
||||
|
||||
GGML_ASSERT(a->ne[2] == b->ne[2]);
|
||||
//GGML_ASSERT(a->type == b->type);
|
||||
|
|
@ -4606,12 +4606,10 @@ struct ggml_tensor * ggml_conv_2d_implicitgemm(
|
|||
ggml_set_op_params_i32(result, 3, p1);
|
||||
ggml_set_op_params_i32(result, 4, d0);
|
||||
ggml_set_op_params_i32(result, 5, d1);
|
||||
ggml_set_op_params_i32(result, 6, layout);
|
||||
|
||||
struct ggml_tensor *ap, *bp;
|
||||
if(layout == 0){
|
||||
// ap = ggml_cont(ctx, ggml_permute(ctx, a, 1, 2, 0, 3));
|
||||
// bp = ggml_cont(ctx, ggml_permute(ctx, b, 1, 2, 0, 3));
|
||||
if(a->type == GGML_TYPE_F16 && (a->ne[0] > 1 || a->ne[1] > 1)){
|
||||
ggml_set_op_params_i32(result, 6, 0);
|
||||
ap = ggml_reshape_4d(ctx,
|
||||
ggml_cont(ctx,
|
||||
ggml_transpose(ctx,
|
||||
|
|
@ -4623,6 +4621,7 @@ struct ggml_tensor * ggml_conv_2d_implicitgemm(
|
|||
ggml_reshape_3d(ctx, b, b->ne[0]*b->ne[1], b->ne[2], b->ne[3]))),
|
||||
b->ne[2], b->ne[0], b->ne[1], b->ne[3]);
|
||||
} else{
|
||||
ggml_set_op_params_i32(result, 6, 1);
|
||||
ap = a;
|
||||
bp = b;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4273,7 +4273,7 @@ struct test_conv_2d_implicit : public test_case {
|
|||
// }
|
||||
|
||||
ggml_tensor * out =
|
||||
ggml_conv_2d_implicitgemm(ctx, kernel, input, stride0, stride1, padding0, padding1, dilation0, dilation1, cwhn?0:1);
|
||||
ggml_conv_2d_implicitgemm(ctx, kernel, input, stride0, stride1, padding0, padding1, dilation0, dilation1);
|
||||
ggml_set_name(out, "out");
|
||||
return out;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -262,7 +262,6 @@ struct ggml_cgraph * build_graph_2(const test_model& model) {
|
|||
int d1 = 1;
|
||||
|
||||
|
||||
|
||||
// recalculate for avoid fragmentation
|
||||
// struct ggml_tensor* conv2d_res = ggml_conv_2d(ctx0, model.a, model.b, s0, s1, p0, p1, d0, d1);
|
||||
// ggml_set_name(conv2d_res, "conv2d_res");
|
||||
|
|
@ -271,7 +270,7 @@ struct ggml_cgraph * build_graph_2(const test_model& model) {
|
|||
// printf("conv2d: (%zu, %zu, %zu, %zu) \n", ne[0], ne[1], ne[2], ne[3]);
|
||||
|
||||
|
||||
struct ggml_tensor* wino_res = ggml_conv_2d_implicitgemm(ctx0, model.a, model.b, s0, s1, p0, p1, d0, d1, 0);
|
||||
struct ggml_tensor* wino_res = ggml_conv_2d_implicitgemm(ctx0, model.a, model.b, s0, s1, p0, p1, d0, d1);
|
||||
// struct ggml_tensor* wino_res = ggml_conv_2d_direct(ctx0, model.a, model.b, s0, s1, p0, p1, d0, d1);
|
||||
ggml_set_name(wino_res, "wino_res");
|
||||
ggml_build_forward_expand(gf, wino_res);
|
||||
|
|
@ -353,9 +352,10 @@ int main(void)
|
|||
// std::make_tuple(640,640,52,76,3,3),
|
||||
// std::make_tuple(640,640,104,152,3,3),
|
||||
// std::make_tuple(960,320,104,152,3,3),
|
||||
std::make_tuple(1280,1280,26,38,3,3),
|
||||
// std::make_tuple(1280,1280,26,38,3,3),
|
||||
// std::make_tuple(1280,1280,26,38,1,1),
|
||||
// std::make_tuple(256,128,768,1024,3,3),
|
||||
std::make_tuple(128,3,768,1024,3,3),
|
||||
// std::make_tuple(256,128,768,1024,1,1),
|
||||
// std::make_tuple(512,256,384,512,1,1),
|
||||
// std::make_tuple(1280,640,52,76,3,3),
|
||||
|
|
@ -389,7 +389,7 @@ int main(void)
|
|||
|
||||
|
||||
struct ggml_cgraph * gf_res_0 = NULL;
|
||||
int iterations = 0;
|
||||
int iterations = 20;
|
||||
|
||||
double run_time0;
|
||||
std::vector<float> im2col_data = compute_graph(model, allocr, build_graph_0, iterations, &run_time0);
|
||||
|
|
|
|||
Loading…
Reference in New Issue