• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2020 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 #ifndef MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_GNN_GRAPH_FEATURE_PARSER_H_
17 #define MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_GNN_GRAPH_FEATURE_PARSER_H_
18 #include <memory>
19 #include <queue>
20 #include <string>
21 #include <unordered_map>
22 #include <unordered_set>
23 #include <vector>
24 
25 #include "minddata/dataset/core/data_type.h"
26 #include "minddata/dataset/core/tensor.h"
27 #if !defined(_WIN32) && !defined(_WIN64)
28 #include "minddata/dataset/engine/gnn/graph_shared_memory.h"
29 #endif
30 #include "minddata/dataset/engine/gnn/feature.h"
31 #include "minddata/dataset/util/status.h"
32 #include "minddata/mindrecord/include/shard_column.h"
33 
34 namespace mindspore {
35 namespace dataset {
36 namespace gnn {
37 
38 using mindrecord::ShardColumn;
39 
40 class GraphFeatureParser {
41  public:
42   explicit GraphFeatureParser(const ShardColumn &shard_column);
43 
44   ~GraphFeatureParser() = default;
45 
46   // @param std::string key - column name
47   // @param std::vector<uint8_t> &blob - contains data in blob field in mindrecord
48   // @param std::vector<int32_t> *ind - return value, list of feature index in int32_t
49   // @return Status - the status code
50   Status LoadFeatureIndex(const std::string &key, const std::vector<uint8_t> &blob, std::vector<int32_t> *ind);
51 
52   // @param std::string &key - column name
53   // @param std::vector<uint8_t> &blob - contains data in blob field in mindrecord
54   // @param std::shared_ptr<Tensor> *tensor - return value feature tensor
55   // @return Status - the status code
56   Status LoadFeatureTensor(const std::string &key, const std::vector<uint8_t> &blob, std::shared_ptr<Tensor> *tensor);
57 #if !defined(_WIN32) && !defined(_WIN64)
58   Status LoadFeatureToSharedMemory(const std::string &key, const std::vector<uint8_t> &col_blob,
59                                    GraphSharedMemory *shared_memory, std::shared_ptr<Tensor> *out_tensor);
60 #endif
61  private:
62   std::unique_ptr<ShardColumn> shard_column_;
63 };
64 }  // namespace gnn
65 }  // namespace dataset
66 }  // namespace mindspore
67 #endif  // MINDSPORE_CCSRC_MINDDATA_DATASET_ENGINE_GNN_GRAPH_FEATURE_PARSER_H_
68