• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020-2021 Huawei Technologies Co., Ltd
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 
17 #include "minddata/dataset/include/dataset/datasets.h"
18 #include "minddata/dataset/engine/opt/pre/input_validation_pass.h"
19 
20 namespace mindspore {
21 namespace dataset {
22 
Visit(std::shared_ptr<DatasetNode> node,bool * const modified)23 Status InputValidationPass::Visit(std::shared_ptr<DatasetNode> node, bool *const modified) {
24   *modified = false;
25   RETURN_IF_NOT_OK(node->ValidateParams());
26 
27   // A data source node must be a leaf node
28   if ((node->IsMappableDataSource() || node->IsNonMappableDataSource()) && !node->IsLeaf()) {
29     std::string err_msg = node->Name() + " is a data source and must be a leaf node.";
30     RETURN_STATUS_UNEXPECTED(err_msg);
31   }
32 
33   // A non-leaf node must not be a data source node
34   if (node->IsNotADataSource() && node->IsLeaf()) {
35     std::string err_msg = node->Name() + " is a dataset operator and must not be a leaf node.";
36     RETURN_STATUS_UNEXPECTED(err_msg);
37   }
38 
39   return Status::OK();
40 }
41 }  // namespace dataset
42 }  // namespace mindspore
43