Use LogSoftmax-5 in the onnx_importer (#2602)

This commit is contained in:
Tomasz Dołbniak
2020-10-21 10:50:16 +02:00
committed by GitHub
parent 8a1653b0d1
commit 3688ff4c51
13 changed files with 303 additions and 22 deletions

View File

@@ -0,0 +1,39 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "data"
output: "y"
op_type: "LogSoftmax"
}
name: "LogSoftmax test"
input {
name: "data"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
}
}
}
}
output {
name: "y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
}
}
}
}
}
opset_import {
version: 13
}

View File

@@ -0,0 +1,45 @@
ir_version: 3
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "x"
output: "y"
op_type: "LogSoftmax"
}
name: "LogSoftmax test"
input {
name: "x"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 2
}
dim {
dim_value: 4
}
}
}
}
}
output {
name: "y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 2
}
dim {
dim_value: 4
}
}
}
}
}
}
opset_import {
version: 13
}

View File

@@ -0,0 +1,37 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "data"
output: "y"
op_type: "LogSoftmax"
}
name: "LogSoftmax test"
input {
name: "data"
type {
tensor_type {
elem_type: 1
shape {
dim {
}
}
}
}
}
output {
name: "y"
type {
tensor_type {
elem_type: 1
shape {
dim {
}
}
}
}
}
}
opset_import {
version: 1
}

View File

@@ -0,0 +1,44 @@
ir_version: 7
producer_name: "nGraph ONNX Importer"
graph {
node {
input: "data"
output: "y"
op_type: "LogSoftmax"
attribute {
name: "axis"
i: 0
type: INT
}
}
name: "LogSoftmax test"
input {
name: "data"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
}
}
}
}
output {
name: "y"
type {
tensor_type {
elem_type: 1
shape {
dim {
dim_value: 3
}
}
}
}
}
}
opset_import {
version: 1
}

View File

@@ -2719,3 +2719,55 @@ NGRAPH_TEST(${BACKEND_NAME}, onnx_group_norm)
test_case.add_expected_output<float>(shape, output);
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_logsoftmax_0D)
{
auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/softmax_0D.prototxt"));
auto test_case = test::TestCase<TestEngine>(function);
test_case.add_input<float>({3.141592});
test_case.add_expected_output<float>({0.0});
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_logsoftmax_1D)
{
const auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/logsoftmax_1D.prototxt"));
auto test_case = test::TestCase<TestEngine>(function);
test_case.add_input<float>({-1.0f, 0.0f, 1.0f});
test_case.add_expected_output<float>(Shape{3}, {-2.4076061, -1.407606, -0.407606});
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_logsoftmax13_1D)
{
const auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/logsoftmax13_1D.prototxt"));
auto test_case = test::TestCase<TestEngine>(function);
test_case.add_input<float>({-1.0f, 0.0f, 1.0f});
test_case.add_expected_output<float>(Shape{3}, {-2.4076061, -1.407606, -0.407606});
test_case.run();
}
NGRAPH_TEST(${BACKEND_NAME}, onnx_model_logsoftmax13_2D)
{
const auto function = onnx_import::import_onnx_model(
file_util::path_join(SERIALIZED_ZOO, "onnx/logsoftmax13_2D.prototxt"));
auto test_case = test::TestCase<TestEngine>(function);
test_case.add_input<float>({0.0f, 1.0f, 2.0f, 3.0f, 10000, 10001, 10002, 10003});
test_case.add_expected_output<float>(Shape{2, 4},
{-3.4401896,
-2.4401896,
-1.4401896,
-0.44018966,
-3.4401896,
-2.4401896,
-1.4401896,
-0.44018966});
test_case.run_with_tolerance_as_fp();
}

View File

@@ -69,6 +69,7 @@ bool_const_op
onnx_model_tile
onnx_model_tile_static
onnx_model_softmax_0D
onnx_model_logsoftmax_0D
builder_opset1_collapse_none
# nGraph function's output number 0 was not found in the CNNNetwork built from it.

View File

@@ -141,3 +141,7 @@ lstm_cell_bias_peepholes_clip_input_forget
# unsupported element type f16
INTERPRETER.ctc_greedy_decoder_f16
# LogSoftmax's reference implementation doesn't handle scalar input properly
onnx_model_logsoftmax_0D