首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

水水水水水水水水水水水水水水水水

前端 31.6KB 29 需要积分: 1
立即下载

资源介绍:

水水水水水水水水水水水水水水水水
// Copyright (c) 2020 Horizon Robotics.All Rights Reserved. // // The material in this file is confidential and contains trade secrets // of Horizon Robotics Inc. This is proprietary information owned by // Horizon Robotics Inc. No part of this work may be disclosed, // reproduced, copied, transmitted, or used in any way for any purpose, // without the express written permission of Horizon Robotics Inc. #include "layer/dequantize.h" #include "test_op.h" #include "gtest/gtest.h" using hobot::dnn::NDArray; using hobot::dnn::TShape; using hobot::dnn::TypeFlag; TEST(Dequantize, Dequantize_case1) { std::cout << "input(24,24), int8->float32, scale" << std::endl; hobot::dnn::Dequantize DequantizeOp; hobot::dnn::VarientMap attr_dict; attr_dict["num_args"] = 2; DequantizeOp.Init(attr_dict); std::vector bottom_blobs; std::vector top_blobs; std::vector x(24 * 24); //std::srand(static_cast(std::time(nullptr))); for (size_t i = 0; i < x.size(); ++i) { x[i] = static_cast(static_cast(std::rand()) / static_cast(RAND_MAX) * 255 - 128); } std::vector scale = {1.5f}; hobot::dnn::TShape shape{24, 24}; hobot::dnn::TShape shape1{1}; std::unique_ptr x_nd( new NDArray(x.data(), shape, TypeFlag::kInt8)); std::unique_ptr scale_nd( new NDArray(scale.data(), shape1, TypeFlag::kFloat32)); std::unique_ptr y_nd(new NDArray(shape, TypeFlag::kFloat32)); bottom_blobs.push_back(x_nd.get()); bottom_blobs.push_back(scale_nd.get()); top_blobs.push_back(y_nd.get()); clock_t start_time = clock(); DequantizeOp.Forward(bottom_blobs, top_blobs); clock_t end_time = clock(); double cost_time = (double) (end_time - start_time) / CLOCKS_PER_SEC * 1000; std::cout << "cost time:" << cost_time << "ms" << std::endl; #ifdef DNN_X86 std::string output_path = "./Output/Dequantize_case1.txt"; std::ofstream output_file(output_path); ASSERT_TRUE(output_file.is_open()) << "Failed to open file " << output_path << " for writing."; for (size_t i = 0; i < y_nd->Size(); ++i) { output_file << std::to_string(y_nd->Dptr()[i]) << "\n"; //std::cout << std::to_string(y_nd->Dptr()[i]) << std::endl; } output_file.close(); std::cout << "Data saved to " << output_path << std::endl; #else std::string input_path = "./Output/Dequantize_case1.txt"; std::ifstream input_file(input_path); ASSERT_TRUE(input_file.is_open()) << "Failed to open file " << input_path << " for reading."; std::vector saved_data; std::string value; while (input_file >> value) { saved_data.push_back(std::stof(value)); } input_file.close(); std::vector current_data(y_nd->Dptr(), y_nd->Dptr() + y_nd->Size()); for (size_t i = 0; i < current_data.size(); ++i) { ASSERT_NEAR(saved_data[i], current_data[i], 0.0001) << "Difference at index " << i << ": saved_data = " << saved_data[i] << ", current_data = " << current_data[i]; } #endif } TEST(Dequantize, Dequantize_case2) { std::cout << "input(24,24), int8->float32, scale_zero" << std::endl; hobot::dnn::Dequantize DequantizeOp; hobot::dnn::VarientMap attr_dict; attr_dict["num_args"] = 3; DequantizeOp.Init(attr_dict); std::vector bottom_blobs; std::vector top_blobs; std::vector x(24 * 24); //std::srand(static_cast(std::time(nullptr))); for (size_t i = 0; i < x.size(); ++i) { x[i] = static_cast(static_cast(std::rand()) / static_cast(RAND_MAX) * 255 - 128); } std::vector scale = {1.5f}; std::vector zero_point = {2}; hobot::dnn::TShape shape{24, 24}; hobot::dnn::TShape shape1{1}; std::unique_ptr x_nd( new NDArray(x.data(), shape, TypeFlag::kInt8)); std::unique_ptr scale_nd( new NDArray(scale.data(), shape1, TypeFlag::kFloat32)); std::unique_ptr zero_point_nd( new NDArray(zero_point.data(), shape1, TypeFlag::kInt8)); std::unique_ptr y_nd(new NDArray(shape, TypeFlag::kFloat32)); bottom_blobs.push_back(x_nd.get()); bottom_blobs.push_back(scale_nd.get()); bottom_blobs.push_back(zero_point_nd.get()); top_blobs.push_back(y_nd.get()); clock_t start_time = clock(); DequantizeOp.Forward(bottom_blobs, top_blobs); clock_t end_time = clock(); double cost_time = (double) (end_time - start_time) / CLOCKS_PER_SEC * 1000; std::cout << "cost time:" << cost_time << "ms" << std::endl; #ifdef DNN_X86 std::string output_path = "./Output/Dequantize_case2.txt"; std::ofstream output_file(output_path); ASSERT_TRUE(output_file.is_open()) << "Failed to open file " << output_path << " for writing."; for (size_t i = 0; i < y_nd->Size(); ++i) { output_file << std::to_string(y_nd->Dptr()[i]) << "\n"; //std::cout << std::to_string(y_nd->Dptr()[i]) << std::endl; } output_file.close(); std::cout << "Data saved to " << output_path << std::endl; #else std::string input_path = "./Output/Dequantize_case2.txt"; std::ifstream input_file(input_path); ASSERT_TRUE(input_file.is_open()) << "Failed to open file " << input_path << " for reading."; std::vector saved_data; std::string value; while (input_file >> value) { saved_data.push_back(std::stof(value)); } input_file.close(); std::vector current_data(y_nd->Dptr(), y_nd->Dptr() + y_nd->Size()); for (size_t i = 0; i < current_data.size(); ++i) { ASSERT_NEAR(saved_data[i], current_data[i], 0.0001) << "Difference at index " << i << ": saved_data = " << saved_data[i] << ", current_data = " << current_data[i]; } #endif } TEST(Dequantize, Dequantize_case3) { std::cout << "input(3,224,224), int16->float32, scale" << std::endl; hobot::dnn::Dequantize DequantizeOp; hobot::dnn::VarientMap attr_dict; attr_dict["num_args"] = 2; DequantizeOp.Init(attr_dict); std::vector bottom_blobs; std::vector top_blobs; std::vector x(3 * 224 * 224); //std::srand(static_cast(std::time(nullptr))); for (size_t i = 0; i < x.size(); ++i) { x[i] = static_cast(static_cast(std::rand()) / static_cast(RAND_MAX) * 2000 - 1000); } std::vector scale = {1.5f}; hobot::dnn::TShape shape{3, 224, 224}; hobot::dnn::TShape shape1{1}; std::unique_ptr x_nd( new NDArray(x.data(), shape, TypeFlag::kInt16)); std::unique_ptr scale_nd( new NDArray(scale.data(), shape1, TypeFlag::kFloat32)); std::unique_ptr y_nd(new NDArray(shape, TypeFlag::kFloat32)); bottom_blobs.push_back(x_nd.get()); bottom_blobs.push_back(scale_nd.get()); top_blobs.push_back(y_nd.get()); clock_t start_time = clock(); DequantizeOp.Forward(bottom_blobs, top_blobs); clock_t end_time = clock(); double cost_time = (double) (end_time - start_time) / CLOCKS_PER_SEC * 1000; std::cout << "cost time:" << cost_time << "ms" << std::endl; #ifdef DNN_X86 std::string output_path = "./Output/Dequantize_case3.txt"; std::ofstream output_file(output_path); ASSERT_TRUE(output_file.is_open()) << "Failed to open file " << output_path << " for writing."; for (size_t i = 0; i < y_nd->Size(); ++i) { output_file << std::to_string(y_nd->Dptr()[i]) << "\n"; //std::cout << std::to_string(y_nd->Dptr()[i]) << std::endl; } output_file.close(); std::cout << "Data saved to " << output_path << std::endl; #else std::string input_path = "./Output/Dequantize_case3.txt"; std::ifstream input_file(input_path); ASSERT_TRUE(input_file.is_open()) << "Failed to open file " << input_path << " for reading."; std::vector saved_data; std::string value; while (input_file >> value) { saved_data.push_back(std::stof(value)); } input_file.

