/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
57 ~ComputeResource() = default;
58
66 ComputeResource(const nlohmann::json &input)
67 : HiCR::ComputeResource()
68 {
69 deserialize(input);
70 }
71
72 __INLINE__ std::string getType() const override { return "Ascend Processor"; }
73
79 __INLINE__ const std::weak_ptr<const ascend::Device> getDevice() const { return _device; }
80
81 private:
82
83 __INLINE__ void serializeImpl(nlohmann::json &output) const override
84 {
85 // Nothing extra to serialize here
86 }
87
88 __INLINE__ void deserializeImpl(const nlohmann::json &input) override
89 {
90 // Nothing extra to deserialize here
91 }
92
98 std::weak_ptr<ascend::Device> _device;
99};
100
101} // namespace HiCR::backend::ascend
Definition computeResource.hpp:39
__INLINE__ void deserialize(const nlohmann::json &input)
Definition computeResource.hpp:79
Definition computeResource.hpp:42
__INLINE__ std::string getType() const override
Definition computeResource.hpp:72
ComputeResource(const nlohmann::json &input)
Definition computeResource.hpp:66
__INLINE__ const std::weak_ptr< const ascend::Device > getDevice() const
Definition computeResource.hpp:79
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.