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) { NNFW_ENSURE_SUCCESS(nnfw_prepare(_session)); }
24 TEST_F(ValidationTestAddModelLoaded, set_available_backends_001)
26 NNFW_ENSURE_SUCCESS(nnfw_set_available_backends(_session, "cpu"));
29 TEST_F(ValidationTestAddModelLoaded, get_input_size)
32 NNFW_ENSURE_SUCCESS(nnfw_input_size(_session, &size));
36 TEST_F(ValidationTestAddModelLoaded, get_output_size)
39 NNFW_ENSURE_SUCCESS(nnfw_output_size(_session, &size));
43 TEST_F(ValidationTestAddModelLoaded, output_tensorinfo)
45 nnfw_tensorinfo tensor_info;
46 NNFW_ENSURE_SUCCESS(nnfw_output_tensorinfo(_session, 0, &tensor_info));
47 ASSERT_EQ(tensor_info.rank, 1);
48 ASSERT_EQ(tensor_info.dims[0], 1);
51 TEST_F(ValidationTestAddModelLoaded, neg_run)
53 // nnfw_prepare is not called
54 ASSERT_EQ(nnfw_run(_session), NNFW_STATUS_INVALID_STATE);
57 TEST_F(ValidationTestAddModelLoaded, neg_set_input)
59 // nnfw_prepare is not called
60 ASSERT_EQ(nnfw_set_input(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 0),
61 NNFW_STATUS_INVALID_STATE);
64 TEST_F(ValidationTestAddModelLoaded, neg_set_output)
66 // nnfw_prepare is not called
67 ASSERT_EQ(nnfw_set_output(_session, 0, NNFW_TYPE_TENSOR_FLOAT32, nullptr, 0),
68 NNFW_STATUS_INVALID_STATE);
71 TEST_F(ValidationTestAddModelLoaded, neg_get_input_size)
73 ASSERT_EQ(nnfw_input_size(_session, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
76 TEST_F(ValidationTestAddModelLoaded, neg_get_output_size)
78 ASSERT_EQ(nnfw_output_size(_session, nullptr), NNFW_STATUS_UNEXPECTED_NULL);
81 TEST_F(ValidationTestAddModelLoaded, neg_load_model)
84 ASSERT_EQ(nnfw_load_model_from_file(
85 _session, NNPackages::get().getModelAbsolutePath(NNPackages::ADD).c_str()),
86 NNFW_STATUS_INVALID_STATE);
89 TEST_F(ValidationTestAddModelLoaded, neg_output_tensorinfo)
91 // tensor_info is null
92 ASSERT_EQ(nnfw_output_tensorinfo(_session, 0, nullptr), NNFW_STATUS_UNEXPECTED_NULL);