Program Listing for File gxf_tensor.hpp
↰ Return to documentation for file (include/holoscan/core/gxf/gxf_tensor.hpp
)
/*
* SPDX-FileCopyrightText: Copyright (c) 2022-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.
*/
#ifndef HOLOSCAN_CORE_GXF_GXF_TENSOR_HPP
#define HOLOSCAN_CORE_GXF_GXF_TENSOR_HPP
#include <memory>
#include <utility>
#include <vector>
#include "gxf/std/tensor.hpp"
#include "holoscan/core/common.hpp"
#include "holoscan/core/domain/tensor.hpp"
namespace holoscan::gxf {
class GXFMemoryBuffer; // forward declaration
class GXFTensor : public nvidia::gxf::Tensor {
public:
GXFTensor() = default;
explicit GXFTensor(std::shared_ptr<DLManagedTensorCtx>& dl_ctx);
explicit GXFTensor(nvidia::gxf::Tensor& tensor, int64_t id = 0);
DLDevice device() const;
DLDataType dtype() const;
std::shared_ptr<holoscan::Tensor> as_tensor();
static std::shared_ptr<GXFTensor> from_tensor(std::shared_ptr<holoscan::Tensor> tensor);
std::shared_ptr<DLManagedTensorCtx>& dl_ctx() { return dl_ctx_; }
protected:
std::shared_ptr<DLManagedTensorCtx> dl_ctx_;
};
class GXFMemoryBuffer : public nvidia::gxf::MemoryBuffer {
public:
using nvidia::gxf::MemoryBuffer::MemoryBuffer;
explicit GXFMemoryBuffer(nvidia::gxf::MemoryBuffer&& other)
: nvidia::gxf::MemoryBuffer(std::forward<nvidia::gxf::MemoryBuffer>(other)) {}
std::vector<int64_t> dl_shape;
std::vector<int64_t> dl_strides;
};
} // namespace holoscan::gxf
#endif/* HOLOSCAN_CORE_GXF_GXF_TENSOR_HPP */