• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "mindir_types.h"
17 
18 #include "validation.h"
19 
20 namespace OHOS {
21 namespace NeuralNetworkRuntime {
22 namespace Validation {
ValidateTensorDataType(OH_NN_DataType dataType)23 bool ValidateTensorDataType(OH_NN_DataType dataType)
24 {
25     if (dataType >= OH_NN_UNKNOWN && dataType <= OH_NN_FLOAT64) {
26         return true;
27     }
28     return false;
29 }
30 
ValidatePerformanceMode(OH_NN_PerformanceMode performanceMode)31 bool ValidatePerformanceMode(OH_NN_PerformanceMode performanceMode)
32 {
33     if ((performanceMode >= OH_NN_PERFORMANCE_NONE) && (performanceMode <= OH_NN_PERFORMANCE_EXTREME)) {
34         return true;
35     }
36     return false;
37 }
38 
ValidatePriority(OH_NN_Priority priority)39 bool ValidatePriority(OH_NN_Priority priority)
40 {
41     if ((priority >= OH_NN_PRIORITY_NONE) && (priority <= OH_NN_PRIORITY_HIGH)) {
42         return true;
43     }
44     return false;
45 }
46 
ValidateFuseType(OH_NN_FuseType fuseType)47 bool ValidateFuseType(OH_NN_FuseType fuseType)
48 {
49     if ((fuseType >= OH_NN_FUSED_NONE) && (fuseType <= OH_NN_FUSED_RELU6)) {
50         return true;
51     }
52     return false;
53 }
54 
ValidatePadMode(int8_t padMode)55 bool ValidatePadMode(int8_t padMode)
56 {
57     if ((padMode >= mindspore::lite::PAD_MODE_PAD) && (padMode <= mindspore::lite::PAD_MODE_VALID)) {
58         return true;
59     }
60     return false;
61 }
62 
ValidateTensorType(OH_NN_TensorType nnTensorType)63 bool ValidateTensorType(OH_NN_TensorType nnTensorType)
64 {
65     if ((nnTensorType >= OH_NN_TENSOR) && (nnTensorType <= OH_NN_UNSQUEEZE_AXIS)) {
66         return true;
67     }
68     return false;
69 }
70 } // namespace Validation
71 } // namespace NeuralNetworkRuntime
72 } // namespace OHOS
73