Program Listing for File TensorBatch.h

Return to documentation for file (nvcv_types/include/nvcv/TensorBatch.h)

/*
 * SPDX-FileCopyrightText: Copyright (c) 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 NVCV_TENSORBATCH_H
#define NVCV_TENSORBATCH_H

#include "Export.h"
#include "Fwd.h"
#include "Image.h"
#include "Status.h"
#include "Tensor.h"
#include "TensorBatchData.h"
#include "TensorLayout.h"

#ifdef __cplusplus
extern "C"
{
#endif

typedef struct NVCVTensorBatch *NVCVTensorBatchHandle;

typedef struct NVCVTensorBatchRequirementsRec
{
    /*< Maximum number of tensors in the batch */
    int32_t capacity;

    /*< Alignment/block size in bytes */
    int32_t alignBytes;

    /*< Tensor resource requirements. */
    NVCVRequirements mem;
} NVCVTensorBatchRequirements;

NVCV_PUBLIC NVCVStatus nvcvTensorBatchCalcRequirements(int32_t capacity, NVCVTensorBatchRequirements *reqs);

NVCVStatus nvcvTensorBatchConstruct(const NVCVTensorBatchRequirements *req, NVCVAllocatorHandle alloc,
                                    NVCVTensorBatchHandle *outHandle);

NVCVStatus nvcvTensorBatchClear(NVCVTensorBatchHandle handle);

NVCVStatus nvcvTensorBatchPushTensors(NVCVTensorBatchHandle handle, const NVCVTensorHandle *tensors,
                                      int32_t numTensors);

NVCVStatus nvcvTensorBatchPopTensors(NVCVTensorBatchHandle handle, int32_t numTensors);

NVCVStatus nvcvTensorBatchPopulate(NVCVTensorBatchHandle batch, int32_t numTensors, const int64_t **shapes,
                                   const int64_t **strides /* optional, dense packing if NULL */,
                                   int32_t         tensorAlignment /* optional, use default if set to 0 */);

NVCVStatus nvcvTensorBatchGetTensors(NVCVTensorBatchHandle batch, int32_t index, NVCVTensorHandle *outTensors,
                                     int32_t numTensors);

NVCVStatus nvcvTensorBatchSetTensors(NVCVTensorBatchHandle batch, int32_t index, const NVCVTensorHandle *tensors,
                                     int32_t numTensors);

NVCVStatus nvcvTensorBatchGetAllocator(NVCVTensorBatchHandle batch, NVCVAllocatorHandle *alloc);

NVCVStatus nvcvTensorBatchGetType(NVCVTensorBatchHandle batch, NVCVTensorBufferType *outType);

NVCV_PUBLIC NVCVStatus nvcvTensorBatchExportData(NVCVTensorBatchHandle handle, CUstream stream,
                                                 NVCVTensorBatchData *data);

NVCVStatus nvcvTensorBatchGetNumTensors(NVCVTensorBatchHandle batch, int32_t *outNumTensors);

NVCV_PUBLIC NVCVStatus nvcvTensorBatchDecRef(NVCVTensorBatchHandle handle, int32_t *newRefCount);

NVCV_PUBLIC NVCVStatus nvcvTensorBatchIncRef(NVCVTensorBatchHandle handle, int32_t *newRefCount);

NVCV_PUBLIC NVCVStatus nvcvTensorBatchRefCount(NVCVTensorBatchHandle handle, int32_t *outRefCount);

NVCV_PUBLIC NVCVStatus nvcvTensorBatchSetUserPointer(NVCVTensorBatchHandle handle, void *userPtr);

NVCV_PUBLIC NVCVStatus nvcvTensorBatchGetUserPointer(NVCVTensorBatchHandle handle, void **outUserPtr);

NVCV_PUBLIC NVCVStatus nvcvTensorBatchGetCapacity(NVCVTensorBatchHandle handle, int32_t *outCapacityPtr);

NVCV_PUBLIC NVCVStatus nvcvTensorBatchGetDType(NVCVTensorBatchHandle handle, NVCVDataType *outDTypePtr);

NVCV_PUBLIC NVCVStatus nvcvTensorBatchGetLayout(NVCVTensorBatchHandle handle, NVCVTensorLayout *outLayoutPtr);

NVCV_PUBLIC NVCVStatus nvcvTensorBatchGetRank(NVCVTensorBatchHandle handle, int32_t *outRankPtr);

#ifdef __cplusplus
}
#endif

#endif // NVCV_TENSORBATCH_H