mirror of https://github.com/kendryte/nncase.git
GNNE-1904 add case file (#1029)
* Support json config for kernel test simply * fix matmul's case * Support skip test no print * Apply code-format changes * get case from json /unary * fix transpose's kernel test's case --------- Co-authored-by: hejunchao <hejunchao@canaan-creative.com> Co-authored-by: lerenhua <2532375005@qq.com> Co-authored-by: lerenhua <lerenhua@users.noreply.github.com> Co-authored-by: Hejunchao6 <Hejunchao6@users.noreply.github.com>pull/1047/head
parent
46644f4f7c
commit
1e98e65624
|
@ -51,6 +51,7 @@ class nncaseConan(ConanFile):
|
|||
if self.options.tests:
|
||||
self.requires('gtest/1.10.0')
|
||||
self.requires('ortki/0.0.2')
|
||||
self.requires('rapidjson/1.1.x')
|
||||
|
||||
if self.options.python:
|
||||
self.requires('pybind11/2.6.1')
|
||||
|
|
|
@ -78,7 +78,7 @@ internal sealed class CSharpPrintVisitor : ExprFunctor<string, string>
|
|||
public override string VisitType(TensorType type) => type.DType switch
|
||||
{
|
||||
PrimType ptype => ptype.GetDisplayName() + (type.Shape.IsScalar ? string.Empty : type.Shape.ToString()),
|
||||
PointerType { ElemType: PrimType etype } ptype => $"*{etype.GetDisplayName()}",
|
||||
PointerType { ElemType: PrimType etype } => $"*{etype.GetDisplayName()}",
|
||||
ValueType => $"{type.DType.ToString()}",
|
||||
_ => throw new NotSupportedException(type.DType.GetType().Name),
|
||||
};
|
||||
|
|
|
@ -265,7 +265,7 @@ internal sealed class ILPrintVisitor : ExprFunctor<string, string>
|
|||
public override string VisitType(TensorType type) => type.DType switch
|
||||
{
|
||||
PrimType ptype => ptype.GetDisplayName() + (type.Shape.IsScalar ? string.Empty : type.Shape.ToString()),
|
||||
PointerType { ElemType: PrimType etype } ptype => $"*{etype.GetDisplayName()}",
|
||||
PointerType { ElemType: PrimType etype } => $"*{etype.GetDisplayName()}",
|
||||
ValueType => $"{type.DType.ToString()}",
|
||||
_ => throw new NotSupportedException(type.DType.GetType().Name),
|
||||
};
|
||||
|
|
|
@ -129,7 +129,7 @@ internal sealed class ScriptPrintVisitor : ExprFunctor<IPrintSymbol, string>
|
|||
public override string VisitType(TensorType type) => type.DType switch
|
||||
{
|
||||
PrimType ptype => ptype.GetDisplayName() + (type.Shape.IsScalar ? string.Empty : type.Shape.ToString()),
|
||||
PointerType { ElemType: PrimType etype } ptype => $"*{etype.GetDisplayName()}",
|
||||
PointerType { ElemType: PrimType etype } => $"*{etype.GetDisplayName()}",
|
||||
ValueType vtype => vtype.GetDisplayName() + (type.Shape.IsScalar ? string.Empty : type.Shape.ToString()),
|
||||
_ => throw new NotSupportedException(type.DType.GetType().Name),
|
||||
};
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
enable_testing()
|
||||
|
||||
find_package(ortki)
|
||||
find_package(rapidjson)
|
||||
|
||||
macro(add_test_exec name)
|
||||
add_executable(${name} ${name}.cpp)
|
||||
target_link_libraries(${name} PRIVATE GTest::gtest_main nncaseruntime ortki::ortki)
|
||||
target_link_libraries(${name} PRIVATE GTest::gtest_main nncaseruntime ortki::ortki rapidjson::rapidjson)
|
||||
add_test(NAME ${name} COMMAND ${CMAKE_COMMAND} -DTEST_EXECUTABLE=$<TARGET_FILE:${name}> -P ${CMAKE_CURRENT_SOURCE_DIR}/../../toolchains/run_test.cmake)
|
||||
endmacro()
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "nncase/shape.h"
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#include <cstdio>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <gtest/gtest.h>
|
||||
|
@ -32,11 +33,16 @@
|
|||
#include <numeric>
|
||||
#include <ortki/c_api.h>
|
||||
#include <random>
|
||||
#include <rapidjson/document.h> // rapidjson's DOM-style API
|
||||
#include <rapidjson/error/en.h>
|
||||
#include <rapidjson/ostreamwrapper.h>
|
||||
#include <rapidjson/writer.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
using namespace nncase::runtime;
|
||||
using namespace nncase::kernels;
|
||||
using namespace rapidjson;
|
||||
namespace nncase {
|
||||
typedef enum { RANDOM, NOZERO, NONEG, NOPOS } initial_mode;
|
||||
|
||||
|
@ -1651,5 +1657,96 @@ class KernelTest {
|
|||
return ok();
|
||||
});
|
||||
}
|
||||
|
||||
static std::string ReadFromJsonFile(std::ifstream &file) {
|
||||
std::string content((std::istreambuf_iterator<char>(file)),
|
||||
std::istreambuf_iterator<char>());
|
||||
file.close();
|
||||
return content;
|
||||
}
|
||||
|
||||
static void ParseJson(Document &document, std::string js_str) {
|
||||
if (document.Parse(js_str.c_str()).HasParseError())
|
||||
std::cout << "Parsing Error: "
|
||||
<< (unsigned)document.GetErrorOffset() << " "
|
||||
<< GetParseError_En(document.GetParseError())
|
||||
<< std::endl;
|
||||
assert(document.IsObject());
|
||||
}
|
||||
|
||||
void ParseJson(std::string js_str) {
|
||||
if (_document.Parse(js_str.c_str()).HasParseError())
|
||||
std::cout << "Parsing Error: "
|
||||
<< (unsigned)_document.GetErrorOffset() << " "
|
||||
<< GetParseError_En(_document.GetParseError())
|
||||
<< std::endl;
|
||||
assert(_document.IsObject());
|
||||
}
|
||||
|
||||
typecode_t Str2DataType(std::string type) {
|
||||
std::cout << type << std::endl;
|
||||
if (str_2_datatype.find(type) != str_2_datatype.end()) {
|
||||
return str_2_datatype[type];
|
||||
} else {
|
||||
return dt_int8;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t GetNumber(const char *key) {
|
||||
assert(_document[key].IsInt64());
|
||||
return _document[key].GetInt64();
|
||||
}
|
||||
|
||||
typecode_t GetDataType(const char *key) {
|
||||
assert(_document[key].IsString());
|
||||
return Str2DataType(_document[key].GetString());
|
||||
}
|
||||
|
||||
dims_t GetShapeArray(const char *key) {
|
||||
assert(_document[key].IsArray());
|
||||
|
||||
Value &array = _document[key];
|
||||
size_t arraySize = array.Size();
|
||||
dims_t cArray(arraySize);
|
||||
for (rapidjson::SizeType i = 0; i < arraySize; i++) {
|
||||
if (array[i].IsUint()) {
|
||||
cArray[i] = array[i].GetUint();
|
||||
} else {
|
||||
std::cout << "Invalid JSON format. Expected unsigned integer "
|
||||
"values in the array."
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
return cArray;
|
||||
}
|
||||
|
||||
axes_t GetAxesArray(const char *key) {
|
||||
assert(_document[key].IsArray());
|
||||
|
||||
Value &array = _document[key];
|
||||
size_t arraySize = array.Size();
|
||||
axes_t cArray(arraySize);
|
||||
for (rapidjson::SizeType i = 0; i < arraySize; i++) {
|
||||
if (array[i].IsUint()) {
|
||||
cArray[i] = array[i].GetUint();
|
||||
} else {
|
||||
std::cout << "Invalid JSON format. Expected unsigned integer "
|
||||
"values in the array."
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
return cArray;
|
||||
}
|
||||
|
||||
private:
|
||||
Document _document;
|
||||
std::map<std::string, typecode_t> str_2_datatype = {
|
||||
{"dt_int8", dt_int8}, {"dt_int16", dt_int16},
|
||||
{"dt_int32", dt_int32}, {"dt_int64", dt_int64},
|
||||
{"dt_uint8", dt_uint8}, {"dt_uint16", dt_uint16},
|
||||
{"dt_uint32", dt_uint32}, {"dt_uint64", dt_uint64},
|
||||
{"dt_float16", dt_float16}, {"dt_float32", dt_float32},
|
||||
{"dt_float64", dt_float64}, {"dt_bfloat16", dt_bfloat16},
|
||||
{"dt_boolean", dt_boolean}};
|
||||
};
|
||||
} // namespace nncase
|
||||
|
|
|
@ -296,3 +296,79 @@
|
|||
{reinterpret_cast<gsl::byte *>(ptr_ort), size}, true, \
|
||||
host_runtime_tensor::pool_cpu_only) \
|
||||
.expect("create expected tensor failed");
|
||||
|
||||
#define MAX_CASE_NUM 100
|
||||
#define ENDFIX ".json"
|
||||
#define PARENT_DIR_1 "../../../tests/kernels/"
|
||||
#define PARENT_DIR_2 "../../../../tests/kernels/"
|
||||
|
||||
#define SPLIT_ELEMENT(key, idx) \
|
||||
rapidjson::Value copiedArray##key(rapidjson::kArrayType); \
|
||||
copiedArray##key.CopyFrom(key[idx], write_doc.GetAllocator()); \
|
||||
write_doc.AddMember(Value(#key, write_doc.GetAllocator()), \
|
||||
copiedArray##key, write_doc.GetAllocator());
|
||||
|
||||
#define FOR_LOOP(key, idx) \
|
||||
assert(document[#key].IsArray()); \
|
||||
Value &key = document[#key]; \
|
||||
for (SizeType idx = 0; idx < key.Size(); ++idx) {
|
||||
|
||||
#define FOR_LOOP_END() }
|
||||
|
||||
#define FILE_NAME_GEN(PARENT_DIR, name) \
|
||||
std::string(PARENT_DIR) + std::string(name) + std::string(ENDFIX)
|
||||
|
||||
#define FILE_NAME_GEN_SUBCASE(case_name, idx) \
|
||||
std::string(case_name) + "_" + std::to_string(idx) + std::string(ENDFIX)
|
||||
|
||||
#define READY_TEST_CASE_GENERATE() \
|
||||
std::string content; \
|
||||
auto filename1 = FILE_NAME_GEN(PARENT_DIR_1, TEST_CASE_NAME); \
|
||||
std::ifstream file1(filename1); \
|
||||
if (file1.fail()) { \
|
||||
file1.close(); \
|
||||
auto filename2 = FILE_NAME_GEN(PARENT_DIR_2, TEST_CASE_NAME); \
|
||||
std::ifstream file2(filename2); \
|
||||
if (file2.fail()) { \
|
||||
file2.close(); \
|
||||
std::cout << "File does not exist: " << filename2 << std::endl; \
|
||||
} else { \
|
||||
content = KernelTest::ReadFromJsonFile(file2); \
|
||||
std::cout << "File exists: " << filename2 << std::endl; \
|
||||
} \
|
||||
} else { \
|
||||
content = KernelTest::ReadFromJsonFile(file1); \
|
||||
std::cout << "File exists: " << filename1 << std::endl; \
|
||||
} \
|
||||
Document document; \
|
||||
KernelTest::ParseJson(document, content); \
|
||||
unsigned case_num = 0; \
|
||||
Document write_doc; \
|
||||
write_doc.SetObject();
|
||||
|
||||
#define WRITE_SUB_CASE() \
|
||||
std::ofstream ofs(FILE_NAME_GEN_SUBCASE(TEST_CASE_NAME, case_num)); \
|
||||
OStreamWrapper osw(ofs); \
|
||||
Writer<OStreamWrapper> writer(osw); \
|
||||
write_doc.Accept(writer); \
|
||||
case_num++; \
|
||||
write_doc.RemoveAllMembers();
|
||||
|
||||
#define READY_SUBCASE() \
|
||||
auto &&[idx] = GetParam(); \
|
||||
auto filename = FILE_NAME_GEN_SUBCASE(TEST_CASE_NAME, idx); \
|
||||
std::ifstream file(filename); \
|
||||
if (file.is_open()) { \
|
||||
std::cout << "Open file: " << filename << std::endl; \
|
||||
ParseJson(ReadFromJsonFile(file)); \
|
||||
} else { \
|
||||
file.close(); \
|
||||
GTEST_SKIP(); \
|
||||
}
|
||||
|
||||
#define CLEAR_SUBCASE() \
|
||||
auto &&[idx] = GetParam(); \
|
||||
auto filename = FILE_NAME_GEN_SUBCASE(TEST_CASE_NAME, idx); \
|
||||
if (std::remove(filename.c_str()) == 0) { \
|
||||
printf("File deleted successfully: %s\n", filename.c_str()); \
|
||||
}
|
||||
|
|
|
@ -26,12 +26,17 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
#define TEST_CASE_NAME "test_matmul"
|
||||
|
||||
class MatMulTest : public KernelTest,
|
||||
public ::testing::TestWithParam<
|
||||
std::tuple<nncase::typecode_t, dims_t, dims_t>> {
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, l_shape, r_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("lhs_type");
|
||||
auto l_shape = GetShapeArray("lhs_shape");
|
||||
auto r_shape = GetShapeArray("rhs_shape");
|
||||
|
||||
lhs = hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
|
@ -42,23 +47,15 @@ class MatMulTest : public KernelTest,
|
|||
init_tensor(rhs);
|
||||
}
|
||||
|
||||
void TearDown() override {}
|
||||
void TearDown() override { CLEAR_SUBCASE() }
|
||||
|
||||
protected:
|
||||
runtime_tensor lhs;
|
||||
runtime_tensor rhs;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
mat_mul, MatMulTest,
|
||||
testing::Combine(testing::Values(dt_int32, dt_int64, dt_float32, dt_float64,
|
||||
dt_int32, dt_uint32, dt_uint64),
|
||||
testing::Values(dims_t{1, 3}, dims_t{1, 3, 3},
|
||||
dims_t{1, 2, 3, 3}, dims_t{3, 3}/*,
|
||||
dims_t{6, 3, 3}, dims_t{6, 2, 3, 3}*/),// todo batch&&channel doesn't support other than 1.
|
||||
testing::Values(dims_t{3, 1}, dims_t{1, 3, 3},
|
||||
dims_t{1, 2, 3, 3}, dims_t{3, 3}/*,
|
||||
dims_t{6, 3, 3}, dims_t{6, 2, 3, 3}*/)));
|
||||
INSTANTIATE_TEST_SUITE_P(mat_mul, MatMulTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(MatMulTest, mat_mul) {
|
||||
auto l_ort = runtime_tensor_2_ort_tensor(lhs);
|
||||
|
@ -95,6 +92,18 @@ TEST_P(MatMulTest, mat_mul) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(lhs_type, i)
|
||||
FOR_LOOP(lhs_shape, j)
|
||||
FOR_LOOP(rhs_shape, k)
|
||||
SPLIT_ELEMENT(lhs_type, i)
|
||||
SPLIT_ELEMENT(lhs_shape, j)
|
||||
SPLIT_ELEMENT(rhs_shape, k)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"lhs_shape":[[1, 3], [3, 3], [1, 3, 3], [1, 2, 3, 3]],
|
||||
"lhs_type":["dt_int32", "dt_int64", "dt_float32", "dt_float64", "dt_uint32", "dt_uint64"],
|
||||
"rhs_shape":[[3, 1], [3, 3], [1, 3, 3], [1, 2, 3, 3]]
|
||||
}
|
|
@ -26,19 +26,23 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
#define TEST_CASE_NAME "test_transpose"
|
||||
|
||||
class TransposeTest : public KernelTest,
|
||||
public ::testing::TestWithParam<
|
||||
std::tuple<nncase::typecode_t, dims_t, axes_t>> {
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, l_shape, value] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("lhs_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
|
||||
perm_value = value;
|
||||
perm_value = GetAxesArray("perm");
|
||||
}
|
||||
|
||||
void TearDown() override {}
|
||||
|
@ -48,27 +52,8 @@ class TransposeTest : public KernelTest,
|
|||
axes_t perm_value;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Transpose, TransposeTest,
|
||||
testing::Combine(
|
||||
testing::Values(dt_float32, dt_int32, dt_int16, dt_float64, dt_int8,
|
||||
dt_uint8, dt_uint16, dt_uint32, dt_uint64, dt_int64,
|
||||
dt_bfloat16, dt_float16, dt_boolean),
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{1, 2, 4, 8},
|
||||
dims_t{2, 2, 4, 4}, dims_t{1, 3, 16}, dims_t{1, 2, 4},
|
||||
dims_t{2, 2, 4}, dims_t{16, 16}, dims_t{2, 4},
|
||||
dims_t{4, 4}),
|
||||
testing::Values(
|
||||
axes_t{0, 1, 2, 3}, axes_t{0, 1, 3, 2}, axes_t{0, 2, 1, 3},
|
||||
axes_t{0, 2, 3, 1}, axes_t{0, 3, 1, 2}, axes_t{0, 3, 2, 1},
|
||||
axes_t{1, 0, 3, 2}, axes_t{1, 3, 2, 0}, axes_t{1, 0, 2, 3},
|
||||
axes_t{1, 2, 0, 3}, axes_t{1, 2, 3, 0}, axes_t{1, 3, 0, 2},
|
||||
axes_t{2, 0, 1, 3}, axes_t{2, 0, 3, 1}, axes_t{2, 1, 0, 3},
|
||||
axes_t{2, 1, 3, 0}, axes_t{2, 3, 0, 1}, axes_t{2, 3, 1, 0},
|
||||
axes_t{3, 0, 1, 2}, axes_t{3, 0, 2, 1}, axes_t{3, 1, 2, 0},
|
||||
axes_t{3, 1, 0, 2}, axes_t{3, 2, 1, 0}, axes_t{3, 2, 0, 1},
|
||||
axes_t{0, 1, 2}, axes_t{0, 2, 1}, axes_t{1, 0, 2}, axes_t{1, 2, 0},
|
||||
axes_t{2, 0, 1}, axes_t{2, 1, 0}, axes_t{0, 1}, axes_t{1, 0})));
|
||||
INSTANTIATE_TEST_SUITE_P(Transpose, TransposeTest,
|
||||
testing::Combine(testing::Range(0, 3744)));
|
||||
|
||||
TEST_P(TransposeTest, Transpose) {
|
||||
|
||||
|
@ -124,6 +109,18 @@ TEST_P(TransposeTest, Transpose) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(lhs_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
FOR_LOOP(perm, k)
|
||||
SPLIT_ELEMENT(lhs_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
SPLIT_ELEMENT(perm, k)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"i_shape":[[1, 3, 16, 16], [1, 2, 4, 8], [2, 2, 4, 4], [1, 3, 16], [1, 2, 4], [2, 2, 4], [16, 16], [2, 4], [4, 4]],
|
||||
"lhs_type":["dt_float32", "dt_int32", "dt_int16", "dt_int64", "dt_int8", "dt_uint8", "dt_uint16", "dt_uint32", "dt_uint64", "dt_bfloat16", "dt_float64", "dt_float16", "dt_boolean"],
|
||||
"perm": [[0, 1, 2, 3], [0, 1, 3, 2], [0, 2, 1, 3], [0, 2, 3, 1], [0, 3, 1, 2], [0, 3, 2, 1], [1, 0, 3, 2], [1, 3, 2, 0], [1, 0, 2, 3], [1, 2, 0, 3], [1, 2, 3, 0], [1, 3, 0, 2], [2, 0, 1, 3], [2, 0, 3, 1], [2, 1, 0, 3], [2, 1, 3, 0], [2, 3, 0, 1], [2, 3, 1, 0], [3, 0, 1, 2], [3, 0, 2, 1], [3, 1, 2, 0], [3, 1, 0, 2], [3, 2, 1, 0], [3, 2, 0, 1], [0, 1, 2], [0, 2, 1], [1, 0, 2], [1, 2, 0], [2, 0, 1], [2, 1, 0], [0, 1], [1, 0]]
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"i_shape":[[1, 3, 16, 16], [3, 16, 16], [3, 16, 1], [16, 16], [16, 1], [1, 16, 1], [16], [1], []],
|
||||
"lhs_type":["dt_float32", "dt_int32", "dt_int64", "dt_float64", "dt_float16"]
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("lhs_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,13 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(
|
||||
testing::Values(dt_float32, dt_int32, dt_int64, dt_float64, dt_float16),
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16}, dims_t{16, 1},
|
||||
dims_t{1, 16, 1}, dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, abs) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -89,6 +88,15 @@ TEST_P(UnaryTest, abs) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(lhs_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(lhs_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,15 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(
|
||||
testing::Values(
|
||||
dt_float32,
|
||||
dt_float16 /*, dt_int32, dt_int64, dt_float64*/), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16}, dims_t{16, 1},
|
||||
dims_t{1, 16, 1}, dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, acos) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -91,6 +88,15 @@ TEST_P(UnaryTest, acos) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -179,15 +183,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(
|
||||
testing::Values(
|
||||
dt_float32,
|
||||
dt_float16 /*, dt_int32, dt_int64, dt_float64*/), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16}, dims_t{16, 1},
|
||||
dims_t{1, 16, 1}, dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, acosh) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -225,6 +222,15 @@ TEST_P(UnaryTest, acosh) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,15 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(
|
||||
testing::Values(
|
||||
dt_float32,
|
||||
dt_float16 /*, dt_int32, dt_int64, dt_float64*/), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16}, dims_t{16, 1},
|
||||
dims_t{1, 16, 1}, dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, asin) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -91,6 +88,15 @@ TEST_P(UnaryTest, asin) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,15 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(
|
||||
testing::Values(
|
||||
dt_float32,
|
||||
dt_float16 /*, dt_int32, dt_int64, dt_float64*/), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16}, dims_t{16, 1},
|
||||
dims_t{1, 16, 1}, dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, asinh) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -91,6 +88,15 @@ TEST_P(UnaryTest, asinh) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,30 +49,23 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32, dt_int32, dt_int64, dt_float64,
|
||||
dt_float16), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, ceil) {
|
||||
// OrtKITensor *orts[1];
|
||||
// orts[0] = runtime_tensor_2_ort_tensor(input);
|
||||
//
|
||||
// // expected
|
||||
// auto output_ort = ortki_Ceil(orts[0]);
|
||||
// size_t size = 0;
|
||||
// void *ptr_ort = tensor_buffer(output_ort, &size);
|
||||
// dims_t shape(tensor_rank(output_ort));
|
||||
// tensor_shape(output_ort, reinterpret_cast<int64_t *>(shape.data()));
|
||||
// auto expected = hrt::create(input.datatype(), shape,
|
||||
// {reinterpret_cast<gsl::byte *>(ptr_ort),
|
||||
// size}, true,
|
||||
// host_runtime_tensor::pool_cpu_only)
|
||||
// .expect("create tensor failed");
|
||||
OrtKITensor *orts[1];
|
||||
orts[0] = runtime_tensor_2_ort_tensor(input);
|
||||
|
||||
// expected
|
||||
auto output_ort = ortki_Ceil(orts[0]);
|
||||
size_t size = 0;
|
||||
void *ptr_ort = tensor_buffer(output_ort, &size);
|
||||
dims_t shape(tensor_rank(output_ort));
|
||||
tensor_shape(output_ort, reinterpret_cast<int64_t *>(shape.data()));
|
||||
auto expected = hrt::create(input.datatype(), shape,
|
||||
{reinterpret_cast<gsl::byte *>(ptr_ort), size},
|
||||
true, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
|
||||
// actual
|
||||
auto output = kernels::stackvm::unary(
|
||||
|
@ -76,21 +73,30 @@ TEST_P(UnaryTest, ceil) {
|
|||
.expect("unary failed");
|
||||
runtime_tensor actual(output.as<tensor>().expect("as tensor failed"));
|
||||
|
||||
// bool result = is_same_tensor(expected, actual) ||
|
||||
// cosine_similarity_tensor(expected, actual);
|
||||
//
|
||||
// if (!result) {
|
||||
// std::cout << "actual ";
|
||||
// print_runtime_tensor(actual);
|
||||
// std::cout << "expected ";
|
||||
// print_runtime_tensor(expected);
|
||||
// }
|
||||
//
|
||||
// // compare
|
||||
// EXPECT_TRUE(result);
|
||||
bool result = is_same_tensor(expected, actual) ||
|
||||
cosine_similarity_tensor(expected, actual);
|
||||
|
||||
if (!result) {
|
||||
std::cout << "actual ";
|
||||
print_runtime_tensor(actual);
|
||||
std::cout << "expected ";
|
||||
print_runtime_tensor(expected);
|
||||
}
|
||||
|
||||
// compare
|
||||
EXPECT_TRUE(result);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,15 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(
|
||||
testing::Values(
|
||||
dt_float32,
|
||||
dt_float16 /*, dt_int32, dt_int64, dt_float64*/), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16}, dims_t{16, 1},
|
||||
dims_t{1, 16, 1}, dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, cos) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -91,6 +88,15 @@ TEST_P(UnaryTest, cos) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,17 +49,10 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(
|
||||
testing::Values(
|
||||
dt_float32,
|
||||
dt_float16 /*, dt_int32, dt_int64, dt_float64*/), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16}, dims_t{16, 1},
|
||||
dims_t{1, 16, 1}, dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, abs) {
|
||||
TEST_P(UnaryTest, cosh) {
|
||||
OrtKITensor *orts[1];
|
||||
orts[0] = runtime_tensor_2_ort_tensor(input);
|
||||
|
||||
|
@ -91,6 +88,15 @@ TEST_P(UnaryTest, abs) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type1"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,15 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32,
|
||||
dt_float16 /*, dt_int32, dt_int64*/,
|
||||
dt_float64), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, exp) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -91,6 +88,15 @@ TEST_P(UnaryTest, exp) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type1"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,15 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32,
|
||||
dt_float16 /*, dt_int32, dt_int64*/,
|
||||
dt_float64), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, floor) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -91,6 +88,15 @@ TEST_P(UnaryTest, floor) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type1"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -179,15 +183,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32,
|
||||
/* dt_int32, dt_int64,*/ dt_float64,
|
||||
dt_float16), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, log) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -225,6 +222,15 @@ TEST_P(UnaryTest, log) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type2"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,13 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_boolean),
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, logical_not) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -90,6 +89,15 @@ TEST_P(UnaryTest, logical_not) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("lhs_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,14 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32, dt_int32, dt_int64, dt_float64,
|
||||
dt_float16), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, neg) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -90,6 +88,15 @@ TEST_P(UnaryTest, neg) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(lhs_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(lhs_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"i_shape":[[1, 3, 16, 16], [3, 16, 16], [3, 16, 1], [16, 16], [16, 1], [1, 16, 1], [16], [1], []],
|
||||
"other_type": ["dt_float32", "dt_float16"]
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"i_shape":[[1, 3, 16, 16], [3, 16, 16], [3, 16, 1], [16, 16], [16, 1], [1, 16, 1], [16], [1], []],
|
||||
"other_type": ["dt_float32", "dt_float16", "dt_float64"]
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"i_shape":[[1, 3, 16, 16], [3, 16, 16], [3, 16, 1], [16, 16], [16, 1], [1, 16, 1], [16], [1], []],
|
||||
"other_type": ["dt_boolean"]
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type1"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,14 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32 /*, dt_int32, dt_int64*/,
|
||||
dt_float64, dt_float16), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, round) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -91,6 +89,15 @@ TEST_P(UnaryTest, round) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -191,15 +195,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(
|
||||
testing::Values(
|
||||
dt_float32,
|
||||
dt_float16 /*, dt_int32, dt_int64, dt_float64*/), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16}, dims_t{16, 1},
|
||||
dims_t{1, 16, 1}, dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, rsqrt) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -257,6 +254,15 @@ TEST_P(UnaryTest, rsqrt) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("lhs_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,14 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32, dt_int32, dt_int64, dt_float64,
|
||||
dt_float16), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, sign) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -90,6 +88,15 @@ TEST_P(UnaryTest, sign) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(lhs_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(lhs_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type1"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,15 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32,
|
||||
/* dt_int32, dt_int64,*/ dt_float64,
|
||||
dt_float16), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, sin) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -91,6 +88,15 @@ TEST_P(UnaryTest, sin) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,15 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(
|
||||
testing::Values(
|
||||
dt_float32,
|
||||
dt_float16 /*, dt_int32, dt_int64, dt_float64*/), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16}, dims_t{16, 1},
|
||||
dims_t{1, 16, 1}, dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, sin) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -91,6 +88,15 @@ TEST_P(UnaryTest, sin) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,21 +26,23 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
||||
void TearDown() override {}
|
||||
|
||||
void init_tensor(runtime_tensor &tensor) override {
|
||||
auto dtype = tensor.datatype();
|
||||
switch (dtype) {
|
||||
|
@ -179,15 +181,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32,
|
||||
/*dt_int32, dt_int64,*/ dt_float64,
|
||||
dt_float16), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, sqrt) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -226,6 +221,15 @@ TEST_P(UnaryTest, sqrt) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(other_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(other_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("lhs_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -179,14 +183,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32, dt_int32, dt_int64, dt_float64,
|
||||
dt_float16), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, sqrt) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -226,6 +224,15 @@ TEST_P(UnaryTest, sqrt) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(lhs_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(lhs_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
|
@ -26,15 +26,19 @@ using namespace nncase;
|
|||
using namespace nncase::runtime;
|
||||
using namespace ortki;
|
||||
|
||||
class UnaryTest
|
||||
: public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<nncase::typecode_t, dims_t>> {
|
||||
#define TEST_CASE_NAME "test_unary_other_type1"
|
||||
|
||||
class UnaryTest : public KernelTest,
|
||||
public ::testing::TestWithParam<std::tuple<int>> {
|
||||
public:
|
||||
void SetUp() override {
|
||||
auto &&[typecode, i_shape] = GetParam();
|
||||
READY_SUBCASE()
|
||||
|
||||
auto typecode = GetDataType("other_type");
|
||||
auto l_shape = GetShapeArray("i_shape");
|
||||
|
||||
input =
|
||||
hrt::create(typecode, i_shape, host_runtime_tensor::pool_cpu_only)
|
||||
hrt::create(typecode, l_shape, host_runtime_tensor::pool_cpu_only)
|
||||
.expect("create tensor failed");
|
||||
init_tensor(input);
|
||||
}
|
||||
|
@ -45,14 +49,8 @@ class UnaryTest
|
|||
runtime_tensor input;
|
||||
};
|
||||
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
Unary, UnaryTest,
|
||||
testing::Combine(testing::Values(dt_float32 /*, dt_int32, dt_int64*/,
|
||||
dt_float64, dt_float16), // onnx no support
|
||||
testing::Values(dims_t{1, 3, 16, 16}, dims_t{3, 16, 16},
|
||||
dims_t{3, 16, 1}, dims_t{16, 16},
|
||||
dims_t{16, 1}, dims_t{1, 16, 1},
|
||||
dims_t{16}, dims_t{1}, dims_t{})));
|
||||
INSTANTIATE_TEST_SUITE_P(Unary, UnaryTest,
|
||||
testing::Combine(testing::Range(0, MAX_CASE_NUM)));
|
||||
|
||||
TEST_P(UnaryTest, tanh) {
|
||||
OrtKITensor *orts[1];
|
||||
|
@ -91,6 +89,15 @@ TEST_P(UnaryTest, tanh) {
|
|||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
READY_TEST_CASE_GENERATE()
|
||||
FOR_LOOP(lhs_type, i)
|
||||
FOR_LOOP(i_shape, j)
|
||||
SPLIT_ELEMENT(lhs_type, i)
|
||||
SPLIT_ELEMENT(i_shape, j)
|
||||
WRITE_SUB_CASE()
|
||||
FOR_LOOP_END()
|
||||
FOR_LOOP_END()
|
||||
|
||||
::testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
Loading…
Reference in New Issue