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

HiCR: /home/runner/work/HiCR/HiCR/include/hicr/backends/ascend/memorySpace.hpp Source File
HiCR
memorySpace.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{
33
37class Device;
38
42class MemorySpace final : public HiCR::MemorySpace
43{
44 public:
45
52 MemorySpace(const std::weak_ptr<ascend::Device> device, const size_t size)
53 : HiCR::MemorySpace(size),
54 _device(device)
55 {
56 _type = "Ascend Device RAM";
57 };
58
62 ~MemorySpace() = default;
63
71 MemorySpace(const nlohmann::json &input)
72 : HiCR::MemorySpace()
73 {
74 deserialize(input);
75 }
76
82 __INLINE__ const std::weak_ptr<const ascend::Device> getDevice() const { return _device; }
83
84 private:
85
86 __INLINE__ void serializeImpl(nlohmann::json &output) const override
87 {
88 // No additional information to serialize for now
89 }
90
91 __INLINE__ void deserializeImpl(const nlohmann::json &input) override
92 {
93 // No additional information to deserialize for now
94 }
95
101 std::weak_ptr<ascend::Device> _device;
102};
103
104} // namespace HiCR::backend::ascend
Provides a definition for the local memory slot class for the Ascend backend.
Definition memorySpace.hpp:45
__INLINE__ void deserialize(const nlohmann::json &input)
Definition memorySpace.hpp:143
std::string _type
Definition memorySpace.hpp:197
Definition memorySpace.hpp:43
MemorySpace(const nlohmann::json &input)
Definition memorySpace.hpp:71
__INLINE__ const std::weak_ptr< const ascend::Device > getDevice() const
Definition memorySpace.hpp:82
MemorySpace(const std::weak_ptr< ascend::Device > device, const size_t size)
Definition memorySpace.hpp:52
Provides a base definition for a HiCR MemorySpace class.