2 * Copyright (c) 2020 Samsung Electronics Co., Ltd. All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "NNPackages.h"
20 using ValidationTestAddModelLoaded = ValidationTestModelLoaded<NNPackages::ADD>;
22 TEST_F(ValidationTestAddModelLoaded, prepare_001)
24 NNFW_ENSURE_SUCCESS(nnfw_prepare(_session));
29 TEST_F(ValidationTestAddModelLoaded, set_available_backends_001)
31 NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(_session, "cpu"));
36 TEST_F(ValidationTestAddModelLoaded, get_input_size)
39 NNFW_ENSURE_SUCCESS(nnfw_input_size(_session, &size));
43 TEST_F(ValidationTestAddModelLoaded, get_output_size)
46 NNFW_ENSURE_SUCCESS(nnfw_output_size(_session, &size));
50 TEST_F(ValidationTestAddModelLoaded, output_tensorinfo)
52 nnfw_tensorinfo tensor_info;
53 NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(_session, 0, &tensor_info));
54 ASSERT_EQ(tensor_info.rank, 1);
55 ASSERT_EQ(tensor_info.dims[0], 1);
58 TEST_F(ValidationTestAddModelLoaded, input_output_tensorindex)
60 uint32_t in_ind = 100;
61 NNFW_ENSURE_SUCCESS(nnfw_input_tensorindex(_session, "X_input", &in_ind));
64 uint32_t out_ind = 100;
65 NNFW_ENSURE_SUCCESS(nnfw_output_tensorindex(_session, "ADD_TOP", &out_ind));
66 ASSERT_EQ(out_ind, 0);
69 TEST_F(ValidationTestAddModelLoaded, neg_run)
71 // nnfw_prepare is not called
72 ASSERT_EQ(nnfw_run(_session), NNFW_STATUS_INVALID_STATE);
75 TEST_F(ValidationTestAddModelLoaded, neg_set_input)
77 // nnfw_prepare is not called
78 ASSERT_EQ(nnfw_set_input(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 0),
79 NNFW_STATUS_INVALID_STATE);
82 TEST_F(ValidationTestAddModelLoaded, neg_set_output)
84 // nnfw_prepare is not called
85 ASSERT_EQ(nnfw_set_output(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 0),
86 NNFW_STATUS_INVALID_STATE);
89 TEST_F(ValidationTestAddModelLoaded, neg_get_input_size)
91 ASSERT_EQ(nnfw_input_size(_session, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
94 TEST_F(ValidationTestAddModelLoaded, neg_get_output_size)
96 ASSERT_EQ(nnfw_output_size(_session, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
99 TEST_F(ValidationTestAddModelLoaded, neg_load_model)
102 ASSERT_EQ(nnfw_load_model_from_file(
103 _session, NNPackages::get().getModelAbsolutePath(NNPackages::ADD).c_str()),
104 NNFW_STATUS_INVALID_STATE);
107 TEST_F(ValidationTestAddModelLoaded, neg_output_tensorinfo)
109 // tensor_info is null
110 ASSERT_EQ(nnfw_output_tensorinfo(_session, 0, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
113 TEST_F(ValidationTestAddModelLoaded, neg_input_output_tensorindex)
115 uint32_t in_ind = 100;
116 ASSERT_EQ(nnfw_input_tensorindex(_session, "ADD_TOP", &in_ind), NNFW_STATUS_ERROR);
117 ASSERT_EQ(in_ind, 100);
118 ASSERT_EQ(nnfw_input_tensorindex(_session, "y_var", &in_ind), NNFW_STATUS_ERROR);
119 ASSERT_EQ(in_ind, 100);
121 uint32_t out_ind = 100;
122 ASSERT_EQ(nnfw_output_tensorindex(_session, "X_input", &out_ind), NNFW_STATUS_ERROR);
123 ASSERT_EQ(out_ind, 100);