pva_apl.h#
Fully qualified name: src/device/fixed_function_library/include/pva_apl.h
File members: src/device/fixed_function_library/include/pva_apl.h
/*
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
*
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
* property and proprietary rights in and to this material, related
* documentation and any modifications thereto. Any use, reproduction,
* disclosure or distribution of this material and related documentation
* without an express license agreement from NVIDIA CORPORATION or
* its affiliates is strictly prohibited.
*/
#ifndef PVA_APL_H
#define PVA_APL_H
#include "pva_apl/pva_apl_impl.h"
#include "pva_apl/pva_apl_types.h"
#include <cupva_device.h>
#include <stdint.h>
void pvaAplInitSepConv5x5S16Vpu(PvaAplSepConv5x5S16 *handle, int16_t *input, int16_t *coeff_h, int16_t *coeff_v,
int32_t width, int32_t height, int32_t inputLinePitch, int32_t outputLinePitch,
int32_t roundNBits, int16_t *output, int16_t *cbStart, int32_t cbSize,
int16_t *scratch);
static inline void pvaAplInitSepConv5x5S16(PvaAplSepConv5x5S16 *handle, int16_t *input, int16_t *coeff_h,
int16_t *coeff_v, int32_t width, int32_t height, int32_t inputLinePitch,
int32_t outputLinePitch, int32_t roundNBits, int16_t *output,
int16_t *cbStart, int32_t cbSize, int16_t *scratch)
{
PVAAPL_IMPL_FUNC(SepConv5x5S16, Init, handle, input, coeff_h, coeff_v, width, height, inputLinePitch,
outputLinePitch, roundNBits, output, cbStart, cbSize, scratch);
}
void pvaAplUpdateSepConv5x5S16Vpu(PvaAplSepConv5x5S16 *handle, int16_t *input, int16_t *output);
static inline void pvaAplUpdateSepConv5x5S16(PvaAplSepConv5x5S16 *handle, int16_t *input, int16_t *output)
{
PVAAPL_IMPL_FUNC(SepConv5x5S16, Update, handle, input, output);
}
void pvaAplExecSepConv5x5S16Vpu(PvaAplSepConv5x5S16 *handle);
static inline void pvaAplExecSepConv5x5S16(PvaAplSepConv5x5S16 *handle)
{
PVAAPL_IMPL_FUNC(SepConv5x5S16, Exec, handle);
}
namespace cupva { namespace device { namespace priv {
inline constexpr uint32_t pvaAplRoundUp(uint32_t x, uint32_t y)
{
cupva::device::priv::vpuAssert((y != 0U));
cupva::device::priv::vpuAssert((x <= (UINT32_MAX - (y - 1U))));
uint32_t const q = (x + (y - 1U)) / y;
cupva::device::priv::vpuAssert((q <= (UINT32_MAX / y)));
return q * y;
}
inline constexpr int32_t clamp(int32_t x, int32_t min, int32_t max)
{
return x < min ? min : x > max ? max : x;
}
}}} // namespace cupva::device::priv
/* 4U = sizeof(int16_t) (fixed by the C/C++ standard) * 2 (dual gx/gy buffers) */
#define PVAAPL_HARRIS_SCRATCH_SIZE(_width_, _height_) \
((cupva::device::priv::pvaAplRoundUp((_width_) - 2U, 32U) + 1U) * \
cupva::device::priv::pvaAplRoundUp((_height_), 32U) * 4U)
void pvaAplInitHarrisCornerS16Vpu(PvaAplHarrisCornerS16 *handle, int16_t *input, int16_t *coeff, int32_t roundNBits,
int32_t lambdaVal, int32_t width, int32_t height, int32_t inputLinePitch,
int32_t outputLinePitch, int32_t *output, int16_t *cbStart, int32_t cbSize,
void *scratch0, void *scratch1, void *scratch2);
static inline void pvaAplInitHarrisCornerS16(PvaAplHarrisCornerS16 *handle, int16_t *input, int16_t *coeff,
int32_t roundNBits, int32_t lambdaVal, int32_t width, int32_t height,
int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output,
int16_t *cbStart, int32_t cbSize, void *scratch0, void *scratch1,
void *scratch2)
{
PVAAPL_IMPL_FUNC(HarrisCornerS16, Init, handle, input, coeff, roundNBits, lambdaVal, width, height, inputLinePitch,
outputLinePitch, output, cbStart, cbSize, scratch0, scratch1, scratch2);
}
void pvaAplUpdateHarrisCornerS16Vpu(PvaAplHarrisCornerS16 *handle, int16_t *input, int32_t *output);
static inline void pvaAplUpdateHarrisCornerS16(PvaAplHarrisCornerS16 *handle, int16_t *input, int32_t *output)
{
PVAAPL_IMPL_FUNC(HarrisCornerS16, Update, handle, input, output);
}
void pvaAplExecHarrisCornerS16Vpu(PvaAplHarrisCornerS16 *handle);
static inline void pvaAplExecHarrisCornerS16(PvaAplHarrisCornerS16 *handle)
{
PVAAPL_IMPL_FUNC(HarrisCornerS16, Exec, handle);
}
#define PVAAPL_NMS_SCRATCH_SIZE(_width_, _height_) \
(cupva::device::priv::pvaAplRoundUp((_width_) * (_height_), 16U) * sizeof(int32_t))
void pvaAplInitNms3x3S32Vpu(PvaAplNms3x3S32 *handle, int32_t *input, int32_t width, int32_t height,
int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output, int32_t *cbStart,
int32_t cbSize, void *scratch);
static inline void pvaAplInitNms3x3S32(PvaAplNms3x3S32 *handle, int32_t *input, int32_t width, int32_t height,
int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output,
int32_t *cbStart, int32_t cbSize, void *scratch)
{
PVAAPL_IMPL_FUNC(Nms3x3S32, Init, handle, input, width, height, inputLinePitch, outputLinePitch, output, cbStart,
cbSize, scratch);
}
void pvaAplUpdateNms3x3S32Vpu(PvaAplNms3x3S32 *handle, int32_t *input, int32_t *output);
static inline void pvaAplUpdateNms3x3S32(PvaAplNms3x3S32 *handle, int32_t *input, int32_t *output)
{
PVAAPL_IMPL_FUNC(Nms3x3S32, Update, handle, input, output);
}
void pvaAplExecNms3x3S32Vpu(PvaAplNms3x3S32 *handle);
static inline void pvaAplExecNms3x3S32(PvaAplNms3x3S32 *handle)
{
PVAAPL_IMPL_FUNC(Nms3x3S32, Exec, handle);
}
void pvaAplInitNms5x5S32Vpu(PvaAplNms5x5S32 *handle, int32_t *input, int32_t width, int32_t height,
int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output, int32_t *cbStart,
int32_t cbSize, void *scratch);
static inline void pvaAplInitNms5x5S32(PvaAplNms5x5S32 *handle, int32_t *input, int32_t width, int32_t height,
int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output,
int32_t *cbStart, int32_t cbSize, void *scratch)
{
PVAAPL_IMPL_FUNC(Nms5x5S32, Init, handle, input, width, height, inputLinePitch, outputLinePitch, output, cbStart,
cbSize, scratch);
}
void pvaAplUpdateNms5x5S32Vpu(PvaAplNms5x5S32 *handle, int32_t *input, int32_t *output);
static inline void pvaAplUpdateNms5x5S32(PvaAplNms5x5S32 *handle, int32_t *input, int32_t *output)
{
PVAAPL_IMPL_FUNC(Nms5x5S32, Update, handle, input, output);
}
void pvaAplExecNms5x5S32Vpu(PvaAplNms5x5S32 *handle);
static inline void pvaAplExecNms5x5S32(PvaAplNms5x5S32 *handle)
{
PVAAPL_IMPL_FUNC(Nms5x5S32, Exec, handle);
}
static inline void pvaAplWait(void)
{
/* AlgoWait is noop on Orin */
#if CUPVA_PVA_GEN_NUMBER > 2
cupvaPPEWait();
#endif
}
#endif //PVA_APL_H