• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright 2023 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 #ifndef GE_MOCK_H
18 #define GE_MOCK_H
19 #include <iostream>
20 #include <memory>
21 #include <string>
22 #include <cstring>
23 #include <sstream>
24 #include "graph/tensor.h"
25 #include "graph/operator_reg.h"
26 #include "graph/operator.h"
27 
28 #include "ge/ge_api.h"
29 
30 namespace ge {
31 
Session(const std::map<std::string,std::string> & options)32 Session::Session(const std::map<std::string, std::string> &options) {}
~Session()33 Session::~Session() {}
34 
RunGraph(uint32_t id,const std::vector<Tensor> & inputs,std::vector<Tensor> & outputs)35 Status Session::RunGraph(uint32_t id, const std::vector<Tensor> &inputs, std::vector<Tensor> &outputs) {
36   // for test!!! just copy inputs to outputs:
37   for (auto it = inputs.begin(); it != inputs.end(); it++) {
38     outputs.emplace_back(*it);
39   }
40   return ge::GRAPH_SUCCESS;
41 }
42 
AddGraph(uint32_t id,const Graph & graph)43 Status Session::AddGraph(uint32_t id, const Graph &graph) { return ge::GRAPH_SUCCESS; }
44 
GEInitialize(const std::map<std::string,std::string> & options)45 Status GEInitialize(const std::map<std::string, std::string> &options) { return ge::GRAPH_SUCCESS; }
46 
GEFinalize()47 Status GEFinalize() { return ge::GRAPH_SUCCESS; }
48 
SaveToFile(const string & file_name) const49 Status Graph::SaveToFile(const string &file_name) const { return ge::GRAPH_SUCCESS; }
50 
RunGraphAsync(uint32_t graph_id,const std::vector<ge::Tensor> & inputs,RunAsyncCallback callback)51 Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<ge::Tensor> &inputs, RunAsyncCallback callback) {
52   return ge::GRAPH_SUCCESS;
53 }
54 
RunGraphAsync(uint32_t graph_id,const ContinuousTensorList & inputs,RunAsyncCallback callback)55 Status Session::RunGraphAsync(uint32_t graph_id, const ContinuousTensorList &inputs, RunAsyncCallback callback) {
56   return ge::GRAPH_SUCCESS;
57 }
58 
AddGraph(uint32_t graph_id,const Graph & graph,const std::map<std::string,std::string> & options)59 Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<std::string, std::string> &options) {
60   return ge::GRAPH_SUCCESS;
61 }
62 
CompileGraph(uint32_t graph_id)63 Status Session::CompileGraph(uint32_t graph_id) { return ge::GRAPH_SUCCESS; }
64 
GetCompiledGraphSummary(uint32_t graph_id)65 CompiledGraphSummaryPtr Session::GetCompiledGraphSummary(uint32_t graph_id) { return nullptr; }
66 
UpdateGraphFeatureMemoryBase(uint32_t graph_id,const void * const memory,size_t size)67 Status Session::UpdateGraphFeatureMemoryBase(uint32_t graph_id, const void *const memory, size_t size) {
68   return ge::GRAPH_SUCCESS;
69 }
70 
SetGraphConstMemoryBase(uint32_t graph_id,const void * const memory,size_t size)71 Status Session::SetGraphConstMemoryBase(uint32_t graph_id, const void *const memory, size_t size) {
72   return ge::GRAPH_SUCCESS;
73 }
74 
RemoveGraph(uint32_t graph_id)75 Status Session::RemoveGraph(uint32_t graph_id) { return ge::GRAPH_SUCCESS; }
76 
RunGraphWithStreamAsync(uint32_t graph_id,void * stream,const std::vector<Tensor> & inputs,std::vector<Tensor> & outputs)77 Status Session::RunGraphWithStreamAsync(uint32_t graph_id, void *stream, const std::vector<Tensor> &inputs,
78                                         std::vector<Tensor> &outputs) {
79   return ge::GRAPH_SUCCESS;
80 }
81 
RequiredAttrWithTypeRegister(const char_t * name,const char_t * type)82 void Operator::RequiredAttrWithTypeRegister(const char_t *name, const char_t *type) {}
83 }  // namespace ge
84 
85 #endif
86