58 Star 280 Fork 3

腾讯开源/ncnn

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
test_rnn.cpp 20.03 KB
一键复制 编辑 原始数据 按行查看 历史
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
// Tencent is pleased to support the open source community by making ncnn available.
//
// Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// https://opensource.org/licenses/BSD-3-Clause
//
// Unless required by applicable law or agreed to in writing, software distributed
// under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
// CONDITIONS OF ANY KIND, either express or implied. See the License for the
// specific language governing permissions and limitations under the License.
#include "testutil.h"
static int test_rnn(int size, int T, int outch, int direction)
{
ncnn::Mat a = RandomMat(size, T);
int num_directions = direction == 2 ? 2 : 1;
ncnn::ParamDict pd;
pd.set(0, outch);
pd.set(1, outch * size * num_directions);
pd.set(2, direction);
std::vector<ncnn::Mat> weights(3);
weights[0] = RandomMat(outch * size * num_directions);
weights[1] = RandomMat(outch * num_directions);
weights[2] = RandomMat(outch * outch * num_directions);
int ret = test_layer("RNN", pd, weights, a);
if (ret != 0)
{
fprintf(stderr, "test_rnn failed size=%d T=%d outch=%d direction=%d\n", size, T, outch, direction);
}
return ret;
}
int test_rnn_with_hidden(int size, int T, int outch, int direction)
{
ncnn::Mat a = RandomMat(size, T);
int num_directions = direction == 2 ? 2 : 1;
ncnn::ParamDict pd;
pd.set(0, outch);
pd.set(1, outch * size * num_directions);
pd.set(2, direction);
std::vector<ncnn::Mat> weights(3);
weights[0] = RandomMat(outch * size * num_directions);
weights[1] = RandomMat(outch * num_directions);
weights[2] = RandomMat(outch * outch * num_directions);
// initial hidden state
ncnn::Mat hidden = RandomMat(outch, num_directions, -1.f, 1.f);
std::vector<ncnn::Mat> as(2);
as[0] = a;
as[1] = hidden;
int ret = test_layer("RNN", pd, weights, as, 2);
if (ret != 0)
{
fprintf(stderr, "test_rnn_with_hidden failed size=%d T=%d outch=%d direction=%d\n", size, T, outch, direction);
}
return ret;
}
int test_rnn_with_hidden_input(int size, int T, int outch, int direction)
{
ncnn::Mat a = RandomMat(size, T);
int num_directions = direction == 2 ? 2 : 1;
ncnn::ParamDict pd;
pd.set(0, outch);
pd.set(1, outch * size * num_directions);
pd.set(2, direction);
std::vector<ncnn::Mat> weights(3);
weights[0] = RandomMat(outch * size * num_directions);
weights[1] = RandomMat(outch * num_directions);
weights[2] = RandomMat(outch * outch * num_directions);
// initial hidden state
ncnn::Mat hidden = RandomMat(outch, num_directions, -1.f, 1.f);
std::vector<ncnn::Mat> as(2);
as[0] = a;
as[1] = hidden;
int ret = test_layer("RNN", pd, weights, as, 1);
if (ret != 0)
{
fprintf(stderr, "test_rnn_with_hidden_input failed size=%d T=%d outch=%d direction=%d\n", size, T, outch, direction);
}
return ret;
}
int test_rnn_with_hidden_output(int size, int T, int outch, int direction)
{
ncnn::Mat a = RandomMat(size, T);
int num_directions = direction == 2 ? 2 : 1;
ncnn::ParamDict pd;
pd.set(0, outch);
pd.set(1, outch * size * num_directions);
pd.set(2, direction);
std::vector<ncnn::Mat> weights(3);
weights[0] = RandomMat(outch * size * num_directions);
weights[1] = RandomMat(outch * num_directions);
weights[2] = RandomMat(outch * outch * num_directions);
std::vector<ncnn::Mat> as(1);
as[0] = a;
int ret = test_layer("RNN", pd, weights, as, 2);
if (ret != 0)
{
fprintf(stderr, "test_rnn_with_hidden_output failed size=%d T=%d outch=%d direction=%d\n", size, T, outch, direction);
}
return ret;
}
static int test_rnn_0()
{
return 0
|| test_rnn(4, 1, 2, 2)
|| test_rnn(8, 2, 2, 2)
|| test_rnn(16, 8, 7, 2)
|| test_rnn(17, 8, 8, 2)
|| test_rnn(19, 15, 8, 2)
|| test_rnn(5, 16, 16, 2)
|| test_rnn(3, 16, 8, 2)
|| test_rnn(8, 16, 16, 2)
|| test_rnn(31, 3, 31, 2)
|| test_rnn(2, 5, 17, 2);
}
static int test_rnn_1()
{
return 0
|| test_rnn_with_hidden(4, 4, 1, 2)
|| test_rnn_with_hidden(8, 2, 2, 2)
|| test_rnn_with_hidden(16, 8, 7, 2)
|| test_rnn_with_hidden(17, 8, 8, 2)
|| test_rnn_with_hidden(19, 15, 8, 2)
|| test_rnn_with_hidden(5, 16, 16, 2)
|| test_rnn_with_hidden(3, 16, 8, 2)
|| test_rnn_with_hidden(2, 5, 79, 2)
|| test_rnn_with_hidden(4, 4, 1, 1)
|| test_rnn_with_hidden(8, 2, 2, 1)
|| test_rnn_with_hidden(16, 8, 7, 1)
|| test_rnn_with_hidden(17, 8, 8, 1)
|| test_rnn_with_hidden(19, 15, 8, 1)
|| test_rnn_with_hidden(5, 16, 16, 1)
|| test_rnn_with_hidden(3, 16, 8, 1)
|| test_rnn_with_hidden(2, 5, 79, 1)
|| test_rnn_with_hidden(4, 2, 1, 0)
|| test_rnn_with_hidden(8, 2, 2, 0)
|| test_rnn_with_hidden(16, 8, 7, 0)
|| test_rnn_with_hidden(17, 8, 8, 0)
|| test_rnn_with_hidden(19, 15, 8, 0)
|| test_rnn_with_hidden(5, 16, 16, 0)
|| test_rnn_with_hidden(3, 16, 8, 0)
|| test_rnn_with_hidden(2, 5, 17, 0)
|| test_rnn_with_hidden_input(4, 4, 1, 2)
|| test_rnn_with_hidden_input(8, 2, 2, 2)
|| test_rnn_with_hidden_input(16, 8, 7, 2)
|| test_rnn_with_hidden_input(17, 8, 8, 2)
|| test_rnn_with_hidden_input(19, 15, 8, 2)
|| test_rnn_with_hidden_input(5, 16, 16, 2)
|| test_rnn_with_hidden_input(3, 16, 8, 2)
|| test_rnn_with_hidden_input(2, 5, 79, 2)
|| test_rnn_with_hidden_input(4, 4, 1, 1)
|| test_rnn_with_hidden_input(8, 2, 2, 1)
|| test_rnn_with_hidden_input(16, 8, 7, 1)
|| test_rnn_with_hidden_input(17, 8, 8, 1)
|| test_rnn_with_hidden_input(19, 15, 8, 1)
|| test_rnn_with_hidden_input(5, 16, 16, 1)
|| test_rnn_with_hidden_input(3, 16, 8, 1)
|| test_rnn_with_hidden_input(2, 5, 79, 1)
|| test_rnn_with_hidden_input(4, 2, 1, 0)
|| test_rnn_with_hidden_input(8, 2, 2, 0)
|| test_rnn_with_hidden_input(16, 8, 7, 0)
|| test_rnn_with_hidden_input(17, 8, 8, 0)
|| test_rnn_with_hidden_input(19, 15, 8, 0)
|| test_rnn_with_hidden_input(5, 16, 16, 0)
|| test_rnn_with_hidden_input(3, 16, 8, 0)
|| test_rnn_with_hidden_input(2, 5, 17, 0)
|| test_rnn_with_hidden_output(4, 4, 1, 2)
|| test_rnn_with_hidden_output(8, 2, 2, 2)
|| test_rnn_with_hidden_output(16, 8, 7, 2)
|| test_rnn_with_hidden_output(17, 8, 8, 2)
|| test_rnn_with_hidden_output(19, 15, 8, 2)
|| test_rnn_with_hidden_output(5, 16, 16, 2)
|| test_rnn_with_hidden_output(3, 16, 8, 2)
|| test_rnn_with_hidden_output(2, 5, 79, 2)
|| test_rnn_with_hidden_output(4, 4, 1, 1)
|| test_rnn_with_hidden_output(8, 2, 2, 1)
|| test_rnn_with_hidden_output(16, 8, 7, 1)
|| test_rnn_with_hidden_output(17, 8, 8, 1)
|| test_rnn_with_hidden_output(19, 15, 8, 1)
|| test_rnn_with_hidden_output(5, 16, 16, 1)
|| test_rnn_with_hidden_output(3, 16, 8, 1)
|| test_rnn_with_hidden_output(2, 5, 79, 1)
|| test_rnn_with_hidden_output(4, 2, 1, 0)
|| test_rnn_with_hidden_output(8, 2, 2, 0)
|| test_rnn_with_hidden_output(16, 8, 7, 0)
|| test_rnn_with_hidden_output(17, 8, 8, 0)
|| test_rnn_with_hidden_output(19, 15, 8, 0)
|| test_rnn_with_hidden_output(5, 16, 16, 0)
|| test_rnn_with_hidden_output(3, 16, 8, 0)
|| test_rnn_with_hidden_output(2, 5, 17, 0);
}
static int test_rnn_2()
{
return 0
|| test_rnn(4, 1, 1, 0)
|| test_rnn(8, 2, 2, 0)
|| test_rnn(16, 8, 7, 0)
|| test_rnn(17, 8, 8, 0)
|| test_rnn(19, 15, 8, 0)
|| test_rnn(5, 16, 16, 0)
|| test_rnn(3, 16, 8, 0)
|| test_rnn(8, 16, 16, 0)
|| test_rnn(2, 5, 17, 0);
}
static int test_rnn_3()
{
return 0
|| test_rnn(4, 1, 1, 1)
|| test_rnn(8, 2, 2, 1)
|| test_rnn(16, 8, 7, 1)
|| test_rnn(17, 8, 8, 1)
|| test_rnn(19, 15, 8, 1)
|| test_rnn(5, 16, 16, 1)
|| test_rnn(3, 16, 8, 1)
|| test_rnn(8, 16, 16, 1)
|| test_rnn(2, 5, 17, 1);
}
#if NCNN_INT8
static void RandomizeA(ncnn::Mat& m, float absmax)
{
absmax = ncnn::float16_to_float32(ncnn::float32_to_float16(absmax));
absmax = ncnn::bfloat16_to_float32(ncnn::float32_to_bfloat16(absmax));
const int h = m.h;
float* p = m;
for (int i = 0; i < h; i++)
{
float* p = m.row(i);
for (int j = 0; j < m.w; j++)
{
p[j] = RandomFloat(-absmax, absmax);
// drop 0.45 ~ 0.55
float v = p[j] * (127.f / absmax);
float vv = fabs(v - (int)v);
float hp = ncnn::float16_to_float32(ncnn::float32_to_float16(p[j]));
float hv = hp * (127.f / absmax);
float hvv = fabs(hv - (int)hv);
float bp = ncnn::bfloat16_to_float32(ncnn::float32_to_bfloat16(p[j]));
float bv = bp * (127.f / absmax);
float bvv = fabs(bv - (int)bv);
while ((vv > 0.45f && vv < 0.55f) || (hvv > 0.45f && hvv < 0.55f) || (bvv > 0.45f && bvv < 0.55f))
{
p[j] = RandomFloat(-absmax, absmax);
v = p[j] * (127.f / absmax);
vv = fabs(v - (int)v);
hp = ncnn::float16_to_float32(ncnn::float32_to_float16(p[j]));
hv = hp * (127.f / absmax);
hvv = fabs(hv - (int)hv);
bp = ncnn::bfloat16_to_float32(ncnn::float32_to_bfloat16(p[j]));
bv = bp * (127.f / absmax);
bvv = fabs(bv - (int)bv);
}
}
}
// set random a and b
m.row(RandomInt(0, h - 1))[RandomInt(0, m.w - 1)] = -absmax;
m.row(RandomInt(0, h - 1))[RandomInt(0, m.w - 1)] = absmax;
}
static int test_rnn_int8(int size, int T, int outch, int direction)
{
int num_directions = direction == 2 ? 2 : 1;
ncnn::ParamDict pd;
pd.set(0, outch);
pd.set(1, outch * size * num_directions);
pd.set(2, direction);
pd.set(8, 2); // int8_scale_term
std::vector<ncnn::Mat> weights(5);
weights[0] = RandomS8Mat(outch * size * num_directions);
weights[1] = RandomMat(outch * num_directions);
weights[2] = RandomS8Mat(outch * outch * num_directions);
weights[3] = RandomMat(outch * num_directions, 100.f, 200.f);
weights[4] = RandomMat(outch * num_directions, 100.f, 200.f);
ncnn::Mat a(size, T);
RandomizeA(a, 10.f);
int ret = test_layer("RNN", pd, weights, a);
if (ret != 0)
{
fprintf(stderr, "test_rnn_int8 failed size=%d T=%d outch=%d direction=%d\n", size, T, outch, direction);
}
return ret;
}
int test_rnn_int8_with_hidden(int size, int T, int outch, int direction)
{
int num_directions = direction == 2 ? 2 : 1;
ncnn::ParamDict pd;
pd.set(0, outch);
pd.set(1, outch * size * num_directions);
pd.set(2, direction);
pd.set(8, 2); // int8_scale_term
std::vector<ncnn::Mat> weights(5);
weights[0] = RandomS8Mat(outch * size * num_directions);
weights[1] = RandomMat(outch * num_directions);
weights[2] = RandomS8Mat(outch * outch * num_directions);
weights[3] = RandomMat(outch * num_directions, 100.f, 200.f);
weights[4] = RandomMat(outch * num_directions, 100.f, 200.f);
ncnn::Mat a(size, T);
RandomizeA(a, 10.f);
// initial hidden state
ncnn::Mat hidden(outch, num_directions);
RandomizeA(hidden, 10.f);
std::vector<ncnn::Mat> as(2);
as[0] = a;
as[1] = hidden;
int ret = test_layer("RNN", pd, weights, as, 2);
if (ret != 0)
{
fprintf(stderr, "test_rnn_int8_with_hidden failed size=%d T=%d outch=%d direction=%d\n", size, T, outch, direction);
}
return ret;
}
int test_rnn_int8_with_hidden_input(int size, int T, int outch, int direction)
{
int num_directions = direction == 2 ? 2 : 1;
ncnn::ParamDict pd;
pd.set(0, outch);
pd.set(1, outch * size * num_directions);
pd.set(2, direction);
pd.set(8, 2); // int8_scale_term
std::vector<ncnn::Mat> weights(5);
weights[0] = RandomS8Mat(outch * size * num_directions);
weights[1] = RandomMat(outch * num_directions);
weights[2] = RandomS8Mat(outch * outch * num_directions);
weights[3] = RandomMat(outch * num_directions, 100.f, 200.f);
weights[4] = RandomMat(outch * num_directions, 100.f, 200.f);
ncnn::Mat a(size, T);
RandomizeA(a, 10.f);
// initial hidden state
ncnn::Mat hidden(outch, num_directions);
RandomizeA(hidden, 10.f);
std::vector<ncnn::Mat> as(2);
as[0] = a;
as[1] = hidden;
int ret = test_layer("RNN", pd, weights, as, 1);
if (ret != 0)
{
fprintf(stderr, "test_rnn_int8_with_hidden_input failed size=%d T=%d outch=%d direction=%d\n", size, T, outch, direction);
}
return ret;
}
int test_rnn_int8_with_hidden_output(int size, int T, int outch, int direction)
{
int num_directions = direction == 2 ? 2 : 1;
ncnn::ParamDict pd;
pd.set(0, outch);
pd.set(1, outch * size * num_directions);
pd.set(2, direction);
pd.set(8, 2); // int8_scale_term
std::vector<ncnn::Mat> weights(5);
weights[0] = RandomS8Mat(outch * size * num_directions);
weights[1] = RandomMat(outch * num_directions);
weights[2] = RandomS8Mat(outch * outch * num_directions);
weights[3] = RandomMat(outch * num_directions, 100.f, 200.f);
weights[4] = RandomMat(outch * num_directions, 100.f, 200.f);
ncnn::Mat a(size, T);
RandomizeA(a, 10.f);
std::vector<ncnn::Mat> as(1);
as[0] = a;
int ret = test_layer("RNN", pd, weights, as, 2);
if (ret != 0)
{
fprintf(stderr, "test_rnn_int8_with_hidden_output failed size=%d T=%d outch=%d direction=%d\n", size, T, outch, direction);
}
return ret;
}
static int test_rnn_4()
{
return 0
|| test_rnn_int8(4, 1, 2, 2)
|| test_rnn_int8(8, 2, 2, 2)
|| test_rnn_int8(16, 8, 7, 2)
|| test_rnn_int8(17, 8, 8, 2)
|| test_rnn_int8(19, 15, 8, 2)
|| test_rnn_int8(5, 16, 16, 2)
|| test_rnn_int8(3, 16, 8, 2)
|| test_rnn_int8(8, 16, 16, 2)
|| test_rnn_int8(31, 3, 31, 2)
|| test_rnn_int8(2, 5, 17, 2);
}
static int test_rnn_5()
{
return 0
|| test_rnn_int8_with_hidden(4, 4, 1, 2)
|| test_rnn_int8_with_hidden(8, 2, 2, 2)
|| test_rnn_int8_with_hidden(16, 8, 7, 2)
|| test_rnn_int8_with_hidden(17, 8, 8, 2)
|| test_rnn_int8_with_hidden(19, 15, 8, 2)
|| test_rnn_int8_with_hidden(5, 16, 16, 2)
|| test_rnn_int8_with_hidden(3, 16, 8, 2)
|| test_rnn_int8_with_hidden(2, 5, 79, 2)
|| test_rnn_int8_with_hidden(4, 4, 1, 1)
|| test_rnn_int8_with_hidden(8, 2, 2, 1)
|| test_rnn_int8_with_hidden(16, 8, 7, 1)
|| test_rnn_int8_with_hidden(17, 8, 8, 1)
|| test_rnn_int8_with_hidden(19, 15, 8, 1)
|| test_rnn_int8_with_hidden(5, 16, 16, 1)
|| test_rnn_int8_with_hidden(3, 16, 8, 1)
|| test_rnn_int8_with_hidden(2, 5, 79, 1)
|| test_rnn_int8_with_hidden(4, 2, 1, 0)
|| test_rnn_int8_with_hidden(8, 2, 2, 0)
|| test_rnn_int8_with_hidden(16, 8, 7, 0)
|| test_rnn_int8_with_hidden(17, 8, 8, 0)
|| test_rnn_int8_with_hidden(19, 15, 8, 0)
|| test_rnn_int8_with_hidden(5, 16, 16, 0)
|| test_rnn_int8_with_hidden(3, 16, 8, 0)
|| test_rnn_int8_with_hidden(2, 5, 17, 0)
|| test_rnn_int8_with_hidden_input(4, 4, 1, 2)
|| test_rnn_int8_with_hidden_input(8, 2, 2, 2)
|| test_rnn_int8_with_hidden_input(16, 8, 7, 2)
|| test_rnn_int8_with_hidden_input(17, 8, 8, 2)
|| test_rnn_int8_with_hidden_input(19, 15, 8, 2)
|| test_rnn_int8_with_hidden_input(5, 16, 16, 2)
|| test_rnn_int8_with_hidden_input(3, 16, 8, 2)
|| test_rnn_int8_with_hidden_input(2, 5, 79, 2)
|| test_rnn_int8_with_hidden_input(4, 4, 1, 1)
|| test_rnn_int8_with_hidden_input(8, 2, 2, 1)
|| test_rnn_int8_with_hidden_input(16, 8, 7, 1)
|| test_rnn_int8_with_hidden_input(17, 8, 8, 1)
|| test_rnn_int8_with_hidden_input(19, 15, 8, 1)
|| test_rnn_int8_with_hidden_input(5, 16, 16, 1)
|| test_rnn_int8_with_hidden_input(3, 16, 8, 1)
|| test_rnn_int8_with_hidden_input(2, 5, 79, 1)
|| test_rnn_int8_with_hidden_input(4, 2, 1, 0)
|| test_rnn_int8_with_hidden_input(8, 2, 2, 0)
|| test_rnn_int8_with_hidden_input(16, 8, 7, 0)
|| test_rnn_int8_with_hidden_input(17, 8, 8, 0)
|| test_rnn_int8_with_hidden_input(19, 15, 8, 0)
|| test_rnn_int8_with_hidden_input(5, 16, 16, 0)
|| test_rnn_int8_with_hidden_input(3, 16, 8, 0)
|| test_rnn_int8_with_hidden_input(2, 5, 17, 0)
|| test_rnn_int8_with_hidden_output(4, 4, 1, 2)
|| test_rnn_int8_with_hidden_output(8, 2, 2, 2)
|| test_rnn_int8_with_hidden_output(16, 8, 7, 2)
|| test_rnn_int8_with_hidden_output(17, 8, 8, 2)
|| test_rnn_int8_with_hidden_output(19, 15, 8, 2)
|| test_rnn_int8_with_hidden_output(5, 16, 16, 2)
|| test_rnn_int8_with_hidden_output(3, 16, 8, 2)
|| test_rnn_int8_with_hidden_output(2, 5, 79, 2)
|| test_rnn_int8_with_hidden_output(4, 4, 1, 1)
|| test_rnn_int8_with_hidden_output(8, 2, 2, 1)
|| test_rnn_int8_with_hidden_output(16, 8, 7, 1)
|| test_rnn_int8_with_hidden_output(17, 8, 8, 1)
|| test_rnn_int8_with_hidden_output(19, 15, 8, 1)
|| test_rnn_int8_with_hidden_output(5, 16, 16, 1)
|| test_rnn_int8_with_hidden_output(3, 16, 8, 1)
|| test_rnn_int8_with_hidden_output(2, 5, 79, 1)
|| test_rnn_int8_with_hidden_output(4, 2, 1, 0)
|| test_rnn_int8_with_hidden_output(8, 2, 2, 0)
|| test_rnn_int8_with_hidden_output(16, 8, 7, 0)
|| test_rnn_int8_with_hidden_output(17, 8, 8, 0)
|| test_rnn_int8_with_hidden_output(19, 15, 8, 0)
|| test_rnn_int8_with_hidden_output(5, 16, 16, 0)
|| test_rnn_int8_with_hidden_output(3, 16, 8, 0)
|| test_rnn_int8_with_hidden_output(2, 5, 17, 0);
}
static int test_rnn_6()
{
return 0
|| test_rnn_int8(4, 1, 1, 0)
|| test_rnn_int8(8, 2, 2, 0)
|| test_rnn_int8(16, 8, 7, 0)
|| test_rnn_int8(17, 8, 8, 0)
|| test_rnn_int8(19, 15, 8, 0)
|| test_rnn_int8(5, 16, 16, 0)
|| test_rnn_int8(3, 16, 8, 0)
|| test_rnn_int8(8, 16, 16, 0)
|| test_rnn_int8(2, 5, 17, 0);
}
static int test_rnn_7()
{
return 0
|| test_rnn_int8(4, 1, 1, 1)
|| test_rnn_int8(8, 2, 2, 1)
|| test_rnn_int8(16, 8, 7, 1)
|| test_rnn_int8(17, 8, 8, 1)
|| test_rnn_int8(19, 15, 8, 1)
|| test_rnn_int8(5, 16, 16, 1)
|| test_rnn_int8(3, 16, 8, 1)
|| test_rnn_int8(8, 16, 16, 1)
|| test_rnn_int8(2, 5, 17, 1);
}
#endif
int main()
{
SRAND(7767517);
#if NCNN_INT8
return 0
|| test_rnn_0()
|| test_rnn_1()
|| test_rnn_2()
|| test_rnn_3()
|| test_rnn_4()
|| test_rnn_5()
|| test_rnn_6()
|| test_rnn_7();
#else
return 0
|| test_rnn_0()
|| test_rnn_1()
|| test_rnn_2()
|| test_rnn_3();
#endif
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C/C++
1
https://gitee.com/Tencent/ncnn.git
git@gitee.com:Tencent/ncnn.git
Tencent
ncnn
ncnn
master

搜索帮助