当前位置:网站首页>[openvx] VX for basic use of objects_ convolution
[openvx] VX for basic use of objects_ convolution
2022-07-28 03:39:00 【zhy29563】
1. Program source code
#include <iostream>
#include <VX/vx.h>
void print_convolution(vx_convolution convolution, const char *message)
{
std::cout << "===============================" << std::endl;
std::cout << message << std::endl;
vx_size rows;
vxQueryConvolution(convolution, (vx_enum)VX_CONVOLUTION_ROWS, &rows, sizeof(rows));
vx_size cols;
vxQueryConvolution(convolution, (vx_enum)VX_CONVOLUTION_COLUMNS, &cols, sizeof(cols));
vx_uint32 scale;
vxQueryConvolution(convolution, (vx_enum)VX_CONVOLUTION_SCALE, &scale, sizeof(scale));
vx_size size;
vxQueryConvolution(convolution, (vx_enum)VX_CONVOLUTION_SIZE, &size, sizeof(size));
std::cout << "rows : " << rows << std::endl;
std::cout << "cols : " << cols << std::endl;
std::cout << "scale : " << scale << std::endl;
std::cout << "size : " << size << std::endl;
std::cout << "item size : " << size / (rows * cols) << std::endl;
void* buffer = malloc(size);
// In user memory , Convolution coefficients are stored in the form of row spindles
vxCopyConvolutionCoefficients(convolution, buffer, VX_READ_ONLY, VX_MEMORY_TYPE_HOST);
std::cout << "convolution coefficients" << std::endl;
for (int row = 0; row < rows; ++row) {
std::cout << "\t";
for (int col = 0; col < cols; ++col) {
std::cout << ((vx_int16*)buffer)[row * cols + col] << "\t";
}
std::cout << std::endl;
}
free(buffer);
}
int main(int argc, char *argv[])
{
(void) argc;
(void) argv;
vx_status status;
vx_context context = vxCreateContext();
// Parameters columns And rows Must be base , And within the scope [3, VX_CONTEXT_CONVOLUTION_MAX_DIMENSION)
vx_size cols = 7U;
vx_size rows = 5U;
vx_convolution convolution = vxCreateConvolution(context, cols, rows);
print_convolution(convolution, "create");
// Update elements
vx_int16 *coefficients = (vx_int16*)malloc(rows * cols * sizeof (vx_int16));
for (int i = 0; i < rows * cols; ++i) {
coefficients[i] = i;
}
vxCopyConvolutionCoefficients(convolution, coefficients, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST);
print_convolution(convolution, "update items");
// Set properties
vx_uint32 scale = 2;
vxSetConvolutionAttribute(convolution, (vx_enum)VX_CONVOLUTION_SCALE, &scale, sizeof (scale));
print_convolution(convolution, "update scale");
free(coefficients);
vxReleaseConvolution(&convolution);
vxReleaseContext(&context);
return EXIT_SUCCESS;
}
2. Running results
===============================
create
rows : 5
cols : 7
scale : 1
size : 70
item size : 2
convolution coefficients
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
===============================
update items
rows : 5
cols : 7
scale : 1
size : 70
item size : 2
convolution coefficients
0 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 32 33 34
===============================
update scale
rows : 5
cols : 7
scale : 2
size : 70
item size : 2
convolution coefficients
0 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31 32 33 34
边栏推荐
- A treasure simulates login and reduces the method of secondary verification
- Win11 how to rename an audio device
- The wonderful use of asemi rectifier bridge GBPC3510 in DC brush motor
- Daily practice ----- realize the lottery function of two-color ball. Rules: Six non repeating numbers are randomly selected from 36 red balls, and one from 15 basketball is randomly selected to form a
- Log analysis tool (Splunk)
- Integrate SSM to realize search of addition, deletion, modification and query
- Responsive high-end website template source code Gallery material resource download platform source code
- 【P4】解决本地文件修改与库文件间的冲突问题
- Shell: resource monitoring script and high load alarm
- CF question making record from July 25th to July 31st
猜你喜欢

【力扣】1337.矩阵中战斗力最弱的k行

4天Excel实战训练营,0.01元特惠仅三天,赠200套学习资料包

Tungsten Fabric SDN — BGP as a Service

Prefix-Tuning: Optimizing Continuous Prompts for Generation

ES6 从入门到精通 # 09:Symbol 类型

⽇志分析⼯具(Splunk)

How to make the Internet access the intranet IP (used by esp8266 web pages)

verticle-align行内元素垂直居中对齐

Responsive high-end website template source code Gallery material resource download platform source code

Swift中的协议
随机推荐
过亿资产地址被拉入黑名单?Tether地址冻结功能该怎么用?
ES6 from getting started to mastering 09: symbol type
Swift中的协议
leetcode刷题:动态规划09(最后一块石头的重量 II)
【力扣】1337.矩阵中战斗力最弱的k行
[错题]Concatenation
How to uninstall clean ZABBIX service? (super detailed)
【P4】解决本地文件修改与库文件间的冲突问题
Play WolframAlpha computing knowledge engine
Unity simply implements the dialog function
【OPENVX】对象基本使用之vx_lut
Responsive high-end website template source code Gallery material resource download platform source code
pip-script.py‘ is not present Verifying transaction: failed
Win11 how to rename an audio device
Redis source code analysis (who says C language can't analyze it?)
Unity简单实现对话功能
Light year admin background management system template
Prefix-Tuning: Optimizing Continuous Prompts for Generation
MySQL stored procedures use cursors to synchronize data between two tables
8000字讲透OBSA原理与应用实践