Program Listing for File dev_mem_info.hpp

(Latest Version)

Return to documentation for file (morpheus/_lib/include/morpheus/objects/dev_mem_info.hpp)


/* * SPDX-FileCopyrightText: Copyright (c) 2021-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. * SPDX-License-Identifier: Apache-2.0 * * 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 * * * * 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. */ #pragma once #include "morpheus/export.h" #include "morpheus/objects/dtype.hpp" // for DType, TypeId #include "morpheus/objects/memory_descriptor.hpp" // for MemoryDescriptor #include "morpheus/types.hpp" // for ShapeType, TensorIndex, TensorSize #include <rmm/device_buffer.hpp> // for device_buffer #include <memory> // for shared_ptr, unique_ptr & make_unique namespace morpheus { /****** Component public implementations *******************/ /****** DevMemInfo******************************************/ class MORPHEUS_EXPORT DevMemInfo { public: DevMemInfo(void* data, DType dtype, std::shared_ptr<MemoryDescriptor> md, ShapeType shape, ShapeType stride, TensorSize offset_bytes = 0); DevMemInfo(std::shared_ptr<rmm::device_buffer> buffer, DType dtype, ShapeType shape, ShapeType stride, TensorSize offset_bytes = 0); DevMemInfo(DevMemInfo&& other) = default; TensorSize bytes() const; TensorSize count() const; TensorSize offset_bytes() const; const DType& dtype() const; TypeId type_id() const; const ShapeType& shape() const; TensorIndex shape(TensorIndex idx) const; const ShapeType& stride() const; TensorIndex stride(TensorIndex idx) const; void* data() const; std::shared_ptr<MemoryDescriptor> memory() const; std::unique_ptr<rmm::device_buffer> make_new_buffer(TensorSize bytes) const; private: // Pointer to the head of our data void* m_data; // Type of elements in the buffer const DType m_dtype; // Shape & stride of the data in the buffer const ShapeType m_shape; const ShapeType m_stride; // Offset from head of data in bytes const TensorSize m_offset_bytes; // Device resources used to allocate this memory std::shared_ptr<MemoryDescriptor> m_md; }; // end of group } // namespace morpheus

© Copyright 2024, NVIDIA. Last updated on Jul 8, 2024.