资源文件列表:

op_zxh.zip 大约有20个文件
  1. layer_rvv/
  2. layer_rvv/dequantize.h 2.41KB
  3. layer_rvv/scatter_elements.h 1.63KB
  4. layer_rvv/quantize.cpp 16.28KB
  5. layer_rvv/dequantize_linear.cpp 17.07KB
  6. layer_rvv/quantize_linear.cpp 26.54KB
  7. layer_rvv/dequantize_linear.h 1.59KB
  8. layer_rvv/quantize.h 1.49KB
  9. layer_rvv/quantize_linear.h 1.57KB
  10. layer_rvv/dequantize.cpp 16.71KB
  11. layer_rvv/scatter_elements.cpp 8.83KB
  12. test_op/
  13. test_op/test_dequantize_linear.cpp 44.52KB
  14. test_op/test_quantize_linear.cpp 49.41KB
  15. test_op/test_quantize.cpp 45.26KB
  16. test_op/main.cpp 599B
  17. test_op/test_op.h 804B
  18. test_op/test_dequantize.cpp 83.35KB
  19. test_op/rvv1.0_op/
  20. test_op/rvv1.0_op/test_scatter_elements.cpp 13.6KB
0评论
提交 加载更多评论
其他资源 给各个学科的知识点总结分析
给各个学科的知识点总结分析
【Unity精品插件】Easy Save v3.5.15 最新版
【0积分下载】Easy Save:简化游戏数据存储与加载 一、Easy Save 简介 Easy Save 是专门为 Unity 开发者设计的一款数据存储和加载工具。它旨在简化数据保存和恢复的过程,使开发者能够专注于游戏的核心逻辑,而不必在数据管理上花费过多的精力。 二、主要特点 (一)多种数据类型支持 支持几乎所有常见的数据类型,包括整数、浮点数、字符串、数组、字典、自定义类等。 例如,可以轻松保存玩家的得分、等级、装备信息以及游戏中的各种配置参数。 (二)简单易用的 API 提供了简洁直观的 API 接口,只需几行代码就能实现数据的保存和加载。 (三)跨平台兼容性 能够在不同的平台上(如 Windows、Mac、Android、iOS 等)保持一致的性能和功能,确保玩家在不同设备上的游戏体验连贯。 (四)加密选项 提供数据加密功能,保障玩家数据的安全性和隐私性。
仿生蝴蝶学习相关所需材料等内容
仿生蝴蝶学习相关所需材料等内容
tomcat smartbi
tomcat smartbi
mcgspro昆仑通态触摸屏与三菱FX3U以太网口通讯说明和样例程序
mcgspro昆仑通态触摸屏与三菱FX3U以太网口通讯说明和样例程序
STM32F407控制机械手源码
STM32F407控制机械手源码
51、32、arduino舵机控制代码
arduino单个舵机控制源码
51、32、arduino舵机控制代码
51单片机单个舵机控制源码
51单片机单个舵机控制源码