commit
2731c1ed44
@ -0,0 +1,32 @@
|
||||
#
|
||||
# NOTE! Don't add files that are generated in specific
|
||||
# subdirectories here. Add them in the ".gitignore" file
|
||||
# in that subdirectory instead.
|
||||
#
|
||||
# NOTE! Please use 'git ls-files -i --exclude-standard'
|
||||
# command after changing this file, to see if there are
|
||||
# any tracked files which get ignored after the change.
|
||||
#
|
||||
# Normal rules (sorted alphabetically)
|
||||
#
|
||||
*.gz
|
||||
|
||||
# Build Directory
|
||||
arm-trusted-firmware/build/
|
||||
|
||||
# output Directory
|
||||
build-output/
|
||||
output/
|
||||
|
||||
# modules nc_lib files
|
||||
modules/__lib/*
|
||||
|
||||
# others
|
||||
.vscode/settings.json
|
||||
arm-trusted-firmware/tools/nextchip/genconfig.h
|
||||
u-boot/tools/nextchip/genconfig.h
|
||||
buildroot/board/nextchip/apache6/mali-weston/base_dir/driver/r44p0/mali_kbase.ko
|
||||
buildroot/board/nextchip/apache6/mali-weston/base_dir/driver/r48p0/mali_kbase.ko
|
||||
buildroot/configs/apache6_mpw_defconfig.old
|
||||
linux-kernel/arch/arm64/configs/apache6_mpw_defconfig.old
|
||||
|
||||
@ -0,0 +1,33 @@
|
||||
# tta-ai-streamer
|
||||
|
||||
## 📘 TTA ai Streamer
|
||||
카메라로 부터 4K영상을 수신 받아, NPU입력 사이즈에 맞게 다운샘플링 한 후 추론한 결과를, 메타데이터에 담아,
|
||||
원본 영상과 함께 python 측 후처리 단으로 송신하는 스트리머,
|
||||
요구하는 기능에 따라 적절히 맞는 모델들을 구동시킴.
|
||||
|
||||
---
|
||||
|
||||
## 📌 개요
|
||||
이 모듈은 다음 역할을 담당함.
|
||||
|
||||
- V4L2 카메라 프레임 캡처
|
||||
- TurboJPEG 기반 JPEG 인코딩
|
||||
- NPU(AIWare) Object Detection 수행
|
||||
- Postprocess + bytesort 트래킹
|
||||
- UDS 프레임(FRA) / 디텍션(UDSD) 패킷 생성
|
||||
- Python 측 모듈(tta-uds-streamer)로 스트리밍
|
||||
|
||||
---
|
||||
|
||||
추후 추가 에정
|
||||
|
||||
## 📁 디렉토리 구조
|
||||
|
||||
## 🔧 빌드 방법
|
||||
|
||||
## 🚀 실행
|
||||
|
||||
## 🎮 기능 제어 (Feature Control)
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
#!/bin/bash
|
||||
|
||||
###########
|
||||
# utility function
|
||||
|
||||
function exit_on_error
|
||||
{
|
||||
if [ $? -ne 0 ] ; then
|
||||
echo -e "\n\n\n!!!!!!!!!!!!!!!!!!!!! Fail to build !!!!!!!!!!!!!!!!!!\n\n\n"
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
###########
|
||||
|
||||
OUTPUT_DIR=${PWD}/../output/user_data/applications
|
||||
mkdir -p ${OUTPUT_DIR}
|
||||
|
||||
echo -e "\n================= build npu_app ================="
|
||||
pushd npu_app
|
||||
make
|
||||
cp -prvf app_npu ${OUTPUT_DIR}/
|
||||
popd
|
||||
|
||||
echo -e "\n================= build wayland_egl_app ================="
|
||||
pushd wayland_egl_app
|
||||
make
|
||||
cp -prvf app_wayland_egl ${OUTPUT_DIR}/
|
||||
popd
|
||||
|
||||
echo -e "\n================= build wayland_cam_app ================="
|
||||
pushd wayland_cam_app
|
||||
make
|
||||
cp -prvf app_wayland_cam ${OUTPUT_DIR}/
|
||||
popd
|
||||
|
||||
echo -e "\n================= build cuuva ================="
|
||||
pushd cuuva
|
||||
make
|
||||
cp -prvf cuuva_test_play ${OUTPUT_DIR}/
|
||||
popd
|
||||
|
||||
# echo -e "\n================= build wayland_npu_app ================="
|
||||
# pushd wayland_npu_app
|
||||
# make
|
||||
# cp -prvf app_wayland_npu ${OUTPUT_DIR}/
|
||||
# popd
|
||||
|
||||
echo -e "\n================= build vcodec_app ================="
|
||||
pushd vcodec_app
|
||||
make
|
||||
cp -prvf app_vcodec ${OUTPUT_DIR}/
|
||||
popd
|
||||
|
||||
echo -e "\n================= build dsr_app ================="
|
||||
pushd dsr_app
|
||||
make
|
||||
cp -prvf app_dsr ${OUTPUT_DIR}/
|
||||
popd
|
||||
|
||||
echo -e "\n================= build tflite_det_app ================="
|
||||
pushd tflite_det_app
|
||||
echo "current directory: $(pwd)"
|
||||
mkdir app_build; pushd app_build
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=../../tool.cmake \
|
||||
-DTFLITE_ENABLE_GPU=ON -DTFLITE_ENABLE_XNNPACK=OFF \
|
||||
-DTFLITE_HOST_TOOLS_DIR=../../common/third_party/flatc/bin \
|
||||
-DBUILD_SHARED_LIBS=ON ..
|
||||
cmake --build . -j
|
||||
cp -prvf app_tflite_det ${OUTPUT_DIR}/
|
||||
if test -f tensorflow-lite/libtensorflow-lite.so; then
|
||||
cp -prvf tensorflow-lite/libtensorflow-lite.so ${OUTPUT_DIR}/misc/lib/
|
||||
fi
|
||||
popd; popd
|
||||
|
||||
echo -e "\n================= copy misc files to ${OUTPUT_DIR} ================="
|
||||
|
||||
if [ ! -d "${OUTPUT_DIR}/misc" ]; then
|
||||
cp -prvf ${PWD}/misc ${OUTPUT_DIR}/
|
||||
mv -v ${OUTPUT_DIR}/misc/run*.sh ${OUTPUT_DIR}/
|
||||
mv -v ${OUTPUT_DIR}/misc/nc_module.ini ${OUTPUT_DIR}/
|
||||
mv -v ${OUTPUT_DIR}/misc/nc_module_load.sh ${OUTPUT_DIR}/
|
||||
mv -v ${OUTPUT_DIR}/misc/start*.sh ${OUTPUT_DIR}/../
|
||||
if [ ! -d "${OUTPUT_DIR}/misc/vcodec" ]; then
|
||||
mkdir -p ${OUTPUT_DIR}/misc/vcodec
|
||||
fi
|
||||
fi
|
||||
|
||||
echo -e "\nBuild done :)\n"
|
||||
@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
OUTPUT_DIR=${PWD}/../output/user_data/applications
|
||||
|
||||
echo clean npu_app
|
||||
pushd npu_app
|
||||
make clean
|
||||
popd
|
||||
|
||||
echo clean wayland_egl_app
|
||||
pushd wayland_egl_app
|
||||
make clean
|
||||
popd
|
||||
|
||||
echo clean wayland_cam_app
|
||||
pushd wayland_cam_app
|
||||
make clean
|
||||
popd
|
||||
|
||||
echo clean wayland_npu_app
|
||||
pushd wayland_npu_app
|
||||
make clean
|
||||
popd
|
||||
|
||||
echo clean vcodec_app
|
||||
pushd vcodec_app
|
||||
make clean
|
||||
popd
|
||||
|
||||
echo clean dsr_app
|
||||
pushd dsr_app
|
||||
make clean
|
||||
popd
|
||||
|
||||
echo clean tflite_det_app
|
||||
pushd tflite_det_app
|
||||
rm -rf app_build
|
||||
popd
|
||||
|
||||
rm -rfv ${OUTPUT_DIR}
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef AIWARE_COMMON_LIB_C_EXPORT_H
|
||||
#define AIWARE_COMMON_LIB_C_EXPORT_H
|
||||
|
||||
#ifdef AIWARE_COMMON_LIB_C_STATIC_DEFINE
|
||||
# define AIWARE_COMMON_LIB_C_EXPORT
|
||||
# define AIWARE_COMMON_LIB_C_NO_EXPORT
|
||||
#else
|
||||
# ifndef AIWARE_COMMON_LIB_C_EXPORT
|
||||
# ifdef aiware_common_lib_c_EXPORTS
|
||||
/* We are building this library */
|
||||
# define AIWARE_COMMON_LIB_C_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define AIWARE_COMMON_LIB_C_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef AIWARE_COMMON_LIB_C_NO_EXPORT
|
||||
# define AIWARE_COMMON_LIB_C_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_COMMON_LIB_C_DEPRECATED
|
||||
# define AIWARE_COMMON_LIB_C_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_COMMON_LIB_C_DEPRECATED_EXPORT
|
||||
# define AIWARE_COMMON_LIB_C_DEPRECATED_EXPORT AIWARE_COMMON_LIB_C_EXPORT AIWARE_COMMON_LIB_C_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_COMMON_LIB_C_DEPRECATED_NO_EXPORT
|
||||
# define AIWARE_COMMON_LIB_C_DEPRECATED_NO_EXPORT AIWARE_COMMON_LIB_C_NO_EXPORT AIWARE_COMMON_LIB_C_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef AIWARE_COMMON_LIB_C_NO_DEPRECATED
|
||||
# define AIWARE_COMMON_LIB_C_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* AIWARE_COMMON_LIB_C_EXPORT_H */
|
||||
@ -0,0 +1,242 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_COMMON_C__BINARY_H
|
||||
#define AIWARE_COMMON_C__BINARY_H
|
||||
|
||||
#include "aiware/common/c/aiware-common-lib-c_export.h"
|
||||
#include "aiware/common/c/deviceconfigdata.h"
|
||||
#include "aiware/common/c/status.h"
|
||||
#include "aiware/common/c/tensordimensions.h"
|
||||
#include "aiware/common/c/types.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Maximum length of a tensor name in binary
|
||||
#define AIWARE_TENSOR_NAME_MAX_LEN (uint32_t)64
|
||||
|
||||
/// Maximum length of a tensor dimension in binary
|
||||
#define AIWARE_DIMENSION_VECTOR_MAX_LEN (uint32_t)20
|
||||
|
||||
/// Contains information of a tensor.
|
||||
struct aiwTensorInfoImpl
|
||||
{
|
||||
/// Id of the tensor in the original neural network.
|
||||
uint32_t id;
|
||||
|
||||
/// Name of the tensor. NULL terminated string.
|
||||
aiw_char_t name[AIWARE_TENSOR_NAME_MAX_LEN];
|
||||
|
||||
/// Dimensions of the tensor.
|
||||
aiwTensorDimensions dim;
|
||||
|
||||
/// Original tensor dimension specified in the NNEF graph
|
||||
uint32_t originalDimCount;
|
||||
uint32_t originalDim[AIWARE_DIMENSION_VECTOR_MAX_LEN];
|
||||
|
||||
/// Sign of the tensor. 0 - unsigned, 1 - signed, other values are not used.
|
||||
uint8_t sign;
|
||||
|
||||
/// Exponent of the tensor.
|
||||
int8_t exponent;
|
||||
};
|
||||
|
||||
/// Creates a new binary by loading its content from a file defined by a path.
|
||||
///
|
||||
/// @param[in] path Path of the file which contains a serialized binary. Can't be NULL,
|
||||
/// and must point to an existing file.
|
||||
///
|
||||
/// @return On success the function returns a new binary instance. The caller is
|
||||
/// responsible for destroying the returned object. If the passed path is NULL,
|
||||
/// or the content of the file is invalid, the function returns NULL.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiwBinary* aiwBinaryLoadFromPath(const char* path);
|
||||
|
||||
/// Creates a new binary by loading its content from a file.
|
||||
///
|
||||
/// @param[in] file Pointer to an opened file which contains the serialized binary.
|
||||
/// Can't be NULL, and the file must be opened for read.
|
||||
///
|
||||
/// @return On success the function returns a new binary instance. The caller is
|
||||
/// responsible for destroying the returned object. If the passed file is NULL,
|
||||
/// or its content is invalid, the function returns NULL.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiwBinary* aiwBinaryLoadFromFile(FILE* file);
|
||||
|
||||
/// Creates a new binary by loading its content from a memory buffer.
|
||||
///
|
||||
/// @param[in] buffer Pointer to the buffer which contains the serialized binary.
|
||||
/// Can't be NULL.
|
||||
/// @param[in] bufferSize Size of the buffer in bytes. Can't be 0.
|
||||
///
|
||||
/// @return On success the function returns a new binary instance. The caller is
|
||||
/// responsible for destroying the returned object. If the passed buffer or its
|
||||
/// content is invalid the function returns NULL.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiwBinary* aiwDeserializeBinary(const uint8_t* buffer, uint32_t bufferSize);
|
||||
|
||||
/// Serializes the passed binary into a file.
|
||||
///
|
||||
/// The function has some options that can affect the serialization process:
|
||||
/// - Compression: some internal buffers can be serialized in compressed form, if the
|
||||
/// compressed buffer size is smaller than the original one's.
|
||||
///
|
||||
/// @param[in] binary The binary to save. Can't be NULL and must be a valid
|
||||
/// binary object.
|
||||
/// @param[in] path Path of the destination file. Can't be NULL. If the file
|
||||
/// doesn't exist, it will be created, if it exists, it will be
|
||||
/// overwritten.
|
||||
/// @param[in] compress If 0 the binary will be written in an uncompressed way, if
|
||||
/// 1, internal buffers will be compressed.
|
||||
///
|
||||
/// @return Returns AIW_SUCCESS on success, otherwise AIW_ERROR.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status aiwSaveBinary(const aiwBinary* binary, const char* path, uint8_t compress);
|
||||
|
||||
/// Serializes the passed binary into a file.
|
||||
///
|
||||
/// The function has some options that can affect the serialization process:
|
||||
/// - Compression: some internal buffers can be serialized in compressed form, if the
|
||||
/// compressed buffer size is smaller than the original one's.
|
||||
///
|
||||
/// @param[in] binary The binary to save. Can't be NULL and must be a valid
|
||||
/// binary object.
|
||||
/// @param[in] file An opened file where the serialized data will be saved into.
|
||||
/// Can't be NULL, and the file must be opened for writing.
|
||||
/// @param[in] compress If 0 the binary will be written in an uncompressed way, if
|
||||
/// 1, internal buffers will be compressed.
|
||||
///
|
||||
/// @return Returns AIW_SUCCESS on success, otherwise AIW_ERROR.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status aiwSaveBinary2(const aiwBinary* binary, FILE* file, uint8_t compress);
|
||||
|
||||
/// Returns the size of the buffer which can store the passed buffer after serialization.
|
||||
///
|
||||
/// @param[in] binary The binary to serialize. Must be a valid binary object.
|
||||
///
|
||||
/// @return On success the function returns a positive integer, which is the size of the
|
||||
/// serialization buffer. In case of any error the function returns 0.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT uint32_t aiwGetBinarySize(const aiwBinary* binary);
|
||||
|
||||
/// Serializes a binary into a memory buffer.
|
||||
///
|
||||
/// The required size of the buffer can be determined by calling the #aiwGetBinarySerializedBufferSize
|
||||
/// method. However the previous function returns the maximum size of the serialized binary.
|
||||
/// Compression and omitting weights can reduce the size of the serialized data, in this
|
||||
/// case back of the buffer won't be used. The function returns the exact size of the
|
||||
/// serialized data.
|
||||
///
|
||||
/// The function has some options that can affect the serialization process:
|
||||
/// - Compression: some internal buffers can be serialized in compressed form, if the
|
||||
/// compressed buffer size is smaller than the original one's.
|
||||
///
|
||||
/// @param[in] binary The binary to serialize. Must be a valid binary object.
|
||||
/// @param[out] buffer The destination buffer. Can't be NULL.
|
||||
/// @param[in] bufferSize Size of the previous buffer in bytes.
|
||||
/// @param[in] compress If 0 the binary will be written in an uncompressed way, if
|
||||
/// 1, internal buffers will be compressed.
|
||||
///
|
||||
/// @return If the serialization was successful, the function returns the number of
|
||||
/// bytes that were actually used from the whole buffer. (The number is always
|
||||
/// less than or equal to \p bufferSize.) In case of any error, the
|
||||
/// function returns 0.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT uint32_t
|
||||
aiwSerializeBinary(const aiwBinary* binary, uint8_t* buffer, uint32_t bufferSize, uint8_t compress);
|
||||
|
||||
/// Returns the device config data which the current binary was built for.
|
||||
///
|
||||
/// @return Returns a const ref to the binary's device config data object. If the
|
||||
/// passed object is null or invalid, then returns NULL.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT const aiwDeviceConfigData* aiwBinaryGetDeviceConfigData(const aiwBinary* binary);
|
||||
|
||||
/// Returns the name of a binary.
|
||||
///
|
||||
/// @return Returns a pointer to a NULL-terminated string. If the passed object is NULL
|
||||
/// or invalid, the function returns NULL.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT const aiw_char_t* aiwGetBinaryName(const aiwBinary* binary);
|
||||
|
||||
/// Returns the number of the binary's input tensors.
|
||||
///
|
||||
/// @return Returns the number of input tensors. If the passed object is NULL
|
||||
/// or invalid, the function returns 0.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT uint32_t aiwBinaryGetInputTensorCount(const aiwBinary* binary);
|
||||
|
||||
/// Returns info of the Nth input tensor of the passed binary.
|
||||
///
|
||||
/// @param[in] inputTensorIndex Index of the input tensor, must be less than the value
|
||||
/// returned by #aiwBinaryGetInputTensorCount.
|
||||
///
|
||||
/// @return If the passed binary object and the input tensor index is valid, then the
|
||||
/// function returns a pointer to the tensor info structure. The ownership of
|
||||
/// the returned object remains at the binary, it must not be deleted. If any
|
||||
/// parameter of the function is invalid the function return NULL.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT const aiwTensorInfo* aiwBinaryGetInputTensorInfo(
|
||||
const aiwBinary* binary,
|
||||
uint32_t inputTensorIndex);
|
||||
|
||||
/// Returns the number of the binary's output tensors.
|
||||
///
|
||||
/// @return Returns the number of output tensors. If the passed object is NULL
|
||||
/// or invalid, the function returns 0.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT uint32_t aiwBinaryGetOutputTensorCount(const aiwBinary* binary);
|
||||
|
||||
/// Returns info of the Nth output tensor of the passed binary.
|
||||
///
|
||||
/// @param[in] outputTensorIndex Index of the input tensor, must be less than the
|
||||
/// value returned by #aiwBinaryGetInputTensorCount.
|
||||
///
|
||||
/// @return If the passed binary object and the output tensor index is valid, then the
|
||||
/// function returns a pointer to the tensor info structure. The ownership of
|
||||
/// the returned object remains at the binary, it must not be deleted. If any
|
||||
/// parameter of the function is invalid the function return NULL.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT const aiwTensorInfo* aiwBinaryGetOutputTensorInfo(
|
||||
const aiwBinary* binary,
|
||||
uint32_t outputTensorIndex);
|
||||
|
||||
/// Destroys a binary.
|
||||
///
|
||||
/// The binary must be created by the #aiwBinaryLoadFromPath, #aiwBinaryLoadFromFile or #aiwDeserializeBinary
|
||||
/// function.
|
||||
///
|
||||
/// @param[in] binary The binary to destroy. Can't be NULL.
|
||||
///
|
||||
/// @return The function returns AIW_SUCCESS on success, otherwise AIW_ERROR.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status aiwReleaseBinary(aiwBinary* binary);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_COMMON_C__BINARY_H
|
||||
@ -0,0 +1,239 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIW_COM_C__DEVICE_CONFIG_DATA_H
|
||||
#define AIW_COM_C__DEVICE_CONFIG_DATA_H
|
||||
|
||||
#include "aiware/common/c/aiware-common-lib-c_export.h"
|
||||
#include "aiware/common/c/memoryarea.h"
|
||||
#include "aiware/common/c/status.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Creates a new instance of aiwDeviceConfigData and initializes it with the content of
|
||||
/// the passed file.
|
||||
///
|
||||
/// @param[in] path The path of the fill which will be used to initialize the new
|
||||
/// instance. Can't be NULL. The file must exist and must contain valid
|
||||
/// device config data.
|
||||
///
|
||||
/// @return If the new instance can be allocated and can be initialized with the content
|
||||
/// of the passed file, the function returns the pointer of the new instance.
|
||||
/// The returned object must be destroyed by the caller by using the method
|
||||
/// #aiwReleaseDeviceConfigData function. If any error happens, the function
|
||||
/// returns NULL and error callback is called.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiwDeviceConfigData* aiwLoadDeviceConfigData(const char* path);
|
||||
|
||||
/// Creates a new instance of aiwDeviceConfigData and initializes it with the content of
|
||||
/// the passed file.
|
||||
///
|
||||
/// @param[in] file Non-null, opened, read-capable file whose content will be
|
||||
/// deserialized.
|
||||
///
|
||||
/// @return If the new instance can be allocated and can be initialized with the content
|
||||
/// of the passed file, the function returns the pointer of the new instance.
|
||||
/// The returned object must be destroyed by the caller by using the method
|
||||
/// #aiwReleaseDeviceConfigData function. If any error happens, the function
|
||||
/// returns NULL and error callback is called.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiwDeviceConfigData* aiwLoadDeviceConfigData2(FILE* file);
|
||||
|
||||
/// Creates a new instance of aiwDeviceConfigData and initializes it with the content of the
|
||||
/// passed buffer.
|
||||
///
|
||||
/// The buffer should contain valid serialized device config data, otherwise the function
|
||||
/// fails.
|
||||
///
|
||||
/// @param[in] buffer Pointer to the buffer which contains serialized device config
|
||||
/// data. Can't be NULL.
|
||||
/// @param[in] bufferSize Size of the previous buffer in bytes.
|
||||
///
|
||||
/// @return If the new instance can be allocated and can be initialized with the content
|
||||
/// of the passed buffer, the function returns the pointer of the new instance.
|
||||
/// The returned object must be destroyed by the caller by using the method
|
||||
/// #aiwReleaseDeviceConfigData function. If any error happens, the function
|
||||
/// returns NULL and the error callback will be called.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiwDeviceConfigData* aiwDeserializeDeviceConfigData(
|
||||
const uint8_t* buffer,
|
||||
uint32_t bufferSize);
|
||||
|
||||
/// Saves device config data into file.
|
||||
///
|
||||
/// @param[in] dcd Device config data instance to save, can't be NULL.
|
||||
/// @param[in] path Path of the target file where the device config data will be saved.
|
||||
/// Can't be NULL. If the target file doesn't exist, it will be be
|
||||
/// created. If it's exist, it will be overwritten.
|
||||
///
|
||||
/// @return On success the function return AIW_SUCCESS, otherwise AIW_ERROR and the
|
||||
/// error callback will be called.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status aiwSaveDeviceConfigData(const aiwDeviceConfigData* dcd, const char* path);
|
||||
|
||||
/// Saves device config data into file.
|
||||
///
|
||||
/// @param[in] dcd Device config data instance to save, can't be NULL.
|
||||
/// @param[in] file Opened, write-capable file where the device config data will be
|
||||
/// saved.
|
||||
///
|
||||
/// @return On success the function return AIW_SUCCESS, otherwise AIW_ERROR and the
|
||||
/// error callback will be called.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status aiwSaveDeviceConfigData2(const aiwDeviceConfigData* dcd, FILE* file);
|
||||
|
||||
/// Returns the minimum size of a buffer which can contain the serialization of the passed
|
||||
/// device config data.
|
||||
///
|
||||
/// @param[in] dcd Device config data instance to serialize, can't be NULL
|
||||
///
|
||||
/// @return On success, the required buffer size will be return, otherwise 0 and the
|
||||
/// error callback will be called.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT uint32_t aiwGetDeviceConfigDataSize(const aiwDeviceConfigData* dcd);
|
||||
|
||||
/// Serializes a device config data instance into the passed buffer.
|
||||
///
|
||||
/// The buffer should be at least as large as the number returned by #aiwGetDeviceConfigDataSerializedBufferSize.
|
||||
/// If the buffer is smaller than that number, the function fails. If the buffer is larger,
|
||||
/// then the back of it will be untouched.
|
||||
///
|
||||
/// @param[in] dcd Device config data to be serialized. Can't be NULL.
|
||||
/// @param[out] buffer Target buffer where the serialized data will be placed. The
|
||||
/// length of the buffer is defined by \p bufferSize parameter.
|
||||
/// Can't be NULL.
|
||||
/// @param[in] bufferSize Size of the buffer in bytes. The number must be at least as
|
||||
/// large as the value returned by #aiwGetDeviceConfigDataSerializedBufferSize
|
||||
/// function.
|
||||
///
|
||||
/// @return On success the function returns AIW_SUCCESS. If the input device config or
|
||||
/// the buffer is invalid, or the buffer's size isn't large enough, the function
|
||||
/// fails, returns AIW_ERROR status and error callback will be called.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwSerializeDeviceConfigData(const aiwDeviceConfigData* dcd, uint8_t* buffer, uint32_t bufferSize);
|
||||
|
||||
/// Copies the source device config data into the target.
|
||||
///
|
||||
/// @param[in] srcDcd Source device config data instance, can't be NULL.
|
||||
/// @param[in] dstDcd Destination device config data instance, can't be NULL.
|
||||
///
|
||||
/// @return On success the function returns AIW_SUCCESS. If any parameter is NULL, then
|
||||
/// the function returns AIW_ERROR status.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwCopyDeviceConfigData(const aiwDeviceConfigData* srcDcd, aiwDeviceConfigData* dstDcd);
|
||||
|
||||
/// Creates a new device config instance and copies the content of the parameter into it.
|
||||
///
|
||||
/// @param[in] dcd Source device config data that will be copied.
|
||||
///
|
||||
/// @return On success the function returns the new device config data instance whose
|
||||
/// content is the same as the parameter. The caller is responsible to release
|
||||
/// the returned object. If any error happens the function will return NULL and
|
||||
/// the error callback will be called.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiwDeviceConfigData* aiwCloneDeviceConfigData(const aiwDeviceConfigData* dcd);
|
||||
|
||||
/// Returns the number of LAMs can be found in the passed device config data.
|
||||
///
|
||||
/// @param[in] dcd Device config data, can't be NULL.
|
||||
///
|
||||
/// @return If a valid device config data instance is passed to the function, then it
|
||||
/// returns a positive number. The returned object must be destroyed by the
|
||||
/// caller by using the method #aiwReleaseDeviceConfigData function. In case of
|
||||
/// any error, the function returns 0.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT uint32_t aiwGetNumberOfLAMs(const aiwDeviceConfigData* dcd);
|
||||
|
||||
/// Returns the number of memory areas can be found in the passed device config data.
|
||||
///
|
||||
/// @param[in] dcd Device config data, can't be NULL.
|
||||
///
|
||||
/// @return If a valid device config data instance is passed to the function, then it
|
||||
/// returns a positive number. In case of any error, the function returns 0.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT int32_t aiwGetNumberOfMemoryAreas(const aiwDeviceConfigData* dcd);
|
||||
|
||||
/// Returns the memory area of the passed device config data identified by the passed index.
|
||||
///
|
||||
/// @param[in] dcd Device config data, can't be NULL.
|
||||
/// @param[in] index Zero based index of the requested memory area. The number must be
|
||||
/// less than the value returned by #aiwGetNumberOfMemoryAreas function.
|
||||
///
|
||||
/// @return If the passed device config data and index is valid, then the function
|
||||
/// returns a reference to the requested memory area object. The ownership of
|
||||
/// the returned object remains at the device config data object. If any
|
||||
/// parameter is invalid, then the function returns NULL.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT const aiwMemoryArea* aiwGetMemoryArea(const aiwDeviceConfigData* dcd, uint32_t index);
|
||||
|
||||
/// Destroys a device config data instance.
|
||||
///
|
||||
/// The function must be used when a device config data instance isn't used anymore, and
|
||||
/// the object is created by #aiwLoadDeviceConfigData, #aiwDeserializeDeviceConfigData and
|
||||
/// #aiwCreateAndCopyDeviceConfigData functions.
|
||||
///
|
||||
/// @param[in] dcd Device config data to be destroyed, can't be NULL.
|
||||
///
|
||||
/// @return On success, the function return AIW_SUCCESS, otherwise AIW_ERROR and the
|
||||
/// error callback will be called.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status aiwReleaseDeviceConfigData(aiwDeviceConfigData* dcd);
|
||||
|
||||
/// Compares 2 instances of device config data.
|
||||
///
|
||||
/// The 2 instances are equal if both of them are valid and contains exactly the same
|
||||
/// configuration.
|
||||
///
|
||||
/// @param[in] dcd1 First device config data instance.
|
||||
/// @param[in] dcd2 Second device config data instance.
|
||||
///
|
||||
/// @return If both instances are valid and they are equal, then the function returns 1
|
||||
/// otherwise 0.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT uint32_t
|
||||
aiwDeviceConfigDataCmpStrict(const aiwDeviceConfigData* dcd1, const aiwDeviceConfigData* dcd2);
|
||||
|
||||
/// Compares the main attributes of 2 device config data instances.
|
||||
///
|
||||
/// The 2 instances are equal if both of them are valid and contains the same configuration
|
||||
/// except some memory attributes.
|
||||
///
|
||||
/// @param[in] dcd1 First device config data instance.
|
||||
/// @param[in] dcd2 Second device config data instance.
|
||||
///
|
||||
/// @return If both instances are valid and they are equal, then the function returns 1
|
||||
/// otherwise 0.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT uint32_t
|
||||
aiwDeviceConfigDataCmpRelaxed(const aiwDeviceConfigData* dcd1, const aiwDeviceConfigData* dcd2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIW_COM_C__DEVICE_CONFIG_DATA_H
|
||||
@ -0,0 +1,139 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_COMMON_C__ENV_H
|
||||
#define AIWARE_COMMON_C__ENV_H
|
||||
|
||||
#include "aiware/common/c/aiware-common-lib-c_export.h"
|
||||
#include "aiware/common/c/status.h"
|
||||
#include "aiware/common/c/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Initializes the aiWare software environment.
|
||||
///
|
||||
/// It must be called before any other function is called from the API.
|
||||
///
|
||||
/// The function sets the default allocator and deallocator, which is platform dependent.
|
||||
/// On Linux and Windows it's malloc and free, on other platform some platform specific
|
||||
/// allocation method.
|
||||
///
|
||||
/// The function also sets the default error callback, which is by default fprintf if it's
|
||||
/// available.
|
||||
///
|
||||
/// Finally the function also sets the logger function, which is printf if it's available.
|
||||
///
|
||||
/// @return On success, the function returns 0.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status aiwInitEnvironment(void);
|
||||
|
||||
/// Destroys the aiWare software environment.
|
||||
///
|
||||
/// Must be called last in the application.
|
||||
///
|
||||
/// @return On success the function returns 0.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status aiwDestroyEnvironment(void);
|
||||
|
||||
/// Signature of the memory allocator method.
|
||||
///
|
||||
/// The function take 2 parameters: the amount of memory that should be allocated and a
|
||||
/// pointer to custom data, that the function can use anything that it want for.
|
||||
/// If the allocation request is feasible, the function should return a non-null pointer
|
||||
/// to that memory buffer. If any error happens, the function should return NULL.
|
||||
///
|
||||
typedef void* (*aiwAllocatorFun)(uint64_t size, void* ctx);
|
||||
|
||||
/// Signature of the memory deallocator method.
|
||||
///
|
||||
/// The function is used to dealloc dynamically allocated memory allocated by the allocator
|
||||
/// function. The function's first parameter is pointer to a previously allocated. It's
|
||||
/// guarantied that no other pointer will be passed to this function.
|
||||
///
|
||||
/// The second parameter is a pointer to custom data, that the function can use anything for.
|
||||
///
|
||||
/// If the first parameter is NULL, the function should not do anything.
|
||||
///
|
||||
typedef void (*aiwDeallocatorFun)(void* ptr, void* ctx);
|
||||
|
||||
/// Sets the dynamic memory allocator and deallocator function which will manage all kind of
|
||||
/// dynamic memory allocation.
|
||||
///
|
||||
/// For further information see #aiwAllocatorFun and #aiwDeallocatorFun.
|
||||
///
|
||||
/// @param[in] allocator Pointer to the allocator function. Can't be NULL.
|
||||
/// @param[in] deallocator Pointer to the deallocator function. Can't be NULL.
|
||||
/// @param[in] allocatorData Pointer to custom data which will be passed to the
|
||||
/// allocator and deallocator as second parameter. Can
|
||||
/// be NULL. The ownership of the passed data remains at
|
||||
/// the caller.
|
||||
/// @return On success, the function return 0, otherwise a positive value. If the
|
||||
/// allocator or deallocator parameters is NULL, then no changes will be made,
|
||||
/// and a non-zero error status will be returned.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwSetAllocator(aiwAllocatorFun allocator, aiwDeallocatorFun deallocator, void* ctx);
|
||||
|
||||
/// Return the total amount of dynamically allocated memory in bytes.
|
||||
///
|
||||
/// @return The amount of dynamically allocated memory in bytes.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT uint64_t aiwGetTotalAllocatedMemorySize(void);
|
||||
|
||||
/// Signature of the error callback function.
|
||||
///
|
||||
/// This kind of callback is called when some error happens within the aiWare SDK. Most
|
||||
/// of the functions returns an error code or something similar simply value. The more
|
||||
/// precise reason of the error can be got by this error callback.
|
||||
///
|
||||
/// The function's first parameter is a number specific to the module where the error
|
||||
/// happened.
|
||||
///
|
||||
/// The second parameter is more specific code about what happened.
|
||||
///
|
||||
/// The third parameter is an error message which can be used as the user wants.
|
||||
/// The ownership of the passed string remains at the caller.
|
||||
///
|
||||
/// The fourth parameter is custom data for callback, can be set by the
|
||||
/// #aiwSetErrorCallback function.
|
||||
///
|
||||
typedef void (*aiwErrorCallbackFun)(uint32_t moduleCode, uint32_t errorCode, const char* message, void* ctx);
|
||||
|
||||
/// Sets the error callback function.
|
||||
///
|
||||
/// For further information see #aiwErrorCallbackFun.
|
||||
///
|
||||
/// @param[in] errorCallback Pointer to the new error callback function. If null,
|
||||
/// then the callback won't be called, and callback custom
|
||||
/// data will be ignored.
|
||||
/// @param[in] errorCallbackData Custom data for the error callback. Can be NULL. The
|
||||
/// ownership of the passed object remains at the caller.
|
||||
///
|
||||
AIWARE_COMMON_LIB_C_EXPORT void aiwSetErrorCallback(aiwErrorCallbackFun errorCallback, void* ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_COMMON_C__ENV_H
|
||||
@ -0,0 +1,64 @@
|
||||
#ifndef AIWARE_COMMON_C__MEMORY_AREA_H
|
||||
#define AIWARE_COMMON_C__MEMORY_AREA_H
|
||||
|
||||
#include "aiware/common/c/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Flags which can tell what kind of data type can be stored in a particular.
|
||||
/// memory area.
|
||||
enum aiwMemoryAreaDataType
|
||||
{
|
||||
/// The memory area can contain tensor data.
|
||||
AIW_MADT_DATA = 0x1,
|
||||
|
||||
/// The memory area can contain weights.
|
||||
AIW_MADT_WEIGHTS = 0x2,
|
||||
|
||||
/// The memory area can contain command queues.
|
||||
AIW_MADT_CMDQ = 0x4,
|
||||
|
||||
/// All type combined together.
|
||||
AIW_MADT_ALL = (uint8_t)AIW_MADT_DATA | (uint8_t)AIW_MADT_WEIGHTS | (uint8_t)AIW_MADT_CMDQ
|
||||
};
|
||||
|
||||
/// Contains basic information about a memory area accessible by aiWare.
|
||||
struct aiwMemoryAreaImpl
|
||||
{
|
||||
/// Tells what kinds of data can be stored in this memory area.
|
||||
/// If this member is 0 it means the memory area is unused.
|
||||
uint8_t dataType;
|
||||
|
||||
/// Start address of the memory area in bytes.
|
||||
uint64_t startAddress;
|
||||
|
||||
/// End address of the memory area in bytes.
|
||||
uint64_t endAddress;
|
||||
|
||||
// The following members are currently not set and not used by
|
||||
// the runtime, but due to compatibility and future proofing
|
||||
// reasons left here in this struct. Thy are also excluded from
|
||||
// strict DeviceConfigData comparison.
|
||||
|
||||
/// Tells whether the memory area is external (i.e. DDR) or internal
|
||||
uint8_t external;
|
||||
|
||||
/// Tells whether the memory area is mapped into the hosts memory
|
||||
/// space or it can be accessed just by DMA.
|
||||
uint8_t mapped;
|
||||
|
||||
/// Contains the bandwidth of the memory area.
|
||||
aiw_f32_t bandwidth;
|
||||
|
||||
/// Contains the latency of the memory area.
|
||||
aiw_f32_t latency;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_COMMON_C__MEMORY_AREA_H
|
||||
@ -0,0 +1,91 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIW_COM_C__MODULE_VERSION_H
|
||||
#define AIW_COM_C__MODULE_VERSION_H
|
||||
|
||||
#include "aiware/common/c/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Describes the version of a module.
|
||||
///
|
||||
/// The string members should not be deleted.
|
||||
#ifndef __cplusplus
|
||||
typedef
|
||||
#endif
|
||||
struct
|
||||
#ifdef __cplusplus
|
||||
aiwModuleVersion
|
||||
#endif
|
||||
{
|
||||
/// The full version (major.minor.path [postfix]) represented as string.
|
||||
const aiw_char_t* version;
|
||||
|
||||
/// The major version number.
|
||||
uint32_t major_;
|
||||
/// The minor version number.
|
||||
uint32_t minor_;
|
||||
/// The patch version number.
|
||||
uint32_t patch_;
|
||||
|
||||
/// The major version number as string.
|
||||
const aiw_char_t* majorStr;
|
||||
/// The minor version number as string.
|
||||
const aiw_char_t* minorStr;
|
||||
/// The patch version number as string.
|
||||
const aiw_char_t* patchStr;
|
||||
|
||||
/// Optional version postfix.
|
||||
const aiw_char_t* postfix;
|
||||
|
||||
/// The full git commit id of the library.
|
||||
const aiw_char_t* gitRev;
|
||||
/// The short, 10 char long git commit if of the library.
|
||||
const aiw_char_t* gitRevShort;
|
||||
|
||||
#ifndef __cplusplus
|
||||
} aiwModuleVersion;
|
||||
#else
|
||||
aiwModuleVersion()
|
||||
: version(nullptr)
|
||||
, major_(0)
|
||||
, minor_(0)
|
||||
, patch_(0)
|
||||
, majorStr(nullptr)
|
||||
, minorStr(nullptr)
|
||||
, patchStr(nullptr)
|
||||
, postfix(nullptr)
|
||||
, gitRev(nullptr)
|
||||
, gitRevShort(nullptr)
|
||||
{
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIW_COM_C__MODULE_VERSION_H
|
||||
@ -0,0 +1,24 @@
|
||||
# Define suppressions to prevent reporting of selected violations
|
||||
# detected by Parasoft analysis.
|
||||
# Note: One suppression entry can affect more than one violation.
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# suppression-begin
|
||||
# file: file.ext (required)
|
||||
# line: 12 (optional)
|
||||
# rule-id: BD-PB-VOVR (optional)
|
||||
# message: Avoid unused values (optional)
|
||||
# reason: Approved (optional)
|
||||
# author: devel (optional)
|
||||
# date: 2020-09-21 (optional)
|
||||
# suppression-end
|
||||
|
||||
suppression-begin
|
||||
file: memoryarea.h
|
||||
line: 29
|
||||
rule-id: MISRAC2012-DIR_4_8-a
|
||||
message: Consider hiding the implementation of the structure 'aiwMemoryAreaImpl' in a translation unit 'binary.c'
|
||||
reason: The implementation of the structure 'aiwMemoryAreaImpl' cannot be hidden because its size is required for the implementation of one of the dereferenced struct.
|
||||
author: brendon.gadacsi
|
||||
suppression-end
|
||||
@ -0,0 +1,33 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIW_COM_C__AIWARE_STATUS_H
|
||||
#define AIW_COM_C__AIWARE_STATUS_H
|
||||
|
||||
#include "aiware/common/c/types.h"
|
||||
|
||||
typedef int32_t aiw_status;
|
||||
|
||||
#define AIW_SUCCESS (aiw_status)0u
|
||||
#define AIW_ERROR (aiw_status)1u
|
||||
#define AIW_TIMEOUT (aiw_status)2u
|
||||
|
||||
#endif //AIW_COM_C__AIWARE_STATUS_H
|
||||
@ -0,0 +1,100 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIW_COM_C__TENSOR_DIMENSIONS_H
|
||||
#define AIW_COM_C__TENSOR_DIMENSIONS_H
|
||||
|
||||
#include "aiware/common/c/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef
|
||||
#endif
|
||||
struct
|
||||
#ifdef __cplusplus
|
||||
aiwTensorDimensions
|
||||
#endif
|
||||
{
|
||||
uint32_t w;
|
||||
uint32_t h;
|
||||
uint32_t ch;
|
||||
uint32_t b;
|
||||
|
||||
#ifndef __cplusplus
|
||||
} aiwTensorDimensions;
|
||||
#else
|
||||
constexpr aiwTensorDimensions(uint32_t width = 1, uint32_t height = 1, uint32_t channels = 1, uint32_t batches = 1)
|
||||
: w(width)
|
||||
, h(height)
|
||||
, ch(channels)
|
||||
, b(batches)
|
||||
{
|
||||
}
|
||||
|
||||
bool operator==(const aiwTensorDimensions& other) const
|
||||
{
|
||||
return w == other.w && h == other.h && ch == other.ch && b == other.b;
|
||||
}
|
||||
|
||||
bool operator!=(const aiwTensorDimensions& other) const { return !(*this == other); }
|
||||
|
||||
uint32_t mulDimensions() const { return w * h * ch * b; }
|
||||
|
||||
uint32_t getAxis(uint32_t axis) const
|
||||
{
|
||||
const uint32_t* ptr = getAxisInternal(axis);
|
||||
return nullptr != ptr ? *ptr : 0u;
|
||||
}
|
||||
|
||||
void setAxis(uint32_t axis, uint32_t value)
|
||||
{
|
||||
uint32_t* ax = const_cast<uint32_t*>(getAxisInternal(axis));
|
||||
if (ax)
|
||||
*ax = value;
|
||||
}
|
||||
|
||||
private:
|
||||
const uint32_t* getAxisInternal(uint32_t axis) const
|
||||
{
|
||||
switch (axis)
|
||||
{
|
||||
case 1:
|
||||
return &ch;
|
||||
case 2:
|
||||
return &h;
|
||||
case 3:
|
||||
return &w;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIW_COM_C__TENSOR_DIMENSIONS_H
|
||||
@ -0,0 +1,77 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_COMMON_C__TYPES_H
|
||||
#define AIWARE_COMMON_C__TYPES_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
/// 8-bit unsigned integer number type - deprecated and will be removed: use uint8_t instead
|
||||
typedef uint8_t aiw_u8_t;
|
||||
|
||||
/// 16-bit unsigned integer number type - deprecated and will be removed: use uint16_t instead
|
||||
typedef uint16_t aiw_u16_t;
|
||||
|
||||
/// 32-bit unsigned integer number type - deprecated and will be removed: use uint32_t instead
|
||||
typedef uint32_t aiw_u32_t;
|
||||
|
||||
/// 64-bit unsigned integer number type - deprecated and will be removed: use uint64_t instead
|
||||
typedef uint64_t aiw_u64_t;
|
||||
|
||||
/// 8-bit signed integer number type - deprecated and will be removed: use int8_t instead
|
||||
typedef int8_t aiw_i8_t;
|
||||
|
||||
/// 16-bit signed integer number type - deprecated and will be removed: use int16_t instead
|
||||
typedef int16_t aiw_i16_t;
|
||||
|
||||
/// 32-bit signed integer number type - deprecated and will be removed: use int32_t instead
|
||||
typedef int32_t aiw_i32_t;
|
||||
|
||||
/// 64-bit signed integer number type - deprecated and will be removed: use int64_t instead
|
||||
typedef int64_t aiw_i64_t;
|
||||
|
||||
/// Character type
|
||||
typedef char aiw_char_t;
|
||||
|
||||
/// 32-bit floating point number
|
||||
typedef float aiw_f32_t;
|
||||
|
||||
/// Represents a binary instance.
|
||||
typedef struct aiwBinaryImpl aiwBinary;
|
||||
|
||||
/// Contains information of a tensor.
|
||||
typedef struct aiwTensorInfoImpl aiwTensorInfo;
|
||||
|
||||
/// Contains all information of an aiWare device.
|
||||
typedef struct aiwDeviceConfigDataImpl aiwDeviceConfigData;
|
||||
|
||||
/// Contains basic information about a memory area accessible by aiWare.
|
||||
typedef struct aiwMemoryAreaImpl aiwMemoryArea;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_COMMON_C__TYPES_H
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_COMMON_C__VERSION_H
|
||||
#define AIWARE_COMMON_C__VERSION_H
|
||||
|
||||
#include "aiware/common/c/aiware-common-lib-c_export.h"
|
||||
#include "aiware/common/c/moduleversion.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Returns the version info of the library.
|
||||
AIWARE_COMMON_LIB_C_EXPORT aiwModuleVersion aiwCommonVersion(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_COMMON_C__VERSION_H
|
||||
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef AIWARE_COMMON_LIB_CPP_EXPORT_H
|
||||
#define AIWARE_COMMON_LIB_CPP_EXPORT_H
|
||||
|
||||
#ifdef AIWARE_COMMON_LIB_CPP_STATIC_DEFINE
|
||||
# define AIWARE_COMMON_LIB_CPP_EXPORT
|
||||
# define AIWARE_COMMON_LIB_CPP_NO_EXPORT
|
||||
#else
|
||||
# ifndef AIWARE_COMMON_LIB_CPP_EXPORT
|
||||
# ifdef aiware_common_lib_cpp_EXPORTS
|
||||
/* We are building this library */
|
||||
# define AIWARE_COMMON_LIB_CPP_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define AIWARE_COMMON_LIB_CPP_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef AIWARE_COMMON_LIB_CPP_NO_EXPORT
|
||||
# define AIWARE_COMMON_LIB_CPP_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_COMMON_LIB_CPP_DEPRECATED
|
||||
# define AIWARE_COMMON_LIB_CPP_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_COMMON_LIB_CPP_DEPRECATED_EXPORT
|
||||
# define AIWARE_COMMON_LIB_CPP_DEPRECATED_EXPORT AIWARE_COMMON_LIB_CPP_EXPORT AIWARE_COMMON_LIB_CPP_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_COMMON_LIB_CPP_DEPRECATED_NO_EXPORT
|
||||
# define AIWARE_COMMON_LIB_CPP_DEPRECATED_NO_EXPORT AIWARE_COMMON_LIB_CPP_NO_EXPORT AIWARE_COMMON_LIB_CPP_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef AIWARE_COMMON_LIB_CPP_NO_DEPRECATED
|
||||
# define AIWARE_COMMON_LIB_CPP_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* AIWARE_COMMON_LIB_CPP_EXPORT_H */
|
||||
@ -0,0 +1,138 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_COMMON_CPP__BINARY_HPP
|
||||
#define AIWARE_COMMON_CPP__BINARY_HPP
|
||||
|
||||
#include "aiware/common/c/tensordimensions.h"
|
||||
#include "aiware/common/cpp/aiware-common-lib-cpp_export.h"
|
||||
#include "aiware/common/cpp/deviceconfigdata.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <stdio.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
|
||||
class AIWARE_COMMON_LIB_CPP_EXPORT TensorInfo
|
||||
{
|
||||
public:
|
||||
TensorInfo() = default;
|
||||
|
||||
TensorInfo(const TensorInfo&) = default;
|
||||
|
||||
TensorInfo(TensorInfo&&) = default;
|
||||
|
||||
TensorInfo& operator=(const TensorInfo&) = default;
|
||||
|
||||
TensorInfo& operator=(TensorInfo&&) = default;
|
||||
|
||||
bool isValid() const;
|
||||
|
||||
uint32_t id() const;
|
||||
|
||||
std::string name() const;
|
||||
|
||||
const aiwTensorDimensions& dim() const;
|
||||
|
||||
std::vector<uint32_t> originalDim() const;
|
||||
|
||||
bool sign() const;
|
||||
|
||||
int8_t exponent() const;
|
||||
|
||||
bool operator==(const TensorInfo& other) const;
|
||||
bool operator!=(const TensorInfo& other) const;
|
||||
|
||||
protected:
|
||||
TensorInfo(void* ti);
|
||||
|
||||
private:
|
||||
friend class Binary;
|
||||
friend class SubBinary;
|
||||
|
||||
protected:
|
||||
void* _ti = nullptr;
|
||||
};
|
||||
|
||||
class AIWARE_COMMON_LIB_CPP_EXPORT Binary
|
||||
{
|
||||
public:
|
||||
using Ptr = std::unique_ptr<Binary>;
|
||||
|
||||
public:
|
||||
static Binary::Ptr load(const char* path);
|
||||
|
||||
static Binary::Ptr load(FILE* file);
|
||||
|
||||
static Binary::Ptr load(const uint8_t* buffer, uint32_t bufferSize);
|
||||
|
||||
public:
|
||||
Binary(const Binary&) = delete;
|
||||
Binary(Binary&&) = delete;
|
||||
Binary& operator=(const Binary&) = delete;
|
||||
Binary& operator=(Binary&&) = delete;
|
||||
|
||||
virtual ~Binary();
|
||||
|
||||
Ptr clone() const;
|
||||
|
||||
const DeviceConfigData& deviceConfigData() const;
|
||||
|
||||
const char* name() const;
|
||||
|
||||
uint32_t inputTensorCount() const;
|
||||
|
||||
TensorInfo inputTensor(uint32_t index) const;
|
||||
|
||||
uint32_t outputTensorCount() const;
|
||||
|
||||
TensorInfo outputTensor(uint32_t index) const;
|
||||
|
||||
uint32_t nnuVariantCount() const;
|
||||
|
||||
uint32_t nnuVariant(uint32_t index) const;
|
||||
|
||||
bool isNNUNumberSupported(uint32_t nnuNumber) const;
|
||||
|
||||
bool save(const char* path, bool compress = true) const;
|
||||
|
||||
bool save(FILE* file, bool compress = true) const;
|
||||
|
||||
std::vector<uint8_t> save(bool compress = true) const;
|
||||
|
||||
protected:
|
||||
Binary(void* data, bool owned);
|
||||
|
||||
protected:
|
||||
void* _data = nullptr;
|
||||
bool _owned = false;
|
||||
DeviceConfigData::Ptr _config;
|
||||
};
|
||||
|
||||
} // namespace common
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_COMMON_CPP__BINARY_HPP
|
||||
@ -0,0 +1,16 @@
|
||||
#ifndef AIWARE_COMMON_CPP__CHANGELOG_HPP
|
||||
#define AIWARE_COMMON_CPP__CHANGELOG_HPP
|
||||
|
||||
#include "aiware/common/cpp/aiware-common-lib-cpp_export.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
AIWARE_COMMON_LIB_CPP_EXPORT std::string changelog();
|
||||
}
|
||||
} // namespace aiware
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,179 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_COMMON_CPP__DEVICE_CONFIG_DATA_HPP
|
||||
#define AIWARE_COMMON_CPP__DEVICE_CONFIG_DATA_HPP
|
||||
|
||||
#include "aiware/common/c/deviceconfigdata.h"
|
||||
#include "aiware/common/cpp/aiware-common-lib-cpp_export.h"
|
||||
|
||||
#include <memory>
|
||||
#include <stdio.h>
|
||||
#include <vector>
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
|
||||
/// Contains all information of an aiWare device.
|
||||
///
|
||||
/// This class can be queried from a device, can be saved and later can be loaded. In the
|
||||
/// last case if any error happened, and invalid instance is returned. The functions return
|
||||
/// dummy or error values if they are called on an invalid instance.
|
||||
///
|
||||
class AIWARE_COMMON_LIB_CPP_EXPORT DeviceConfigData
|
||||
{
|
||||
public:
|
||||
using Ptr = std::unique_ptr<DeviceConfigData>;
|
||||
|
||||
/// Creates a new instance of device config data by loading a serialized device config
|
||||
/// data stored in a file.
|
||||
///
|
||||
/// @param[in] path Path of the file to load. Can't be null and must point to an
|
||||
/// existing file with a serialized device config data content.
|
||||
///
|
||||
/// @return If the file exists and valid, it will be parsed, and a new device
|
||||
/// config data instance will be returned. Otherwise and invalid object
|
||||
/// will be returned.
|
||||
///
|
||||
static DeviceConfigData::Ptr load(const char* path);
|
||||
|
||||
/// Creates a new instance of device config data by loading a serialized device config
|
||||
/// data stored in a file.
|
||||
///
|
||||
/// @param[in] file Opened file whose content will be used to create the new device
|
||||
/// config instance. Can't be NULL, and must be read-capable.
|
||||
///
|
||||
/// @return If the file exists and valid, it will be parsed, and a new device
|
||||
/// config data instance will be returned. Otherwise and invalid object
|
||||
/// will be returned.
|
||||
///
|
||||
static DeviceConfigData::Ptr load(FILE* file);
|
||||
|
||||
/// Creates a new instance of device config data by deserializing data of the passed
|
||||
/// buffer.
|
||||
///
|
||||
/// @param[in] buffer Pointer to serialized data buffer. Can't be null.
|
||||
/// @param[in] bufferSize Size of the data buffer. Can't be 0.
|
||||
///
|
||||
/// @return If the buffer contains valid data it will be parsed and a new instance
|
||||
/// will be returned. Otherwise and invalid object will be returned.
|
||||
///
|
||||
static DeviceConfigData::Ptr load(const uint8_t* buffer, uint32_t bufferSize);
|
||||
|
||||
public:
|
||||
DeviceConfigData(const DeviceConfigData& other) = delete;
|
||||
DeviceConfigData(DeviceConfigData&& other) = delete;
|
||||
DeviceConfigData& operator=(DeviceConfigData&& other) noexcept = delete;
|
||||
|
||||
DeviceConfigData& operator=(const DeviceConfigData& other);
|
||||
|
||||
/// Destroys the instance.
|
||||
virtual ~DeviceConfigData();
|
||||
|
||||
/// Creates a new instance by cloning the current one.
|
||||
Ptr clone() const;
|
||||
|
||||
/// Same as #strictCompare.
|
||||
bool operator==(const DeviceConfigData& other) const;
|
||||
|
||||
/// Compares the current instance to another one in the strict way and returns true
|
||||
/// if they are different.
|
||||
bool operator!=(const DeviceConfigData& other) const;
|
||||
|
||||
/// Compares the current instance to another one in the strict way and returns true
|
||||
/// if they are equal.
|
||||
bool strictCompare(const DeviceConfigData& other) const;
|
||||
|
||||
/// Compares the current instance to another one in the loose way and returns true if
|
||||
/// they are equal.
|
||||
bool relaxedCompare(const DeviceConfigData& other) const;
|
||||
|
||||
/// Returns the number of LAMs can be found in the current configuration.
|
||||
/// If the object is invalid it returns 0.
|
||||
uint32_t lamCount() const;
|
||||
|
||||
/// Returns the number of memory areas can be found in the current configuration.
|
||||
/// If the object is invalid it returns 0.
|
||||
uint32_t memoryAreaCount() const;
|
||||
|
||||
/// Returns the Nth memory area descriptor object can be found in the current
|
||||
/// configuration.
|
||||
///
|
||||
/// @param[in] index Index of the requested memory area. Must be larger than the
|
||||
/// value returned by #memoryAreaCount().
|
||||
///
|
||||
/// @return If the object and the passed index is valid, then returns a weak
|
||||
/// pointer to the proper memory area object.
|
||||
///
|
||||
const aiwMemoryArea* memoryArea(uint32_t index) const;
|
||||
|
||||
/// Serializes the current instance into a file.
|
||||
///
|
||||
/// The object can be saved only if it's valid.
|
||||
///
|
||||
/// @param[in] path Path of the destination file. Can't be null.
|
||||
///
|
||||
/// @return Returns the status of the serialization.
|
||||
///
|
||||
bool save(const char* path) const;
|
||||
|
||||
/// Serializes the current instance into a file.
|
||||
///
|
||||
/// The object can be saved only if it's valid.
|
||||
///
|
||||
/// @param[in] file Pointer to the opened file, where the config will be saved.
|
||||
/// Can't be saved.
|
||||
///
|
||||
/// @return Returns the status of the serialization.
|
||||
///
|
||||
bool save(FILE* file) const;
|
||||
|
||||
/// Serializes the current instance into a buffer.
|
||||
///
|
||||
/// The object can be saved only if it's valid.
|
||||
///
|
||||
/// @return Returns a non-empty vector if the serialization was successful,
|
||||
/// otherwise it's returns an empty one.
|
||||
///
|
||||
std::vector<uint8_t> save() const;
|
||||
|
||||
protected:
|
||||
/// Constructs an object by using the passed raw data.
|
||||
///
|
||||
/// @param[in] data Pointer to the raw data. If null, the object will be invalid.
|
||||
/// @param[in] owned Tells whether the new instance takes the ownership of the passed
|
||||
/// object or doesn't.
|
||||
DeviceConfigData(void* data, bool owned);
|
||||
|
||||
protected:
|
||||
/// Pointer to the raw data. If null, the instance is invalid.
|
||||
void* _data = nullptr;
|
||||
|
||||
/// Tells whether the instance owns the raw data or doesn't.
|
||||
bool _owned = false;
|
||||
};
|
||||
|
||||
} // namespace common
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_COMMON_CPP__DEVICE_CONFIG_DATA_HPP
|
||||
@ -0,0 +1,37 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_COMMON_CPP__VERSION_STRUCT_HPP
|
||||
#define AIWARE_COMMON_CPP__VERSION_STRUCT_HPP
|
||||
|
||||
#include "aiware/common/c/moduleversion.h"
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
|
||||
typedef aiwModuleVersion ModuleVersion;
|
||||
|
||||
}
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_COMMON_CPP__VERSION_STRUCT_HPP
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_COMMON_CPP__VERSION_HPP
|
||||
#define AIWARE_COMMON_CPP__VERSION_HPP
|
||||
|
||||
#include "aiware/common/cpp/aiware-common-lib-cpp_export.h"
|
||||
#include "aiware/common/cpp/moduleversion.hpp"
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
|
||||
/// Returns the version info of the library.
|
||||
AIWARE_COMMON_LIB_CPP_EXPORT ModuleVersion version();
|
||||
|
||||
} // namespace common
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_COMMON_CPP__VERSION_HPP
|
||||
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef AIWARE_EMULATOR_LIB_EXPORT_H
|
||||
#define AIWARE_EMULATOR_LIB_EXPORT_H
|
||||
|
||||
#ifdef AIWARE_EMULATOR_LIB_STATIC_DEFINE
|
||||
# define AIWARE_EMULATOR_LIB_EXPORT
|
||||
# define AIWARE_EMULATOR_LIB_NO_EXPORT
|
||||
#else
|
||||
# ifndef AIWARE_EMULATOR_LIB_EXPORT
|
||||
# ifdef aiware_emulator_lib_EXPORTS
|
||||
/* We are building this library */
|
||||
# define AIWARE_EMULATOR_LIB_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define AIWARE_EMULATOR_LIB_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef AIWARE_EMULATOR_LIB_NO_EXPORT
|
||||
# define AIWARE_EMULATOR_LIB_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_EMULATOR_LIB_DEPRECATED
|
||||
# define AIWARE_EMULATOR_LIB_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_EMULATOR_LIB_DEPRECATED_EXPORT
|
||||
# define AIWARE_EMULATOR_LIB_DEPRECATED_EXPORT AIWARE_EMULATOR_LIB_EXPORT AIWARE_EMULATOR_LIB_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_EMULATOR_LIB_DEPRECATED_NO_EXPORT
|
||||
# define AIWARE_EMULATOR_LIB_DEPRECATED_NO_EXPORT AIWARE_EMULATOR_LIB_NO_EXPORT AIWARE_EMULATOR_LIB_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef AIWARE_EMULATOR_LIB_NO_DEPRECATED
|
||||
# define AIWARE_EMULATOR_LIB_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* AIWARE_EMULATOR_LIB_EXPORT_H */
|
||||
@ -0,0 +1,54 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_EMULATOR__EMULATOR_DEVICE_H
|
||||
#define AIWARE_EMULATOR__EMULATOR_DEVICE_H
|
||||
|
||||
#include "aiware/emulator/aiware-emulator-lib_export.h"
|
||||
#include "aiware/runtime/c/device.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Creates a new emulator instance by using the given configuration.
|
||||
///
|
||||
/// If a valid configuration is passed to this function, and there is enough memory in the
|
||||
/// system, then this function instantiates and initializes a new aiWare Emulator object,
|
||||
/// and returns its pointer. The caller have to destroy the new emulator instance by
|
||||
/// calling #aiwDeviceClose function when it's no longer needed.
|
||||
///
|
||||
/// If there is enough resource in the system, multiple emulator instances can be created.
|
||||
///
|
||||
/// @param[in] config Defines the configuration of the emulator. Can't be NULL, and
|
||||
/// must be a valid device configuration object.
|
||||
///
|
||||
/// @return On success the function returns a non-null pointer to the new emulator
|
||||
/// instance. In case of any error, the function returns NULL.
|
||||
///
|
||||
AIWARE_EMULATOR_LIB_EXPORT aiwDevice* aiwCreateEmulator(const aiwDeviceConfigData* config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_EMULATOR__EMULATOR_DEVICE_H
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_EMULATOR_C__VERSION_H
|
||||
#define AIWARE_EMULATOR_C__VERSION_H
|
||||
|
||||
#include "aiware/common/c/moduleversion.h"
|
||||
#include "aiware/emulator/aiware-emulator-lib_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Returns the version info of the library.
|
||||
AIWARE_EMULATOR_LIB_EXPORT aiwModuleVersion aiwEmulatorVersion(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_EMULATOR_C__VERSION_H
|
||||
@ -0,0 +1,18 @@
|
||||
#ifndef AIWARE_EMULATOR_CPP__CHANGELOG_HPP
|
||||
#define AIWARE_EMULATOR_CPP__CHANGELOG_HPP
|
||||
|
||||
#include "aiware/emulator/aiware-emulator-lib_export.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace emulator
|
||||
{
|
||||
|
||||
AIWARE_EMULATOR_LIB_EXPORT std::string changelog();
|
||||
|
||||
}
|
||||
} // namespace aiware
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,38 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_EMULATOR__EMULATOR_DEVICE_HPP
|
||||
#define AIWARE_EMULATOR__EMULATOR_DEVICE_HPP
|
||||
|
||||
#include "aiware/emulator/aiware-emulator-lib_export.h"
|
||||
#include "aiware/runtime/cpp/device.hpp"
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace emulator
|
||||
{
|
||||
|
||||
AIWARE_EMULATOR_LIB_EXPORT runtime::Device::Ptr createEmulator(const common::DeviceConfigData& config);
|
||||
|
||||
}
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_EMULATOR__EMULATOR_DEVICE_HPP
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_EMULATOR_CPP__VERSION_HPP
|
||||
#define AIWARE_EMULATOR_CPP__VERSION_HPP
|
||||
|
||||
#include "aiware/common/cpp/moduleversion.hpp"
|
||||
#include "aiware/emulator/aiware-emulator-lib_export.h"
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace emulator
|
||||
{
|
||||
|
||||
/// Returns the version info of the library.
|
||||
AIWARE_EMULATOR_LIB_EXPORT aiware::common::ModuleVersion version();
|
||||
|
||||
} // namespace emulator
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_EMULATOR_CPP__VERSION_HPP
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_LIB_C_EXPORT_H
|
||||
#define AIWARE_RUNTIME_COMMON_LIB_C_EXPORT_H
|
||||
|
||||
#ifdef AIWARE_RUNTIME_COMMON_LIB_C_STATIC_DEFINE
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_C_EXPORT
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_C_NO_EXPORT
|
||||
#else
|
||||
# ifndef AIWARE_RUNTIME_COMMON_LIB_C_EXPORT
|
||||
# ifdef aiware_runtime_common_lib_c_EXPORTS
|
||||
/* We are building this library */
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_C_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_C_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef AIWARE_RUNTIME_COMMON_LIB_C_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_C_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_LIB_C_DEPRECATED
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_C_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_LIB_C_DEPRECATED_EXPORT
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_C_DEPRECATED_EXPORT AIWARE_RUNTIME_COMMON_LIB_C_EXPORT AIWARE_RUNTIME_COMMON_LIB_C_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_LIB_C_DEPRECATED_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_C_DEPRECATED_NO_EXPORT AIWARE_RUNTIME_COMMON_LIB_C_NO_EXPORT AIWARE_RUNTIME_COMMON_LIB_C_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef AIWARE_RUNTIME_COMMON_LIB_C_NO_DEPRECATED
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_C_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* AIWARE_RUNTIME_COMMON_LIB_C_EXPORT_H */
|
||||
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT_H
|
||||
#define AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT_H
|
||||
|
||||
#ifdef AIWARE_RUNTIME_DEVICE_LIB_C_STATIC_DEFINE
|
||||
# define AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT
|
||||
# define AIWARE_RUNTIME_DEVICE_LIB_C_NO_EXPORT
|
||||
#else
|
||||
# ifndef AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT
|
||||
# ifdef aiware_runtime_device_lib_c_EXPORTS
|
||||
/* We are building this library */
|
||||
# define AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef AIWARE_RUNTIME_DEVICE_LIB_C_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_DEVICE_LIB_C_NO_EXPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_DEVICE_LIB_C_DEPRECATED
|
||||
# define AIWARE_RUNTIME_DEVICE_LIB_C_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_DEVICE_LIB_C_DEPRECATED_EXPORT
|
||||
# define AIWARE_RUNTIME_DEVICE_LIB_C_DEPRECATED_EXPORT AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT AIWARE_RUNTIME_DEVICE_LIB_C_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_DEVICE_LIB_C_DEPRECATED_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_DEVICE_LIB_C_DEPRECATED_NO_EXPORT AIWARE_RUNTIME_DEVICE_LIB_C_NO_EXPORT AIWARE_RUNTIME_DEVICE_LIB_C_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef AIWARE_RUNTIME_DEVICE_LIB_C_NO_DEPRECATED
|
||||
# define AIWARE_RUNTIME_DEVICE_LIB_C_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT_H */
|
||||
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef AIWARE_RUNTIME_SELFTESTDATA_EXPORT_H
|
||||
#define AIWARE_RUNTIME_SELFTESTDATA_EXPORT_H
|
||||
|
||||
#ifdef AIWARE_RUNTIME_SELFTESTDATA_STATIC_DEFINE
|
||||
# define AIWARE_RUNTIME_SELFTESTDATA_EXPORT
|
||||
# define AIWARE_RUNTIME_SELFTESTDATA_NO_EXPORT
|
||||
#else
|
||||
# ifndef AIWARE_RUNTIME_SELFTESTDATA_EXPORT
|
||||
# ifdef aiware_runtime_selftestdata_EXPORTS
|
||||
/* We are building this library */
|
||||
# define AIWARE_RUNTIME_SELFTESTDATA_EXPORT
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define AIWARE_RUNTIME_SELFTESTDATA_EXPORT
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef AIWARE_RUNTIME_SELFTESTDATA_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_SELFTESTDATA_NO_EXPORT
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_SELFTESTDATA_DEPRECATED
|
||||
# define AIWARE_RUNTIME_SELFTESTDATA_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_SELFTESTDATA_DEPRECATED_EXPORT
|
||||
# define AIWARE_RUNTIME_SELFTESTDATA_DEPRECATED_EXPORT AIWARE_RUNTIME_SELFTESTDATA_EXPORT AIWARE_RUNTIME_SELFTESTDATA_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_SELFTESTDATA_DEPRECATED_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_SELFTESTDATA_DEPRECATED_NO_EXPORT AIWARE_RUNTIME_SELFTESTDATA_NO_EXPORT AIWARE_RUNTIME_SELFTESTDATA_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef AIWARE_RUNTIME_SELFTESTDATA_NO_DEPRECATED
|
||||
# define AIWARE_RUNTIME_SELFTESTDATA_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* AIWARE_RUNTIME_SELFTESTDATA_EXPORT_H */
|
||||
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef AIWARE_RUNTIME_UTILS_LIB_C_EXPORT_H
|
||||
#define AIWARE_RUNTIME_UTILS_LIB_C_EXPORT_H
|
||||
|
||||
#ifdef AIWARE_RUNTIME_UTILS_LIB_C_STATIC_DEFINE
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_C_EXPORT
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_C_NO_EXPORT
|
||||
#else
|
||||
# ifndef AIWARE_RUNTIME_UTILS_LIB_C_EXPORT
|
||||
# ifdef aiware_runtime_utils_lib_c_EXPORTS
|
||||
/* We are building this library */
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_C_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_C_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef AIWARE_RUNTIME_UTILS_LIB_C_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_C_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_UTILS_LIB_C_DEPRECATED
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_C_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_UTILS_LIB_C_DEPRECATED_EXPORT
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_C_DEPRECATED_EXPORT AIWARE_RUNTIME_UTILS_LIB_C_EXPORT AIWARE_RUNTIME_UTILS_LIB_C_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_UTILS_LIB_C_DEPRECATED_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_C_DEPRECATED_NO_EXPORT AIWARE_RUNTIME_UTILS_LIB_C_NO_EXPORT AIWARE_RUNTIME_UTILS_LIB_C_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef AIWARE_RUNTIME_UTILS_LIB_C_NO_DEPRECATED
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_C_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* AIWARE_RUNTIME_UTILS_LIB_C_EXPORT_H */
|
||||
@ -0,0 +1,59 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME__AIWARE_DEVICE_H
|
||||
#define AIWARE_RUNTIME__AIWARE_DEVICE_H
|
||||
|
||||
#include "aiware/common/c/status.h"
|
||||
#include "aiware/common/c/types.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-device-lib-c_export.h"
|
||||
#include "aiware/runtime/c/runtimedevice.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Returns the number of aiWare devices can be found in the system.
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT uint32_t aiwRuntimeDeviceCount(void);
|
||||
|
||||
/// Returns the aiwWare device identified by the passedIndex.
|
||||
///
|
||||
/// Opens and initializes an aiWare device. If a device identified by a specific index
|
||||
/// is already opened, then it can't be opened again. The caller must close the device
|
||||
/// by calling the #aiwDeviceClose function when it's no longer needed.
|
||||
///
|
||||
/// @param[in] deviceIndex Index of the device to open. The value must be less
|
||||
/// the value returned by #aiwDeviceCount.
|
||||
///
|
||||
/// @return If the index is valid and the device could be opened successfully, then
|
||||
/// the function returns a non-null pointer to the device. In case of any
|
||||
/// error the function return NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceOpen(struct aiwRuntimeDevice* device, uint32_t deviceIndex);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AIWARE_RUNTIME__AIWARE_DEVICE_H
|
||||
@ -0,0 +1,92 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME__CONFIGS_H
|
||||
#define AIWARE_RUNTIME__CONFIGS_H
|
||||
|
||||
#include "aiware/common/c/deviceconfigdata.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-common-lib-c_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Creates the default Apache5 MP config.
|
||||
///
|
||||
/// Convenience method, calls #aiwCreateApache5Config with 800 MHz. For further info see
|
||||
/// the previously mentioned function.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwDeviceConfigData* aiwCreateApache5ConfigDefault(void);
|
||||
|
||||
/// Creates Apache5 MP2 config and sets its frequency to the given value.
|
||||
///
|
||||
/// @param[in] frequencyMHz Frequency of the configuration given in MHz. Must be
|
||||
/// greater than 0.
|
||||
///
|
||||
/// @return On success a new device config data instance is created by using the given
|
||||
/// parameters. The returned instance must be deleted by the caller when it's
|
||||
/// no longer used. In case of any error the function returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwDeviceConfigData* aiwCreateApache5Config(uint32_t frequencyMHz);
|
||||
|
||||
/// Creates the default Apache6 config.
|
||||
///
|
||||
/// Convenience method, calls #aiwCreateApache6Config with 1300 MHz. For further info see
|
||||
/// the previously mentioned function.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwDeviceConfigData* aiwCreateApache6ConfigDefault(void);
|
||||
|
||||
/// Creates Apache6 config and sets its frequency to the given value.
|
||||
///
|
||||
/// @param[in] frequencyMHz Frequency of the configuration given in MHz. Must be
|
||||
/// greater than 0.
|
||||
///
|
||||
/// @return On success a new device config data instance is created by using the given
|
||||
/// parameters. The returned instance must be deleted by the caller when it's
|
||||
/// no longer used. In case of any error the function returns NULL.
|
||||
|
||||
// TODO remove this
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwDeviceConfigData* aiwCreateApache6Config(uint32_t frequencyMHz);
|
||||
|
||||
/// Creates the default Apache6 ES config.
|
||||
///
|
||||
/// Convenience method, calls #aiwCreateApache6ESConfig with 1300 MHz. For further info see
|
||||
/// the previously mentioned function.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwDeviceConfigData* aiwCreateApache6ESConfigDefault(void);
|
||||
|
||||
/// Creates Apache6 ES config and sets its frequency to the given value.
|
||||
///
|
||||
/// @param[in] frequencyMHz Frequency of the configuration given in MHz. Must be
|
||||
/// greater than 0.
|
||||
///
|
||||
/// @return On success a new device config data instance is created by using the given
|
||||
/// parameters. The returned instance must be deleted by the caller when it's
|
||||
/// no longer used. In case of any error the function returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwDeviceConfigData* aiwCreateApache6ESConfig(uint32_t frequencyMHz);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_RUNTIME__CONFIGS_H
|
||||
@ -0,0 +1,146 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_C__DEVICE_H
|
||||
#define AIWARE_RUNTIME_COMMON_C__DEVICE_H
|
||||
|
||||
#include "aiware/common/c/deviceconfigdata.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-common-lib-c_export.h"
|
||||
#include "aiware/runtime/c/rawbufferordering.h"
|
||||
#include "aiware/runtime/c/types.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Opens a device.
|
||||
///
|
||||
/// Allocates all resources used by the device. The device can't be used after this
|
||||
/// function called.
|
||||
///
|
||||
/// @param[in] deviceIndex The device index that should be opened.
|
||||
///
|
||||
/// @return NULL on error, a pointer to an aiwDevice otherwise.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwDevice* aiwDeviceOpen(uint32_t deviceIndex);
|
||||
|
||||
/// Returns the number of devices found in the system.
|
||||
///
|
||||
/// @return The number of devices accessible for the runtime.
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT uint32_t aiwDeviceCount(void);
|
||||
|
||||
/// Gets the configuration of a device
|
||||
///
|
||||
/// The ownership of the returned object remains at the device, the caller don't have to
|
||||
/// release it.
|
||||
///
|
||||
/// @param[in] device The device whose config the user interested in. Can't be NULL.
|
||||
///
|
||||
/// @return If the passed device pointer is NULL, then returns NULL. Otherwise the
|
||||
/// function returns the device config data object that belongs to the device.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT const aiwDeviceConfigData* aiwDeviceGetConfig(aiwDevice* device);
|
||||
|
||||
/// Closes the passed device.
|
||||
///
|
||||
/// Releases all resource allocated by the device. The device can't be used after this
|
||||
/// function called.
|
||||
///
|
||||
/// @param[in] device The device that should be closed. Can't be NULL.
|
||||
///
|
||||
/// @return If NULL pointer is passed or the device couldn't be closed successfully,
|
||||
/// the function returns AIW_ERROR, otherwise AIW_SUCCESS.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwDeviceClose(aiwDevice* device);
|
||||
|
||||
/// Free all programs (device and host memory) currently associated with the device.
|
||||
/// This function is also called on device destruction.
|
||||
///
|
||||
/// @param[in] device The device whose programs should be freed.
|
||||
///
|
||||
/// @return If the passed device is NULL or invalid or an error happens internally.
|
||||
/// the function returns AIW_ERROR.
|
||||
///
|
||||
/// @note This function does not need to be called explicitly if aiwDeviceClose is called,
|
||||
/// as it is called internally. It is provided for convenience in case the user wants to
|
||||
/// free the programs without closing the device to avoid the overhead of reopening the device.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwDeviceFreePrograms(aiwDevice* device);
|
||||
|
||||
/// Returns the number of program sets associated to the device
|
||||
///
|
||||
/// @return If the passed device is NULL or invalid, the function returns -1. Otherwise
|
||||
/// the function return a non-negative value.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT int32_t aiwDeviceProgramSetCount(const aiwDevice* device);
|
||||
|
||||
/// Returns the Nth program set.
|
||||
///
|
||||
/// @param[in] programSetIndex Index of the requested program set, must be less than
|
||||
/// the value returned by #aiwDeviceProgramSetCount (if it
|
||||
/// was positive).
|
||||
///
|
||||
/// @return If the passed device and the index is valid, then the function returns a
|
||||
/// pointer to the requested program set. THe ownership of the returned object
|
||||
/// remains at the device, it must not be deleted. If any of the parameters is
|
||||
/// invalid, then the function returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwProgramSet* aiwDeviceGetProgramSet(
|
||||
aiwDevice* device,
|
||||
uint32_t programSetIndex);
|
||||
|
||||
/// Deletes the Nth program set.
|
||||
///
|
||||
/// @param[in] programSetIndex Index of the requested program set, must be less than
|
||||
/// the value returned by #aiwDeviceProgramSetCount (if it
|
||||
/// was positive).
|
||||
/// @return If the passed device and the index is valid, then the function destroys
|
||||
/// the program set identified by the index, and returns AIW_SUCCESS. If any
|
||||
/// parameter is invalid, then no program set will be deleted and the function
|
||||
/// returns AIW_ERROR.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwDeviceDeleteProgramSet(aiwDevice* device, uint32_t programSetIndex);
|
||||
|
||||
/// Returns the ordering type of all raw tensor buffers of all tensors that belong to the passed
|
||||
/// device.
|
||||
///
|
||||
/// The programs and their tensors also have a function to query this property, but all of them
|
||||
/// returns the same ordering type like the associated device does.
|
||||
///
|
||||
/// @return Returns AIW_RTBO_INVALID if the passed device pointer is null or invalid. Otherwise
|
||||
/// returns one of the valid ids of #aiwRawTensorBufferOrdering enum.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwRawTensorBufferOrdering aiwDeviceRawTensorBufferOrdering(aiwDevice* device);
|
||||
|
||||
/// Returns if the device supports tensor export.
|
||||
///
|
||||
/// @return Returns AIW_ERROR if the passed device pointer is null or invalid or the device
|
||||
/// doesn't support tensor export. Otherwise returns AIW_SUCCESS.
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwDeviceHasTensorExportSupport(aiwDevice* device);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON_C__DEVICE_H
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2024
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_UTILS__DEVICES_H
|
||||
#define AIWARE_RUNTIME_UTILS__DEVICES_H
|
||||
|
||||
#include "aiware/runtime/c/aiware-runtime-utils-lib-c_export.h"
|
||||
#include "aiware/runtime/c/device.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Returns the version info of the library.
|
||||
AIWARE_RUNTIME_UTILS_LIB_C_EXPORT aiwDevice* aiwDeviceOpenUrl(const char* url);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_RUNTIME_UTILS__DEVICES_H
|
||||
@ -0,0 +1,82 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_DEVICE_COMMON_C__HOSTBUFFER_H
|
||||
#define AIWARE_RUNTIME_DEVICE_COMMON_C__HOSTBUFFER_H
|
||||
#include <stdlib.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
enum HostBufferType
|
||||
{
|
||||
HBT_INVALID = 0,
|
||||
HBT_CONTIGUOUS, // Physically contiguous memory, e.g. hugepage or CMA backed
|
||||
HBT_DEVICE, // Device memory mapped into CPU memory space
|
||||
HBT_USER, // Userspace memory (e.g. malloc())
|
||||
HBT_FD, // DMABUF backed file descriptor
|
||||
};
|
||||
|
||||
struct ContiguousMemoryBuffer
|
||||
{
|
||||
void* virtBase; // virtual memory pointer for CPU access
|
||||
void* physBase; // physical address mapped to DMA controller required for DMA transfers
|
||||
};
|
||||
|
||||
struct DeviceMemoryBuffer
|
||||
{
|
||||
void* virtBase; // virtual memory pointer for CPU access, memory mapped
|
||||
};
|
||||
|
||||
struct DeviceUserspaceBuffer
|
||||
{
|
||||
void* virtBase; // virtual memory pointer for CPU access, userspace buffer
|
||||
int handle; // driver handle
|
||||
size_t offset; // offset to the address imported by the driver
|
||||
};
|
||||
|
||||
struct DeviceDMABufBuffer
|
||||
{
|
||||
int dmaFd; // file descriptor for Linux dmabuf
|
||||
};
|
||||
|
||||
struct aiwHostBuffer
|
||||
{
|
||||
enum HostBufferType type;
|
||||
union
|
||||
{
|
||||
struct ContiguousMemoryBuffer contig;
|
||||
struct DeviceMemoryBuffer device;
|
||||
struct DeviceUserspaceBuffer user;
|
||||
struct DeviceDMABufBuffer dmabuf;
|
||||
} d;
|
||||
size_t length; // length of the buffer
|
||||
};
|
||||
|
||||
#define AIW_HOST_BUFFER_REQUIRES_DMA(buffer) \
|
||||
(((buffer)->type == HBT_CONTIGUOUS) || ((buffer)->type == HBT_USER) || ((buffer)->type == HBT_FD))
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,18 @@
|
||||
#ifndef AIWARE_RUNTIME_COMMON_C__PARITYBIT_CALCULATOR_H
|
||||
#define AIWARE_RUNTIME_COMMON_C__PARITYBIT_CALCULATOR_H
|
||||
#include "aiware/common/c/types.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-common-lib-c_export.h"
|
||||
#include "aiware/runtime/c/types.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT uint16_t aiwCalculateParityBits(const uint8_t* command, size_t size);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_PLATFORM_COMMON_C__PLATFORM_H
|
||||
#define AIWARE_RUNTIME_PLATFORM_COMMON_C__PLATFORM_H
|
||||
#include "aiware/common/c/types.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-device-lib-c_export.h"
|
||||
#include "aiware/runtime/c/platform/socket.h"
|
||||
#include "aiware/runtime/c/platform/threads.h"
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT uint64_t aiwRuntimeGetTimeMs(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,81 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2024
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_PRIVATE__SOCKET_H
|
||||
#define AIWARE_RUNTIME_PRIVATE__SOCKET_H
|
||||
|
||||
#include "aiware/common/c/status.h"
|
||||
#include "aiware/common/c/types.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-device-lib-c_export.h"
|
||||
#include "aiware/runtime/c/platform/defines.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwPlatformSocketContextCreate(aiwSocketContext* context); /* Also defined in platform specific implementation */
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwPlatformSocketContextFree(aiwSocketContext* context); /* Also defined in platform specific implementation */
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwPlatformGetAddrInfo(const char* node, const char* service, const struct addrinfo* hints, struct addrinfo** res);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwPlatformFreeAddrInfo(struct addrinfo* res);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwPlatformSocket(int domain, int type, int protocol, aiwSocket* socket);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwPlatformConnect(aiwSocket socket, const aiwSockAddr* address, aiwSockLen addressLength);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwPlatformBind(aiwSocket socket, const aiwSockAddr* address, aiwSockLen addressLength);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwPlatformListen(aiwSocket socket, int backlog);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT
|
||||
aiw_status aiwPlatformAccept(
|
||||
aiwSocket socket,
|
||||
aiwSockAddr* address,
|
||||
aiwSockLen* addressLength,
|
||||
aiwSocket* retSocket);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT void aiwPlatformCloseSocket(
|
||||
aiwSocket socket); /* Also defined in platform specific implementation */
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT
|
||||
aiw_status aiwPlatformSend(aiwSocket socket, const void* buffer, size_t length, int flags, size_t* sent);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT
|
||||
aiw_status aiwPlatformRecv(aiwSocket socket, void* buffer, size_t length, int flags, size_t* recvd);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwPlatformRecvExact(aiwSocket socket, uint8_t* data, size_t length);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AIWARE_RUNTIME_PRIVATE__SOCKET_H
|
||||
@ -0,0 +1,69 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2024
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_PRIVATE__THREADS_H
|
||||
#define AIWARE_RUNTIME_PRIVATE__THREADS_H
|
||||
|
||||
#include "aiware/common/c/status.h"
|
||||
#include "aiware/common/c/types.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-device-lib-c_export.h"
|
||||
#include "aiware/runtime/c/platform/defines.h"
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwPlatformThreadCreate(aiwThread* threadId, void (*startRoutine)(void*), void* arg);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT void aiwPlatformThreadJoin(aiwThread* threadId);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwPlatformMutexCreate(aiwMutex* mutex);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT void aiwPlatformMutexDestroy(aiwMutex* mutex);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwPlatformMutexLock(aiwMutex* mutex);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwPlatformMutexTimedLock(aiwMutex* mutex, uint32_t timeoutMsec);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwPlatformMutexUnlock(aiwMutex* mutex);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwPlatformCondCreate(aiwCond* cond);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT void aiwPlatformCondDestroy(aiwCond* cond);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwPlatformCondWaitWithTimeout(aiwCond* cond, aiwMutex* mutex, uint32_t timeoutMsec);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwPlatformCondWait(aiwCond* cond, aiwMutex* mutex);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwPlatformCondSignal(aiwCond* cond);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT void aiwPlatformSleepMs(size_t milliseconds);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // AIWARE_RUNTIME_PRIVATE__THREADS_H
|
||||
@ -0,0 +1,384 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_C__PROGRAM_H
|
||||
#define AIWARE_RUNTIME_COMMON_C__PROGRAM_H
|
||||
|
||||
#include "aiware/common/c/binary.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-common-lib-c_export.h"
|
||||
#include "aiware/runtime/c/device.h"
|
||||
#include "aiware/runtime/c/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Returns info of the passed tensor.
|
||||
///
|
||||
/// @param[in] tensor Tensor to query. Can't be NULL.
|
||||
///
|
||||
/// @return When a valid tensor instance is passed the function returns its info. The
|
||||
/// returned object must not be released. If the passed tensor is NULL or
|
||||
/// invalid, the function returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT const aiwTensorInfo* aiwTensorGetInfo(const aiwTensor* tensor);
|
||||
|
||||
/// Returns the size in bytes of the raw buffer that belongs to the tensor.
|
||||
///
|
||||
/// For further info please see #aiwTensorRawBufferPointer.
|
||||
///
|
||||
/// @param[in] tensor Tensor to query. Can't be NULL.
|
||||
///
|
||||
/// @return When a valid object tensor instance is passed the function returns the size,
|
||||
/// which is a positive integer. Otherwise the function returns 0.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT uint64_t aiwTensorRawBufferSize(const aiwTensor* tensor);
|
||||
|
||||
/// Returns the ordering of the raw buffer that belongs to the passed tensor.
|
||||
///
|
||||
/// Returns the same value as the program and device the tensor belongs to.
|
||||
///
|
||||
/// @return Returns AIW_RTBO_INVALID if the passed tensor is null or invalid. Otherwise returns
|
||||
/// one of the valid items from the #aiwRawTensorBufferOrdering enum.
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwRawTensorBufferOrdering aiwTensorRawBufferOrdering(const aiwTensor* tensor);
|
||||
|
||||
/// Acquires and returns the pointer to the raw buffer that belongs to the tensor.
|
||||
///
|
||||
/// Through the returned pointer the caller can get direct access to data that is assigned
|
||||
/// to a specific tensor. The data is stored in the host memory in special, aiWare related ordering.
|
||||
/// The ordering can be queried by #aiwTensowRawBufferOrdering function.
|
||||
///
|
||||
/// To give direct access to internal buffers, internal structures must be locked. After
|
||||
/// the buffer's content was accessed, it must be released by calling
|
||||
/// #aiwTensorAcquireRawBufferPointer, which releases the internal locks. No buffer can
|
||||
/// be locked during the execution of the program whom the tensor belongs to. It's also not
|
||||
/// sure the function will return the same pointer for the same tensor if it's called twice.
|
||||
/// So the returned pointer should not stored in the application.
|
||||
///
|
||||
/// Each tensor has a counterpart in the device's memory. When one modifies the data of
|
||||
/// the tensor via this pointer, it only affects the copy being in the host's memory. To
|
||||
/// modify the pair of the tensor in the device's memory the tensor must be uploaded into
|
||||
/// it by calling #aiwProgramUploadInputs. Similarly, the result of a program's execution doesn't
|
||||
/// immediately changes the data in the host memory, it has to be downloaded first.
|
||||
///
|
||||
/// @param[in] tensor Tensor to query. Can't be NULL.
|
||||
///
|
||||
/// @return When a valid object tensor instance is passed the function returns a non-NULL
|
||||
/// pointer that points to the raw buffer. Otherwise then function returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT uint8_t* aiwTensorAcquireRawBufferPointer(aiwTensor* tensor);
|
||||
|
||||
/// Releases a previously acquired internal buffer pointer.
|
||||
///
|
||||
/// For further info please see #aiwTensorAcquireRawdBufferPointer
|
||||
///
|
||||
/// @return If the function gets a valid tensor object, and it has been acquired, then
|
||||
/// the function releases it and returns AIW_SUCCESS. In any other case the
|
||||
/// function return AIW_ERROR.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwTensorReleaseRawBufferPointer(aiwTensor* tensor);
|
||||
|
||||
/// Returns the tensor's export object.
|
||||
///
|
||||
/// The export object contains the tensor's underlying memory area in an structure that can be used by other
|
||||
/// hardware accelerators or libraries.
|
||||
/// This routine is platform dependent. The ownership of the returned object remains at the tensor,
|
||||
/// which is managed by the program. If needed, the export object may be released manually by calling #aiwTensorExportRelease.
|
||||
///
|
||||
/// @param[in] tensor Tensor to query. Can't be NULL.
|
||||
/// @param[out] tensorExport Pointer to hold the export object of the tensor.
|
||||
///
|
||||
/// @return When a valid tensor instance is passed the function returns the export object in tensorExport and AIW_SUCCESS
|
||||
/// Otherwise the function returns AIW_ERROR.
|
||||
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwTensorExport(aiwTensor* tensor, aiwExternalMemoryDescriptor** tensorExport);
|
||||
|
||||
/// Releases the tensor's export object.
|
||||
///
|
||||
/// For further info please see #aiwTensorExport.
|
||||
///
|
||||
/// @param[in] tensor Tensor used to create the export.
|
||||
/// @param[in] tensorExport Export object to release.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwTensorExportRelease(aiwTensor* tensor, aiwExternalMemoryDescriptor* tensorExport);
|
||||
|
||||
/// Returns the NCHW size of the passed tensor.
|
||||
///
|
||||
/// The returned value is equal to the multiplication of all dimensions of the tensor.
|
||||
///
|
||||
/// @param[in] tensor Tensor to query. Can't be NULL.
|
||||
///
|
||||
/// @return When a valid tensor instance is passed the function returns the size, which
|
||||
/// is a positive integer. If the passed tensor is invalid, the function returns
|
||||
/// 0.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT uint32_t aiwTensorSizeNCHW(const aiwTensor* tensor);
|
||||
|
||||
/// Sets the tensor's data by using uint8 NCHW ordered data.
|
||||
///
|
||||
/// The passed buffer's size must be at least as large as the size returned by
|
||||
/// #aiwTensorSizeNCHW. The input data in NCHW representation will be reordered to the
|
||||
/// proper internal format. The reordering performed by the host's CPU, so it can be an overhead in
|
||||
/// the execution.
|
||||
///
|
||||
/// @param[in] tensor Tensor whose data will be modified. Can't be NULL.
|
||||
/// @param[in] data Source data buffer. Can't be NULL and the buffer size must be
|
||||
/// at least #aiwTensorSizeNCHW bytes large.
|
||||
///
|
||||
/// @return On success it returns AIW_SUCCESS, otherwise return AIW_ERROR.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwTensorSetDataNCHWUInt8(const aiwTensor* tensor, const uint8_t* data);
|
||||
|
||||
/// Sets the tensor's data by using float NCHW ordered data.
|
||||
///
|
||||
/// The number of elements of the passed buffer must be at least as large as the size
|
||||
/// returned by #aiwTensorSizeNCHW. The input data in NCHW representation will be quantized
|
||||
/// and reordered to the proper internal format. The reordering performed by the host's CPU, so it
|
||||
/// can be an overhead in the execution.
|
||||
///
|
||||
/// @param[in] tensor Tensor whose data will be modified. Can't be NULL.
|
||||
/// @param[in] data Source data buffer. Can't be NULL and the buffer size must be
|
||||
/// at least #aiwTensorSizeNCHW bytes large.
|
||||
///
|
||||
/// @return On success it returns AIW_SUCCESS, otherwise return AIW_ERROR.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwTensorSetDataNCHWFloat(const aiwTensor* tensor, const aiw_f32_t* data);
|
||||
|
||||
/// Gets the tensor's data and writes it into the passed buffer in NCHW order.
|
||||
///
|
||||
/// For further information please see #aiwTensorSetDataNCHWUInt8.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwTensorGetDataNCHWUInt8(const aiwTensor* tensor, uint8_t* data);
|
||||
|
||||
/// Gets the tensor's data, dequantize it to float and writes it into the passed buffer in
|
||||
/// NCHW order.
|
||||
///
|
||||
/// For further information please see #aiwTensorSetDataNCHWFloat.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwTensorGetDataNCHWFloat(const aiwTensor* tensor, aiw_f32_t* data);
|
||||
|
||||
/// Returns the device associated to the passed program.
|
||||
///
|
||||
/// The program will be executed on this device.
|
||||
///
|
||||
/// @return If the passed program is valid, then returns a non-null pointer to its
|
||||
/// devices. Otherwise the function returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwDevice* aiwProgramGetDevice(const aiwProgram* program);
|
||||
|
||||
/// Returns the program set where the program belongs to.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwProgramSet* aiwProgramGetProgramSet(const aiwProgram* program);
|
||||
|
||||
/// Returns the binary that was used to build to the program.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT const aiwBinary* aiwProgramGetBinary(const aiwProgram* program);
|
||||
|
||||
/// Returns the number of input tensors belongs to the passed program.
|
||||
///
|
||||
/// @return If the passed pointer is not null and a valid program instance, then the
|
||||
/// function returns a positive integer. In case of any error, the function
|
||||
/// returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT uint32_t aiwProgramGetInputTensorCount(const aiwProgram* program);
|
||||
|
||||
/// Returns the Nth input tensor of the program.
|
||||
///
|
||||
/// @param[in] inputTensorIndex Index of the input tensor, must be less than the value
|
||||
/// returned by #aiwProgramGetInputTensorCount.
|
||||
///
|
||||
/// @return If the passed program and the inputTensorIndex are both valid, then the
|
||||
/// function returns a non-null pointer to the tensor object. The ownership of
|
||||
/// the returned object remains at the program, doesn't need deleting. If any
|
||||
/// parameter of the function is invalid, the function returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT const aiwTensor* aiwProgramGetInputTensorConst(
|
||||
const aiwProgram* program,
|
||||
uint32_t inputTensorIndex);
|
||||
|
||||
/// Returns the Nth input tensor of the program, non-const version.
|
||||
///
|
||||
/// For further info please check #aiwProgramGetInputTensorConst.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwTensor* aiwProgramGetInputTensor(
|
||||
const aiwProgram* program,
|
||||
uint32_t inputTensorIndex);
|
||||
|
||||
/// Returns the number of output tensors belongs to the passed program.
|
||||
///
|
||||
/// @return If the passed pointer is not null and a valid program instance, then the
|
||||
/// function returns a positive integer. In case of any error, the function
|
||||
/// returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT uint32_t aiwProgramGetOutputTensorCount(const aiwProgram* program);
|
||||
|
||||
/// Returns the Nth output tensor of the program.
|
||||
///
|
||||
/// @param[in] outputTensorIndex Index of the input tensor, must be less than the
|
||||
/// value returned by #aiwProgramGetOutputTensorCount.
|
||||
///
|
||||
/// @return If the passed program and the outputTensorIndex are both valid, then the
|
||||
/// function returns a non-null pointer to the tensor object. The ownership of
|
||||
/// the returned object remains at the program, doesn't need deleting. If any
|
||||
/// parameter of the function is invalid, the function returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT const aiwTensor* aiwProgramGetOutputTensorConst(
|
||||
const aiwProgram* program,
|
||||
uint32_t outputTensorIndex);
|
||||
|
||||
/// Returns the Nth output tensor of the program, non-const version.
|
||||
///
|
||||
/// For further info please check #aiwProgramGetOutputTensorConst.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwTensor* aiwProgramGetOutputTensor(
|
||||
const aiwProgram* program,
|
||||
uint32_t outputTensorIndex);
|
||||
|
||||
/// Executes the passed program.
|
||||
///
|
||||
/// Starts the execution on the associated device, and waits until the program finishes or
|
||||
/// the execution timeout set by #aiwProgramSetExecutionTimeout is reached.
|
||||
///
|
||||
/// @param[in] program Program to execute, must be a valid program object.
|
||||
///
|
||||
/// @return If the passed program is valid, and could be executed successfully, then
|
||||
/// the function returns AIW_SUCCESS. If the execution timeout is reached, the
|
||||
/// function returns AIW_TIMEOUT. Otherwise the function returns with an error,
|
||||
/// and the error callback will be called with the detailed reasons of fail.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwProgramExecute(aiwProgram* program);
|
||||
|
||||
/// Starts the execution of the passed program.
|
||||
///
|
||||
/// If no program is executing, the function returns immediately, and the program will be executed in the background.
|
||||
/// #aiwProgramAwait should be used to wait for the completion of the program and finish the execution.
|
||||
/// Only one program can be executed at a time, if the device already executing a program, the function returns
|
||||
/// immediately with AIW_TIMEOUT.
|
||||
///
|
||||
/// @param[in] program Program to start, must be a valid program object.
|
||||
///
|
||||
/// @return If the passed program is valid, and could be started successfully, then
|
||||
/// the function returns AIW_SUCCESS. If the device is already executing a program,
|
||||
/// the function returns AIW_TIMEOUT. Otherwise the function returns with an error,
|
||||
/// and the error callback will be called with the detailed reasons of fail.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwProgramExecuteAsync(aiwProgram* program);
|
||||
|
||||
/// Waits for the completion of the passed program.
|
||||
///
|
||||
/// The function blocks until the program finishes its execution. Timeouts set by
|
||||
/// aiwProgramSetExecutionTimeout() are respected, but time measurement starts from the call of
|
||||
/// aiwProgramExecuteAwait().
|
||||
///
|
||||
/// @param[in] program Program to wait for, must be a valid program object.
|
||||
///
|
||||
/// @return If the passed program is valid, and could be waited successfully, then
|
||||
/// the function returns AIW_SUCCESS. Otherwise the function returns AIW_ERROR,
|
||||
/// and the error callback will be called with the detailed reasons of fail.
|
||||
///
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwProgramAwait(aiwProgram* program);
|
||||
|
||||
/// Returns the time of the program's last execution in milliseconds.
|
||||
///
|
||||
/// @return If the passed program is NULL or invalid, the function returns 0. It also
|
||||
/// returns 0 when the last execution of the program was unsuccessful. Otherwise
|
||||
/// returns a positive integer.
|
||||
/// On asynchronous execution, the function returns the time elapsed between the call
|
||||
/// of aiwProgramExecuteAsync() and the return of aiwProgramAwait().
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT uint32_t aiwProgramExecutionTimeMsec(const aiwProgram* program);
|
||||
|
||||
/// Returns the time of the program's last execution in clock cycles.
|
||||
///
|
||||
/// Clock cycles interpreted in the frequency of the program's associated device.
|
||||
///
|
||||
/// @return If the passed program is NULL or invalid, the function returns 0. It also
|
||||
/// returns 0 when the last execution of the program was unsuccessful. Otherwise
|
||||
/// returns a positive integer.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT uint64_t aiwProgramExecutionTimeClockCycles(const aiwProgram* program);
|
||||
|
||||
/// Uploads the content of internal input tensor buffers into the device's memory.
|
||||
/// Timeouts set by aiwProgramSetMemoryTransferTimeout() are respected, the function returns
|
||||
/// with AIW_TIMEOUT if the upload operation couldn't be finished in time. On error, the return
|
||||
/// value is AIW_ERROR, and the error callback will be called with the detailed reasons of fail.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwProgramUploadInputs(aiwProgram* program);
|
||||
|
||||
/// Updates the internal output tensor buffers by downloading their content from the
|
||||
/// device's memory.
|
||||
/// Timeouts set by aiwProgramSetMemoryTransferTimeout() are respected, the function returns
|
||||
/// with AIW_TIMEOUT if the download operation couldn't be finished in time. On error, the return
|
||||
/// value is AIW_ERROR, and the error callback will be called with the detailed reasons of fail.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwProgramDownloadOutputs(aiwProgram* program);
|
||||
|
||||
/// @brief Set memory transfer timeout for the program.
|
||||
/// @param program
|
||||
/// @param transferTimeoutMs Timeout for data transfer (DMA) operations in milliseconds. If 0, no wait happens.
|
||||
/// @return
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwProgramSetMemoryTransferTimeout(aiwProgram* program, uint32_t transferTimeoutMs);
|
||||
|
||||
/// @brief Set execution timeout for the program.
|
||||
/// @param program
|
||||
/// @param executionTimeoutMs Timeout for the execution of the program in milliseconds. If 0, no wait happens.
|
||||
/// @return
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwProgramSetExecutionTimeout(aiwProgram* program, uint32_t executionTimeoutMs);
|
||||
|
||||
/// @brief Get memory transfer timeout for the program.
|
||||
/// @param program
|
||||
/// @param transferTimeoutMs Timeout for data transfer (DMA) operations in milliseconds.
|
||||
/// @return
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwProgramGetMemoryTransferTimeout(const aiwProgram* program, uint32_t* transferTimeoutMs);
|
||||
|
||||
/// @brief Get execution timeout for the program.
|
||||
/// @param program
|
||||
/// @param executionTimeoutMs Timeout for the execution of the program in milliseconds.
|
||||
/// @return
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwProgramGetExecutionTimeout(const aiwProgram* program, uint32_t* executionTimeoutMs);
|
||||
|
||||
/// @brief Sets if selftest should be enabled for the program when selftest execution policy is AIW_SEP_BEFORE_PROGRAM
|
||||
|
||||
/// When device selftest policy is automatic (AIW_SEP_BEFORE_PROGRAM), the selftest is executed before the program.
|
||||
/// If there are multiple different neural networks executed in a row, the selftest can be disabled to save time
|
||||
/// by setting this to false, if the safety requirements of the use case allow it.
|
||||
///
|
||||
/// @param program
|
||||
/// @param enable
|
||||
/// @return
|
||||
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwProgramEnableSelftest(aiwProgram* program, bool enable);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON_C__PROGRAM_H
|
||||
@ -0,0 +1,148 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_C__PROGRAM_SET_H
|
||||
#define AIWARE_RUNTIME_COMMON_C__PROGRAM_SET_H
|
||||
|
||||
#include "aiware/common/c/binary.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-common-lib-c_export.h"
|
||||
#include "aiware/runtime/c/device.h"
|
||||
#include "aiware/runtime/c/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Returns the device associated to the passed program set.
|
||||
///
|
||||
/// @return If the passed pointer refers to a valid program set instance, the function
|
||||
/// returns a non-null pointer. In case of any error, the function return NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwDevice* aiwProgramSetGetDevice(const aiwProgramSet* programSet);
|
||||
|
||||
/// Returns the number of programs in a program set.
|
||||
///
|
||||
/// @return Returns a positive integer number if the programSet object is valid,
|
||||
/// otherwise 0.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT uint32_t aiwProgramSetGetProgramCount(const aiwProgramSet* programSet);
|
||||
|
||||
/// Returns the Nth program of the program set.
|
||||
///
|
||||
/// @param[in] programIndex Index of the requested program. Must be less than the value
|
||||
/// returned by #aiwProgramSetGetProgramCount.
|
||||
///
|
||||
/// @return If both parameters are valid, then function returns the pointer of the
|
||||
/// requested program instance. The ownership of the returned object remains at
|
||||
/// the program set, the caller doesn't have to destroy it. If any parameter is
|
||||
/// invalid, the function returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwProgram* aiwProgramSetGetProgram(
|
||||
const aiwProgramSet* programSet,
|
||||
uint32_t programIndex);
|
||||
|
||||
/// Destroys the passed program set.
|
||||
///
|
||||
/// All program sets belong to a device, and is destroyed when the associated device is
|
||||
/// destroyed. However a program set can be destroyed before that by using this function.
|
||||
/// The call of this function will unregister the program set from its device, so it can
|
||||
/// modify the indices of other program sets that belong to the same device (if there is
|
||||
/// any).
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwReleaseProgramSet(aiwProgramSet* programSet);
|
||||
|
||||
/// Creates a simple program set from a binary for a device.
|
||||
///
|
||||
/// The passed binary instance will be copied, an one program instance will be built from it
|
||||
/// for the passed device. The binary must be built for the device. The new built program
|
||||
/// set will be registered to the device and it will be the owner, so the caller doesn't
|
||||
/// have to release it.
|
||||
///
|
||||
/// @return If the passed device and binary is valid and if they are compatible, then
|
||||
/// the function returns the pointer of the set's only program.
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwProgram* aiwBuildSimpleProgramByCopy(
|
||||
aiwDevice* device,
|
||||
const aiwBinary* binary);
|
||||
|
||||
/// Creates a simple program set from a binary for a device.
|
||||
///
|
||||
/// The same as #aiwBuildSimpleProgramByCopy, except it takes the ownership of the binary
|
||||
/// object: the caller won't be responsible for destroying it. Even if the function fails,
|
||||
/// the passed binary object will be released.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwProgram* aiwBuildSimpleProgramByMove(aiwDevice* device, aiwBinary* binary);
|
||||
|
||||
/// Creates a program set builder for the device.
|
||||
///
|
||||
/// The program set builder can create multiple programs from binaries and pack them into
|
||||
/// a single program set.
|
||||
///
|
||||
/// @return If the passed device is valid, the function returns a new builder object.
|
||||
/// The caller is responsible for destroying the created object. In case of any
|
||||
/// error the function returns NULL.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwProgramSetBuilder* aiwCreateProgramSetBuilder(aiwDevice* device);
|
||||
|
||||
/// Adds programs to the program set by using the passed binary.
|
||||
///
|
||||
/// Creates \p instances number of programs by using the passed binary, which will be
|
||||
/// copied during the construction. The new programs will be added to programs set created
|
||||
/// by the passed builder.
|
||||
///
|
||||
/// @param[in] instances Number of new program instances, can't be 0.
|
||||
///
|
||||
/// @return If all parameter is valid the program returns AIW_SUCCESS, otherwise
|
||||
/// AIW_ERROR.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwProgramSetBuilderAddBinaryCopy(aiwProgramSetBuilder* builder, const aiwBinary* binary, uint8_t instances);
|
||||
|
||||
/// Adds programs to the program set by using the passed binary.
|
||||
///
|
||||
/// The same as #aiwProgramSetBuilderAddBinaryCopy except it takes the ownership of the binary
|
||||
/// object: the caller won't be responsible for destroying it.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwProgramSetBuilderAddBinaryMove(aiwProgramSetBuilder* builder, aiwBinary* binary, uint8_t instances);
|
||||
|
||||
/// Finishes building the new program set.
|
||||
///
|
||||
/// If the builder is valid, and at least one program has been added to the set, then the
|
||||
/// builder creates the program set, and registers it to the device which was associated to the
|
||||
/// builder at its creation. The device will be the owner of the returned program set. The
|
||||
/// builder object can't be used anymore, and should be destroyed by calling
|
||||
/// #aiwReleaseProgramSetBuilder.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwProgramSet* aiwProgramSetBuilderFinish(aiwProgramSetBuilder* builder);
|
||||
|
||||
/// Destroys a program set builder instance.
|
||||
///
|
||||
/// If the building process hasn't been completed yet, the function will destroy every
|
||||
/// unfinished objects.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwReleaseProgramSetBuilder(aiwProgramSetBuilder* builder);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON_C__PROGRAM_SET_H
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_C__RAW_BUFFER_ORDERING_H
|
||||
#define AIWARE_RUNTIME_COMMON_C__RAW_BUFFER_ORDERING_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Defines the ordering types of raw tensor buffers.
|
||||
typedef enum aiwRawTensorBufferOrdering
|
||||
{
|
||||
AIW_RTBO_INVALID = 0,
|
||||
AIW_RTBO_TILE_ORDERED = 1,
|
||||
AIW_RTBO_CELLROW_ORDERED = 2
|
||||
} aiwRawTensorBufferOrdering;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON_C__RAW_BUFFER_ORDERING_H
|
||||
@ -0,0 +1,384 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_DEVICE_COMMON_C__RUNTIMEDEVICE_H
|
||||
#define AIWARE_RUNTIME_DEVICE_COMMON_C__RUNTIMEDEVICE_H
|
||||
#include "aiware/common/c/memoryarea.h"
|
||||
#include "aiware/common/c/status.h"
|
||||
#include "aiware/common/c/types.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-device-lib-c_export.h"
|
||||
#include "aiware/runtime/c/hostbuffer.h"
|
||||
|
||||
#include <stdbool.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
struct aiwRuntimeDevice;
|
||||
enum aiwRuntimeDeviceLockType
|
||||
{
|
||||
LOCK_HARDWARE = 0, // exclusive hardware access is required
|
||||
LOCK_MEMORY = 1, // exclusive memory access is required
|
||||
LOCK_PROGRAM = 2 // exclusive command queue manipulation is required
|
||||
};
|
||||
|
||||
enum aiwRuntimeInterruptSource
|
||||
{
|
||||
CMDQ_FINISHED = 0,
|
||||
CHECKPOINT = 1,
|
||||
BLOCK_FINISHED = 2,
|
||||
INTERNAL_ERROR = 3,
|
||||
ILLEGAL_CONTROL = 4,
|
||||
ACC_OVERFLOW = 5,
|
||||
MAX_INTERRUPTS = 6
|
||||
};
|
||||
|
||||
static const uint32_t AIW_INTERRUPT_MASK = (1u << MAX_INTERRUPTS) - 1u;
|
||||
|
||||
enum aiwRuntimeExtendedRegisterType
|
||||
{
|
||||
/* aiWare IP register area: 0-15 reserved */
|
||||
REG_AIWARE = 0, /* Standard register set from HSI */
|
||||
REG_DRL = 1, /* Data rate limiter*/
|
||||
REG_AIWARE_LAST = 15,
|
||||
/* SoC specific register area */
|
||||
REG_SOC_FIRST = REG_AIWARE_LAST + 1,
|
||||
REG_SOC_LAST = REG_SOC_FIRST + 15,
|
||||
/* Board specific register area */
|
||||
REG_BOARD_FIRST = REG_SOC_LAST + 1,
|
||||
REG_BOARD_LAST = REG_BOARD_FIRST + 15,
|
||||
/* User specific register area */
|
||||
REG_USER_FIRST = REG_BOARD_LAST + 1
|
||||
};
|
||||
|
||||
struct aiwRuntimeDeviceMemoryBank
|
||||
{
|
||||
uintptr_t physAddr; /* Device physical address for the memory bank */
|
||||
size_t length; /* Size of memory bank */
|
||||
uint32_t type; /* What can be put into the memory bank, combination of aiwRuntimeDeviceMemoryBankType */
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiwRuntimeDeviceMemoryBank(uintptr_t physAddr0, size_t length0, uint32_t type0)
|
||||
: physAddr(physAddr0)
|
||||
, length(length0)
|
||||
, type(type0)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
struct aiwDeviceBuffer
|
||||
{
|
||||
uintptr_t physAddr; /* Device physical address for the memory area */
|
||||
size_t length; /* Size of memory area */
|
||||
|
||||
#ifdef __cplusplus
|
||||
aiwDeviceBuffer(uintptr_t physAddr0, size_t length0) : physAddr(physAddr0), length(length0) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
enum aiwRuntimeDeviceFeatures
|
||||
{
|
||||
/* Memory access features */
|
||||
FEATURE_CONTIG_DMA = 0x1,
|
||||
FEATURE_USER_DMA = 0x2,
|
||||
FEATURE_DMABUF_DMA = 0x4,
|
||||
FEATURE_DIRECT_MAPPING = 0x8,
|
||||
FEATURE_EXTERNAL_EXPORT = 0x10,
|
||||
/* RESERVED*/
|
||||
|
||||
/* Interrupt handling features */
|
||||
FEATURE_EVENTFD_IRQ = 0x20,
|
||||
/* RESERVED */
|
||||
/* Device locking for user */
|
||||
FEATURE_USER_LOCK = 0x100,
|
||||
/* Additional features */
|
||||
FEATURE_EXTENDED = 0x1000,
|
||||
FEATURE_DRL = 0x1000, /* Data Rate Limiter */
|
||||
};
|
||||
|
||||
#define AIW_RUNTIME_DEVICE_DEFAULT_IMPLEMENTATION (NULL)
|
||||
struct aiwRuntimeDeviceFunctions
|
||||
{
|
||||
/* Lifetime management */
|
||||
aiw_status (*release)(struct aiwRuntimeDevice* device);
|
||||
/* Device information */
|
||||
aiw_status (*getDeviceFeatures)(struct aiwRuntimeDevice* device, uint32_t* featuresResult);
|
||||
aiw_status (*getMemoryBankCount)(struct aiwRuntimeDevice* device, uint8_t* count);
|
||||
aiw_status (*getMemoryBankInformation)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint8_t index,
|
||||
struct aiwRuntimeDeviceMemoryBank* bankResult);
|
||||
|
||||
/* Clock handling */
|
||||
aiw_status (*getClockFrequency)(struct aiwRuntimeDevice* device, uint64_t* freq);
|
||||
aiw_status (*setClockFrequency)(struct aiwRuntimeDevice* device, uint64_t freq);
|
||||
|
||||
/* Reset handling */
|
||||
aiw_status (*resetDevice)(struct aiwRuntimeDevice* device);
|
||||
|
||||
/* Register access */
|
||||
aiw_status (*writeRegister)(struct aiwRuntimeDevice* device, uint64_t reg, uint64_t value);
|
||||
aiw_status (*readRegister)(struct aiwRuntimeDevice* device, uint64_t reg, uint64_t* value);
|
||||
|
||||
aiw_status (*writeRegisters)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint64_t regStart,
|
||||
const void* value,
|
||||
size_t regSize,
|
||||
size_t regCount);
|
||||
aiw_status (*readRegisters)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint64_t regStart,
|
||||
void* value,
|
||||
size_t regSize,
|
||||
size_t regCount);
|
||||
|
||||
/* Extended register access - DRL, etc. */
|
||||
aiw_status (*writeExtendedRegister)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
enum aiwRuntimeExtendedRegisterType type,
|
||||
uint64_t reg,
|
||||
uint64_t value);
|
||||
aiw_status (*readExtendedRegister)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
enum aiwRuntimeExtendedRegisterType type,
|
||||
uint64_t reg,
|
||||
uint64_t* value);
|
||||
|
||||
/* Interrupt handling */
|
||||
aiw_status (*pollInterrupts)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint64_t* mask,
|
||||
uint32_t timeoutMs); /* read the status for every interrupt line aiWare has */
|
||||
aiw_status (*readInterruptCount)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
enum aiwRuntimeInterruptSource irq,
|
||||
uint64_t* count); /* read the interrupt count for an interrupt line since the last read */
|
||||
aiw_status (
|
||||
*waitInterrupts)(struct aiwRuntimeDevice* device, uint64_t* mask); /* block until interrupt happens */
|
||||
|
||||
/* Support for OS-dependent interrupt waiting, advanced API */
|
||||
aiw_status (*getInterruptEventSource)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
enum aiwRuntimeInterruptSource irq,
|
||||
void* sourceData,
|
||||
size_t* sourceDataSize);
|
||||
aiw_status (*handleInterruptEventSource)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
enum aiwRuntimeInterruptSource irq,
|
||||
void* sourceData,
|
||||
size_t* sourceDataSize);
|
||||
|
||||
/* Memory handling */
|
||||
aiw_status (*createContigBuffer)(struct aiwRuntimeDevice* device, struct aiwHostBuffer* buffer);
|
||||
aiw_status (*destroyContigBuffer)(struct aiwRuntimeDevice* device, struct aiwHostBuffer* buffer);
|
||||
|
||||
// Buffer preparation: before first use a host buffer is needed to be prepared, and after last use it is needed to be released
|
||||
|
||||
aiw_status (*prepareBuffer)(struct aiwRuntimeDevice* device, struct aiwHostBuffer* buffer);
|
||||
aiw_status (*unprepareBuffer)(struct aiwRuntimeDevice* device, struct aiwHostBuffer* buffer);
|
||||
|
||||
// DMA operation
|
||||
aiw_status (*uploadBuffer)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
struct aiwHostBuffer* source,
|
||||
size_t sourceOffset,
|
||||
struct aiwDeviceBuffer* destination,
|
||||
size_t destinationOffset,
|
||||
size_t length,
|
||||
uint32_t timeoutMs);
|
||||
aiw_status (*downloadBuffer)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
struct aiwDeviceBuffer* source,
|
||||
size_t sourceOffset,
|
||||
struct aiwHostBuffer* destination,
|
||||
size_t destinationOffset,
|
||||
size_t length,
|
||||
uint32_t timeoutMs);
|
||||
|
||||
// Device locking
|
||||
aiw_status (
|
||||
*lockDevice)(struct aiwRuntimeDevice* device, enum aiwRuntimeDeviceLockType type, uint32_t timeoutMs);
|
||||
aiw_status (*unlockDevice)(struct aiwRuntimeDevice* device, enum aiwRuntimeDeviceLockType type);
|
||||
|
||||
// Device information
|
||||
aiw_status (*description)(struct aiwRuntimeDevice* device, char* retStr, size_t maxLength);
|
||||
|
||||
// User locking
|
||||
aiw_status (*userLock)(struct aiwRuntimeDevice* device);
|
||||
aiw_status (*userUnlock)(struct aiwRuntimeDevice* device);
|
||||
aiw_status (*userLocked)(struct aiwRuntimeDevice* device);
|
||||
|
||||
// Export physical memory to shared buffer
|
||||
aiw_status (*exportMemory)(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint8_t memoryBankIndex,
|
||||
uintptr_t memoryOffset,
|
||||
size_t length,
|
||||
void** externalMemory);
|
||||
aiw_status (*exportRelease)(struct aiwRuntimeDevice* device, void* externalMemory);
|
||||
|
||||
aiw_status (
|
||||
*getDriverVersion)(struct aiwRuntimeDevice* device, uint32_t* major, uint32_t* minor, uint32_t* patch);
|
||||
};
|
||||
|
||||
struct aiwRuntimeDevice
|
||||
{
|
||||
const struct aiwRuntimeDeviceFunctions* operations;
|
||||
uint32_t defaultMemoryTransferTimeoutMs; // Initial suggested timeout for memory transfer.
|
||||
// Emulator and remote can set this to a large enough value
|
||||
// to have a sane default.
|
||||
uint32_t defaultCommandQueueExecutionTimeoutMs; // Initial suggested timeout for command queue execution.
|
||||
// Emulator and remote can set this to a large enough value
|
||||
// to have a sane default.
|
||||
|
||||
uint64_t quirks; // Device specific quirks which needed to be handled in runtime. It is a mask of aiwQuirkMask
|
||||
|
||||
void* priv; // Private data for runtime device, platform specific
|
||||
};
|
||||
|
||||
/* These functions should be provided by the runtime device port */
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT uint32_t aiwRuntimeDeviceCount(void);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceOpen(struct aiwRuntimeDevice* device, uint32_t deviceIndex);
|
||||
|
||||
/* These convenience functions are exported by this library */
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT void* aiwHostBufferGetVirt(struct aiwHostBuffer* hostBuffer);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceRelease(struct aiwRuntimeDevice* device);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceGetDeviceFeatures(struct aiwRuntimeDevice* device, uint32_t* featuresResult);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceGetMemoryBankCount(struct aiwRuntimeDevice* device, uint8_t* count);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceGetMemoryBankInformation(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint8_t index,
|
||||
struct aiwRuntimeDeviceMemoryBank* bankResult);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceGetClockFrequency(struct aiwRuntimeDevice* device, uint64_t* freq);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceSetClockFrequency(struct aiwRuntimeDevice* device, uint64_t freq);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceResetDevice(struct aiwRuntimeDevice* device);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceWriteRegister(struct aiwRuntimeDevice* device, uint64_t reg, uint64_t value);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceReadRegister(struct aiwRuntimeDevice* device, uint64_t reg, uint64_t* value);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceWriteRegisters(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint64_t regStart,
|
||||
const void* value,
|
||||
size_t regSize,
|
||||
size_t regCount);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceReadRegisters(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint64_t regStart,
|
||||
void* value,
|
||||
size_t regSize,
|
||||
size_t regCount);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceWriteExtendedRegister(
|
||||
struct aiwRuntimeDevice* device,
|
||||
enum aiwRuntimeExtendedRegisterType type,
|
||||
uint64_t reg,
|
||||
uint64_t value);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceReadExtendedRegister(
|
||||
struct aiwRuntimeDevice* device,
|
||||
enum aiwRuntimeExtendedRegisterType type,
|
||||
uint64_t reg,
|
||||
uint64_t* value);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDevicePollInterrupts(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint64_t* mask,
|
||||
uint32_t timeoutMs); /* read the status for every interrupt line aiWare has */
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceReadInterruptCount(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint8_t irq,
|
||||
uint64_t* count); /* read the interrupt count for an interrupt line since the last read */
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceWaitInterrupts(struct aiwRuntimeDevice* device, uint64_t* mask); /* block until interrupt happens */
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceGetInterruptEventSource(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint8_t irq,
|
||||
void* sourceData,
|
||||
size_t* sourceDataSize);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceHandleInterruptEventSource(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint8_t irq,
|
||||
void* sourceData,
|
||||
size_t* sourceDataSize);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceCreateContigBuffer(struct aiwRuntimeDevice* device, struct aiwHostBuffer* buffer);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceDestroyContigBuffer(struct aiwRuntimeDevice* device, struct aiwHostBuffer* buffer);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDevicePrepareBuffer(struct aiwRuntimeDevice* device, struct aiwHostBuffer* buffer);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceUnprepareBuffer(struct aiwRuntimeDevice* device, struct aiwHostBuffer* buffer);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceUploadBuffer(
|
||||
struct aiwRuntimeDevice* device,
|
||||
struct aiwHostBuffer* source,
|
||||
size_t sourceOffset,
|
||||
struct aiwDeviceBuffer* destination,
|
||||
size_t destinationOffset,
|
||||
size_t length,
|
||||
uint32_t timeoutMs);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceDownloadBuffer(
|
||||
struct aiwRuntimeDevice* device,
|
||||
struct aiwDeviceBuffer* source,
|
||||
size_t sourceOffset,
|
||||
struct aiwHostBuffer* destination,
|
||||
size_t destinationOffset,
|
||||
size_t length,
|
||||
uint32_t timeoutMs);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceLockDevice(struct aiwRuntimeDevice* device, enum aiwRuntimeDeviceLockType type, uint32_t timeoutMs);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceUnlockDevice(struct aiwRuntimeDevice* device, enum aiwRuntimeDeviceLockType type);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceDescription(struct aiwRuntimeDevice* device, char* retStr, size_t maxLength);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceUserLock(struct aiwRuntimeDevice* device);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceUserUnlock(struct aiwRuntimeDevice* device);
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceUserLocked(struct aiwRuntimeDevice* device);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceExportMemory(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint8_t memoryBankIndex,
|
||||
uintptr_t memoryOffset,
|
||||
size_t length,
|
||||
void** externalMemory);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status
|
||||
aiwRuntimeDeviceExportRelease(struct aiwRuntimeDevice* device, void* externalMemory);
|
||||
|
||||
AIWARE_RUNTIME_DEVICE_LIB_C_EXPORT aiw_status aiwRuntimeDeviceGetDriverVersion(
|
||||
struct aiwRuntimeDevice* device,
|
||||
uint32_t* major,
|
||||
uint32_t* minor,
|
||||
uint32_t* patch);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,83 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2024
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_C__SELFTEST_H
|
||||
#define AIWARE_RUNTIME_COMMON_C__SELFTEST_H
|
||||
|
||||
#include "aiware/runtime/c/aiware-runtime-common-lib-c_export.h"
|
||||
#include "aiware/runtime/c/device.h"
|
||||
#include "aiware/runtime/c/program.h"
|
||||
#include "aiware/runtime/c/types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
/// @brief The selftest execution policy
|
||||
///
|
||||
/// The selftest execution policy defines how the selftest program should be executed.
|
||||
///
|
||||
/// AIW_SEP_NO_EXEC (default): The selftest program is not loaded, never executed.
|
||||
/// AIW_SEP_MANUAL: The selftest program is loaded, but not executed automatically, #aiwSelftestExecute must be called by user.
|
||||
/// AIW_AIW_SEP_BEFORE_PROGRAM: The selftest program is loaded at the call of #aiwSetSelftestExecutionPolicy and executed before every program execution (except selftest program).
|
||||
///
|
||||
/// Selftest program is loaded when #aiwSetSelftestExecutionPolicy is called with AIW_SEP_NO_EXEC!=policy first time.
|
||||
typedef enum
|
||||
{
|
||||
AIW_SEP_NO_EXEC = -1,
|
||||
AIW_SEP_MANUAL = 0,
|
||||
AIW_SEP_BEFORE_PROGRAM,
|
||||
} aiwSelftestExecutionPolicy;
|
||||
|
||||
/// Run the selftest
|
||||
/// @param[in] device The device to run the selftest on
|
||||
/// @return AIW_SUCCESS on success, AIW_ERROR otherwise
|
||||
///
|
||||
/// This function immediately runs the selftest program on the device. The selftest program
|
||||
/// should be already loaded by calling #aiwSetSelftestExecutionPolicy with AIW_SEP_NO_EXEC!=policy.
|
||||
///
|
||||
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status aiwSelftestExecute(aiwDevice* device);
|
||||
|
||||
/// Get the selftest execution policy
|
||||
/// @param[in] device The device to get the selftest execution policy from
|
||||
/// @param[out] policy The policy to use for selftest execution
|
||||
/// @return AIW_SUCCESS on success, AIW_ERROR otherwise
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwGetSelftestExecutionPolicy(aiwDevice* device, aiwSelftestExecutionPolicy* policy);
|
||||
|
||||
/// Set the selftest execution policy
|
||||
/// @param[in] device The device to set the selftest execution policy on
|
||||
/// @param[in] policy The policy to use for selftest execution
|
||||
/// @return AIW_SUCCESS on success, AIW_ERROR otherwise
|
||||
///
|
||||
/// This function sets the selftest execution policy for the device. On the first call with
|
||||
/// AIW_SEP_NO_EXEC!=policy, the selftest program for the device is found and loaded.
|
||||
/// The selftest program is freed when the device is closed by #aiwDeviceClose.
|
||||
///
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiw_status
|
||||
aiwSetSelftestExecutionPolicy(aiwDevice* device, aiwSelftestExecutionPolicy policy);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON_C__SELFTEST_H
|
||||
@ -0,0 +1,34 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_C__TYPES_H
|
||||
#define AIWARE_RUNTIME_COMMON_C__TYPES_H
|
||||
/// Represents an aiWare device
|
||||
typedef struct aiwDeviceImpl aiwDevice;
|
||||
/// Represents an aiWare program
|
||||
typedef struct aiwProgramImpl aiwProgram;
|
||||
typedef struct aiwProgramSetImpl aiwProgramSet;
|
||||
typedef struct aiwProgramSetBuilderImpl aiwProgramSetBuilder;
|
||||
typedef struct aiwProgramImplTensorInfo aiwTensor;
|
||||
/// Opaque type representing a memory area by which the tensor is backed.
|
||||
typedef void aiwExternalMemoryDescriptor;
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON_C__TYPES_H
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_C__VERSION_H
|
||||
#define AIWARE_RUNTIME_COMMON_C__VERSION_H
|
||||
|
||||
#include "aiware/common/c/moduleversion.h"
|
||||
#include "aiware/runtime/c/aiware-runtime-common-lib-c_export.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/// Returns the version info of the library.
|
||||
AIWARE_RUNTIME_COMMON_LIB_C_EXPORT aiwModuleVersion aiwRuntimeVersion(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON_C__VERSION_H
|
||||
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT_H
|
||||
#define AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT_H
|
||||
|
||||
#ifdef AIWARE_RUNTIME_COMMON_LIB_CPP_STATIC_DEFINE
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_CPP_NO_EXPORT
|
||||
#else
|
||||
# ifndef AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT
|
||||
# ifdef aiware_runtime_common_lib_cpp_EXPORTS
|
||||
/* We are building this library */
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef AIWARE_RUNTIME_COMMON_LIB_CPP_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_CPP_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_LIB_CPP_DEPRECATED
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_CPP_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_LIB_CPP_DEPRECATED_EXPORT
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_CPP_DEPRECATED_EXPORT AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT AIWARE_RUNTIME_COMMON_LIB_CPP_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_LIB_CPP_DEPRECATED_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_CPP_DEPRECATED_NO_EXPORT AIWARE_RUNTIME_COMMON_LIB_CPP_NO_EXPORT AIWARE_RUNTIME_COMMON_LIB_CPP_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef AIWARE_RUNTIME_COMMON_LIB_CPP_NO_DEPRECATED
|
||||
# define AIWARE_RUNTIME_COMMON_LIB_CPP_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT_H */
|
||||
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef AIWARE_RUNTIME_INF_LIB_CPP_EXPORT_H
|
||||
#define AIWARE_RUNTIME_INF_LIB_CPP_EXPORT_H
|
||||
|
||||
#ifdef AIWARE_RUNTIME_INF_LIB_CPP_STATIC_DEFINE
|
||||
# define AIWARE_RUNTIME_INF_LIB_CPP_EXPORT
|
||||
# define AIWARE_RUNTIME_INF_LIB_CPP_NO_EXPORT
|
||||
#else
|
||||
# ifndef AIWARE_RUNTIME_INF_LIB_CPP_EXPORT
|
||||
# ifdef aiware_runtime_inf_lib_cpp_EXPORTS
|
||||
/* We are building this library */
|
||||
# define AIWARE_RUNTIME_INF_LIB_CPP_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define AIWARE_RUNTIME_INF_LIB_CPP_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef AIWARE_RUNTIME_INF_LIB_CPP_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_INF_LIB_CPP_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_INF_LIB_CPP_DEPRECATED
|
||||
# define AIWARE_RUNTIME_INF_LIB_CPP_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_INF_LIB_CPP_DEPRECATED_EXPORT
|
||||
# define AIWARE_RUNTIME_INF_LIB_CPP_DEPRECATED_EXPORT AIWARE_RUNTIME_INF_LIB_CPP_EXPORT AIWARE_RUNTIME_INF_LIB_CPP_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_INF_LIB_CPP_DEPRECATED_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_INF_LIB_CPP_DEPRECATED_NO_EXPORT AIWARE_RUNTIME_INF_LIB_CPP_NO_EXPORT AIWARE_RUNTIME_INF_LIB_CPP_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef AIWARE_RUNTIME_INF_LIB_CPP_NO_DEPRECATED
|
||||
# define AIWARE_RUNTIME_INF_LIB_CPP_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* AIWARE_RUNTIME_INF_LIB_CPP_EXPORT_H */
|
||||
@ -0,0 +1,42 @@
|
||||
|
||||
#ifndef AIWARE_RUNTIME_UTILS_LIB_CPP_EXPORT_H
|
||||
#define AIWARE_RUNTIME_UTILS_LIB_CPP_EXPORT_H
|
||||
|
||||
#ifdef AIWARE_RUNTIME_UTILS_LIB_CPP_STATIC_DEFINE
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_CPP_EXPORT
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_CPP_NO_EXPORT
|
||||
#else
|
||||
# ifndef AIWARE_RUNTIME_UTILS_LIB_CPP_EXPORT
|
||||
# ifdef aiware_runtime_utils_lib_cpp_EXPORTS
|
||||
/* We are building this library */
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_CPP_EXPORT __attribute__((visibility("default")))
|
||||
# else
|
||||
/* We are using this library */
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_CPP_EXPORT __attribute__((visibility("default")))
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifndef AIWARE_RUNTIME_UTILS_LIB_CPP_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_CPP_NO_EXPORT __attribute__((visibility("hidden")))
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_UTILS_LIB_CPP_DEPRECATED
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_CPP_DEPRECATED __attribute__ ((__deprecated__))
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_UTILS_LIB_CPP_DEPRECATED_EXPORT
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_CPP_DEPRECATED_EXPORT AIWARE_RUNTIME_UTILS_LIB_CPP_EXPORT AIWARE_RUNTIME_UTILS_LIB_CPP_DEPRECATED
|
||||
#endif
|
||||
|
||||
#ifndef AIWARE_RUNTIME_UTILS_LIB_CPP_DEPRECATED_NO_EXPORT
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_CPP_DEPRECATED_NO_EXPORT AIWARE_RUNTIME_UTILS_LIB_CPP_NO_EXPORT AIWARE_RUNTIME_UTILS_LIB_CPP_DEPRECATED
|
||||
#endif
|
||||
|
||||
#if 0 /* DEFINE_NO_DEPRECATED */
|
||||
# ifndef AIWARE_RUNTIME_UTILS_LIB_CPP_NO_DEPRECATED
|
||||
# define AIWARE_RUNTIME_UTILS_LIB_CPP_NO_DEPRECATED
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* AIWARE_RUNTIME_UTILS_LIB_CPP_EXPORT_H */
|
||||
@ -0,0 +1,42 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME__AIWARE_DEVICE_HPP
|
||||
#define AIWARE_RUNTIME__AIWARE_DEVICE_HPP
|
||||
|
||||
#include "aiware/runtime/cpp/aiware-runtime-common-lib-cpp_export.h"
|
||||
#include "aiware/runtime/cpp/device.hpp"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace runtime
|
||||
{
|
||||
|
||||
AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT uint32_t deviceCount();
|
||||
|
||||
AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT Device::Ptr openDevice(uint32_t deviceIndex);
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_RUNTIME__AIWARE_DEVICE_HPP
|
||||
@ -0,0 +1,18 @@
|
||||
#ifndef AIWARE_RUNTIME__CHANGELOG_HPP
|
||||
#define AIWARE_RUNTIME__CHANGELOG_HPP
|
||||
|
||||
#include "aiware/runtime/cpp/aiware-runtime-common-lib-cpp_export.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace runtime
|
||||
{
|
||||
|
||||
AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT std::string changelog();
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace aiware
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,40 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME__CONFIGS_HPP
|
||||
#define AIWARE_RUNTIME__CONFIGS_HPP
|
||||
|
||||
#include "aiware/common/cpp/deviceconfigdata.hpp"
|
||||
#include "aiware/runtime/cpp/aiware-runtime-common-lib-cpp_export.h"
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace runtime
|
||||
{
|
||||
|
||||
AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT common::DeviceConfigData::Ptr createApache5Config(uint32_t frequencyMhz = 0);
|
||||
|
||||
AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT common::DeviceConfigData::Ptr createApache6ESConfig(uint32_t frequencyMhz = 0);
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_RUNTIME__CONFIGS_HPP
|
||||
@ -0,0 +1,125 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON__DEVICE_HPP
|
||||
#define AIWARE_RUNTIME_COMMON__DEVICE_HPP
|
||||
|
||||
#include "aiware/common/cpp/deviceconfigdata.hpp"
|
||||
#include "aiware/runtime/cpp/aiware-runtime-common-lib-cpp_export.h"
|
||||
#include "aiware/runtime/cpp/runtimeinf.hpp"
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace runtime
|
||||
{
|
||||
|
||||
class ProgramSet;
|
||||
|
||||
/// Represents and aiWare device
|
||||
class AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT Device : public inf::Device
|
||||
{
|
||||
public:
|
||||
using Ptr = std::unique_ptr<Device>;
|
||||
|
||||
public:
|
||||
/// Destructor
|
||||
~Device() override;
|
||||
|
||||
/// Returns the device's configuration.
|
||||
const aiware::common::DeviceConfigData& deviceConfigData() const;
|
||||
|
||||
uint32_t programCount() const override;
|
||||
const inf::Program* program(uint32_t index) const override;
|
||||
inf::Program* program(uint32_t index) override;
|
||||
|
||||
/// Returns the number of program sets associated with the current device.
|
||||
uint32_t programSetCount() const;
|
||||
|
||||
/// Returns the Nth program set.
|
||||
///
|
||||
/// @param[in] index Index of the requested device, must be less than the value
|
||||
/// returned by #programSetCount.
|
||||
///
|
||||
/// @return If the device and the passed index is valid, the functions returns a
|
||||
/// non-null pointer to the requested program set. The ownership of the
|
||||
/// returned object remains at the device. In case of an invalid device or
|
||||
/// index the function returns nullptr.
|
||||
///
|
||||
const ProgramSet* programSet(uint32_t index) const;
|
||||
|
||||
/// Returns the Nth program set, non-const version.
|
||||
ProgramSet* programSet(uint32_t index);
|
||||
|
||||
/// Deletes the Nth program set.
|
||||
///
|
||||
/// @return If the index is invalid, the function returns false, otherwise it
|
||||
/// destroys the requested program set and returns true.
|
||||
///
|
||||
bool deleteProgramSet(uint32_t index);
|
||||
|
||||
/// Deletes the passed program set if it belongs to the current device.
|
||||
///
|
||||
/// @param[in] programSet Program set to delete. The program set must belong to
|
||||
/// the current device.
|
||||
///
|
||||
/// @return If the passed programSet belongs to the device, then the function
|
||||
/// destroys it and returns true, otherwise returns false.
|
||||
bool deleteProgramSet(ProgramSet& programSet);
|
||||
|
||||
inf::Buffer::Ordering rawBufferOrdering() const;
|
||||
|
||||
/// Returns if the device supports tensor export or not.
|
||||
///
|
||||
/// @return Returns true if the device supports tensor export, otherwise false.
|
||||
bool tensorExportSupported() const override;
|
||||
|
||||
bool setSelftestExecutionPolicy(aiwSelftestExecutionPolicy policy) override;
|
||||
|
||||
bool selftestExecutionPolicy(aiwSelftestExecutionPolicy& policy) const override;
|
||||
|
||||
inf::Status executeSelftest() override;
|
||||
|
||||
protected:
|
||||
Device(void* impl, std::unique_ptr<aiware::common::DeviceConfigData> dcd);
|
||||
|
||||
void updateProgramSets();
|
||||
|
||||
const inf::Program* getProgram(uint32_t index) const;
|
||||
|
||||
private:
|
||||
friend void updateProgramSets(Device& device);
|
||||
|
||||
using ProgramSetPtr = std::unique_ptr<ProgramSet>;
|
||||
using ProgramSetPtrVec = std::vector<ProgramSetPtr>;
|
||||
|
||||
protected:
|
||||
void* _impl = nullptr;
|
||||
ProgramSetPtrVec* _programSets = nullptr;
|
||||
bool _owned = false;
|
||||
std::unique_ptr<aiware::common::DeviceConfigData> _dcd;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON__DEVICE_HPP
|
||||
@ -0,0 +1,105 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON__PROGRAM_HPP
|
||||
#define AIWARE_RUNTIME_COMMON__PROGRAM_HPP
|
||||
|
||||
#include "aiware/common/cpp/binary.hpp"
|
||||
#include "aiware/runtime/cpp/aiware-runtime-common-lib-cpp_export.h"
|
||||
#include "aiware/runtime/cpp/runtimeinf.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace runtime
|
||||
{
|
||||
|
||||
class Device;
|
||||
class ProgramSet;
|
||||
|
||||
using Tensor = inf::Tensor;
|
||||
class Buffer;
|
||||
class TensorImpl;
|
||||
|
||||
class AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT Program : public inf::Program
|
||||
{
|
||||
public:
|
||||
Program() = delete;
|
||||
~Program() override;
|
||||
|
||||
uint32_t inputTensorCount() const override;
|
||||
const Tensor* inputTensor(uint32_t index) const override;
|
||||
Tensor* inputTensor(uint32_t) override;
|
||||
|
||||
uint32_t outputTensorCount() const override;
|
||||
const Tensor* outputTensor(uint32_t index) const override;
|
||||
Tensor* outputTensor(uint32_t) override;
|
||||
|
||||
inf::Status execute() override;
|
||||
|
||||
inf::Status executeAsync() override;
|
||||
inf::Status await() override;
|
||||
bool asyncExecutionSupported() const override;
|
||||
|
||||
inf::Status uploadInputs() override;
|
||||
inf::Status downloadOutputs() override;
|
||||
|
||||
bool memoryTransferTimeoutSupported() const override;
|
||||
bool executionTimeoutSupported() const override;
|
||||
|
||||
bool setMemoryTransferTimeout(uint32_t transferTimeoutMs) override;
|
||||
bool setExecutionTimeout(uint32_t executionTimeoutMs) override;
|
||||
|
||||
bool getMemoryTransferTimeout(uint32_t& transferTimeoutMs) const override;
|
||||
bool getExecutionTimeout(uint32_t& executionTimeoutMs) const override;
|
||||
|
||||
bool enableSelftest(bool enabled) override;
|
||||
|
||||
Device& device() const;
|
||||
|
||||
ProgramSet& programSet() const;
|
||||
|
||||
const aiware::common::Binary& binary() const;
|
||||
|
||||
uint32_t executionTimeMsec() const;
|
||||
|
||||
uint64_t executionTimeClockCycles() const;
|
||||
|
||||
inf::Buffer::Ordering rawBufferOrdering() const;
|
||||
|
||||
protected:
|
||||
Program(Device& device, ProgramSet& programSet, const aiware::common::Binary& binary, void* impl);
|
||||
|
||||
protected:
|
||||
Device& _device;
|
||||
ProgramSet& _programSet;
|
||||
const aiware::common::Binary& _binary;
|
||||
void* _impl = nullptr;
|
||||
std::vector<std::unique_ptr<TensorImpl>> _inputTensors;
|
||||
std::vector<std::unique_ptr<TensorImpl>> _outputTensors;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON__PROGRAM_HPP
|
||||
@ -0,0 +1,196 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON__PROGRAM_SET_HPP
|
||||
#define AIWARE_RUNTIME_COMMON__PROGRAM_SET_HPP
|
||||
|
||||
#include "aiware/runtime/cpp/aiware-runtime-common-lib-cpp_export.h"
|
||||
#include "aiware/runtime/cpp/program.hpp"
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace common
|
||||
{
|
||||
class Binary;
|
||||
}
|
||||
} // namespace aiware
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace runtime
|
||||
{
|
||||
|
||||
class Device;
|
||||
|
||||
/// Represents a program set object.
|
||||
class AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT ProgramSet final
|
||||
{
|
||||
public:
|
||||
ProgramSet() = delete;
|
||||
ProgramSet(const ProgramSet&) = delete;
|
||||
ProgramSet(ProgramSet&&) = delete;
|
||||
|
||||
ProgramSet& operator=(const ProgramSet&) = delete;
|
||||
ProgramSet& operator=(ProgramSet&&) = delete;
|
||||
|
||||
~ProgramSet();
|
||||
|
||||
/// Returns whether the instance is a valid program set object or not.
|
||||
bool isValid() const;
|
||||
|
||||
/// Returns the device where the current program set is associated to.
|
||||
///
|
||||
/// @return If the program set is valid, the function returns a non-null pointer
|
||||
/// to the associated device, otherwise nullptr.
|
||||
///
|
||||
Device& device() const;
|
||||
|
||||
/// Returns the number of binaries that belong to the program set.
|
||||
uint32_t binaryCount() const;
|
||||
|
||||
/// Returns the Nth binary of the program set.
|
||||
///
|
||||
/// @param[in] index Index of the requested binary, must be less than the value
|
||||
/// returned by #binaryCount.
|
||||
///
|
||||
/// @return If the passed index is valid, then the function returns the a pointer
|
||||
/// to the requested binary object. The ownership of the returned object
|
||||
/// remains at the program set, it must not be deleted. If the passed index
|
||||
/// or the program set itself is invalid, nullptr will be returned.
|
||||
///
|
||||
const aiware::common::Binary* binary(uint32_t index) const;
|
||||
|
||||
/// Returns the number of programs in the program set.
|
||||
uint32_t programCount() const;
|
||||
|
||||
/// Returns the Nth program of the set.
|
||||
///
|
||||
/// @param[in] index Index of the requested program set, must be less than the value
|
||||
/// returned by #programCount.
|
||||
///
|
||||
/// @return If the index is valid, a pointer will be returned to the requested
|
||||
/// program. The ownership of the returned object remains at the program
|
||||
/// set, it must not be deleted. If the passed index or the program set
|
||||
/// object itself is invalid, the function returns nullptr.
|
||||
///
|
||||
const Program* program(uint32_t index) const;
|
||||
|
||||
/// Returns the Nth program of the set, non-const version.
|
||||
Program* program(uint32_t);
|
||||
|
||||
private:
|
||||
ProgramSet(Device& device, void* impl);
|
||||
|
||||
friend class Device;
|
||||
|
||||
void* internal() const;
|
||||
|
||||
private:
|
||||
void* _impl = nullptr;
|
||||
Device& _device;
|
||||
std::vector<std::unique_ptr<aiware::common::Binary>> _binaries;
|
||||
std::vector<std::unique_ptr<Program>> _programs;
|
||||
};
|
||||
|
||||
/// Represents a program set builder.
|
||||
///
|
||||
/// This object can be used to build programs from binaries for a specific device. Every
|
||||
/// builder object can be used only once: after the #finish method is called, the object
|
||||
/// can't be used anymore.
|
||||
///
|
||||
class AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT ProgramSetBuilder final
|
||||
{
|
||||
public:
|
||||
/// Creates a simple program set from a binary for a device.
|
||||
///
|
||||
/// The passed binary instance will be copied, an one program instance will be built
|
||||
/// from it for the passed device. The binary must be built for the device. The new
|
||||
/// built program set will be registered to the device and it will be the owner, so the
|
||||
/// caller doesn't have to release it.
|
||||
///
|
||||
/// @return If the passed device and binary is valid and if they are compatible,
|
||||
/// then the function returns the pointer of the new program set. Otherwise
|
||||
/// the function returns null.
|
||||
///
|
||||
static Program* buildSimpleProgram(Device& device, const aiware::common::Binary& binary);
|
||||
|
||||
/// Creates a simple program set from a binary for a device.
|
||||
///
|
||||
/// The same as #buildSimpleProgramSet, except it takes the ownership of the binary
|
||||
/// object: the caller won't be responsible for destroying it. Even if the function
|
||||
/// fails, the passed binary object will be released.
|
||||
///
|
||||
static Program* buildSimpleProgram(Device& device, aiware::common::Binary::Ptr&& binary);
|
||||
|
||||
public:
|
||||
ProgramSetBuilder() = delete;
|
||||
|
||||
/// Creates a program set builder for the device.
|
||||
ProgramSetBuilder(Device& device);
|
||||
|
||||
ProgramSetBuilder(const ProgramSetBuilder&) = delete;
|
||||
ProgramSetBuilder(ProgramSetBuilder&& other) noexcept;
|
||||
|
||||
ProgramSetBuilder& operator=(const ProgramSetBuilder&) = delete;
|
||||
ProgramSetBuilder& operator=(ProgramSetBuilder&& other) noexcept;
|
||||
|
||||
~ProgramSetBuilder();
|
||||
|
||||
/// Adds programs to the program set by using the passed binary.
|
||||
///
|
||||
/// Creates #instances number of programs by using the passed binary, which will be
|
||||
/// copied during the construction. The new programs will be added to programs set
|
||||
/// created by the passed builder.
|
||||
///
|
||||
/// @param[in] instances Number of new program instances, can't be 0.
|
||||
///
|
||||
/// @return If all parameter is valid the program returns true, otherwise false.
|
||||
///
|
||||
bool addBinary(const aiware::common::Binary& binary, uint32_t instances = 1);
|
||||
|
||||
/// Adds programs to the program set by using the passed binary.
|
||||
///
|
||||
/// The same as #addBinary except it takes the ownership of the binary object: the
|
||||
/// caller won't be responsible for destroying it.
|
||||
///
|
||||
bool addBinary(aiware::common::Binary::Ptr&& binary, uint32_t instances = 1);
|
||||
|
||||
/// Finishes building the new program set.
|
||||
///
|
||||
/// If at least one program has been added to the set, then the builder creates the
|
||||
/// program set, and registers it to the device which was associated to the builder at
|
||||
/// its creation. The device will be the owner of the returned program set. The
|
||||
/// builder object can't be used anymore.
|
||||
///
|
||||
ProgramSet* finish();
|
||||
|
||||
private:
|
||||
Device* _device = nullptr;
|
||||
void* _impl = nullptr;
|
||||
};
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON__PROGRAM_SET_HPP
|
||||
@ -0,0 +1,568 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This interface is th base for every system which is able to execute a neural network
|
||||
* workload with aiWare arithmetic.
|
||||
*/
|
||||
#ifndef AIWARE_RUNTIME__RUNTIME_INF_HPP
|
||||
#define AIWARE_RUNTIME__RUNTIME_INF_HPP
|
||||
|
||||
#include "aiware/common/c/status.h"
|
||||
#include "aiware/common/c/tensordimensions.h"
|
||||
#include "aiware/runtime/c/selftest.h"
|
||||
#include "aiware/runtime/cpp/aiware-runtime-inf-lib-cpp_export.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace runtime
|
||||
{
|
||||
namespace inf
|
||||
{
|
||||
|
||||
class Buffer;
|
||||
class Program;
|
||||
class Status;
|
||||
|
||||
/// An interface for any kind of device which is capable of performing neural network
|
||||
/// workloads with aiWare arithmetic.
|
||||
///
|
||||
/// Each device has a set of programs associated with itself. These programs represent
|
||||
/// the workloads, and the device provides methods to query and manage them. The device
|
||||
/// is also responsible for destroying these programs.
|
||||
class AIWARE_RUNTIME_INF_LIB_CPP_EXPORT Device
|
||||
{
|
||||
public:
|
||||
virtual ~Device();
|
||||
|
||||
Device(const Device&) = delete;
|
||||
Device& operator=(const Device&) = delete;
|
||||
Device(Device&&) = delete;
|
||||
Device& operator=(Device&&) = delete;
|
||||
|
||||
/// Returns the number of Programs associated with this device instance.
|
||||
virtual uint32_t programCount() const = 0;
|
||||
|
||||
/// Returns the program identified by the given index, or nullptr if the index is out of range.
|
||||
virtual const Program* program(uint32_t index) const = 0;
|
||||
|
||||
/// Returns the program identified by the given index, or nullptr if the index is out of range.
|
||||
virtual Program* program(uint32_t index) = 0;
|
||||
|
||||
/// Deletes the given program.
|
||||
///
|
||||
/// The default implementation doesn't do anything and returns false. The derived classes
|
||||
/// may override this behaviour with something meaningful. These implementation should take
|
||||
/// care of only such programs can be deleted by a device which are associated with it.
|
||||
virtual bool deleteProgram(Program* program);
|
||||
|
||||
/// Returns if the device supports tensor export or not.
|
||||
///
|
||||
/// The default implementation doesn't do anything and returns false. The derived classes
|
||||
/// may override this behaviour with something meaningful.
|
||||
virtual bool tensorExportSupported() const;
|
||||
|
||||
/// Sets if the selftest should be executed
|
||||
/// before a program or not.
|
||||
/// Returns true if the operation was successful.
|
||||
virtual bool setSelftestExecutionPolicy(aiwSelftestExecutionPolicy policy);
|
||||
|
||||
/// Returns the selftest execution policy.
|
||||
/// If the operation was successful, then the policy
|
||||
/// will be stored in the policy parameter.
|
||||
/// Returns true if the operation was successful.
|
||||
virtual bool selftestExecutionPolicy(aiwSelftestExecutionPolicy& policy) const;
|
||||
|
||||
/// Manually executes the selftest program.
|
||||
/// Return value is the same as the execute() method.
|
||||
virtual Status executeSelftest();
|
||||
|
||||
protected:
|
||||
Device();
|
||||
};
|
||||
|
||||
/// Internal helper for implementing RAII style raw buffer pointer management.
|
||||
///
|
||||
/// #BufferPtr will call the #acquire method during its construction, which will
|
||||
/// get a raw pointer. This pointer will be released in the destructor by calling
|
||||
/// this class' #release method.
|
||||
///
|
||||
/// If the buffer is pinned, then the #acquire method shall return the same pointer
|
||||
/// each time it's called.
|
||||
class AIWARE_RUNTIME_INF_LIB_CPP_EXPORT BufferOperations
|
||||
{
|
||||
public:
|
||||
virtual ~BufferOperations();
|
||||
|
||||
BufferOperations(const BufferOperations&) = delete;
|
||||
BufferOperations(BufferOperations&&) = delete;
|
||||
|
||||
BufferOperations& operator=(const BufferOperations&) = delete;
|
||||
BufferOperations& operator=(BufferOperations&&) = delete;
|
||||
|
||||
/// Returns the size of the buffer in bytes.
|
||||
virtual uint64_t size() = 0;
|
||||
|
||||
/// Gets the raw pointer to a buffer which can be used until
|
||||
/// the #release method is called (unless it's a pinned buffer).
|
||||
virtual void* acquire() = 0;
|
||||
|
||||
/// Releases the acquired pointer which shouldn't be used anymore
|
||||
/// (unless it's a pinned buffer).
|
||||
virtual void release() = 0;
|
||||
|
||||
/// If returns true, then #acquire method shall return the same pointer
|
||||
/// every time, and this pointer can be cached. Otherwise the #acquire
|
||||
/// may return different pointers, and they can be used only until #release
|
||||
/// is called.
|
||||
virtual bool pinned() const = 0;
|
||||
|
||||
protected:
|
||||
BufferOperations();
|
||||
};
|
||||
|
||||
/// Wrapper class for a buffers memory location.
|
||||
///
|
||||
/// Don't store the raw pointer this object can be casted to unless the
|
||||
/// parent buffer is a pinned one.
|
||||
///
|
||||
/// The const version of this object has only const conversion operators,
|
||||
/// while the non-const version has both.
|
||||
///
|
||||
/// The class has conversion operator for multiple raw pointer types, but
|
||||
/// it doesn't change the basic data type of the buffer, which can be
|
||||
/// queried from the #Buffer class.
|
||||
template<bool Const>
|
||||
class AIWARE_RUNTIME_INF_LIB_CPP_EXPORT BufferPtr final
|
||||
{
|
||||
public:
|
||||
BufferPtr() = delete;
|
||||
BufferPtr(const BufferPtr&) = delete;
|
||||
BufferPtr(BufferPtr&& other) noexcept;
|
||||
|
||||
BufferPtr& operator=(const BufferPtr&) = delete;
|
||||
BufferPtr& operator=(BufferPtr&&) noexcept;
|
||||
|
||||
~BufferPtr();
|
||||
|
||||
operator const void*() const;
|
||||
|
||||
operator const uint8_t*() const;
|
||||
|
||||
operator const int8_t*() const;
|
||||
|
||||
operator const char*() const;
|
||||
|
||||
operator const float*() const;
|
||||
|
||||
template<bool B = Const, typename = typename std::enable_if<!B, void*>::type>
|
||||
operator void*()
|
||||
{
|
||||
return _ptr;
|
||||
}
|
||||
|
||||
template<bool B = Const, typename = typename std::enable_if<!B, uint8_t*>::type>
|
||||
operator uint8_t*()
|
||||
{
|
||||
return static_cast<uint8_t*>(_ptr);
|
||||
}
|
||||
|
||||
template<bool B = Const, typename = typename std::enable_if<!B, int8_t*>::type>
|
||||
operator int8_t*()
|
||||
{
|
||||
return static_cast<int8_t*>(_ptr);
|
||||
}
|
||||
|
||||
template<bool B = Const, typename = typename std::enable_if<!B, char*>::type>
|
||||
operator char*()
|
||||
{
|
||||
return static_cast<char*>(_ptr);
|
||||
}
|
||||
|
||||
template<bool B = Const, typename = typename std::enable_if<!B, float*>::type>
|
||||
operator float*()
|
||||
{
|
||||
return static_cast<float*>(_ptr);
|
||||
}
|
||||
|
||||
private:
|
||||
BufferPtr(BufferOperations& ops);
|
||||
|
||||
friend class Buffer;
|
||||
|
||||
private:
|
||||
BufferOperations* _ops = nullptr;
|
||||
void* _ptr = nullptr;
|
||||
};
|
||||
|
||||
/// Represents a data buffer associated with a tensor.
|
||||
///
|
||||
/// Through such an object the content of the tensor can be manipulated
|
||||
/// directly. To do so, the layout of th buffer's data (the ordering) must
|
||||
/// be taken into account. This ordering can be queried by the #ordering
|
||||
/// method.
|
||||
///
|
||||
/// However aiWare like devices usually use int8 arithmetic, these buffer
|
||||
/// can represent float data too if that's how the implementation defines.
|
||||
/// In this case take care of using the #size method, which always returns
|
||||
/// the size of the buffer in bytes instead of the element count.
|
||||
///
|
||||
/// The actual memory behind the buffer can be get by the #ptr functions
|
||||
/// (const and non-const). Instead of returning actual raw pointers these
|
||||
/// functions return wrapper objects, which can be casted to pointers. The
|
||||
/// reason for this is these buffers may not pinned to a specific memory
|
||||
/// location but changes time to time. These wrappers manage the acquiring
|
||||
/// and releasing of these raw buffer in a RAII style. Thus the raw pointers
|
||||
/// coming from these wrappers shouldn't be cached or stored, unless the
|
||||
/// buffer is pinned (which means the buffer location doesn't change), so
|
||||
/// it can be safely stored and used.
|
||||
class AIWARE_RUNTIME_INF_LIB_CPP_EXPORT Buffer
|
||||
{
|
||||
public:
|
||||
using ConstPtr = BufferPtr<true>;
|
||||
using Ptr = BufferPtr<false>;
|
||||
|
||||
enum class Ordering : std::uint8_t
|
||||
{
|
||||
TileBase,
|
||||
CellRowBased,
|
||||
RowMajor
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~Buffer();
|
||||
|
||||
Buffer(const Buffer&) = delete;
|
||||
Buffer& operator=(const Buffer&) = delete;
|
||||
Buffer(Buffer&&) = delete;
|
||||
Buffer& operator=(Buffer&&) = delete;
|
||||
|
||||
/// Returns the size of the buffer in bytes.
|
||||
virtual uint64_t size() const = 0;
|
||||
|
||||
/// Returns the ordering of the underlying buffer.
|
||||
virtual Ordering ordering() const = 0;
|
||||
|
||||
/// Returns whether the buffer is pinned (fixed location) or not.
|
||||
bool pinned() const;
|
||||
|
||||
/// Returns a const pointer to the underlying raw buffer.
|
||||
ConstPtr ptr() const;
|
||||
|
||||
/// Returns a non-const pointer to the underlying raw buffer.
|
||||
Ptr ptr();
|
||||
|
||||
protected:
|
||||
Buffer();
|
||||
|
||||
virtual const BufferOperations& bufferOperations() const = 0;
|
||||
virtual BufferOperations& bufferOperations() = 0;
|
||||
};
|
||||
|
||||
/// Represents an external memory descriptor for an aiWare memory tensor.
|
||||
///
|
||||
/// This object is used to store the export or import descriptors ofthe physical memory of
|
||||
/// a given tensor. The descriptor can be used by other accelerators to access the memory area.
|
||||
///
|
||||
/// The descriptor is hardware platform and operating system specific.
|
||||
class AIWARE_RUNTIME_INF_LIB_CPP_EXPORT ExternalMemoryDescriptor final
|
||||
{
|
||||
public:
|
||||
ExternalMemoryDescriptor();
|
||||
|
||||
ExternalMemoryDescriptor(const ExternalMemoryDescriptor&);
|
||||
ExternalMemoryDescriptor(ExternalMemoryDescriptor&&) noexcept;
|
||||
|
||||
ExternalMemoryDescriptor& operator=(const ExternalMemoryDescriptor&);
|
||||
ExternalMemoryDescriptor& operator=(ExternalMemoryDescriptor&&) noexcept;
|
||||
|
||||
/// Returns the status of the descriptor, true if it's valid, false otherwise.
|
||||
operator bool() const;
|
||||
/// @brief Returns the descriptor to be used by other accelerators.
|
||||
/// @return The platform-dependent descriptor object.
|
||||
void* descriptor() const;
|
||||
|
||||
private:
|
||||
ExternalMemoryDescriptor(bool status, void* descriptor = nullptr);
|
||||
|
||||
friend class Tensor;
|
||||
|
||||
private:
|
||||
bool _status = false;
|
||||
void* _descriptor = nullptr;
|
||||
};
|
||||
|
||||
/// Represents a tensor of the neural network.
|
||||
///
|
||||
/// Tensor interface has 3 group of member functions: the first group
|
||||
/// is the property getter functions. Note that some of these functions
|
||||
/// may not implemented by the derived classes.
|
||||
///
|
||||
/// The second group of method provide an easy way to get or set the
|
||||
/// tensor's data. These methods take an int8/uint8 or float buffer in
|
||||
/// NCHW order and copy the data from it into the internal buffer or
|
||||
/// vice versa, regardless of the internal data representation or layout.
|
||||
/// All subclass must properly implement these methods.
|
||||
///
|
||||
/// The subclasses also shall provide access to these internal buffers,
|
||||
/// where the data is actually stored. The third group of methods serve
|
||||
/// this purpose.
|
||||
class AIWARE_RUNTIME_INF_LIB_CPP_EXPORT Tensor
|
||||
{
|
||||
public:
|
||||
enum class DataType : std::uint8_t
|
||||
{
|
||||
Int8,
|
||||
Float32
|
||||
};
|
||||
|
||||
public:
|
||||
virtual ~Tensor();
|
||||
|
||||
Tensor(const Tensor&) = delete;
|
||||
Tensor(Tensor&&) = delete;
|
||||
Tensor& operator=(const Tensor&) = delete;
|
||||
Tensor& operator=(Tensor&&) = delete;
|
||||
|
||||
/// Returns the id of the buffer if implemented, otherwise returns 0.
|
||||
virtual uint32_t id() const;
|
||||
|
||||
/// Returns the name of the buffer if implemented, otherwise returns
|
||||
/// an empty string.
|
||||
virtual const std::string& name() const;
|
||||
|
||||
/// Returns the dimension of tensor if implemented, otherwise returns
|
||||
/// an invalid dimension object (all dimensions are 0).
|
||||
virtual const aiwTensorDimensions& dim() const;
|
||||
|
||||
/// Returns the original dimension of the tensor if implemented,
|
||||
/// otherwise returns an empty vector.
|
||||
///
|
||||
/// The original dimension is the one can be found in the original
|
||||
/// network descriptor file (i.e. NNEF graph file), not affected by
|
||||
/// any transformations.
|
||||
virtual std::vector<uint32_t> originalDim() const;
|
||||
|
||||
/// Returns the data type of the buffer if implemented, otherwise
|
||||
/// returns DataType::Int8.
|
||||
virtual DataType dataType() const;
|
||||
|
||||
/// Returns the sign of the tensor, or false if it's not implemented
|
||||
/// in the subclasses. It also may return dummy value if the tensor's
|
||||
/// data type is float.
|
||||
virtual bool sign() const;
|
||||
|
||||
/// Returns the exponent of the tensor, or 0 if it's not implemented
|
||||
/// in the subclasses. It also may return dummy value if the tensor's
|
||||
/// data type is float.
|
||||
virtual int8_t exponent() const;
|
||||
|
||||
/// Returns the size of the elements in the tensor.
|
||||
///
|
||||
/// Always returns a positive number, otherwise some error happened.
|
||||
/// Note that it usually doesn't return the same number as #Buffer::size.
|
||||
virtual uint32_t nchwSize() const = 0;
|
||||
|
||||
/// Sets the tensor's data from the passed NCHW ordered buffer, and
|
||||
/// returns true if it was successful.
|
||||
///
|
||||
/// The passed buffer can't be null and must be at least #nchwSize element
|
||||
/// large.
|
||||
///
|
||||
/// If the tensor's data type is float, then the function should do
|
||||
/// anything, just return with false.
|
||||
virtual bool setDataNCHW(const uint8_t* data) = 0;
|
||||
|
||||
/// Sets the tensor's data from the passed NCHW ordered buffer, and
|
||||
/// returns true if it was successful.
|
||||
///
|
||||
/// The passed buffer can't be null and must be at least #nchwSize element
|
||||
/// large.
|
||||
///
|
||||
/// This function always shall be properly implemented. If the tensor's
|
||||
/// data type is int8, then he values will be quantized, otherwise simple
|
||||
/// copy will be performed.
|
||||
virtual bool setDataNCHW(const float* data) = 0;
|
||||
|
||||
/// Same as int8 variant of #setDataNCHW except if fills the passed buffer
|
||||
/// with the tensor's data.
|
||||
virtual bool getDataNCHW(uint8_t* data) const = 0;
|
||||
|
||||
/// Same as float variant of #setDataNCHW except if fills the passed buffer
|
||||
/// with the tensor's data.
|
||||
virtual bool getDataNCHW(float* data) const = 0;
|
||||
|
||||
/// Returns the buffer to the underlying raw data.
|
||||
virtual const Buffer& rawBuffer() const = 0;
|
||||
|
||||
/// Returns the buffer to the underlying raw data.
|
||||
virtual Buffer& rawBuffer() = 0;
|
||||
|
||||
/// Exports the tensor's memory descriptor.
|
||||
virtual ExternalMemoryDescriptor exportMemory();
|
||||
|
||||
/// Releases the memory descriptor, optional.
|
||||
virtual bool releaseExportedMemory(ExternalMemoryDescriptor& descriptor);
|
||||
|
||||
protected:
|
||||
Tensor();
|
||||
|
||||
ExternalMemoryDescriptor createExtMemDescriptor(bool status, void* desc);
|
||||
|
||||
private:
|
||||
static const std::string _sDummyName;
|
||||
static const aiwTensorDimensions _sDummyDim;
|
||||
};
|
||||
|
||||
/// Represents a return status code of an operation where the status can differ from success or error.
|
||||
/// The status code can be used to determine the result of an operation but is also compatible with
|
||||
/// the "classical" SUCCESS/ERROR status codes.
|
||||
class AIWARE_RUNTIME_INF_LIB_CPP_EXPORT Status final
|
||||
{
|
||||
public:
|
||||
Status();
|
||||
Status(aiw_status s);
|
||||
Status(bool s);
|
||||
|
||||
Status(const Status&);
|
||||
Status(Status&&) noexcept;
|
||||
|
||||
Status& operator=(const Status&);
|
||||
Status& operator=(Status&&) noexcept;
|
||||
|
||||
aiw_status statusCode() const;
|
||||
|
||||
bool success() const;
|
||||
bool error() const;
|
||||
bool timeout() const;
|
||||
|
||||
operator bool() const;
|
||||
|
||||
private:
|
||||
aiw_status _s;
|
||||
};
|
||||
|
||||
/// Represents and executable neural network workload associated
|
||||
/// with a device.
|
||||
class AIWARE_RUNTIME_INF_LIB_CPP_EXPORT Program
|
||||
{
|
||||
public:
|
||||
virtual ~Program();
|
||||
|
||||
Program(const Program&) = delete;
|
||||
Program(Program&&) = delete;
|
||||
Program& operator=(const Program&) = delete;
|
||||
Program& operator=(Program&&) = delete;
|
||||
|
||||
/// Number of the input tensor, shall return a positive number,
|
||||
/// otherwise some error happened.
|
||||
virtual uint32_t inputTensorCount() const = 0;
|
||||
|
||||
/// Returns the input tensor identified by the given index, or nullptr
|
||||
/// if index is out of range.
|
||||
virtual const Tensor* inputTensor(uint32_t index) const = 0;
|
||||
|
||||
/// Returns the input tensor identified by the given index, or nullptr
|
||||
/// if index is out of range.
|
||||
virtual Tensor* inputTensor(uint32_t) = 0;
|
||||
|
||||
/// Number of the output tensor, shall return a positive number,
|
||||
/// otherwise some error happened.
|
||||
virtual uint32_t outputTensorCount() const = 0;
|
||||
|
||||
/// Returns the output tensor identified by the given index, or nullptr
|
||||
/// if index is out of range.
|
||||
virtual const Tensor* outputTensor(uint32_t index) const = 0;
|
||||
|
||||
/// Returns the output tensor identified by the given index, or nullptr
|
||||
/// if index is out of range.
|
||||
virtual Tensor* outputTensor(uint32_t) = 0;
|
||||
|
||||
/// Executes the workload, and returns the status.
|
||||
virtual Status execute() = 0;
|
||||
|
||||
/// Starts the execution of the workload without blocking, and returns the status.
|
||||
virtual Status executeAsync();
|
||||
|
||||
/// Waits for the execution of the workload to finish, and returns the status.
|
||||
virtual Status await();
|
||||
|
||||
/// Checks if program supports asynchronous execution.
|
||||
virtual bool asyncExecutionSupported() const;
|
||||
|
||||
/// Synchronizes the input tensors data between the host and the
|
||||
/// device (from the host to the device) if necessary.
|
||||
virtual Status uploadInputs() = 0;
|
||||
|
||||
/// Synchronizes the output tensors data between the host and the
|
||||
/// device (from the device to the host) if necessary.
|
||||
virtual Status downloadOutputs() = 0;
|
||||
|
||||
/// Returns whether setting memory transfer timeout is supported.
|
||||
virtual bool memoryTransferTimeoutSupported() const;
|
||||
|
||||
/// Returns whether setting execution timeout is supported.
|
||||
virtual bool executionTimeoutSupported() const;
|
||||
|
||||
/// Sets the memory transfer (DMA) timeout. Timeout 0 means no timeout.
|
||||
/// Returns true if the operation was successful.
|
||||
/// If memory transfer timeout isn't supported, then it always return false.
|
||||
virtual bool setMemoryTransferTimeout(uint32_t transferTimeoutMs);
|
||||
|
||||
/// Sets the program execution timeout. Timeout 0 means no timeout.
|
||||
/// Returns true if the operation was successful.
|
||||
/// If execution timeout isn't supported, then it always return false.
|
||||
virtual bool setExecutionTimeout(uint32_t executionTimeoutMs);
|
||||
|
||||
/// Gets the memory transfer (DMA) timeout.
|
||||
/// Returns true if the operation was successful.
|
||||
/// If memory transfer timeout isn't supported, then it always return false.
|
||||
virtual bool getMemoryTransferTimeout(uint32_t& transferTimeoutMs) const;
|
||||
|
||||
/// Gets the program execution timeout.
|
||||
/// Returns true if the operation was successful.
|
||||
/// If execution timeout isn't supported, then it always return false.
|
||||
virtual bool getExecutionTimeout(uint32_t& executionTimeoutMs) const;
|
||||
|
||||
/// Fine-grained selftest control.
|
||||
/// If the selftest is enabled, then it will be executed
|
||||
/// according to the device policy. If it's disabled, then
|
||||
/// it won't be executed, regardless the policy - useful
|
||||
/// for performance reasons when multiple networks are executed for a
|
||||
/// single frame. By default the selftest is enabled.
|
||||
/// Returns true if the operation was successful.
|
||||
|
||||
virtual bool enableSelftest(bool enabled);
|
||||
|
||||
protected:
|
||||
Program();
|
||||
};
|
||||
|
||||
} // namespace inf
|
||||
} // namespace runtime
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_RUNTIME__RUNTIME_INF_HPP
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
** Copyright (c) AImotive Kft. 2020
|
||||
**
|
||||
** The intellectual and technical concepts and implementations contained herein (including
|
||||
** data structures, algorithms and essential business logic developed by AImotive Kft.) are
|
||||
** proprietary to AImotive Kft., and may be covered by patents, and/or copyright law. This
|
||||
** hardware or software is protected by trade secret, confidential business secret and as a
|
||||
** general principle must be treated as confidential information.
|
||||
**
|
||||
** You may not use this hardware or software without specific prior written permission
|
||||
** obtained from AImotive Kft.
|
||||
**
|
||||
** Access to this hardware or software is hereby forbidden to anyone except for Contracted
|
||||
** Partners who have prior signed License Agreement, or Confidentiality, Non-Disclosure
|
||||
** Agreements or any other equivalent Agreements explicitly covering such access and use.
|
||||
**
|
||||
** UNLESS OTHERWISE AGREED, THIS HARDWARE OR SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS
|
||||
** OR IMPLIED WARRANTIES, INCLUDING - BUT NOT LIMITED TO - THE IMPLIED WARRANTIES OF
|
||||
** MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||
*/
|
||||
|
||||
#ifndef AIWARE_RUNTIME_COMMON_CPP__VERSION_HPP
|
||||
#define AIWARE_RUNTIME_COMMON_CPP__VERSION_HPP
|
||||
|
||||
#include "aiware/common/cpp/moduleversion.hpp"
|
||||
#include "aiware/runtime/cpp/aiware-runtime-common-lib-cpp_export.h"
|
||||
|
||||
namespace aiware
|
||||
{
|
||||
namespace runtime
|
||||
{
|
||||
|
||||
/// Returns the version info of the library.
|
||||
AIWARE_RUNTIME_COMMON_LIB_CPP_EXPORT aiware::common::ModuleVersion version();
|
||||
|
||||
} // namespace runtime
|
||||
} // namespace aiware
|
||||
|
||||
#endif //AIWARE_RUNTIME_COMMON_CPP__VERSION_HPP
|
||||
Binary file not shown.
@ -0,0 +1,40 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2024 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : ADAS_LD_Lib.h
|
||||
*
|
||||
* @brief : ADAS LD library header
|
||||
*
|
||||
* @author : AI SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2024.
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2024. / 1.0.0 / Initial released.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __ADAS_LD_LIB_H__
|
||||
#define __ADAS_LD_LIB_H__
|
||||
|
||||
|
||||
extern int NC_ADAS_OPEN(void);
|
||||
extern int NC_ADAS_CLOSE(void);
|
||||
|
||||
extern void *ld_task(void *arg);
|
||||
|
||||
extern void draw_ld_output_opengl(void);
|
||||
extern void ld_opengl_program_set(void *prog);
|
||||
|
||||
#endif // __ADAS_LD_LIB_H__
|
||||
Binary file not shown.
Binary file not shown.
@ -0,0 +1,180 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_ts_circular_buffers.c
|
||||
*
|
||||
* @brief : nc_ts_circular_buffers source (thread-safe circular buffers)
|
||||
* for single producer / consumer
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.08.09
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.08.09 / 1.0.0 / Initial released. (bwryu@nextchip)
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
********************************************************************************
|
||||
* INCLUDES
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#include "nc_ts_circular_buffers.h"
|
||||
|
||||
// #define PRINT_DEBUG
|
||||
|
||||
#define MAX_TSB_CNT (20)
|
||||
|
||||
/**
|
||||
* @brief buffer management
|
||||
*
|
||||
*/
|
||||
|
||||
int g_buf_tcnt[MAX_TSB_CNT] = {0,};
|
||||
int g_buf_size[MAX_TSB_CNT] = {0,};
|
||||
uint64_t g_head[MAX_TSB_CNT] = {0,};
|
||||
uint64_t g_tail[MAX_TSB_CNT] = {0,};
|
||||
|
||||
typedef struct {
|
||||
void* data_ptr;
|
||||
size_t data_size;
|
||||
} s_element;
|
||||
|
||||
pthread_spinlock_t g_write_spinlock[MAX_TSB_CNT];
|
||||
s_element g_circular_queue[MAX_TSB_CNT][MAX_CBQ_BUF_CNT] = {{{NULL,0},},};
|
||||
|
||||
void lock_cb_write_spinlock(int owner) { pthread_spin_lock(&g_write_spinlock[owner]); }
|
||||
void unlock_cb_write_spinlock(int owner) { pthread_spin_unlock(&g_write_spinlock[owner]); }
|
||||
|
||||
int nc_tscb_create_buffers(unsigned int owner, int max_cnt, int buf_max_size)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
|
||||
if (max_cnt > (int)MAX_CBQ_BUF_CNT) {
|
||||
#ifdef PRINT_DEBUG
|
||||
printf("[error] can't create thread-safe circular buffer : max count(%d) > pre-defined max buffer count (%d)\n", max_cnt, (int)MAX_CBQ_BUF_CNT);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_buf_tcnt[owner] = max_cnt;
|
||||
g_buf_size[owner] = buf_max_size;
|
||||
g_tail[owner] = 0;
|
||||
g_head[owner] = 0;
|
||||
pthread_spin_init(&g_write_spinlock[owner], 0);
|
||||
|
||||
for (int i = 0; i < g_buf_tcnt[owner]; i++) {
|
||||
g_circular_queue[owner][i].data_ptr = malloc(g_buf_size[owner]);
|
||||
g_circular_queue[owner][i].data_size = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nc_tscb_destroy_buffers(unsigned int owner)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return;
|
||||
|
||||
lock_cb_write_spinlock(owner);
|
||||
g_buf_tcnt[owner] = 0;
|
||||
g_buf_size[owner] = 0;
|
||||
g_tail[owner] = 0;
|
||||
g_head[owner] = 0;
|
||||
for (int i = 0; i < g_buf_tcnt[owner]; i++) {
|
||||
if (g_circular_queue[owner][i].data_ptr) {
|
||||
free(g_circular_queue[owner][i].data_ptr);
|
||||
g_circular_queue[owner][i].data_ptr = NULL;
|
||||
g_circular_queue[owner][i].data_size = 0;
|
||||
}
|
||||
}
|
||||
unlock_cb_write_spinlock(owner);
|
||||
|
||||
pthread_spin_destroy(&g_write_spinlock[owner]);
|
||||
}
|
||||
|
||||
int nc_tscb_max_count (unsigned int owner)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
return g_buf_tcnt[owner];
|
||||
}
|
||||
|
||||
int nc_tscb_current_count (unsigned int owner)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
return g_tail[owner] - g_head[owner];
|
||||
}
|
||||
|
||||
int nc_tscb_max_buf_size(unsigned int owner)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
return g_buf_size[owner];
|
||||
}
|
||||
|
||||
int nc_tscb_enqueue(unsigned int owner, void* data, size_t size)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
if (!data || size == 0) return -1;
|
||||
|
||||
lock_cb_write_spinlock(owner);
|
||||
int tail = g_tail[owner];
|
||||
int head = g_head[owner];
|
||||
|
||||
if ((tail - head) >= g_buf_tcnt[owner]) {
|
||||
#ifdef PRINT_DEBUG
|
||||
// queue is full
|
||||
printf("[error] queue is full : tail(%d) - head(%d) >= g_buf_tcnt(%d) --- c_cnt(%d)\n", tail, head, g_buf_tcnt[owner], tail - head);
|
||||
#endif
|
||||
unlock_cb_write_spinlock(owner);
|
||||
return -1;
|
||||
}
|
||||
|
||||
int c_idx = tail % g_buf_tcnt[owner];
|
||||
memcpy(g_circular_queue[owner][c_idx].data_ptr, data, size);
|
||||
g_circular_queue[owner][c_idx].data_size = size;
|
||||
|
||||
g_tail[owner]++;
|
||||
|
||||
unlock_cb_write_spinlock(owner);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nc_tscb_dequeue(unsigned int owner, void* ret_data, size_t *ret_size)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
if (!ret_data) return -1;
|
||||
|
||||
lock_cb_write_spinlock(owner);
|
||||
int tail = g_tail[owner];
|
||||
unlock_cb_write_spinlock(owner);
|
||||
int head = g_head[owner];
|
||||
|
||||
if (head == tail) {
|
||||
#ifdef PRINT_DEBUG
|
||||
// queue is empty
|
||||
printf("[error] queue is empty : tail(%d) head(%d) c_cnt(%d)\n", tail, head, tail - head);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
int c_idx = head % g_buf_tcnt[owner];
|
||||
memcpy(ret_data, g_circular_queue[owner][c_idx].data_ptr, g_circular_queue[owner][c_idx].data_size);
|
||||
*ret_size = g_circular_queue[owner][c_idx].data_size;
|
||||
|
||||
g_head[owner]++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_ts_circular_buffers.h
|
||||
*
|
||||
* @brief : nc_ts_circular_buffers header (thread-safe circular buffers)
|
||||
* for single producer / consumer
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.08.09
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.08.09 / 1.0.0 / Initial released. (bwryu@nextchip)
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef NC_TS_CIRCULAR_BUFFERS_H
|
||||
#define NC_TS_CIRCULAR_BUFFERS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
#define MAX_CBQ_BUF_CNT (10)
|
||||
|
||||
extern int nc_tscb_create_buffers (unsigned int owner, int max_cnt, int buf_max_size);
|
||||
extern void nc_tscb_destroy_buffers (unsigned int owner);
|
||||
|
||||
extern int nc_tscb_max_count (unsigned int owner);
|
||||
extern int nc_tscb_current_count (unsigned int owner);
|
||||
extern int nc_tscb_max_buf_size (unsigned int owner);
|
||||
|
||||
extern int nc_tscb_enqueue (unsigned int owner, void* data, size_t size);
|
||||
extern int nc_tscb_dequeue (unsigned int owner, void* ret_data, size_t *ret_size);
|
||||
|
||||
#endif // #ifndef NC_TS_CIRCULAR_BUFFERS_H
|
||||
@ -0,0 +1,148 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_ts_flipflop_buffers.c
|
||||
*
|
||||
* @brief : nc thread-safe flip-flop buffers source (max 10 instances available)
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.08.09
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.08.09 / 1.0.0 / Initial released. (bwryu@nextchip)
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
********************************************************************************
|
||||
* INCLUDES
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#include "nc_ts_flipflop_buffers.h"
|
||||
#include "nc_utils.h"
|
||||
|
||||
// define
|
||||
#define MAX_TSB_CNT (20)
|
||||
|
||||
typedef struct {
|
||||
int buf_size;
|
||||
int write_idx;
|
||||
int read_idx;
|
||||
void* buffer_ptr[FIXED_FLIP_FLOP_BUF_CNT];
|
||||
pthread_spinlock_t read_spinlock;
|
||||
pthread_spinlock_t write_spinlock;
|
||||
} s_tsff_element;
|
||||
|
||||
// variable
|
||||
s_tsff_element g_tsff_buf_arr[MAX_TSB_CNT];
|
||||
|
||||
// function
|
||||
void lock_tsff_read_spinlock(int owner) { pthread_spin_lock(&g_tsff_buf_arr[owner].read_spinlock); }
|
||||
void unlock_tsff_read_spinlock(int owner) { pthread_spin_unlock(&g_tsff_buf_arr[owner].read_spinlock); }
|
||||
void lock_tsff_write_spinlock(int owner) { pthread_spin_lock(&g_tsff_buf_arr[owner].write_spinlock); }
|
||||
void unlock_tsff_write_spinlock(int owner) { pthread_spin_unlock(&g_tsff_buf_arr[owner].write_spinlock); }
|
||||
|
||||
// owner value range : 0 ~ (MAX_TSB_CNT-1)
|
||||
int nc_tsff_create_buffers(unsigned int owner, int each_buf_size)
|
||||
{
|
||||
if(owner >= (int)MAX_TSB_CNT) {
|
||||
printf("[Error] fail to create tsff buffer...\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_tsff_buf_arr[owner].buf_size = each_buf_size;
|
||||
g_tsff_buf_arr[owner].write_idx = -1;
|
||||
g_tsff_buf_arr[owner].read_idx = -1;
|
||||
pthread_spin_init(&g_tsff_buf_arr[owner].read_spinlock, 0);
|
||||
pthread_spin_init(&g_tsff_buf_arr[owner].write_spinlock, 0);
|
||||
for (int i = 0; i < FIXED_FLIP_FLOP_BUF_CNT; i++) {
|
||||
g_tsff_buf_arr[owner].buffer_ptr[i] = malloc(g_tsff_buf_arr[owner].buf_size);
|
||||
}
|
||||
|
||||
printf("[Info] %s() called... owner(%d) each buffer size(%d)....\n", __FUNCTION__, owner, each_buf_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nc_tsff_destroy_buffers(unsigned int owner)
|
||||
{
|
||||
g_tsff_buf_arr[owner].buf_size = 0;
|
||||
g_tsff_buf_arr[owner].write_idx = -1;
|
||||
g_tsff_buf_arr[owner].read_idx = -1;
|
||||
pthread_spin_destroy(&g_tsff_buf_arr[owner].read_spinlock);
|
||||
pthread_spin_destroy(&g_tsff_buf_arr[owner].write_spinlock);
|
||||
for (int i = 0; i < FIXED_FLIP_FLOP_BUF_CNT; i++) {
|
||||
if (g_tsff_buf_arr[owner].buffer_ptr[i]) {
|
||||
free(g_tsff_buf_arr[owner].buffer_ptr[i]);
|
||||
g_tsff_buf_arr[owner].buffer_ptr[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void* nc_tsff_get_addr_of_buffer(unsigned int owner, int idx)
|
||||
{
|
||||
lock_tsff_write_spinlock(owner);
|
||||
if (idx >= (int)FIXED_FLIP_FLOP_BUF_CNT) {
|
||||
unlock_tsff_write_spinlock(owner);
|
||||
return NULL;
|
||||
}
|
||||
void *ptr = g_tsff_buf_arr[owner].buffer_ptr[idx];
|
||||
unlock_tsff_write_spinlock(owner);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
int nc_tsff_get_buf_size (unsigned int owner)
|
||||
{
|
||||
return g_tsff_buf_arr[owner].buf_size;
|
||||
}
|
||||
|
||||
// for reading
|
||||
void* nc_tsff_get_readable_buffer(unsigned int owner)
|
||||
{
|
||||
lock_tsff_read_spinlock(owner);
|
||||
if (g_tsff_buf_arr[owner].read_idx < 0) {
|
||||
return NULL;
|
||||
}
|
||||
return g_tsff_buf_arr[owner].buffer_ptr[g_tsff_buf_arr[owner].read_idx];
|
||||
}
|
||||
|
||||
void nc_tsff_finish_read_buf(unsigned int owner)
|
||||
{
|
||||
unlock_tsff_read_spinlock(owner);
|
||||
}
|
||||
|
||||
// for writing
|
||||
void* nc_tsff_get_writable_buffer (unsigned int owner, int* ret_idx)
|
||||
{
|
||||
lock_tsff_write_spinlock(owner);
|
||||
|
||||
if (g_tsff_buf_arr[owner].write_idx < 0) {
|
||||
g_tsff_buf_arr[owner].write_idx = 0;
|
||||
}
|
||||
*ret_idx = g_tsff_buf_arr[owner].write_idx;
|
||||
|
||||
return g_tsff_buf_arr[owner].buffer_ptr[*ret_idx];
|
||||
}
|
||||
|
||||
void nc_tsff_finish_write_buf(unsigned int owner)
|
||||
{
|
||||
lock_tsff_read_spinlock(owner);
|
||||
g_tsff_buf_arr[owner].read_idx = g_tsff_buf_arr[owner].write_idx;
|
||||
unlock_tsff_read_spinlock(owner);
|
||||
|
||||
g_tsff_buf_arr[owner].write_idx = (g_tsff_buf_arr[owner].write_idx + 1) % FIXED_FLIP_FLOP_BUF_CNT;
|
||||
|
||||
unlock_tsff_write_spinlock(owner);
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_ts_flipflop_buffers.h
|
||||
*
|
||||
* @brief : nc thread-safe flip-flop buffers header (max 10 instances available)
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.08.09
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.08.09 / 1.0.0 / Initial released. (bwryu@nextchip)
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef NC_TS_FLIPFLOP_BUFFERS_H
|
||||
#define NC_TS_FLIPFLOP_BUFFERS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
#define FIXED_FLIP_FLOP_BUF_CNT (2)
|
||||
|
||||
extern int nc_tsff_create_buffers (unsigned int owner, int each_buf_size);
|
||||
extern void nc_tsff_destroy_buffers (unsigned int owner);
|
||||
extern void* nc_tsff_get_addr_of_buffer (unsigned int owner, int idx);
|
||||
extern int nc_tsff_get_buf_size (unsigned int owner);
|
||||
|
||||
// for read
|
||||
extern void* nc_tsff_get_readable_buffer (unsigned int owner);
|
||||
extern void nc_tsff_finish_read_buf (unsigned int owner);
|
||||
|
||||
// for write
|
||||
extern void* nc_tsff_get_writable_buffer (unsigned int owner, int* ret_idx);
|
||||
extern void nc_tsff_finish_write_buf (unsigned int owner);
|
||||
|
||||
#endif // #ifndef NC_TS_FLIPFLOP_BUFFERS_H
|
||||
@ -0,0 +1,204 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_ts_fsync_circular_buffers.c
|
||||
*
|
||||
* @brief : nc_ts_fsync_circular_buffers source (thread-safe circular buffers)
|
||||
* for single producer / consumer
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.08.09
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.08.09 / 1.0.0 / Initial released. (bwryu@nextchip)
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
********************************************************************************
|
||||
* INCLUDES
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#include "nc_ts_fsync_circular_buffers.h"
|
||||
|
||||
// #define PRINT_DEBUG
|
||||
|
||||
#define MAX_TSB_CNT (20)
|
||||
|
||||
/**
|
||||
* @brief buffer management
|
||||
*
|
||||
*/
|
||||
|
||||
uint64_t g_fs_buf_tcnt[MAX_TSB_CNT] = {0,};
|
||||
uint64_t g_fs_buf_size[MAX_TSB_CNT] = {0,};
|
||||
uint64_t g_fs_head[MAX_TSB_CNT] = {0,};
|
||||
uint64_t g_fs_tail[MAX_TSB_CNT] = {0,};
|
||||
|
||||
pthread_spinlock_t g_fs_write_spinlock[MAX_TSB_CNT];
|
||||
stFrameElement g_fs_circular_queue[MAX_TSB_CNT][MAX_FSYNC_CBQ_BUF_CNT] = {{{0,0,NULL},},};
|
||||
|
||||
void lock_fscb_write_spinlock(int owner) { pthread_spin_lock(&g_fs_write_spinlock[owner]); }
|
||||
void unlock_fscb_write_spinlock(int owner) { pthread_spin_unlock(&g_fs_write_spinlock[owner]); }
|
||||
|
||||
int nc_tsfs_cb_create_buffers(unsigned int owner, int max_cnt, int buf_max_size)
|
||||
{
|
||||
uint64_t i = 0;
|
||||
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
|
||||
if (max_cnt > (int)MAX_FSYNC_CBQ_BUF_CNT) {
|
||||
#ifdef PRINT_DEBUG
|
||||
printf("[error] can't create thread-safe circular buffer : max count(%d) > pre-defined max buffer count (%d)\n", max_cnt, (int)MAX_FSYNC_CBQ_BUF_CNT);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_fs_buf_tcnt[owner] = max_cnt;
|
||||
g_fs_buf_size[owner] = buf_max_size;
|
||||
g_fs_tail[owner] = 0;
|
||||
g_fs_head[owner] = 0;
|
||||
pthread_spin_init(&g_fs_write_spinlock[owner], 0);
|
||||
|
||||
for (i = 0; i < g_fs_buf_tcnt[owner]; i++) {
|
||||
g_fs_circular_queue[owner][i].data_ptr = malloc(g_fs_buf_size[owner]);
|
||||
g_fs_circular_queue[owner][i].data_size = 0;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nc_tsfs_cb_destroy_buffers(unsigned int owner)
|
||||
{
|
||||
uint64_t i = 0;
|
||||
|
||||
if (owner >= MAX_TSB_CNT) return;
|
||||
|
||||
lock_fscb_write_spinlock(owner);
|
||||
g_fs_buf_tcnt[owner] = 0;
|
||||
g_fs_buf_size[owner] = 0;
|
||||
g_fs_tail[owner] = 0;
|
||||
g_fs_head[owner] = 0;
|
||||
for (i = 0; i < g_fs_buf_tcnt[owner]; i++) {
|
||||
if (g_fs_circular_queue[owner][i].data_ptr) {
|
||||
free(g_fs_circular_queue[owner][i].data_ptr);
|
||||
g_fs_circular_queue[owner][i].data_ptr = NULL;
|
||||
g_fs_circular_queue[owner][i].data_size = 0;
|
||||
}
|
||||
}
|
||||
unlock_fscb_write_spinlock(owner);
|
||||
|
||||
pthread_spin_destroy(&g_fs_write_spinlock[owner]);
|
||||
}
|
||||
|
||||
uint64_t nc_tsfs_cb_max_count (unsigned int owner)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
return g_fs_buf_tcnt[owner];
|
||||
}
|
||||
|
||||
uint64_t nc_tsfs_cb_current_count (unsigned int owner)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
return g_fs_tail[owner] - g_fs_head[owner];
|
||||
}
|
||||
|
||||
uint64_t nc_tsfs_cb_max_buf_size(unsigned int owner)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
return g_fs_buf_size[owner];
|
||||
}
|
||||
|
||||
int nc_tsfs_cb_enqueue(unsigned int owner, uint64_t time_stamp, void* data, size_t size)
|
||||
{
|
||||
uint64_t c_idx = 0;
|
||||
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
if (!data || size == 0) return -1;
|
||||
|
||||
lock_fscb_write_spinlock(owner);
|
||||
uint64_t tail = g_fs_tail[owner];
|
||||
uint64_t head = g_fs_head[owner];
|
||||
|
||||
if ((tail - head) >= g_fs_buf_tcnt[owner]) {
|
||||
#ifdef PRINT_DEBUG
|
||||
// queue is full
|
||||
printf("[error] queue is full : tail(%d) - head(%d) >= g_fs_buf_tcnt(%d) --- c_cnt(%d)\n", tail, head, g_fs_buf_tcnt[owner], tail - head);
|
||||
#endif
|
||||
unlock_fscb_write_spinlock(owner);
|
||||
return -1;
|
||||
}
|
||||
|
||||
c_idx = tail % g_fs_buf_tcnt[owner];
|
||||
g_fs_circular_queue[owner][c_idx].time_stamp = time_stamp;
|
||||
g_fs_circular_queue[owner][c_idx].data_size = size;
|
||||
memcpy(g_fs_circular_queue[owner][c_idx].data_ptr, data, size);
|
||||
|
||||
g_fs_tail[owner]++;
|
||||
|
||||
unlock_fscb_write_spinlock(owner);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nc_tsfs_cb_get_time_stamp_of_current(unsigned int owner, uint64_t *ts)
|
||||
{
|
||||
if(nc_tsfs_cb_current_count(owner) < 1) return -1;
|
||||
*ts = g_fs_circular_queue[owner][g_fs_head[owner] % g_fs_buf_tcnt[owner]].time_stamp;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nc_tsfs_cb_dequeue_start(unsigned int owner, stFrameElement* ret_data)
|
||||
{
|
||||
uint64_t c_idx = 0;
|
||||
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
if (!ret_data) return -1;
|
||||
// if (!ret_data->data_ptr) return -1;
|
||||
|
||||
lock_fscb_write_spinlock(owner);
|
||||
uint64_t tail = g_fs_tail[owner];
|
||||
unlock_fscb_write_spinlock(owner);
|
||||
uint64_t head = g_fs_head[owner];
|
||||
|
||||
if (head == tail) {
|
||||
#ifdef PRINT_DEBUG
|
||||
// queue is empty
|
||||
printf("[error] queue is empty : tail(%d) head(%d) c_cnt(%d)\n", tail, head, tail - head);
|
||||
#endif
|
||||
return -1;
|
||||
}
|
||||
|
||||
c_idx = head % g_fs_buf_tcnt[owner];
|
||||
ret_data->time_stamp = g_fs_circular_queue[owner][c_idx].time_stamp;
|
||||
ret_data->data_size = g_fs_circular_queue[owner][c_idx].data_size;
|
||||
// if (cp_data) {
|
||||
// memcpy(ret_data->data_ptr, g_fs_circular_queue[owner][c_idx].data_ptr, ret_data->data_size);
|
||||
// }
|
||||
ret_data->data_ptr = g_fs_circular_queue[owner][c_idx].data_ptr;
|
||||
// g_fs_head[owner]++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nc_tsfs_cb_dequeue_finish(unsigned int owner)
|
||||
{
|
||||
if (owner >= MAX_TSB_CNT) return -1;
|
||||
|
||||
g_fs_head[owner]++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_ts_fsync_circular_buffers.h
|
||||
*
|
||||
* @brief : nc_ts_fsync_circular_buffers header (thread-safe circular buffers)
|
||||
* for single producer / consumer
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.08.09
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.08.09 / 1.0.0 / Initial released. (bwryu@nextchip)
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef NC_TS_FSYNC_CIRCULAR_BUFFERS_H
|
||||
#define NC_TS_FSYNC_CIRCULAR_BUFFERS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
#define MAX_FSYNC_CBQ_BUF_CNT (10)
|
||||
|
||||
typedef struct {
|
||||
uint64_t time_stamp;
|
||||
size_t data_size;
|
||||
void* data_ptr;
|
||||
} stFrameElement;
|
||||
|
||||
extern int nc_tsfs_cb_create_buffers (unsigned int owner, int max_cnt, int buf_max_size);
|
||||
extern void nc_tsfs_cb_destroy_buffers (unsigned int owner);
|
||||
|
||||
extern uint64_t nc_tsfs_cb_max_count (unsigned int owner);
|
||||
extern uint64_t nc_tsfs_cb_current_count (unsigned int owner);
|
||||
extern uint64_t nc_tsfs_cb_max_buf_size (unsigned int owner);
|
||||
|
||||
extern int nc_tsfs_cb_enqueue(unsigned int owner, uint64_t time_stamp, void* data, size_t size);
|
||||
extern int nc_tsfs_cb_get_time_stamp_of_current(unsigned int owner, uint64_t *ts);
|
||||
extern int nc_tsfs_cb_dequeue_start(unsigned int owner, stFrameElement* ret_data);
|
||||
extern int nc_tsfs_cb_dequeue_finish(unsigned int owner);
|
||||
|
||||
#endif // #ifndef NC_TS_CIRCULAR_BUFFERS_H
|
||||
Binary file not shown.
@ -0,0 +1,155 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_ts_fsync_flipflop_buffers.c
|
||||
*
|
||||
* @brief : nc thread-safe flip-flop buffers for frame sync source (max 10 instances available)
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.08.09
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.08.09 / 1.0.0 / Initial released. (bwryu@nextchip)
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
/*
|
||||
********************************************************************************
|
||||
* INCLUDES
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#include "nc_ts_fsync_flipflop_buffers.h"
|
||||
#include "nc_utils.h"
|
||||
|
||||
// define
|
||||
#define MAX_TSB_CNT (20)
|
||||
|
||||
typedef struct {
|
||||
int buf_size;
|
||||
int write_idx;
|
||||
int read_idx;
|
||||
|
||||
uint64_t time_stamp[FIXED_FSYNC_FLIP_FLOP_BUF_CNT];
|
||||
void* buffer_ptr[FIXED_FSYNC_FLIP_FLOP_BUF_CNT];
|
||||
|
||||
pthread_spinlock_t read_spinlock;
|
||||
pthread_spinlock_t write_spinlock;
|
||||
} s_tsfs_ff_element;
|
||||
|
||||
// variable
|
||||
s_tsfs_ff_element g_tsfs_ff_buf_arr[MAX_TSB_CNT];
|
||||
|
||||
// function
|
||||
void lock_tsfs_ff_read_spinlock(int owner) { pthread_spin_lock(&g_tsfs_ff_buf_arr[owner].read_spinlock); }
|
||||
void unlock_tsfs_ff_read_spinlock(int owner) { pthread_spin_unlock(&g_tsfs_ff_buf_arr[owner].read_spinlock); }
|
||||
void lock_tsfs_ff_write_spinlock(int owner) { pthread_spin_lock(&g_tsfs_ff_buf_arr[owner].write_spinlock); }
|
||||
void unlock_tsfs_ff_write_spinlock(int owner) { pthread_spin_unlock(&g_tsfs_ff_buf_arr[owner].write_spinlock); }
|
||||
|
||||
// owner value range : 0 ~ (MAX_TSB_CNT-1)
|
||||
int nc_tsfs_ff_create_buffers(unsigned int owner, int each_buf_size)
|
||||
{
|
||||
if(owner >= (int)MAX_TSB_CNT) {
|
||||
printf("[Error] fail to create tsfs_ff buffer...\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
g_tsfs_ff_buf_arr[owner].buf_size = each_buf_size;
|
||||
g_tsfs_ff_buf_arr[owner].write_idx = -1;
|
||||
g_tsfs_ff_buf_arr[owner].read_idx = -1;
|
||||
pthread_spin_init(&g_tsfs_ff_buf_arr[owner].read_spinlock, 0);
|
||||
pthread_spin_init(&g_tsfs_ff_buf_arr[owner].write_spinlock, 0);
|
||||
for (int i = 0; i < FIXED_FSYNC_FLIP_FLOP_BUF_CNT; i++) {
|
||||
g_tsfs_ff_buf_arr[owner].time_stamp[i] = 0;
|
||||
g_tsfs_ff_buf_arr[owner].buffer_ptr[i] = malloc(g_tsfs_ff_buf_arr[owner].buf_size);
|
||||
}
|
||||
|
||||
printf("[Info] %s() called... owner(%d) each buffer size(%d)....\n", __FUNCTION__, owner, each_buf_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void nc_tsfs_ff_destroy_buffers (unsigned int owner)
|
||||
{
|
||||
g_tsfs_ff_buf_arr[owner].buf_size = 0;
|
||||
g_tsfs_ff_buf_arr[owner].write_idx = -1;
|
||||
g_tsfs_ff_buf_arr[owner].read_idx = -1;
|
||||
pthread_spin_destroy(&g_tsfs_ff_buf_arr[owner].read_spinlock);
|
||||
pthread_spin_destroy(&g_tsfs_ff_buf_arr[owner].write_spinlock);
|
||||
for (int i = 0; i < FIXED_FSYNC_FLIP_FLOP_BUF_CNT; i++) {
|
||||
g_tsfs_ff_buf_arr[owner].time_stamp[i] = 0;
|
||||
if (g_tsfs_ff_buf_arr[owner].buffer_ptr[i]) {
|
||||
free(g_tsfs_ff_buf_arr[owner].buffer_ptr[i]);
|
||||
g_tsfs_ff_buf_arr[owner].buffer_ptr[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void* nc_tsfs_ff_get_addr_of_buffer (unsigned int owner, int idx)
|
||||
{
|
||||
lock_tsfs_ff_write_spinlock(owner);
|
||||
if (idx >= (int)FIXED_FSYNC_FLIP_FLOP_BUF_CNT) {
|
||||
unlock_tsfs_ff_write_spinlock(owner);
|
||||
return NULL;
|
||||
}
|
||||
void *ptr = g_tsfs_ff_buf_arr[owner].buffer_ptr[idx];
|
||||
unlock_tsfs_ff_write_spinlock(owner);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
int nc_tsfs_ff_get_buf_size (unsigned int owner)
|
||||
{
|
||||
return g_tsfs_ff_buf_arr[owner].buf_size;
|
||||
}
|
||||
|
||||
// for reading
|
||||
void* nc_tsfs_ff_get_readable_buffer_and_timestamp (unsigned int owner, uint64_t* ret_timestamp)
|
||||
{
|
||||
lock_tsfs_ff_read_spinlock(owner);
|
||||
if (g_tsfs_ff_buf_arr[owner].read_idx < 0) {
|
||||
return NULL;
|
||||
}
|
||||
*ret_timestamp = g_tsfs_ff_buf_arr[owner].time_stamp[g_tsfs_ff_buf_arr[owner].read_idx];
|
||||
return g_tsfs_ff_buf_arr[owner].buffer_ptr[g_tsfs_ff_buf_arr[owner].read_idx];
|
||||
}
|
||||
|
||||
void nc_tsfs_ff_finish_read_buf(unsigned int owner)
|
||||
{
|
||||
unlock_tsfs_ff_read_spinlock(owner);
|
||||
}
|
||||
|
||||
// for writing
|
||||
void* nc_tsfs_ff_get_writable_buffer_and_set_timestamp (unsigned int owner, int* ret_idx, uint64_t set_timestamp)
|
||||
{
|
||||
lock_tsfs_ff_write_spinlock(owner);
|
||||
|
||||
if (g_tsfs_ff_buf_arr[owner].write_idx < 0) {
|
||||
g_tsfs_ff_buf_arr[owner].write_idx = 0;
|
||||
}
|
||||
*ret_idx = g_tsfs_ff_buf_arr[owner].write_idx;
|
||||
|
||||
g_tsfs_ff_buf_arr[owner].time_stamp[*ret_idx] = set_timestamp;
|
||||
return g_tsfs_ff_buf_arr[owner].buffer_ptr[*ret_idx];
|
||||
}
|
||||
|
||||
void nc_tsfs_ff_finish_write_buf(unsigned int owner)
|
||||
{
|
||||
lock_tsfs_ff_read_spinlock(owner);
|
||||
g_tsfs_ff_buf_arr[owner].read_idx = g_tsfs_ff_buf_arr[owner].write_idx;
|
||||
unlock_tsfs_ff_read_spinlock(owner);
|
||||
|
||||
g_tsfs_ff_buf_arr[owner].write_idx = (g_tsfs_ff_buf_arr[owner].write_idx + 1) % FIXED_FSYNC_FLIP_FLOP_BUF_CNT;
|
||||
|
||||
unlock_tsfs_ff_write_spinlock(owner);
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_ts_fsync_flipflop_buffers.h
|
||||
*
|
||||
* @brief : nc thread-safe flip-flop buffers for frame sync header (max 10 instances available)
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.08.09
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.08.09 / 1.0.0 / Initial released. (bwryu@nextchip)
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef NC_TS_FSYNC_FLIPFLOP_BUFFERS_H
|
||||
#define NC_TS_FSYNC_FLIPFLOP_BUFFERS_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "pthread.h"
|
||||
|
||||
#define FIXED_FSYNC_FLIP_FLOP_BUF_CNT (2)
|
||||
|
||||
extern int nc_tsfs_ff_create_buffers (unsigned int owner, int each_buf_size);
|
||||
extern void nc_tsfs_ff_destroy_buffers (unsigned int owner);
|
||||
extern void* nc_tsfs_ff_get_addr_of_buffer (unsigned int owner, int idx);
|
||||
extern int nc_tsfs_ff_get_buf_size (unsigned int owner);
|
||||
|
||||
// for read
|
||||
extern void* nc_tsfs_ff_get_readable_buffer_and_timestamp (unsigned int owner, uint64_t* ret_timestamp);
|
||||
extern void nc_tsfs_ff_finish_read_buf (unsigned int owner);
|
||||
|
||||
// for write
|
||||
extern void* nc_tsfs_ff_get_writable_buffer_and_set_timestamp (unsigned int owner, int* ret_idx, uint64_t set_timestamp);
|
||||
extern void nc_tsfs_ff_finish_write_buf (unsigned int owner);
|
||||
|
||||
#endif // #ifndef NC_TS_FSYNC_FLIPFLOP_BUFFERS_H
|
||||
Binary file not shown.
@ -0,0 +1,557 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2021 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_aiware_runtime.c
|
||||
*
|
||||
* @brief : Implementation of nc_cnn_aiware_runtime
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2021.10.08.
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 10.08.2021 / 1.0.0 / Initial released.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
/*
|
||||
********************************************************************************
|
||||
* INCLUDES
|
||||
********************************************************************************
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <poll.h>
|
||||
#include <sys/time.h>
|
||||
#include <mqueue.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/ioctl.h>
|
||||
#include <errno.h>
|
||||
#include <stdint.h>
|
||||
#include "nc_utils.h"
|
||||
#include "nc_neon.h"
|
||||
#include "nc_cnn_aiware_runtime.h"
|
||||
#include "nc_cnn_config_parser.h"
|
||||
|
||||
#include "nc_cnn_communicator.h"
|
||||
|
||||
#ifdef AIWARE_EMULATOR_SUPPORTED
|
||||
#include "aiware/emulator/c/emulatordevice.h"
|
||||
#include "aiware/emulator/c/emulatorconfigs.h"
|
||||
#endif
|
||||
|
||||
#ifdef AIWARE_DEVICE_SUPPORTED
|
||||
#include "aiware/runtime/c/aiwaredevice.h"
|
||||
#endif
|
||||
|
||||
// #define VERBOSE(f_, ...) printf((f_), ##__VA_ARGS__)
|
||||
#define VERBOSE(f_, ...)
|
||||
|
||||
// #define SHOW_CNN_TIME
|
||||
|
||||
#define EACH_PROGRAM_INST_CNT ((int)1)
|
||||
|
||||
static int g_networks_num = 0;
|
||||
aiwDevice *g_aiw_device = NULL;
|
||||
static aiwProgramSetBuilder *g_aiwProgSetbuilder = NULL;
|
||||
struct cnn_config *g_cnn_config_list[MAX_NETWORK_IDS] ={0,};
|
||||
static aiwModuleVersion aiwRuntimeVerInfo;
|
||||
|
||||
// Tries to open a physical device, or an emulator if it wasn't successful, and returns its
|
||||
// pointer. The caller will be the owner of the returned object.
|
||||
aiwDevice* openDevice()
|
||||
{
|
||||
aiwDevice* device = NULL;
|
||||
|
||||
// If real device support is available on the current platform, then try to open one
|
||||
// physical device.
|
||||
#ifdef AIWARE_DEVICE_SUPPORTED
|
||||
VERBOSE("%s", "try to get real device\n");
|
||||
// aiwDeviceCount returns the number of physical devices presented in the current
|
||||
// system.
|
||||
if (aiwDeviceCount() > 0)
|
||||
{
|
||||
device = aiwDeviceOpen(0);
|
||||
if (!device)
|
||||
{
|
||||
fprintf(stderr, "Failed to open device #0\n");
|
||||
return NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
return device;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// If real device support is not available, or there isn't any physical device in the
|
||||
// system, and if we have emulator support, then try to create an emulator.
|
||||
#ifdef AIWARE_EMULATOR_SUPPORTED
|
||||
aiwDeviceConfigData* config = NULL;
|
||||
VERBOSE("try to get emulator\n");
|
||||
// First we have to define which kind of emulator we want to create. This is a
|
||||
// predefined configuration for APACHE6.
|
||||
config = aiwCreateApache6ESConfigDefault();
|
||||
if (!config)
|
||||
{
|
||||
fprintf(stderr, "Failed to get APACHE6 device configuration\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
device = aiwCreateEmulator(config);
|
||||
|
||||
// Config is no longer needed.
|
||||
aiwReleaseDeviceConfigData(config);
|
||||
|
||||
#endif
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
int nc_aiw_init_cnn(void)
|
||||
{
|
||||
aiwModuleVersion aiwModuleVerInfo;
|
||||
|
||||
mq_unlink(MQ_NAME_DATA);
|
||||
|
||||
aiwRuntimeVerInfo = aiwRuntimeVersion();
|
||||
printf("aiWare Runtime version: %s\n", aiwRuntimeVerInfo.version);
|
||||
aiwModuleVerInfo = aiwCommonVersion();
|
||||
printf("aiwModule Version: %s\n", aiwModuleVerInfo.version);
|
||||
printf("Opening device\n");
|
||||
g_aiw_device = openDevice();
|
||||
if (!g_aiw_device) {
|
||||
fprintf(stderr, "Failed to open device\n");
|
||||
return -1;
|
||||
}
|
||||
g_aiwProgSetbuilder = aiwCreateProgramSetBuilder(g_aiw_device);
|
||||
if (!g_aiwProgSetbuilder) {
|
||||
fprintf(stderr, "Failed to create ProgramSetBuilder on the device\n");
|
||||
return -1;
|
||||
}
|
||||
g_networks_num = 0;
|
||||
for (int i = 0; i < MAX_NETWORK_IDS; i++) {
|
||||
g_cnn_config_list[i] = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nc_aiw_add_network_to_builder(const char *path, E_NETWORK_UID uid, PtrFuncPostprc ptr_pp_func)
|
||||
{
|
||||
aiw_status status = AIW_ERROR;
|
||||
aiwBinary *binary_data = NULL;
|
||||
|
||||
printf("Loading binary_data : %s\n", path);
|
||||
binary_data = aiwBinaryLoadFromPath(path);
|
||||
if (!binary_data) {
|
||||
fprintf(stderr, "Failed to load binary_data\n");
|
||||
return -1;
|
||||
}
|
||||
status = aiwProgramSetBuilderAddBinaryCopy(g_aiwProgSetbuilder, binary_data, EACH_PROGRAM_INST_CNT);
|
||||
if (status != AIW_SUCCESS) {
|
||||
fprintf(stderr, "Failed to aiwProgramSetBuilderAddBinaryCopy\n");
|
||||
return -1;
|
||||
}
|
||||
g_cnn_config_list[(int)uid] = (struct cnn_config *)malloc(sizeof(struct cnn_config));
|
||||
if (g_cnn_config_list[(int)uid] == NULL) {
|
||||
fprintf(stderr, "config list creation failure\n");
|
||||
return -1;
|
||||
}
|
||||
g_cnn_config_list[(int)uid]->network_id = uid;
|
||||
g_cnn_config_list[(int)uid]->program_idx = g_networks_num++;
|
||||
g_cnn_config_list[(int)uid]->program = NULL;
|
||||
g_cnn_config_list[(int)uid]->callback_pp = ptr_pp_func;
|
||||
|
||||
if (nc_set_network_info(path, uid) < 0){
|
||||
printf("Failed to set network info\n");
|
||||
return -1;
|
||||
}
|
||||
printf("Network (g_networks_num=%d) is added to builder\n", g_networks_num);
|
||||
return g_networks_num;
|
||||
}
|
||||
|
||||
static int nc_get_cnn_network_input_tinfo(struct cnn_config* config)
|
||||
{
|
||||
aiw_u32_t tensor_count = 0;
|
||||
// aiwTensor *tensor = NULL;
|
||||
const aiwTensorInfo *tinfo = NULL;
|
||||
|
||||
tensor_count = aiwProgramGetInputTensorCount(config->program);
|
||||
if(tensor_count != 1)
|
||||
{
|
||||
fprintf(stderr, "[Warning]Invalid input tensor count\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (aiw_u32_t i = 0; i < tensor_count; ++i)
|
||||
{
|
||||
// Get the input tensor
|
||||
config->input_tensor = aiwProgramGetInputTensor(config->program, i);
|
||||
if (!config->input_tensor)
|
||||
{
|
||||
fprintf(stderr, "Invalid input tensor object\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Get the corresponding information object
|
||||
tinfo = aiwTensorGetInfo(config->input_tensor);
|
||||
if (!tinfo)
|
||||
{
|
||||
fprintf(stderr, "Failed to get info for tensor\n");
|
||||
return -1;
|
||||
}
|
||||
memcpy(&config->input_tinfo, tinfo, sizeof(aiwTensorInfo));
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int nc_aiw_finish_network_builder(void)
|
||||
{
|
||||
aiw_status status = AIW_ERROR;
|
||||
aiwProgramSet* prog_set = NULL;
|
||||
|
||||
if (g_networks_num == 0) {
|
||||
fprintf(stderr, "network does not exist!\n");
|
||||
return -1;
|
||||
}
|
||||
prog_set = aiwProgramSetBuilderFinish(g_aiwProgSetbuilder);
|
||||
if (!prog_set) {
|
||||
fprintf(stderr, "Failed to aiwProgramSetBuilderFinish\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
status = aiwReleaseProgramSetBuilder(g_aiwProgSetbuilder);
|
||||
if (status != AIW_SUCCESS) {
|
||||
fprintf(stderr, "Failed to aiwReleaseProgramSetBuilder\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_NETWORK_IDS; i++) {
|
||||
if (g_cnn_config_list[i] != NULL) {
|
||||
g_cnn_config_list[i]->program = aiwProgramSetGetProgram(prog_set,
|
||||
g_cnn_config_list[i]->program_idx);
|
||||
if(nc_get_cnn_network_input_tinfo(g_cnn_config_list[i]) < 0)
|
||||
{
|
||||
fprintf(stderr, "Failed to nc_get_cnn_network_input_tinfo\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nc_get_cnn_networks_num(void)
|
||||
{
|
||||
return g_networks_num;
|
||||
}
|
||||
|
||||
int nc_get_cnn_networks_id(void)
|
||||
{
|
||||
int net_id = -1;
|
||||
|
||||
if(g_networks_num == 0) {
|
||||
fprintf(stderr, "network does not exist!\n");
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < MAX_NETWORK_IDS; i++) {
|
||||
if (g_cnn_config_list[i] != NULL) {
|
||||
net_id = g_cnn_config_list[i]->network_id;
|
||||
}
|
||||
}
|
||||
return net_id;
|
||||
}
|
||||
|
||||
int nc_get_cnn_networks_id_by_uid(E_NETWORK_UID uid)
|
||||
{
|
||||
if ((int)uid < 0 || (int)uid >= MAX_NETWORK_IDS) return -1;
|
||||
if (g_cnn_config_list[(int)uid] == NULL) return -1;
|
||||
|
||||
return g_cnn_config_list[(int)uid]->network_id;
|
||||
}
|
||||
|
||||
|
||||
int nc_get_cnn_network_input_resol(int uid, aiwTensorInfo *tinfo)
|
||||
{
|
||||
if(!tinfo) {
|
||||
fprintf(stderr, "failed to get NPU network input tensor information\n");
|
||||
return -1;
|
||||
}
|
||||
if(!g_cnn_config_list[uid]) {
|
||||
fprintf(stderr, "failed to get NPU network input resolution (uid=%d)\n", uid);
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(tinfo, &g_cnn_config_list[uid]->input_tinfo, sizeof(aiwTensorInfo));
|
||||
|
||||
return 0;
|
||||
}
|
||||
aiw_i8_t is_float_or_uint8(E_NETWORK_UID net_id, int tensor_index)
|
||||
{
|
||||
aiw_i8_t net_type = -1;
|
||||
if(net_id == NETWORK_TRI_CHIMERA){
|
||||
if(tensor_index < 3 || tensor_index == 6 || tensor_index == 9){
|
||||
net_type = FLOAT_TYPE;
|
||||
}
|
||||
else{
|
||||
net_type = UINT8_TYPE;
|
||||
}
|
||||
}
|
||||
if(net_id == NETWORK_FACE_DET){
|
||||
net_type = FLOAT_TYPE;
|
||||
}
|
||||
if(net_id == NETWORK_CUUVA_DET){
|
||||
net_type = FLOAT_TYPE;
|
||||
}
|
||||
if(net_id == NETWORK_FIRE_DET){
|
||||
net_type = FLOAT_TYPE;
|
||||
}
|
||||
if(net_id == NETWORK_LPR_DET){
|
||||
net_type = FLOAT_TYPE;
|
||||
}
|
||||
else if(net_id == NETWORK_YOLOV5_DET){
|
||||
net_type = FLOAT_TYPE;
|
||||
}
|
||||
else if(net_id == NETWORK_PELEE_SEG){
|
||||
net_type = UINT8_TYPE;
|
||||
}
|
||||
else if(net_id == NETWORK_PELEE_DET){
|
||||
net_type = FLOAT_TYPE;
|
||||
}
|
||||
else if(net_id == NETWORK_UFLD_LANE){
|
||||
if(tensor_index == 2 || tensor_index == 5){
|
||||
net_type = FLOAT_TYPE;
|
||||
}
|
||||
else{
|
||||
net_type = UINT8_TYPE;
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
||||
}
|
||||
|
||||
return net_type;
|
||||
}
|
||||
static void *run_cnn_program(struct cnn_config* config, unsigned char *planar_rgb, uint64_t time_stamp, uint32_t cam_ch, E_NETWORK_UID net_id)
|
||||
{
|
||||
aiw_u32_t tensor_count = 0;
|
||||
aiwTensor *tensor = NULL;
|
||||
const aiwTensorInfo *tinfo = NULL;
|
||||
aiw_u64_t buffer_size = 0;
|
||||
aiw_status status = AIW_ERROR;
|
||||
void *inference_output = NULL;
|
||||
aiwTensorInfo *send_tinfo = NULL;
|
||||
aiw_u8_t* buffer = NULL;
|
||||
cnn_output_info cnn_output;
|
||||
aiw_u8_t net_datatype = 0;
|
||||
#ifdef SHOW_CNN_TIME
|
||||
uint64_t start_time = 0;
|
||||
uint64_t elapsed_ms = 0;
|
||||
|
||||
start_time = nc_get_mono_time();
|
||||
#endif
|
||||
if(!planar_rgb)
|
||||
{
|
||||
fprintf(stderr, "Failed to get planar rgb image\n");
|
||||
exit(0);
|
||||
}
|
||||
status = aiwTensorSetDataNCHWUInt8(config->input_tensor, planar_rgb);
|
||||
if (status != AIW_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Failed to initialize input tensor with random data\n");
|
||||
exit(0);
|
||||
}
|
||||
// Upload the input tensors' content from the host memory into aiWare's memory.
|
||||
// Please note that this step is always required, even when the host and aiWare share
|
||||
// the same memory. In that case CPU cache is flushed to make sure the latest data will
|
||||
// be seen by aiWare.
|
||||
status = aiwProgramUploadInputs(config->program);
|
||||
if (status != AIW_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Failed to upload input into aiWare's memory\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
// printf("+++Exe\n");
|
||||
status = aiwProgramExecute(config->program);
|
||||
if (status != AIW_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Failed to execute program\n");
|
||||
exit(0);
|
||||
}
|
||||
// printf("---Exe\n");
|
||||
|
||||
// Now download the result from aiWare's memory into host buffers.
|
||||
// Like aiwProgramUploadInputs, this step is always required.
|
||||
status = aiwProgramDownloadOutputs(config->program);
|
||||
if (status != AIW_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Failed to download output from aiWare's memory\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
VERBOSE("%s", "Print output tensor info and save the tensors into files\n");
|
||||
tensor_count = aiwProgramGetOutputTensorCount(config->program);
|
||||
if (tensor_count == 0)
|
||||
{
|
||||
fprintf(stderr, "Invalid output tensor count %d\n", tensor_count);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
VERBOSE("tensor_count = %d\n", tensor_count);
|
||||
cnn_output.total_tensor_cnt = tensor_count;
|
||||
for (aiw_u32_t i = 0; i < tensor_count; ++i)
|
||||
{
|
||||
// uint64_t s_time = nc_get_mono_us_time();
|
||||
tensor = aiwProgramGetOutputTensor(config->program, i);
|
||||
if (!tensor)
|
||||
{
|
||||
fprintf(stderr, "Invalid output tensor object\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
tinfo = aiwTensorGetInfo(tensor);
|
||||
if (!tinfo)
|
||||
{
|
||||
fprintf(stderr, "Failed to get info for tensor\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
VERBOSE("Output tensor #%u\n", i);
|
||||
VERBOSE("Name: %s\n", tinfo->name);
|
||||
VERBOSE("Dimension: %u x %u x %u\n", tinfo->dim.w, tinfo->dim.h, tinfo->dim.ch);
|
||||
// printf("cam%d Dimension: %u x %u x %u\n", cam_ch, tinfo->dim.w, tinfo->dim.h, tinfo->dim.ch);
|
||||
cnn_output.index_of_total = i;
|
||||
cnn_output.cam_ch = cam_ch;
|
||||
cnn_output.width = tinfo->dim.w;
|
||||
cnn_output.height = tinfo->dim.h;
|
||||
cnn_output.channel = tinfo->dim.ch;
|
||||
cnn_output.data_type = tinfo->exponent?CNN_TILED_DT_FLOAT:CNN_TILED_DT_U8;
|
||||
cnn_output.net_id = net_id;
|
||||
|
||||
// copy tinfo
|
||||
send_tinfo = (aiwTensorInfo *)malloc(sizeof(aiwTensorInfo));
|
||||
memset((void*)send_tinfo, 0, sizeof(aiwTensorInfo));
|
||||
memcpy(send_tinfo, tinfo, sizeof(aiwTensorInfo));
|
||||
cnn_output.tinfo = (aiwTensorInfo *)send_tinfo;
|
||||
|
||||
nc_get_cnn_network_input_resol(config->network_id, &cnn_output.tinfo_in);
|
||||
buffer_size = aiwTensorSizeNCHW(tensor);
|
||||
net_datatype = is_float_or_uint8(net_id, i) < 0 ? tinfo->exponent : is_float_or_uint8(net_id, i);
|
||||
buffer = aiwTensorAcquireRawBufferPointer(tensor);
|
||||
if (!buffer)
|
||||
{
|
||||
fprintf(stderr, "Failed to get tensor buffer pointer\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
||||
if (net_datatype) { // data type : float
|
||||
// printf("## EXPONENT\n");
|
||||
buffer_size = buffer_size * sizeof(float);
|
||||
// printf("buffer size=%d \n", buffer_size);
|
||||
|
||||
inference_output = (float*)malloc(buffer_size);
|
||||
if (!inference_output)
|
||||
{
|
||||
fprintf(stderr, "Failed to allocate output float buffer\n");
|
||||
exit(0);
|
||||
}
|
||||
memset(inference_output, 0, buffer_size);
|
||||
if (nc_neon_get_data_NCHW_float_cellrow(cnn_output.tinfo, buffer, (float *)inference_output) != AIW_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Failed to get output float tensor data\n");
|
||||
exit(0);
|
||||
}
|
||||
} else { // data type : uint8_t
|
||||
// seg의 buffer_size는 dim.w * dim.h *dim.ch 가 아닌 tile size로 계산
|
||||
// printf("buffer size=%d \n", buffer_size);
|
||||
|
||||
inference_output = (aiw_u8_t *)malloc(buffer_size);
|
||||
if (!inference_output)
|
||||
{
|
||||
fprintf(stderr, "Failed to allocate output uint8 buffer\n");
|
||||
exit(0);
|
||||
}
|
||||
memset(inference_output, 0, buffer_size);
|
||||
|
||||
if (aiwTensorGetDataNCHWUInt8(tensor, (aiw_u8_t *)inference_output) != AIW_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Failed to get output uint8 tensor data\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
status = aiwTensorReleaseRawBufferPointer(tensor);
|
||||
if (status != AIW_SUCCESS) {
|
||||
fprintf(stderr, "Failed to release tensor buffer\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
tensor = NULL;
|
||||
buffer = NULL;
|
||||
cnn_output.tiled_data = inference_output;
|
||||
// printf("......... tensor(%d) elapsed time : %llu us\n", i, nc_elapsed_us_time(s_time));
|
||||
|
||||
// s_time = nc_get_mono_us_time();
|
||||
nc_cnn_send_inference_result(config, time_stamp, cnn_output);
|
||||
// printf("......... nc_cnn_send_inference_result() elapsed time : %llu us\n", nc_elapsed_us_time(s_time));
|
||||
}
|
||||
|
||||
#ifdef SHOW_CNN_TIME
|
||||
static uint64_t max_e_time = 0;
|
||||
static double avg_time = 0.0;
|
||||
static uint64_t t_time = 0;
|
||||
static uint64_t f_cnt = 0;
|
||||
static uint64_t over_66_cnt = 0;
|
||||
|
||||
elapsed_ms = nc_elapsed_time(start_time);
|
||||
|
||||
f_cnt++;
|
||||
t_time += elapsed_ms;
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wconversion"
|
||||
avg_time = (double)t_time / (double)f_cnt;
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
if (f_cnt > 15*10 && elapsed_ms > max_e_time) {
|
||||
max_e_time = elapsed_ms;
|
||||
}
|
||||
if (elapsed_ms > 66) over_66_cnt++;
|
||||
|
||||
printf("(RUN_CNN %d) elapsed time: %lu ms (max: %lu ms, avg: %0.1f ms)\n",
|
||||
config->network_id,
|
||||
(unsigned long)elapsed_ms,
|
||||
(unsigned long)max_e_time,
|
||||
avg_time);
|
||||
#endif
|
||||
return inference_output;
|
||||
}
|
||||
|
||||
void nc_aiw_run_cnn(unsigned char *planar_rgb, uint64_t time_stamp, uint32_t cam_ch, E_NETWORK_UID net_id)
|
||||
{
|
||||
VERBOSE("entering %s\n", __func__);
|
||||
|
||||
if (g_cnn_config_list[(int)net_id] != NULL){
|
||||
run_cnn_program(g_cnn_config_list[(int)net_id], planar_rgb, time_stamp, cam_ch, net_id);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,140 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2021 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_aiware_runtime.h
|
||||
*
|
||||
* @brief : nc_cnn_aiware_runtime header
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2021.10.08.
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 10.08.2021 / 1.0.0 / Initial released.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __CNN_AIW_RUNTIME_H__
|
||||
#define __CNN_AIW_RUNTIME_H__
|
||||
|
||||
#include "aiware/common/c/binary.h"
|
||||
#include "aiware/common/c/version.h"
|
||||
#include "aiware/runtime/c/device.h"
|
||||
#include "aiware/runtime/c/program.h"
|
||||
#include "aiware/runtime/c/programset.h"
|
||||
#include "aiware/runtime/c/version.h"
|
||||
#include "aiware/common/c/types.h"
|
||||
|
||||
#include "nc_cnn_network_includes.h"
|
||||
#include "nc_cnn_worker_for_postprocess.h"
|
||||
#include "nc_cnn_common.h"
|
||||
|
||||
/**
|
||||
***********************************************************
|
||||
**************** DON'T modify below ***********
|
||||
***********************************************************
|
||||
*/
|
||||
#define APACHE6_BLK_CNN_AIW_BASE (0x08000000U)
|
||||
#define SFR_REMAP_BASE (0U)
|
||||
|
||||
#define TILESIZE 64
|
||||
#define TILESIZE_SQR (TILESIZE * TILESIZE)
|
||||
#define CELLSIZE 8
|
||||
#define CELLSIZE_SQR (CELLSIZE * CELLSIZE)
|
||||
#define CELLSIZE_TWI (2 * CELLSIZE)
|
||||
#define CELLSIZE_QUA (4 * CELLSIZE)
|
||||
|
||||
#define MAX_MQ_MSG_CNT 20
|
||||
#define MQ_NAME_DATA "/post_cnn_data"
|
||||
|
||||
#define RGB_CNT (3)
|
||||
|
||||
#define FLOAT_TYPE (1U)
|
||||
#define UINT8_TYPE (0U)
|
||||
|
||||
#define AIW_VERSION_CODE(major, minor, patch) \
|
||||
(((major) << 16) + ((minor) << 8) + (patch))
|
||||
|
||||
typedef enum {
|
||||
CNN_TILED_DT_FLOAT,
|
||||
CNN_TILED_DT_U8,
|
||||
} E_CNN_TILED_DT;
|
||||
|
||||
typedef struct cnn_output_info {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
uint32_t channel;
|
||||
E_CNN_TILED_DT data_type;
|
||||
void *tiled_data;
|
||||
uint32_t cam_ch;
|
||||
E_NETWORK_UID net_id;
|
||||
|
||||
uint32_t index_of_total; // index of total tensor count
|
||||
uint32_t total_tensor_cnt; // tensor total count : (ex) yolov5 has 3 tensor output by 1 frame
|
||||
|
||||
aiwTensorInfo tinfo_in;
|
||||
aiwTensorInfo *tinfo;
|
||||
aiw_u64_t buffer_size;
|
||||
} cnn_output_info;
|
||||
|
||||
typedef struct cnn_config {
|
||||
E_NETWORK_UID network_id;
|
||||
int program_idx;
|
||||
aiwProgram *program;
|
||||
aiwTensor *input_tensor;
|
||||
aiwTensorInfo input_tinfo;
|
||||
PtrFuncPostprc callback_pp;
|
||||
} cnn_config;
|
||||
|
||||
typedef struct inference_result_msg {
|
||||
E_NETWORK_UID network_id;
|
||||
uint64_t time_stamp;
|
||||
cnn_output_info cnn_output;
|
||||
PtrFuncPostprc ptr_pp;
|
||||
} inference_result_msg;
|
||||
|
||||
typedef struct {
|
||||
uint32_t cam_ch;
|
||||
uint8_t *ptr_cnn_buf;
|
||||
uint64_t time_stamp_us;
|
||||
E_NETWORK_UID net_id;
|
||||
uint8_t owns_buf;
|
||||
} stCnnData;
|
||||
|
||||
typedef struct st_npu_input_info {
|
||||
unsigned int w;
|
||||
unsigned int h;
|
||||
unsigned int rgb_size;
|
||||
} st_npu_input_info;
|
||||
|
||||
typedef struct {
|
||||
uint64_t time_stamp;
|
||||
int cam_channel;
|
||||
E_NETWORK_UID net_id;
|
||||
E_NETWORK_TASK net_task;
|
||||
stObjDrawInfo draw_info; // To be removed (cnn)
|
||||
stSegDrawInfo seg_info;
|
||||
stLaneDrawInfo lane_draw_info;
|
||||
stCnnPostprocessingResults cnn_result;
|
||||
} pp_result_buf;
|
||||
|
||||
extern int nc_aiw_init_cnn(void);
|
||||
extern int nc_aiw_add_network_to_builder(const char *path, E_NETWORK_UID uid, PtrFuncPostprc ptr_pp_func);
|
||||
extern int nc_aiw_finish_network_builder(void);
|
||||
extern void nc_aiw_run_cnn(unsigned char *planar_rgb, uint64_t time_stamp, uint32_t cam_ch, E_NETWORK_UID net_id);
|
||||
extern int nc_get_cnn_networks_num(void);
|
||||
extern int nc_get_cnn_network_input_resol(int uid, aiwTensorInfo *tinfo);
|
||||
extern int nc_get_cnn_networks_id(void);
|
||||
extern int nc_get_cnn_networks_id_by_uid(E_NETWORK_UID uid);
|
||||
#endif // __CNN_AIW_RUNTIME_H__
|
||||
Binary file not shown.
@ -0,0 +1,256 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_anchor.c
|
||||
*
|
||||
* @brief : nc_cnn_anchor source
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.11.10
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.11.10 / 1.0.0 / Initial released.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "nc_cnn_anchor.h"
|
||||
|
||||
float Box_iou(stBBox *a, stBBox *b);
|
||||
float Box_intersection(stBBox *a, stBBox *b);
|
||||
float Box_union(stBBox *a, stBBox *b);
|
||||
float Overlap(float x1, float w1, float x2, float w2);
|
||||
|
||||
float nc_Logistic_activate(float x)
|
||||
{
|
||||
return (float)(1. / (1. + exp(-x)));
|
||||
}
|
||||
|
||||
void nc_Nms_box_yolov8(detection *dets, int *total, int classes, float thresh)
|
||||
{
|
||||
int i, j, k;
|
||||
|
||||
for (k = 0; k < classes; ++k) {
|
||||
for (i = 0; i < *total; ++i) {
|
||||
if (dets[i].prob[k] == 0) continue;
|
||||
stBBox *a = &dets[i].bbox;
|
||||
for (j = i + 1; j < *total; ++j) {
|
||||
stBBox *b = &dets[j].bbox;
|
||||
if (Box_iou(a, b) > thresh) {
|
||||
for(int cls = 0; cls < classes ; ++cls){
|
||||
//모든 class index의 score 비교하여 1개의 box만 남도록 nms
|
||||
if (dets[i].prob[k] >= dets[j].prob[cls])
|
||||
{
|
||||
dets[j].prob[cls] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dets[i].prob[k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void nc_Nms_box(detection *dets, int *total, int classes, float thresh)
|
||||
{
|
||||
int i, j, k, m;
|
||||
|
||||
for (k = 0; k < classes; ++k) {
|
||||
for (i = 0; i < *total; ++i) {
|
||||
if (dets[i].prob[k] == 0 && dets[i].objectness == 0) continue;
|
||||
stBBox *a = &dets[i].bbox;
|
||||
for (j = i + 1; j < *total; ++j) {
|
||||
stBBox *b = &dets[j].bbox;
|
||||
if (Box_iou(a, b) >= thresh) {
|
||||
if (dets[i].objectness >= dets[j].objectness)
|
||||
{
|
||||
dets[j].objectness = 0;
|
||||
for (m = 0; m < classes; ++m) {
|
||||
dets[j].prob[k] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dets[i].objectness = 0;
|
||||
for (m = 0; m < classes; ++m) {
|
||||
dets[i].prob[k] = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//class별 score비교
|
||||
void nc_Nms_box_by_class(detection *dets, int *total, int classes, float thresh)
|
||||
{
|
||||
int i, j, k;
|
||||
int pred_class = 0;
|
||||
float best_score = 0;
|
||||
int class_index = 0;
|
||||
int class_index_overlap = 0;
|
||||
float curr_score = 0;
|
||||
|
||||
for (int i = 0; i < *total; ++i)
|
||||
{
|
||||
//pull out best score
|
||||
for (class_index = 0; class_index < classes; ++class_index) {
|
||||
curr_score = dets[i].prob[class_index];
|
||||
if (curr_score >= best_score) {
|
||||
if (curr_score == best_score) {
|
||||
class_index_overlap = 1;
|
||||
}
|
||||
else{
|
||||
class_index_overlap = 0;
|
||||
}
|
||||
best_score = curr_score;
|
||||
pred_class = class_index;
|
||||
}
|
||||
}
|
||||
|
||||
//best score인 클래스 이외의 클래스 score들은 모두 0으로 만듦
|
||||
for (class_index = 0; class_index < classes; ++class_index) {
|
||||
if(class_index_overlap == 1){
|
||||
dets[i].prob[class_index] = 0; //다른 class끼리 best score가 겹치면 detection결과에서 제외
|
||||
}
|
||||
else
|
||||
{
|
||||
if(class_index != pred_class){
|
||||
dets[i].prob[class_index] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//다른 class끼리 best score가 겹치면 detection결과에서 제외
|
||||
if(class_index_overlap == 1) dets[i].objectness = 0;
|
||||
|
||||
best_score = 0;
|
||||
pred_class = 0;
|
||||
}
|
||||
|
||||
//nms비교
|
||||
for (k = 0; k < classes; ++k) {
|
||||
for (i = 0; i < *total; ++i) {
|
||||
if (dets[i].prob[k] == 0) continue;
|
||||
stBBox *a = &dets[i].bbox;
|
||||
for (j = i + 1; j < *total; ++j) {
|
||||
if(dets[j].prob[k] != 0) {
|
||||
stBBox *b = &dets[j].bbox;
|
||||
if (Box_iou(a, b) >= thresh) {
|
||||
if (dets[i].prob[k] >= dets[j].prob[k])
|
||||
{
|
||||
dets[j].prob[k] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dets[i].prob[k] = 0;
|
||||
}
|
||||
}
|
||||
else //iou값이 nms threshoid값보다는 낮지만 박스 끼리 겹쳤을때 제거
|
||||
{
|
||||
if(Box_iou(a, b) > 0)
|
||||
{
|
||||
// b박스가 a박스 내부에 있을때 b박스 제거
|
||||
if(((a->x - a->w / 2) <= b->x))
|
||||
{
|
||||
if((b->x <= (a->x + a->w / 2)))
|
||||
{
|
||||
if(((a->y - a->h / 2) <= b->y))
|
||||
{
|
||||
if((b->y <= (a->y + a->h / 2)))
|
||||
{
|
||||
if (dets[i].prob[k] >= dets[j].prob[k])
|
||||
{
|
||||
dets[j].prob[k] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dets[i].prob[k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// a박스가 b박스 내부에 있을때 a박스 제거
|
||||
else if(((b->x - b->w/2) <= a->x))
|
||||
{
|
||||
if((a->x <= (b->x + b->w/2)))
|
||||
{
|
||||
if(((b->y - b->h/2) <= a->y))
|
||||
{
|
||||
if((a->y <= (b->y + b->h/2)))
|
||||
{
|
||||
if (dets[i].prob[k] >= dets[j].prob[k])
|
||||
{
|
||||
dets[j].prob[k] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
dets[i].prob[k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float Box_intersection(stBBox *a, stBBox *b)
|
||||
{
|
||||
float w = Overlap(a->x, a->w, b->x, b->w);
|
||||
if (w <= 0) return 0;
|
||||
float h = Overlap(a->y, a->h, b->y, b->h);
|
||||
if (h <= 0) return 0;
|
||||
float area = w * h;
|
||||
return area;
|
||||
}
|
||||
|
||||
float Overlap(float x1, float w1, float x2, float w2)
|
||||
{
|
||||
float l1 = x1 - w1 / 2;
|
||||
float l2 = x2 - w2 / 2;
|
||||
float left = l1 > l2 ? l1 : l2;
|
||||
float r1 = x1 + w1 / 2;
|
||||
float r2 = x2 + w2 / 2;
|
||||
float right = r1 < r2 ? r1 : r2;
|
||||
return right - left;
|
||||
}
|
||||
|
||||
float Box_union(stBBox *a, stBBox *b)
|
||||
{
|
||||
float i = Box_intersection(a, b);
|
||||
float u = a->w*a->h + b->w*b->h - i;
|
||||
return u;
|
||||
}
|
||||
|
||||
float Box_iou(stBBox *a, stBBox *b)
|
||||
{
|
||||
float I = Box_intersection(a, b);
|
||||
if (I <= 0) return 0;
|
||||
float U = Box_union(a, b);
|
||||
if (U <= 0) return 0;
|
||||
return I / U;
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_anchor.h
|
||||
*
|
||||
* @brief : nc_cnn_anchor header
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.11.10
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.11.10 / 1.0.0 / Initial released.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NC_CNN_ANCHOR_H__
|
||||
#define __NC_CNN_ANCHOR_H__
|
||||
|
||||
#include "nc_cnn_common.h"
|
||||
|
||||
/***************************************************************
|
||||
**************** for anchor object detection ******************
|
||||
***************************************************************/
|
||||
enum {
|
||||
OBJ_CLASS_ID_0,
|
||||
OBJ_CLASS_ID_1,
|
||||
OBJ_CLASS_ID_2,
|
||||
OBJ_CLASS_ID_3,
|
||||
OBJ_CLASS_ID_4,
|
||||
OBJ_CLASS_ID_5,
|
||||
OBJ_CLASS_ID_6,
|
||||
OBJ_CLASS_ID_7,
|
||||
OBJ_CLASS_ID_8,
|
||||
OBJ_CLASS_ID_9,
|
||||
MAX_CLASS_ID_CNT
|
||||
};
|
||||
|
||||
#define BOX_MAX_NUM 9999
|
||||
|
||||
typedef struct detection {
|
||||
stBBox bbox;
|
||||
float prob[MAX_CLASS_ID_CNT]; //classes
|
||||
float objectness;
|
||||
} detection;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *max_indices;
|
||||
uint8_t *valid_anchor;
|
||||
} lane_data;
|
||||
|
||||
extern float nc_Logistic_activate(float x);
|
||||
extern void nc_Nms_box_yolov8(detection *dets, int *total, int classes, float thresh);
|
||||
extern void nc_Nms_box(detection *dets, int *total, int classes, float thresh);
|
||||
extern void nc_Nms_box_by_class(detection *dets, int *total, int classes, float thresh);
|
||||
|
||||
#endif // __NC_CNN_ANCHOR_H__
|
||||
Binary file not shown.
@ -0,0 +1,171 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_common.h
|
||||
*
|
||||
* @brief : nc_cnn_common header
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.09.07
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.09.07 / 1.0.0 / Initial released.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __NC_CNN_COMMON_H__
|
||||
#define __NC_CNN_COMMON_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define MAX_CNN_CLASS_CNT (20)
|
||||
#define MAX_CNN_RESULT_CNT_OF_CLASS (100)
|
||||
|
||||
#define MAX_POINT_CNT_OF_LANE (50)
|
||||
#define MAX_LANE_DET_CNT (10)
|
||||
|
||||
#define NPU_INPUT_WIDTH (640)
|
||||
#define NPU_INPUT_HEIGHT (384)
|
||||
|
||||
#define NPU_INPUT_DATA_SIZE (NPU_INPUT_WIDTH * NPU_INPUT_HEIGHT)
|
||||
|
||||
typedef struct {
|
||||
int x;
|
||||
int y;
|
||||
} stIntPoint;
|
||||
|
||||
////////////////////////////////
|
||||
// for draw //
|
||||
////////////////////////////////
|
||||
typedef struct {
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
} stRGB24;
|
||||
|
||||
typedef struct {
|
||||
uint8_t r;
|
||||
uint8_t g;
|
||||
uint8_t b;
|
||||
uint8_t a;
|
||||
} stRGBA32;
|
||||
|
||||
|
||||
typedef struct {
|
||||
int max_class_cnt;
|
||||
char** class_names;
|
||||
stRGB24* class_colors;
|
||||
} stObjDrawInfo;
|
||||
|
||||
typedef struct {
|
||||
uint32_t width;
|
||||
uint32_t height;
|
||||
int max_class_cnt;
|
||||
char** class_names;
|
||||
stRGBA32* class_colors;
|
||||
} stSegDrawInfo;
|
||||
|
||||
typedef struct {
|
||||
int max_lane_num;
|
||||
stRGB24* index_colors;
|
||||
#ifdef USE_UFLD_NETWORK_DEBUGGING
|
||||
int* lane_anchor_info;
|
||||
float* row_anchor;
|
||||
float* col_anchor;
|
||||
int row_anchor_num;
|
||||
int col_anchor_num;
|
||||
float row_anchor_min;
|
||||
float row_anchor_max;
|
||||
float col_anchor_min;
|
||||
float col_anchor_max;
|
||||
int row_cell_num;
|
||||
int col_cell_num;
|
||||
#endif
|
||||
} stLaneDrawInfo;
|
||||
|
||||
////////////////////////////////
|
||||
// for segmentation //
|
||||
////////////////////////////////
|
||||
// linked list for segmentation
|
||||
typedef struct STSegInfo {
|
||||
stIntPoint pos;
|
||||
uint8_t val;
|
||||
struct STSegInfo *next;
|
||||
} stSegInfo;
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
// for object detection //
|
||||
////////////////////////////////
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
float w;
|
||||
float h;
|
||||
} stBBox;
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
} stPoint;
|
||||
|
||||
typedef struct {
|
||||
stBBox bbox;
|
||||
int track_id; // -1, if not use tracker
|
||||
float prob;
|
||||
} stObjInfo;
|
||||
|
||||
typedef struct {
|
||||
int class_id; // unique class id
|
||||
int obj_cnt;
|
||||
stObjInfo objs[MAX_CNN_RESULT_CNT_OF_CLASS];
|
||||
} stClassObjs;
|
||||
|
||||
typedef struct {
|
||||
int class_id; // unique class id
|
||||
int class_dummy;
|
||||
} stClassSegs;
|
||||
|
||||
#ifdef USE_UFLD_NETWORK_DEBUGGING
|
||||
typedef struct {
|
||||
float x; // x coordinate of max_indices cell
|
||||
float y; // y coordinate of max_indices cell
|
||||
float index_min;
|
||||
float index_max;
|
||||
|
||||
stPoint final_point;
|
||||
} stUFLD_dbg_info;
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
stPoint point[MAX_POINT_CNT_OF_LANE];
|
||||
int point_cnt;
|
||||
int lane_class;
|
||||
#ifdef USE_UFLD_NETWORK_DEBUGGING
|
||||
stUFLD_dbg_info ufld_dbg_info[MAX_POINT_CNT_OF_LANE];
|
||||
int dbg_info_cnt;
|
||||
#endif
|
||||
} stLaneDet;
|
||||
|
||||
typedef struct {
|
||||
// uint64_t timestamp;
|
||||
stClassObjs class_objs[MAX_CNN_CLASS_CNT];
|
||||
stClassSegs class_segs;
|
||||
void* seg;
|
||||
stLaneDet lane_det[MAX_LANE_DET_CNT];
|
||||
} stCnnPostprocessingResults;
|
||||
|
||||
#endif // __NC_CNN_COMMON_H__
|
||||
@ -0,0 +1,91 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_communicator.c
|
||||
*
|
||||
* @brief : nc_cnn_communicator source code
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.11.10
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.11.10 / 1.0.0 / Initial released.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#include "nc_cnn_communicator.h"
|
||||
|
||||
int nc_cnn_send_inference_result(struct cnn_config* config, uint64_t time_stamp, cnn_output_info cnn_output)
|
||||
{
|
||||
// send message to postprocess task
|
||||
struct inference_result_msg *npu_msg;
|
||||
int ret = 0;
|
||||
|
||||
struct mq_attr attr;
|
||||
attr.mq_maxmsg = MAX_MQ_MSG_CNT;
|
||||
attr.mq_msgsize = sizeof(struct inference_result_msg*);
|
||||
int oflag = O_WRONLY | O_CREAT;
|
||||
// uint64_t s_time = nc_get_mono_us_time();
|
||||
mqd_t mfd = mq_open(MQ_NAME_DATA, oflag, 0666, &attr);
|
||||
// printf("......... [%s] mq_open() elapsed : %llu us\n", __FUNCTION__, nc_elapsed_us_time(s_time));
|
||||
if (mfd == -1) {
|
||||
perror("mq open error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
npu_msg = (struct inference_result_msg*)malloc(sizeof(struct inference_result_msg));
|
||||
npu_msg->network_id = config->network_id;
|
||||
npu_msg->time_stamp = time_stamp;
|
||||
npu_msg->cnn_output = cnn_output;
|
||||
npu_msg->network_id = cnn_output.net_id;
|
||||
npu_msg->ptr_pp = config->callback_pp;
|
||||
if ((ret = mq_send(mfd, (const char *)&npu_msg, attr.mq_msgsize, 1)) == -1) {
|
||||
printf("errno of mq_send = %d\n", errno);
|
||||
}
|
||||
mq_close(mfd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int nc_cnn_receive_inference_result (inference_result_msg **out_inference_result)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
struct mq_attr attr;
|
||||
attr.mq_maxmsg = MAX_MQ_MSG_CNT;
|
||||
attr.mq_msgsize = sizeof(struct inference_result_msg *);
|
||||
int oflag = O_RDONLY | O_CREAT;
|
||||
// uint64_t s_time = nc_get_mono_us_time();
|
||||
mqd_t mfd = mq_open(MQ_NAME_DATA, oflag, 0666, &attr);
|
||||
// printf("......... [%s] mq_open() elapsed : %llu us\n", __FUNCTION__, nc_elapsed_us_time(s_time));
|
||||
if (mfd == -1) {
|
||||
perror("mq open error");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((ret = (int32_t)mq_receive(mfd, (char*)out_inference_result, attr.mq_msgsize, NULL)) == -1) {
|
||||
printf("errno of mq_receive = %d\n", errno);
|
||||
}
|
||||
mq_close(mfd);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void nc_cnn_cleanup_inference_result (inference_result_msg **out_inference_result)
|
||||
{
|
||||
if (*out_inference_result) {
|
||||
free((*out_inference_result)->cnn_output.tinfo);
|
||||
free((*out_inference_result)->cnn_output.tiled_data);
|
||||
free((*out_inference_result));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,43 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2022 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
*/
|
||||
/**
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_communicator.h
|
||||
*
|
||||
* @brief : nc_cnn_communicator header
|
||||
*
|
||||
* @author : SoC SW team. NextChip Inc.
|
||||
*
|
||||
* @date : 2022.11.10
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
* 2022.11.10 / 1.0.0 / Initial released.
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __NC_CNN_COMMUNICATOR_H__
|
||||
#define __NC_CNN_COMMUNICATOR_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
#include <mqueue.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "nc_utils.h"
|
||||
#include "nc_cnn_aiware_runtime.h"
|
||||
|
||||
extern int nc_cnn_send_inference_result (struct cnn_config* config, uint64_t time_stamp, cnn_output_info cnn_output);
|
||||
extern int nc_cnn_receive_inference_result (inference_result_msg **out_inference_result);
|
||||
extern void nc_cnn_cleanup_inference_result (inference_result_msg **out_inference_result);
|
||||
#endif
|
||||
Binary file not shown.
@ -0,0 +1,341 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2024 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_draw_cairo.c
|
||||
*
|
||||
* @brief : nc_cnn_draw_cairo source
|
||||
*
|
||||
* @author : Software Development Team. NextChip Inc.
|
||||
*
|
||||
* @date : 2024.09.20.
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <string.h>
|
||||
#include <mqueue.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "cairo.h"
|
||||
#include "nc_utils.h"
|
||||
#include "nc_logo.h"
|
||||
#include "nc_cnn_aiware_runtime.h"
|
||||
#include "nc_ts_fsync_flipflop_buffers.h"
|
||||
#include "nc_ts_fsync_circular_buffers.h"
|
||||
#include "nc_opencv_wrapper.h"
|
||||
#include "nc_cnn_segmentation_postprocess.h"
|
||||
#include "nc_cnn_draw_cairo.h"
|
||||
|
||||
// #define SHOW_FPS
|
||||
// #define SHOW_CNN_THRESHOLD
|
||||
|
||||
#ifdef SHOW_FPS
|
||||
float calc_fps_at_loop_ent(int update_period_fcnt)
|
||||
{
|
||||
static uint64_t s_time = 0;
|
||||
static float fps = 0.f;
|
||||
static uint64_t fcnt = 0;
|
||||
uint64_t elapsed_ms = 0;
|
||||
fcnt++;
|
||||
if (fcnt % update_period_fcnt == 1) {
|
||||
if (s_time == 0) {
|
||||
s_time = nc_get_mono_time();
|
||||
} else {
|
||||
elapsed_ms = nc_elapsed_time(s_time);
|
||||
// printf("fcnt(%d) elapsed_ms(%d)\n", fcnt, elapsed_ms);
|
||||
if (elapsed_ms > 0) fps = (float)((fcnt-1) / (elapsed_ms/1000.f));
|
||||
|
||||
// re-init
|
||||
fcnt = 1;
|
||||
s_time = nc_get_mono_time();
|
||||
}
|
||||
}
|
||||
|
||||
return fps;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// cairo control //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
static cairo_t* cr;
|
||||
static cairo_t* cairo[FIXED_FSYNC_FLIP_FLOP_BUF_CNT] = {NULL, };
|
||||
#ifdef USE_GUI_CQ_BUFFER
|
||||
unsigned char* gui_buffer = NULL;
|
||||
#endif
|
||||
void nc_cairo_init_cavas (unsigned int canvas_w, unsigned int canvas_h)
|
||||
{
|
||||
// init canvas
|
||||
printf("GUI WIDTH: %d, HEIGHT: %d\n", canvas_w, canvas_h);
|
||||
#ifdef USE_GUI_CQ_BUFFER
|
||||
// int gui_buf_size = canvas_w * canvas_h * 4;
|
||||
gui_buffer = (unsigned char*)malloc(canvas_w * canvas_h * 4);
|
||||
cr = cairo_create( cairo_image_surface_create_for_data( gui_buffer,
|
||||
CAIRO_FORMAT_ARGB32, canvas_w, canvas_h, canvas_w*4) );
|
||||
#else
|
||||
for (int i = 0; i < FIXED_FSYNC_FLIP_FLOP_BUF_CNT; i++) {
|
||||
cairo[i] = cairo_create( cairo_image_surface_create_for_data(
|
||||
(unsigned char *)nc_tsfs_ff_get_addr_of_buffer(UID_TSB_GUI, i),
|
||||
CAIRO_FORMAT_ARGB32, canvas_w, canvas_h, canvas_w*4) );
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
cairo_t* nc_cairo_clear_and_ready_writebuffer (uint64_t time_stamp)
|
||||
{
|
||||
int gui_write_idx = 0;
|
||||
|
||||
#ifndef USE_GUI_CQ_BUFFER
|
||||
// get gui writable buffer & index from flip-flop(double) buffers
|
||||
nc_tsfs_ff_get_writable_buffer_and_set_timestamp(UID_TSB_GUI, &gui_write_idx, time_stamp);
|
||||
|
||||
// prepare & clear gui buffer(cairo canvas)
|
||||
cr = cairo[gui_write_idx];
|
||||
#endif
|
||||
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_CLEAR);
|
||||
cairo_paint(cr);
|
||||
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
|
||||
return cr;
|
||||
}
|
||||
|
||||
void nc_cairo_draw_extended_infos_and_logo (uint64_t framecnt)
|
||||
{
|
||||
unsigned char text[128] = {0,};
|
||||
|
||||
#ifdef SHOW_FPS
|
||||
float fps = 0.0f;
|
||||
fps = calc_fps_at_loop_ent(30);
|
||||
// printf("[%s] ....... fps(%0.1f) ........\n", __FUNCTION__, fps);
|
||||
#endif
|
||||
float ratio = 0.8f;//canvas_w/1280.f;
|
||||
|
||||
// show frame count
|
||||
cairo_select_font_face(cr, "monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
|
||||
cairo_set_font_size(cr, 20*ratio);
|
||||
cairo_set_source_rgba(cr, 0, 0, 1.0, 1.0);
|
||||
cairo_move_to(cr, 20, 22);
|
||||
|
||||
#ifdef SHOW_FPS
|
||||
sprintf((char *)text, "Frame Count : %lu FPS : %0.1f", framecnt, fps);
|
||||
#else
|
||||
sprintf((char *)text, "Frame Count : %lu", framecnt);
|
||||
#endif
|
||||
|
||||
cairo_show_text(cr, (const char *)text);
|
||||
|
||||
#ifdef SHOW_CNN_THRESHOLD
|
||||
unsigned char text2[128] = {0,};
|
||||
cairo_move_to(cr, 10, 45);
|
||||
sprintf((char *)text2, "Objectness-TH(%0.1f) Detection-TH(%0.1f)", PELEE_CONFIDENCE_OBJECTNESS_THRESHOLD, PELEE_CONFIDENCE_DETECTION_THRESHOLD);
|
||||
cairo_show_text(cr, (const char *)text2);
|
||||
#endif
|
||||
}
|
||||
|
||||
void nc_cairo_finish_draw_writebuffer(void)
|
||||
{
|
||||
#ifndef USE_GUI_CQ_BUFFER
|
||||
nc_tsfs_ff_finish_write_buf(UID_TSB_GUI);
|
||||
#endif
|
||||
}
|
||||
|
||||
void nc_cairo_destroy (void)
|
||||
{
|
||||
#ifndef USE_GUI_CQ_BUFFER
|
||||
for (int i = 0; i < FIXED_FSYNC_FLIP_FLOP_BUF_CNT; i++) {
|
||||
if (cairo[i]) cairo_destroy(cairo[i]);
|
||||
}
|
||||
#else
|
||||
if (cr) cairo_destroy(cr);
|
||||
free(gui_buffer);
|
||||
#endif
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// draw object detection //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// #define PRINT_AVG_DETECTION_DRAW_TIME
|
||||
void nc_cairo_draw_object_detections (cairo_t *canvas, stObjDrawInfo* drawInfo, stCnnPostprocessingResults *cnn_results)
|
||||
{
|
||||
static int canvas_w = 0;
|
||||
static int canvas_h = 0;
|
||||
static float ratio = 1.f;
|
||||
if (canvas_w == 0 || canvas_h == 0) {
|
||||
cairo_surface_t* cr_surface = cairo_get_target(canvas);
|
||||
canvas_w = cairo_image_surface_get_width(cr_surface);
|
||||
canvas_h = cairo_image_surface_get_height(cr_surface);
|
||||
//ratio = (float)canvas_w/1280;
|
||||
ratio = (float)canvas_w/1920;
|
||||
}
|
||||
|
||||
char text[128] = {'\0',};
|
||||
cairo_select_font_face(canvas, "monospace", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
|
||||
cairo_set_font_size(canvas, 21*ratio);
|
||||
cairo_set_line_width(canvas, 2.0*ratio);
|
||||
|
||||
#ifdef PRINT_AVG_DETECTION_DRAW_TIME
|
||||
static uint64_t fcnt = 0;
|
||||
static uint64_t t_time = 0;
|
||||
uint64_t s_time = nc_get_mono_us_time();
|
||||
uint64_t el_time = 0;
|
||||
#endif
|
||||
for (int i = 0; i < drawInfo->max_class_cnt; i++) {
|
||||
for (int bidx = 0; bidx < cnn_results->class_objs[i].obj_cnt; bidx++) {
|
||||
stObjInfo obj_info = cnn_results->class_objs[i].objs[bidx];
|
||||
if (obj_info.bbox.w >= 3 && obj_info.bbox.h >= 3)
|
||||
{
|
||||
#ifdef SHOW_CNN_PROBABILITY
|
||||
// show cnn probability (not track id)
|
||||
if (obj_info.track_id < 0) sprintf((char *)text, "%s:%0.2f", drawInfo->class_names[i], obj_info.prob);
|
||||
else sprintf((char *)text, "%s:%0.2f", drawInfo->class_names[i], obj_info.prob);
|
||||
#else
|
||||
// show track id (not cnn probability)
|
||||
if (obj_info.track_id < 0) sprintf((char *)text, "%s", drawInfo->class_names[i]);
|
||||
else sprintf((char *)text, "%s:%d", drawInfo->class_names[i], obj_info.track_id);
|
||||
#endif
|
||||
|
||||
cairo_set_source_rgb (canvas, drawInfo->class_colors[i].r, drawInfo->class_colors[i].g, drawInfo->class_colors[i].b);
|
||||
cairo_rectangle(canvas, obj_info.bbox.x, obj_info.bbox.y, obj_info.bbox.w, obj_info.bbox.h);
|
||||
|
||||
double lx, ly;
|
||||
cairo_text_extents_t c_ext;
|
||||
cairo_text_extents(canvas, text, &c_ext);
|
||||
|
||||
#ifdef SHOW_CLASS_LABEL_BOX
|
||||
double lw, lh;
|
||||
cairo_stroke (canvas);
|
||||
lh = c_ext.height+4;
|
||||
lw = c_ext.width+4;
|
||||
|
||||
#if 1
|
||||
lx = obj_info.bbox.x-ratio;
|
||||
ly = obj_info.bbox.y-lh;
|
||||
// if (ly - lh < 0) ly = obj_info.bbox.y + obj_info.bbox.h;
|
||||
#else
|
||||
if (obj_info.bbox.w >= lw) {
|
||||
lx = obj_info.bbox.x+obj_info.bbox.w-lw;
|
||||
// lx = obj_info.bbox.x;
|
||||
ly = obj_info.bbox.y-lh;
|
||||
}
|
||||
else {
|
||||
lx = obj_info.bbox.x;
|
||||
ly = obj_info.bbox.y-lh;
|
||||
}
|
||||
#endif
|
||||
|
||||
cairo_rectangle(canvas, lx, ly, lw, lh);
|
||||
cairo_fill (canvas);
|
||||
|
||||
cairo_set_source_rgb (canvas, 1.0-drawInfo->class_colors[i].r, 1.0-drawInfo->class_colors[i].g, 1.0-drawInfo->class_colors[i].b);
|
||||
cairo_move_to(canvas, lx+1, ly + c_ext.height+1);
|
||||
cairo_show_text(canvas, (char *)text);
|
||||
cairo_stroke (canvas);
|
||||
#else
|
||||
lx = (obj_info.bbox.x+obj_info.bbox.w/2)-(c_ext.width/2);
|
||||
ly = (obj_info.bbox.y+obj_info.bbox.h/2)-(c_ext.height/2);
|
||||
cairo_move_to(canvas, lx, ly);
|
||||
cairo_show_text(canvas, (char *)text);
|
||||
cairo_stroke (canvas);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef PRINT_AVG_DETECTION_DRAW_TIME
|
||||
fcnt++;
|
||||
el_time = nc_elapsed_us_time(s_time);
|
||||
t_time += el_time;
|
||||
if (fcnt % 30 == 0) {
|
||||
printf("[%s:%d]........... (detection:fcnt(%llu)) avg draw elapsed : %llu us\n", __FUNCTION__, __LINE__, fcnt, t_time/fcnt);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// draw segmentation //
|
||||
// //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
#if 0
|
||||
void nc_opencv_draw_freespace(unsigned int canvas_w, unsigned int canvas_h, unsigned int *canvas, cnn_output_info cnn_output)
|
||||
{
|
||||
uint32_t *npu_canvas;
|
||||
struct img_info src_img, dst_img;
|
||||
|
||||
npu_canvas = (uint32_t *)malloc(cnn_output.width*cnn_output.height*sizeof(uint32_t));
|
||||
nc_tiled_to_scanline(cnn_output, (unsigned int *)npu_canvas);
|
||||
|
||||
// source image <== npu output
|
||||
src_img.width = cnn_output.width;
|
||||
src_img.height = cnn_output.height;
|
||||
src_img.buff = (uint8_t *)npu_canvas;
|
||||
|
||||
// destination image <== canvas_ptr for display
|
||||
dst_img.width = canvas_w;
|
||||
dst_img.height = canvas_h;
|
||||
dst_img.buff = (uint8_t *)canvas;
|
||||
nc_opencv_resize(&src_img, &dst_img);
|
||||
free(npu_canvas);
|
||||
}
|
||||
#endif
|
||||
|
||||
void nc_cairo_draw_argmax_freespace(unsigned int canvas_w, unsigned int canvas_h, cairo_t *cr, cnn_output_info cnn_output)
|
||||
{
|
||||
double h_ratio_coeff;
|
||||
double y_pos;
|
||||
double v_ratio_coeff;
|
||||
uint32_t i = 0;
|
||||
|
||||
uint32_t* freespace = (uint32_t*)malloc(cnn_output.width * sizeof(uint32_t));
|
||||
if (freespace == NULL) {
|
||||
printf("Failed to allocate freespace memory");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
memset(freespace, 0, cnn_output.width * sizeof(uint32_t));
|
||||
|
||||
h_ratio_coeff = (double)(canvas_w / cnn_output.width);
|
||||
v_ratio_coeff = (double)(canvas_h / cnn_output.height);
|
||||
nc_argmax_opt2((unsigned char*)cnn_output.tiled_data, cnn_output.width, cnn_output.height, (uint8_t *)freespace);
|
||||
|
||||
// draw freespace
|
||||
//printf("ratio_coeff: %f, %d\n", v_ratio_coeff, h_ratio_coeff);
|
||||
cairo_set_source_rgba(cr, 0, 0, 1, 0.5);
|
||||
cairo_set_line_width(cr, h_ratio_coeff);
|
||||
for (i = 0 ; i < cnn_output.width ; i++) {
|
||||
y_pos = ((double)freespace[i] * v_ratio_coeff);
|
||||
if (y_pos > 0) {
|
||||
cairo_move_to(cr, (double)i*h_ratio_coeff, y_pos);
|
||||
cairo_line_to(cr, (double)i*h_ratio_coeff, canvas_h-1);
|
||||
}
|
||||
}
|
||||
cairo_stroke(cr);
|
||||
|
||||
free(freespace);
|
||||
}
|
||||
|
||||
void nc_direct_draw_freespace_to_canvas(unsigned int canvas_w, unsigned int canvas_h, unsigned int *canvas, cnn_output_info cnn_output)
|
||||
{
|
||||
nc_tiled_to_scanline_n_scale_up(cnn_output, canvas_w, canvas_h, canvas);
|
||||
}
|
||||
@ -0,0 +1,51 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2024 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_draw_cairo.h
|
||||
*
|
||||
* @brief : nc_cnn_draw_cairo header
|
||||
*
|
||||
* @author : Software Development Team. NextChip Inc.
|
||||
*
|
||||
* @date : 2024.09.20.
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __NC_CNN_DRAW_CAIRO_H__
|
||||
#define __NC_CNN_DRAW_CAIRO_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "nc_cnn_common.h"
|
||||
|
||||
struct cnn_output_info; // To be removed (cnn)
|
||||
// cairo control
|
||||
extern void nc_cairo_init_cavas (unsigned int canvas_w, unsigned int canvas_h);
|
||||
extern cairo_t* nc_cairo_clear_and_ready_writebuffer (uint64_t time_stamp);
|
||||
extern void nc_cairo_draw_extended_infos_and_logo (uint64_t framecnt);
|
||||
extern void nc_cairo_finish_draw_writebuffer(void);
|
||||
extern void nc_cairo_destroy (void);
|
||||
|
||||
// draw object detection
|
||||
extern void nc_cairo_draw_object_detections (cairo_t *canvas, stObjDrawInfo* drawInfo, stCnnPostprocessingResults *cnn_results);
|
||||
|
||||
// draw segmentation
|
||||
#if 0
|
||||
extern void nc_opencv_draw_freespace (unsigned int canvas_w, unsigned int canvas_h, unsigned int *canvas, cnn_output_info cnn_output); // To be removed (cnn)
|
||||
#endif
|
||||
extern void nc_cairo_draw_argmax_freespace (unsigned int canvas_w, unsigned int canvas_h, cairo_t *cr, cnn_output_info cnn_output); // To be removed (cnn)
|
||||
extern void nc_direct_draw_freespace_to_canvas (unsigned int canvas_w, unsigned int canvas_h, unsigned int *canvas, cnn_output_info cnn_output); // To be removed (cnn)
|
||||
// extern void *cnn_draw_task(void *arg);
|
||||
|
||||
#endif // __NC_CNN_DRAW_CAIRO_H__
|
||||
@ -0,0 +1,156 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2024 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_tracker.c
|
||||
*
|
||||
* @brief : nc_cnn_tracker source
|
||||
*
|
||||
* @author : Software Development Team. NextChip Inc.
|
||||
*
|
||||
* @date : 2024.09.23.
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#include "nc_cnn_config_parser.h"
|
||||
#include "nc_bytetrack_wrapper.h"
|
||||
#include "nc_cnn_tracker.h"
|
||||
#include "nc_utils.h"
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// #define SHOW_BYTETRACK_TIMEMEASURE
|
||||
|
||||
uint32_t tracked_out_bbox_cnt = 0;
|
||||
stObjInfo *tracked_objs_info_arr = NULL;
|
||||
|
||||
// TODO: ignore specific class
|
||||
// static int is_not_tracking_class (int class_id) {
|
||||
// #ifdef IGN_SPECIFIC_CLASS_TRACKING
|
||||
// if (strcmp(yolov5_class_names[class_id],"air") == 0) {
|
||||
// return 1;
|
||||
// }
|
||||
// #endif
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int nc_init_bytetrackers (int fps, int cam_ch, E_NETWORK_UID net_id)
|
||||
{
|
||||
stNetwork_info* net_info = NULL;
|
||||
|
||||
net_info = nc_cnn_get_network_info(net_id);
|
||||
if (net_info == NULL){
|
||||
printf("%s, nc_cnn_get_network_info fail. net_id:%d\n", __FUNCTION__, (int)net_id);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tracked_objs_info_arr = (stObjInfo *)malloc(sizeof(stObjInfo) * MAX_CNN_RESULT_CNT_OF_CLASS);
|
||||
return nc_init_bytetracker(fps, fps/2, net_info->class_id, net_info->class_num, cam_ch);
|
||||
}
|
||||
|
||||
void nc_deInit_bytetrackers (int cam_ch)
|
||||
{
|
||||
// deinit byte tracker
|
||||
nc_destroy_byettracker(cam_ch);
|
||||
|
||||
if (tracked_objs_info_arr != NULL) {
|
||||
free(tracked_objs_info_arr);
|
||||
}
|
||||
}
|
||||
|
||||
void nc_cnn_track(stCnnPostprocessingResults *out_cnn_results, E_NETWORK_UID net_id, int cam_ch)
|
||||
{
|
||||
int i = 0;
|
||||
stNetwork_info* net_info = NULL;
|
||||
|
||||
net_info = nc_cnn_get_network_info(net_id);
|
||||
if (net_info == NULL){
|
||||
printf("%s, nc_cnn_get_network_info fail. net_id:%d\n", __FUNCTION__, (int)net_id);
|
||||
return;
|
||||
}
|
||||
|
||||
stCnnDetectedObjInfo detected_objs[net_info->class_num][MAX_CNN_RESULT_CNT_OF_CLASS] = {0,};
|
||||
int each_class_det_cnt[net_info->class_num] = {0,};
|
||||
|
||||
// Formatting with tracker input
|
||||
for (i = 0; i < net_info->class_num; i++)
|
||||
{
|
||||
for(int bidx = 0; bidx < out_cnn_results->class_objs[i].obj_cnt; bidx++)
|
||||
{
|
||||
// TODO: ignore specific class
|
||||
// if not tracking class -> don't transfer to bytetracker..
|
||||
// if (is_not_tracking_class(i)) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
int idx = each_class_det_cnt[i];
|
||||
if (idx == MAX_CNN_RESULT_CNT_OF_CLASS) {
|
||||
continue;
|
||||
}
|
||||
detected_objs[i][idx].class_id = out_cnn_results->class_objs[i].class_id;
|
||||
detected_objs[i][idx].x = out_cnn_results->class_objs[i].objs[bidx].bbox.x;
|
||||
detected_objs[i][idx].y = out_cnn_results->class_objs[i].objs[bidx].bbox.y;
|
||||
detected_objs[i][idx].w = out_cnn_results->class_objs[i].objs[bidx].bbox.w;
|
||||
detected_objs[i][idx].h = out_cnn_results->class_objs[i].objs[bidx].bbox.h;
|
||||
detected_objs[i][idx].prob = out_cnn_results->class_objs[i].objs[bidx].prob;
|
||||
each_class_det_cnt[i]++;
|
||||
|
||||
#if 0
|
||||
float prob = detected_objs[pred_class][idx].prob;
|
||||
if (prob < 0.9) {
|
||||
printf("............... class id : %d / prob : %f ..............\n", pred_class, prob);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SHOW_BYTETRACK_TIMEMEASURE
|
||||
uint64_t elapsed_ms = 0;
|
||||
#endif
|
||||
|
||||
// Update tracker
|
||||
for (i = 0; i < net_info->class_num; i++)
|
||||
{
|
||||
if (each_class_det_cnt[i] < 1) continue;
|
||||
|
||||
// TODO: ignore specific class
|
||||
// if not tracking class
|
||||
// if (is_not_tracking_class(i)) continue;
|
||||
|
||||
#ifdef SHOW_BYTETRACK_TIMEMEASURE
|
||||
uint64_t start_time;
|
||||
start_time = nc_get_mono_time();
|
||||
#endif
|
||||
|
||||
tracked_out_bbox_cnt = 0;
|
||||
memset(tracked_objs_info_arr, 0, sizeof(stObjInfo) * MAX_CNN_RESULT_CNT_OF_CLASS);
|
||||
nc_update_bytetracked_objs_per_frame(i, detected_objs[i], each_class_det_cnt[i], tracked_objs_info_arr, &tracked_out_bbox_cnt, cam_ch);
|
||||
|
||||
out_cnn_results->class_objs[i].class_id = i;
|
||||
out_cnn_results->class_objs[i].obj_cnt = tracked_out_bbox_cnt;
|
||||
#ifdef SHOW_BYTETRACK_TIMEMEASURE
|
||||
elapsed_ms += nc_elapsed_time(start_time);
|
||||
#endif
|
||||
|
||||
for (uint32_t bidx = 0; bidx < tracked_out_bbox_cnt; bidx++) {
|
||||
out_cnn_results->class_objs[i].objs[bidx] = tracked_objs_info_arr[bidx];
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SHOW_BYTETRACK_TIMEMEASURE
|
||||
printf("....... bytetrack update time (total w/o draw) ch=%d : %lu ms%s\n", cam_ch, elapsed_ms, (elapsed_ms > 5)?" > 5 ms":"");
|
||||
#endif
|
||||
}
|
||||
@ -0,0 +1,35 @@
|
||||
/**
|
||||
********************************************************************************
|
||||
* Copyright (C) 2024 NEXTCHIP Inc. All rights reserved.
|
||||
* This software is the confidential and proprietary information of
|
||||
* NEXTCHIP, Inc. ("Confidential Information"). You shall not disclose such
|
||||
* Confidential Information and shall use it only in accordance with
|
||||
* the terms of the license agreement you entered into with NEXTCHIP.
|
||||
********************************************************************************
|
||||
|
||||
********************************************************************************
|
||||
* @file : nc_cnn_tracker.h
|
||||
*
|
||||
* @brief : nc_cnn_tracker header
|
||||
*
|
||||
* @author : Software Development Team. NextChip Inc.
|
||||
*
|
||||
* @date : 2024.09.23.
|
||||
*
|
||||
* @version : 1.0.0
|
||||
********************************************************************************
|
||||
* @note
|
||||
*
|
||||
********************************************************************************
|
||||
*/
|
||||
|
||||
#ifndef __NC_CNN_TRACKER_H__
|
||||
#define __NC_CNN_TRACKER_H__
|
||||
|
||||
#include "nc_cnn_common.h"
|
||||
|
||||
int nc_init_bytetrackers (int fps, int cam_ch, E_NETWORK_UID net_id);
|
||||
void nc_deInit_bytetrackers (int cam_ch);
|
||||
void nc_cnn_track(stCnnPostprocessingResults *out_cnn_results, E_NETWORK_UID net_id, int cam_ch);
|
||||
|
||||
#endif // __NC_CNN_TRACKER_H__
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue