风翼冰舟的留言板

风翼冰舟
博客专家认证
2020-01-02 06:45:03
大家好,这里是我的留言板,如果有问题,欢迎大家留言,我会第一时间进行回复
...全文
108 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
风翼冰舟 2020-04-09
  • 打赏
  • 举报
回复
引用 7 楼 caomeng0905 的回复:
[quote=引用 6 楼 风翼冰舟 的回复:] [quote=引用 5 楼 caomeng0905 的回复:] 博主,你好。我在用openblas求最大最小值的时候,发小效率差异很多,求最大值的效率几乎是最小值的4倍左右。请问可能的原因有哪些 ?
求最大最小值的算法是一样的时间复杂度么,试试求最小值和负最大值是不是一样的时间效率啥的,直接说最大最小值,我有点meng [/quote] 我说的是cblas_icamin 和 cblas_icamax的执行效率。完整测试代码如下: #include <time.h> #include <stdio.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <stdbool.h> #include <math.h> #include <float.h> #include "cblas.h" #define ALIGN16 __attribute__ ((aligned(16))) #define ALIGN32 __attribute__ ((aligned(32))) #define ALIGN64 __attribute__ ((aligned(64))) #define ALIGN128 __attribute__ ((aligned(128))) #define INT64 long long int INT64 vos_task_time_read() { struct timespec time; clock_gettime(CLOCK_MONOTONIC, &time); return (time.tv_sec * 1000000000 + time.tv_nsec); } void matrix_init_c( float *matrix_in, int m, int n) { float init = 0.0; float increase = 0.0; for(int i = 0; i < m; i++) { for(int j = 0; j < n ; j++) { matrix_in[i * n * 2 + 2 * j] = (float)rand()/(float)(RAND_MAX); matrix_in[i * n * 2 + 2 * j + 1] = (float)rand()/(float)(RAND_MAX);; } } } void openblas_matrix_min(float *matrix, int row, int col,float *value,int *index_m,int *index_n) { CBLAS_INDEX index = 0; index = cblas_icamin(row * col,matrix,1); value[0] = matrix[index * 2]; value[1] = matrix[index * 2 + 1]; *index_m = index / col; *index_n = index - col * (*index_m); } void openblas_matrix_max(float *matrix, int row, int col,float *value,int *index_m,int *index_n) { CBLAS_INDEX index = 0; index = cblas_icamax(row * col,matrix,1); value[0] = matrix[index * 2]; value[1] = matrix[index * 2 + 1]; *index_m = index / col; *index_n = index - col * (*index_m); } int main(void) { int m = 512, n = 32; float A[n * m * 2] = {0.0}; float value[2] = {0}; int index_m = 0,index_n = 0; matrix_init_c(A,m,n); INT64 start_time,end_time; int test_num = 1000; start_time = vos_task_time_read(); for(int i = 0; i < test_num;i++) { openblas_matrix_max(A,m,n,value,&index_m,&index_n); } end_time = vos_task_time_read(); printf("max : openblas time = %.2f us\n",(end_time - start_time)/1000.0/test_num); start_time = vos_task_time_read(); for(int i = 0; i < test_num;i++) { openblas_matrix_min(A,m,n,value,&index_m,&index_n); } end_time = vos_task_time_read(); printf("min : openblas time = %.2f us\n",(end_time - start_time)/1000.0/test_num); return 0; }[/quote] 我周六日尝试一波看看
caomeng0905 2020-04-08
  • 打赏
  • 举报
