Program Listing for File vart_tensor_buffer.hpp

Return to documentation for file (/workspace/amdinfer/src/amdinfer/buffers/vart_tensor_buffer.hpp)

// Copyright 2021 Xilinx, Inc.
// Copyright 2022 Advanced Micro Devices, Inc.
//
// 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 GUARD_AMDINFER_BUFFERS_VART_TENSOR_BUFFER
#define GUARD_AMDINFER_BUFFERS_VART_TENSOR_BUFFER

#include <cstddef>                              // for size_t
#include <cstdint>                              // for int32_t
#include <memory>                               // for unique_ptr
#include <string>                               // for string
#include <vart/experimental/runner_helper.hpp>  // for CpuFlatTensorBufferOwned
#include <vector>                               // for vector
#include <xir/tensor/tensor.hpp>                // for Tensor
#include <xir/util/data_type.hpp>               // for DataType

#include "amdinfer/buffers/buffer.hpp"

namespace vart {
class TensorBuffer;
}  // namespace vart

namespace amdinfer {

class VartTensorBuffer : public Buffer {
 public:
  VartTensorBuffer(const std::string& name, std::vector<int32_t>& shape,
                   xir::DataType data_type);
  VartTensorBuffer(const char* name, std::vector<int32_t>& shape,
                   xir::DataType data_type);

  void* data(size_t offset) override;

  void reset() override;

  vart::TensorBuffer* getTensorBuffer();

 private:
  std::unique_ptr<xir::Tensor> tensor_;
  vart::CpuFlatTensorBufferOwned data_;
};

}  // namespace amdinfer

#endif  // GUARD_AMDINFER_BUFFERS_VART_TENSOR_BUFFER