You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
graphengine/ge/single_op/single_op_manager.h

68 lines
2.1 KiB

5 years ago
/**
* Copyright 2019-2020 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef GE_SINGLE_OP_SINGLE_OP_MANAGER_H_
#define GE_SINGLE_OP_SINGLE_OP_MANAGER_H_
#include <mutex>
#include <unordered_map>
#include <string>
#include "common/ge/op_tiling_manager.h"
5 years ago
#include "single_op/single_op_model.h"
#include "single_op/stream_resource.h"
namespace ge {
class SingleOpManager {
public:
~SingleOpManager();
static SingleOpManager &GetInstance() {
static SingleOpManager instance;
return instance;
}
4 years ago
Status GetOpFromModel(const std::string &model_name,
const ge::ModelData &model_data,
void *stream,
SingleOp **single_op,
const uint64_t model_id);
4 years ago
Status GetDynamicOpFromModel(const std::string &model_name,
const ge::ModelData &model_data,
void *stream,
DynamicSingleOp **dynamic_single_op,
const uint64_t model_id);
StreamResource *GetResource(uintptr_t resource_id, rtStream_t stream);
5 years ago
Status ReleaseResource(void *stream);
void RegisterTilingFunc();
5 years ago
private:
static Status GetResourceId(rtStream_t stream, uintptr_t &resource_id);
5 years ago
StreamResource *TryGetResource(uintptr_t resource_id);
std::mutex mutex_;
bool tiling_func_registered_ = false;
5 years ago
std::unordered_map<uintptr_t, StreamResource *> stream_resources_;
OpTilingManager op_tiling_manager_;
5 years ago
};
} // namespace ge
#endif // GE_SINGLE_OP_SINGLE_OP_MANAGER_H_