Program Listing for File dev_mem_info.hpp

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

Copy
Copied!
            

/* * SPDX-FileCopyrightText: Copyright (c) 2021-2023, 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 * * 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. */ #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 2023, NVIDIA. Last updated on Feb 2, 2024.