编辑:附加一些代码以帮助生成类似的结果(附加在末尾)
我有一个非常小的模型,其架构[2, 3, 6]中的隐藏层使用 ReLU,它是用于多类分类的 softmax 激活。离线训练并静态量化到 qint8。我现在想做的是提取权重,以便我可以通过矩阵乘法/加法在其他硬件上使用它们。我遇到的问题是它似乎没有按预期运行。以 state_dict() 的 GraphModule 输出为例:
OrderedDict([('input_layer_input_scale_0', tensor(0.0039)),
('input_layer_input_zero_point_0', tensor(0)),
('input_layer.scale', tensor(0.0297)),
('input_layer.zero_point', tensor(0)),
('input_layer._packed_params.dtype', torch.qint8),
('input_layer._packed_params._packed_params',
(tensor([[-0.1180, 0.1180],
[-0.2949, -0.5308],
[-3.3029, -7.5496]], size=(3, 2), dtype=torch.qint8,
quantization_scheme=torch.per_tensor_affine, scale=0.05898105353116989,
zero_point=0),
Parameter containing:
tensor([-0.4747, -0.3563, 7.7603], requires_grad=True))),
('out.scale', tensor(1.5963)),
('out.zero_point', tensor(243)),
('out._packed_params.dtype', torch.qint8),
('out._packed_params._packed_params',
(tensor([[ 0.4365, 0.4365, -55.4356],
[ 0.4365, 0.0000, 1.3095],
[ 0.4365, 0.0000, -13.9680],
[ 0.4365, -0.4365, 4.3650],
[ 0.4365, 0.4365, -3.0555],
[ 0.4365, 0.0000, -1.3095],
[ 0.4365, 0.0000, 3.0555]], size=(7, 3), …Run Code Online (Sandbox Code Playgroud) 在我的 std::list 中,我有 10 个元素,我想将数字 1000 移到列表的后面。
https://leetcode.com/playground/gucNuPit
有没有更好的方法,使用 std::move、后插入器或任何其他 C++ 语法的 1 行有意识地实现此目的?
// Move the number 1000 to the end of the list
#include <iostream>
#include <algorithm>
#include <list>
using namespace std;
int main() {
list<int> myList({2,3,4,1000,5,6,7,8,9,10});
cout << "List before " << endl;
for(auto e : myList)
cout << e << " ";
// get iterator to the number 1000 in the list
list<int>::iterator findIter = std::find(myList.begin(), myList.end(), 1000);
int val_to_move_to_end = *findIter;
myList.erase(findIter);
myList.push_back(val_to_move_to_end);
cout << …Run Code Online (Sandbox Code Playgroud) Nvidia在Cg 3.1 Toolkit文档中有一些功能
arctan2实现如下
float2 atan2(float2 y, float2 x)
{
float2 t0, t1, t2, t3, t4;
t3 = abs(x);
t1 = abs(y);
t0 = max(t3, t1);
t1 = min(t3, t1);
t3 = float(1) / t0;
t3 = t1 * t3;
t4 = t3 * t3;
t0 = - float(0.013480470);
t0 = t0 * t4 + float(0.057477314);
t0 = t0 * t4 - float(0.121239071);
t0 = t0 * t4 + float(0.195635925);
t0 = t0 * t4 - float(0.332994597);
t0 …Run Code Online (Sandbox Code Playgroud)