.. _program_listing_file__tmp_ws_src_vitis_common_include_imgproc_xf_svm.hpp: Program Listing for File xf_svm.hpp =================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/vitis_common/include/imgproc/xf_svm.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /* * Copyright 2019 Xilinx, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef _XF_SVM_H_ #define _XF_SVM_H_ #include "../common/xf_common.hpp" /**************************************************************** * xFSVM: SVM core computation (dot product function) * ------ * * Inputs: * ------- * in_1: Input array 1 * in_2: Input array 2 * idx1: Starting index of Input array 1 * idx2: Starting index of Input array 2 * frac1: Fractional bits in the Input array 1 * frac2: Fractional bits in the Input array 2 * n: number of kernel operations * * Output: * ------- * out_frac: Fractional bits in the output result * ***************************************************************/ namespace xf { namespace cv { template ap_int xfSVM(xf::cv::Mat& in_1, xf::cv::Mat& in_2, uint16_t idx1, uint16_t idx2, uchar_t frac1, uchar_t frac2, uint16_t n, uchar_t* out_frac) { // clang-format off #pragma HLS INLINE OFF // clang-format on // temporary result ap_int result = 0; svmCoreLoop: for (int i = 0; i < n; i++) { // clang-format off #pragma HLS LOOP_TRIPCOUNT min=N max=N avg=N #pragma HLS PIPELINE // clang-format on ap_int val_in1 = in_1.read(idx1 + i); ap_int val_in2 = in_2.read(idx2 + i); // Dot product operation ap_int tmp_svm = (ap_int)(val_in1 * val_in2); result += tmp_svm; } *out_frac = frac1 + frac2; return result; } template void SVM(xf::cv::Mat& in_1, xf::cv::Mat& in_2, uint16_t idx1, uint16_t idx2, uchar_t frac1, uchar_t frac2, uint16_t n, uchar_t* out_frac, ap_int* result) { #ifndef __SYNTHESIS__ assert(((SRC1_T == XF_16SC1)) && "Only 16 bit, single channel images are supported"); assert(((SRC2_T == XF_16SC1)) && "Only 16 bit, single channel images are supported"); #endif ap_int svm_res = xfSVM( in_1, in_2, idx1, idx2, frac1, frac2, n, out_frac); *result = svm_res; } } // namespace cv } // namespace xf #endif