/home/runner/work/HiCR/HiCR/include/hicr/backends/ascend/computeResource.hpp Source File

HiCR: /home/runner/work/HiCR/HiCR/include/hicr/backends/ascend/computeResource.hpp Source File
HiCR
computeResource.hpp
Go to the documentation of this file.
1/*
2 * Copyright 2025 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
24#pragma once
25
26#include <nlohmann_json/json.hpp>
27#include <hicr/core/definitions.hpp>
30
31namespace HiCR::backend::ascend
32{
36class Device;
37
42{
43 public:
44
50 ComputeResource(const std::shared_ptr<ascend::Device> &device)
51 : HiCR::ComputeResource(),
52 _device(device)
53 {
54 _type = "Ascend Processor";
55 };
56
60 ~ComputeResource() = default;
61
69 ComputeResource(const nlohmann::json &input)
70 : HiCR::ComputeResource()
71 {
72 deserialize(input);
73 }
74
80 __INLINE__ const std::weak_ptr<const ascend::Device> getDevice() const { return _device; }
81
82 private:
83
84 __INLINE__ void serializeImpl(nlohmann::json &output) const override
85 {
86 // Nothing extra to serialize here
87 }
88
89 __INLINE__ void deserializeImpl(const nlohmann::json &input) override
90 {
91 // Nothing extra to deserialize here
92 }
93
99 std::weak_ptr<ascend::Device> _device;
100};
101
102} // namespace HiCR::backend::ascend
Definition computeResource.hpp:40
std::string _type
Definition computeResource.hpp:109
__INLINE__ void deserialize(const nlohmann::json &input)
Definition computeResource.hpp:95
Definition computeResource.hpp:42
ComputeResource(const nlohmann::json &input)
Definition computeResource.hpp:69
__INLINE__ const std::weak_ptr< const ascend::Device > getDevice() const
Definition computeResource.hpp:80
ComputeResource(const std::shared_ptr< ascend::Device > &device)
Definition computeResource.hpp:50
Provides a base definition for a HiCR ComputeResource class.
Provides a failure model and corresponding exception classes.