回复
引用 6 楼 风翼冰舟 的回复:
[quote=引用 5 楼 caomeng0905 的回复:] 博主,你好。我在用openblas求最大最小值的时候,发小效率差异很多,求最大值的效率几乎是最小值的4倍左右。请问可能的原因有哪些 ?
求最大最小值的算法是一样的时间复杂度么,试试求最小值和负最大值是不是一样的时间效率啥的,直接说最大最小值,我有点meng [/quote] 我说的是cblas_icamin 和 cblas_icamax的执行效率。完整测试代码如下: #include <time.h> #include <stdio.h> #include <unistd.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h> #include <stdbool.h> #include <math.h> #include <float.h> #include "cblas.h" #define ALIGN16 __attribute__ ((aligned(16))) #define ALIGN32 __attribute__ ((aligned(32))) #define ALIGN64 __attribute__ ((aligned(64))) #define ALIGN128 __attribute__ ((aligned(128))) #define INT64 long long int INT64 vos_task_time_read() { struct timespec time; clock_gettime(CLOCK_MONOTONIC, &time); return (time.tv_sec * 1000000000 + time.tv_nsec); } void matrix_init_c( float *matrix_in, int m, int n) { float init = 0.0; float increase = 0.0; for(int i = 0; i < m; i++) { for(int j = 0; j < n ; j++) { matrix_in[i * n * 2 + 2 * j] = (float)rand()/(float)(RAND_MAX); matrix_in[i * n * 2 + 2 * j + 1] = (float)rand()/(float)(RAND_MAX);; } } } void openblas_matrix_min(float *matrix, int row, int col,float *value,int *index_m,int *index_n) { CBLAS_INDEX index = 0; index = cblas_icamin(row * col,matrix,1); value[0] = matrix[index * 2]; value[1] = matrix[index * 2 + 1]; *index_m = index / col; *index_n = index - col * (*index_m); } void openblas_matrix_max(float *matrix, int row, int col,float *value,int *index_m,int *index_n) { CBLAS_INDEX index = 0; index = cblas_icamax(row * col,matrix,1); value[0] = matrix[index * 2]; value[1] = matrix[index * 2 + 1]; *index_m = index / col; *index_n = index - col * (*index_m); } int main(void) { int m = 512, n = 32; float A[n * m * 2] = {0.0}; float value[2] = {0}; int index_m = 0,index_n = 0; matrix_init_c(A,m,n); INT64 start_time,end_time; int test_num = 1000; start_time = vos_task_time_read(); for(int i = 0; i < test_num;i++) { openblas_matrix_max(A,m,n,value,&index_m,&index_n); } end_time = vos_task_time_read(); printf("max : openblas time = %.2f us\n",(end_time - start_time)/1000.0/test_num); start_time = vos_task_time_read(); for(int i = 0; i < test_num;i++) { openblas_matrix_min(A,m,n,value,&index_m,&index_n); } end_time = vos_task_time_read(); printf("min : openblas time = %.2f us\n",(end_time - start_time)/1000.0/test_num); return 0; }
风翼冰舟 2020-04-07
  • 打赏
  • 举报
回复
引用 5 楼 caomeng0905 的回复:
博主,你好。我在用openblas求最大最小值的时候,发小效率差异很多,求最大值的效率几乎是最小值的4倍左右。请问可能的原因有哪些 ?
求最大最小值的算法是一样的时间复杂度么,试试求最小值和负最大值是不是一样的时间效率啥的,直接说最大最小值,我有点meng
caomeng0905 2020-04-07
  • 打赏
  • 举报
回复
博主,你好。我在用openblas求最大最小值的时候,发小效率差异很多,求最大值的效率几乎是最小值的4倍左右。请问可能的原因有哪些 ?
TacoTuesday 2020-04-02
  • 打赏
  • 举报
回复
引用 3 楼 风翼冰舟的回复:
[quote=引用 2 楼 TacoTuesday 的回复:] 博主,你好,有没有用Python实现RBF神经网络预测的代码?
暂时没写过哦,可以去GitHub上找一下,或者后面我有时间就动手写一个试试[/quote] 好的,谢谢,网上大多是分类的,需要非线性预测的模型参考一下,自己改的有问题。
风翼冰舟 2020-04-02
  • 打赏
  • 举报
回复
引用 2 楼 TacoTuesday 的回复:
博主,你好,有没有用Python实现RBF神经网络预测的代码?
暂时没写过哦,可以去GitHub上找一下,或者后面我有时间就动手写一个试试
TacoTuesday 2020-04-01
  • 打赏
  • 举报
回复
博主,你好,有没有用Python实现RBF神经网络预测的代码?
TacoTuesday 2020-04-01
  • 打赏
  • 举报
回复
博主,你好,有没有用Python实现RBF神经网络预测的代码?

588

社区成员

发帖
与我相关
我的任务
社区描述
提出问题
其他 技术论坛(原bbs)
社区管理员
  • community_281
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