Skip to content

Commit e6cb118

Browse files
authored
Merge branch 'Ascend:main' into main
2 parents c508d07 + 586920d commit e6cb118

5 files changed

Lines changed: 221 additions & 15 deletions

File tree

_static/ascend_actions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ $(document).ready(function () {
197197

198198
if (options['install_type'] === 'direct') {
199199
// download and install cann
200-
$('#codecell11').html('wget "' + cann_url + '"\nsh ' + cann_name + ' --install');
200+
$('#codecell11').html('wget "' + cann_url + '"\nsh ' + cann_name + ' --full');
201201

202202
// download and install kernel if exist.
203203
if (kernel_url == null) {
@@ -208,7 +208,7 @@ $(document).ready(function () {
208208
var kernel_name = parts[parts.length - 1];
209209
$('#install_kernel_section').show();
210210
// download and install kernel
211-
$('#codecell13').html('wget "' + kernel_url + '"\nsh ' + kernel_name + ' --install');
211+
$('#codecell14').html('wget "' + kernel_url + '"\nsh ' + kernel_name + ' --install');
212212
}
213213

214214
$('#use_docker_section').hide();

conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
author = 'Ascend'
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '1.0'
25+
release = ''
2626

2727

2828
# -- General configuration ---------------------------------------------------

sources/ascend/quick_install.rst

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ Python 3.8, 3.9, 3.10
112112
</div>
113113
<div class="highlight-default notranslate">
114114
<div class="highlight">
115-
<pre>sudo groupadd -g HwHiAiUser<br>sudo useradd -g HwHiAiUser -d /home/HwHiAiUser -m HwHiAiUser -s /bin/bash<br>sudo usermod -aG HwHiAiUser $USER</pre>
115+
<pre>sudo groupadd HwHiAiUser<br>sudo useradd -g HwHiAiUser -d /home/HwHiAiUser -m HwHiAiUser -s /bin/bash<br>sudo usermod -aG HwHiAiUser $USER</pre>
116116
</div>
117117
</div>
118118
<p><b>2.1.3 下载并安装</b></p>
@@ -159,7 +159,7 @@ Python 3.8, 3.9, 3.10
159159
<p><b>2.3.1 安装python依赖</b></p>
160160
<div class="highlight-default notranslate">
161161
<div class="highlight">
162-
<pre>pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple attrs numpy decorator sympy cffi pyyaml pathlib2 psutil protobuf scipy requests absl-py wheel typing_extensions</pre>
162+
<pre>pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple attrs numpy==1.24.0 decorator sympy cffi pyyaml pathlib2 psutil protobuf scipy requests absl-py wheel typing_extensions</pre>
163163
</div>
164164
</div>
165165
<p><b>2.3.2 下载并安装</b></p>
@@ -174,8 +174,14 @@ Python 3.8, 3.9, 3.10
174174
<pre>Ascend-cann-toolkit install success.</pre>
175175
</div>
176176
</div>
177+
<p><b>2.3.3 设置环境变量</b></p>
178+
<div class="highlight-default notranslate">
179+
<div class="highlight">
180+
<pre>source /usr/local/Ascend/ascend-toolkit/set_env.sh</pre>
181+
</div>
182+
</div>
177183
<div id="install_kernel_section">
178-
<p><b>2.3.3 安装算子包</b></p>
184+
<p><b>2.3.4 安装算子包</b></p>
179185
<div class="highlight-default notranslate">
180186
<div class="highlight">
181187
<pre></pre>
@@ -188,12 +194,6 @@ Python 3.8, 3.9, 3.10
188194
<pre>Ascend-cann-kernels install success.</pre>
189195
</div>
190196
</div>
191-
<p><b>2.3.4 设置环境变量</b></p>
192-
<div class="highlight-default notranslate">
193-
<div class="highlight">
194-
<pre>echo "source ~/Ascend/ascend-toolkit/set_env.sh" >> ~/.bashrc<br>source ~/.bashrc</pre>
195-
</div>
196-
</div>
197197
</section>
198198
<section id="use_docker_section">
199199
<h3>2.3 运行Docker容器</h3>

sources/llamafactory/quick_start.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ yaml 配置文件
7272
learning_rate: 0.0001
7373
num_train_epochs: 3.0
7474
lr_scheduler_type: cosine
75-
warmup_steps: 0.1
75+
warmup_ratio: 0.1
7676
fp16: true
7777

7878
### eval

sources/pytorch/api_doc.rst

Lines changed: 208 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ PyTorch-NPU 除了提供了 PyTorch 官方算子实现之外,也提供了大
234234
:param Int adam_mode: 选择adam模式。0表示“adam”, 1表示“mbert_adam”, 默认值为0
235235

236236
关键字参数:
237-
out (Tensor,可选) - 输出张量。
237+
out (Tensor,可选) - 输出张量。
238238

239239
示例:
240240

@@ -309,4 +309,210 @@ PyTorch-NPU 除了提供了 PyTorch 官方算子实现之外,也提供了大
309309
>>> output = torch_npu.npu_bounding_box_decode(rois, deltas, 0, 0, 0, 0, 1, 1, 1, 1, (10, 10), 0.1)
310310
>>> output
311311
tensor([[2.5000, 6.5000, 9.0000, 9.0000],
312-
[9.0000, 9.0000, 9.0000, 9.0000]], device='npu:0')
312+
[9.0000, 9.0000, 9.0000, 9.0000]], device='npu:0')
313+
314+
.. py:function:: npu_broadcast(self, size) -> Tensor
315+
:module: torch_npu
316+
317+
返回self张量的新视图,其单维度扩展,结果连续。
318+
319+
:param Tensor self: 输入张量。
320+
:param ListInt size: 对应扩展尺寸。
321+
322+
:rtype: Tensor
323+
324+
示例:
325+
326+
.. code-block:: python
327+
:linenos:
328+
329+
>>> x = torch.tensor([[1], [2], [3]]).npu()
330+
>>> x.shape
331+
torch.Size([3, 1])
332+
>>> x.npu_broadcast(3, 4)
333+
tensor([[1, 1, 1, 1],
334+
[2, 2, 2, 2],
335+
[3, 3, 3, 3]], device='npu:0')
336+
337+
.. py:function:: npu_ciou(Tensor self, Tensor gtboxes, bool trans=False, bool is_cross=True, int mode=0, bool atan_sub_flag=False) -> Tensor
338+
:module: torch_npu
339+
340+
应用基于NPU的CIoU操作。在DIoU的基础上增加了penalty item,并propose CIoU。
341+
342+
:param Tensor boxes1: 格式为xywh、shape为(4, n)的预测检测框。
343+
:param Tensor boxes2: 相应的gt检测框,shape为(4, n)。
344+
:param Bool trans: 是否有偏移。
345+
:param Bool is_cross: box1和box2之间是否有交叉操作。
346+
:param Int mode: 选择CIoU的计算方式。0表示IoU,1表示IoF。
347+
:param Bool atan_sub_flag:是否将正向的第二个值传递给反向。
348+
349+
:rtype: Tensor
350+
351+
约束说明:
352+
到目前为止,CIoU向后只支持当前版本中的trans==True、is_cross==False、mode==0('iou')。如果需要反向传播,确保参数正确。
353+
354+
示例:
355+
356+
.. code-block:: python
357+
:linenos:
358+
359+
>>> box1 = torch.randn(4, 32).npu()
360+
>>> box1.requires_grad = True
361+
>>> box2 = torch.randn(4, 32).npu()
362+
>>> box2.requires_grad = True
363+
>>> diou = torch_npu.contrib.function.npu_ciou(box1, box2)
364+
>>> l = ciou.sum()
365+
>>> l.backward()
366+
367+
.. py:function:: npu_clear_float_status(self) -> Tensor
368+
:module: torch_npu
369+
370+
在每个核中设置地址0x40000的值为0。
371+
372+
:param Tensor self: 数据类型为float32的张量。
373+
374+
:rtype: Tensor
375+
376+
示例:
377+
378+
.. code-block:: python
379+
:linenos:
380+
381+
>>> x = torch.rand(2).npu()
382+
>>> torch_npu.npu_clear_float_status(x)
383+
tensor([0., 0., 0., 0., 0., 0., 0., 0.], device='npu:0')
384+
385+
.. py:function:: npu_confusion_transpose(self, perm, shape, transpose_first) -> Tensor
386+
:module: torch_npu
387+
388+
混淆reshape和transpose运算。
389+
390+
:param Tensor self: 数据类型:float16、float32、int8、int16、int32、int64、uint8、uint16、uint32、uint64。
391+
:param ListInt perm: self张量的维度排列。
392+
:param ListInt shape: 输入shape。
393+
:param Bool transpose_first: 如果值为True,首先执行transpose,否则先执行reshape。
394+
395+
:rtype: Tensor
396+
397+
示例:
398+
399+
.. code-block:: python
400+
:linenos:
401+
402+
>>> x = torch.rand(2, 3, 4, 6).npu()
403+
>>> x.shape
404+
torch.Size([2, 3, 4, 6])
405+
>>> y = torch_npu.npu_confusion_transpose(x, (0, 2, 1, 3), (2, 4, 18), True)
406+
>>> y.shape
407+
torch.Size([2, 4, 18])
408+
>>> y2 = torch_npu.npu_confusion_transpose(x, (0, 2, 1), (2, 12, 6), False)
409+
>>> y2.shape
410+
torch.Size([2, 6, 12])
411+
412+
.. py:function:: npu_conv2d(input, weight, bias, stride, padding, dilation, groups) -> Tensor
413+
:module: torch_npu
414+
415+
在由多个输入平面组成的输入图像上应用一个2D卷积。
416+
417+
:param Tensor input: shape的输入张量,值为 (minibatch, in_channels, iH, iW)。
418+
:param Tensor weight: shape过滤器,值为 (out_channels, in_channels/groups, kH, kW)。
419+
:param Tensor bias: shape偏差 (out_channels)。
420+
:param ListInt stride: 卷积核步长。
421+
:param ListInt padding: 输入两侧的隐式填充。
422+
:param ListInt dilation: 内核元素间距。
423+
:param Int groups: 对输入进行分组。In_channels可被组数整除。
424+
425+
:rtype: Tensor
426+
427+
.. py:function:: npu_conv3d(input, weight, bias, stride, padding, dilation, groups) -> Tensor
428+
:module: torch_npu
429+
430+
在由多个输入平面组成的输入图像上应用一个3D卷积。
431+
432+
:param Tensor input: shape的输入张量,值为 (minibatch, in_channels, iT, iH, iW)。
433+
:param Tensor weight: shape过滤器,值为 (out_channels, in_channels/groups, kT, kH, kW)。
434+
:param Tensor bias: shape偏差 (out_channels)。
435+
:param ListInt stride: 卷积核步长。
436+
:param ListInt padding: 输入两侧的隐式填充。
437+
:param ListInt dilation: 内核元素间距。
438+
:param Int groups: 对输入进行分组。In_channels可被组数整除。
439+
440+
:rtype: Tensor
441+
442+
.. py:function:: npu_conv_transpose2d(input, weight, bias, padding, output_padding, stride, dilation, groups) -> Tensor
443+
:module: torch_npu
444+
445+
在由多个输入平面组成的输入图像上应用一个2D转置卷积算子,有时这个过程也被称为“反卷积”。
446+
447+
:param Tensor input: shape的输入张量,值为 (minibatch, in_channels, iH, iW)。
448+
:param Tensor weight: shape过滤器,值为 (in_channels, out_channels/groups, kH, kW)。
449+
:param Tensor bias: shape偏差 (out_channels)。
450+
:param ListInt padding: (dilation * (kernel_size - 1) - padding) 用零来填充输入每个维度的两侧。
451+
:param ListInt output_padding: 添加到输出shape每个维度一侧的附加尺寸。
452+
:param ListInt stride: 卷积核步长。
453+
:param ListInt dilation: 内核元素间距。
454+
:param Int groups: 对输入进行分组。In_channels可被组数整除。
455+
456+
:rtype: Tensor
457+
458+
.. py:function:: npu_convolution(input, weight, bias, stride, padding, dilation, groups) -> Tensor
459+
:module: torch_npu
460+
461+
在由多个输入平面组成的输入图像上应用一个2D或3D卷积。
462+
463+
:param Tensor input: shape的输入张量,值为 (minibatch, in_channels, iH, iW) 或 (minibatch, in_channels, iT, iH, iW)。
464+
:param Tensor weight: shape过滤器,值为 (out_channels, in_channels/groups, kH, kW) 或 (out_channels, in_channels/groups, kT, kH, kW)。
465+
:param Tensor bias: shape偏差 (out_channels)。
466+
:param ListInt stride: 卷积核步长。
467+
:param ListInt padding: 输入两侧的隐式填充。
468+
:param ListInt dilation: 内核元素间距。
469+
:param Int groups: 对输入进行分组。In_channels可被组数整除。
470+
471+
:rtype: Tensor
472+
473+
.. py:function:: npu_convolution_transpose(input, weight, bias, padding, output_padding, stride, dilation, groups) -> Tensor
474+
:module: torch_npu
475+
476+
在由多个输入平面组成的输入图像上应用一个2D或3D转置卷积算子,有时这个过程也被称为“反卷积”。
477+
478+
:param Tensor input: shape的输入张量,值为 (minibatch, in_channels, iH, iW) 或 (minibatch, in_channels, iT, iH, iW)。
479+
:param Tensor weight: shape过滤器,值为 (in_channels, out_channels/groups, kH, kW) 或 (in_channels, out_channels/groups, kT, kH, kW)。
480+
:param Tensor bias: shape偏差 (out_channels)。
481+
:param ListInt padding: (dilation * (kernel_size - 1) - padding) 用零来填充输入每个维度的两侧。
482+
:param ListInt output_padding: 添加到输出shape每个维度一侧的附加尺寸。
483+
:param ListInt stride: 卷积核步长。
484+
:param ListInt dilation: 内核元素间距。
485+
:param Int groups: 对输入进行分组。In_channels可被组数整除。
486+
487+
:rtype: Tensor
488+
489+
.. py:function:: npu_deformable_conv2d(self, weight, offset, bias, kernel_size, stride, padding, dilation=[1,1,1,1], groups=1, deformable_groups=1, modulated=True) -> (Tensor, Tensor)
490+
:module: torch_npu
491+
492+
使用预期输入计算变形卷积输出(deformed convolution output)。
493+
494+
:param Tensor self: 输入图像的4D张量。格式为“NHWC”,数据按以下顺序存储:[batch, in_height, in_width, in_channels]。
495+
:param Tensor weight: 可学习过滤器的4D张量。数据类型需与self相同。格式为“HWCN”,数据按以下顺序存储:[filter_height, filter_width, in_channels / groups, out_channels]。
496+
:param Tensor offset: x-y坐标偏移和掩码的4D张量。格式为“NHWC”,数据按以下顺序存储:[batch, out_height, out_width, deformable_groups * filter_height * filter_width * 3]。bias (Tensor,可选) - 过滤器输出附加偏置(additive bias)的1D张量,数据按[out_channels]的顺序存储。
497+
:param ListInt[2] kernel_size: 内核大小,2个整数的元组/列表。
498+
:param ListInt stride: 4个整数的列表,表示每个输入维度的滑动窗口步长。维度顺序根据self的数据格式解释。N维和C维必须设置为1。
499+
:param ListInt padding: 4个整数的列表,表示要添加到输入每侧(顶部、底部、左侧、右侧)的像素数。
500+
501+
:param ListInt dilation: 4个整数的列表,表示输入每个维度的膨胀系数(dilation factor)。维度顺序根据self的数据格式解释。N维和C维必须设置为1。
502+
:param Int groups: int32类型单整数,表示从输入通道到输出通道的阻塞连接数。In_channels和out_channels需都可被“groups”数整除。
503+
:param Int deformable_groups: int32类型单整数,表示可变形组分区的数量。In_channels需可被“deformable_groups”数整除。
504+
:param Bool transpose_first: 默认值为True, 指定DeformableConv2D版本。True表示v2版本, False表示v1版本,目前仅支持v2。
505+
506+
:rtype: (Tensor, Tensor)
507+
508+
示例:
509+
510+
.. code-block:: python
511+
:linenos:
512+
513+
>>> x = torch.rand(16, 32, 32, 32).npu()
514+
>>> weight = torch.rand(32, 32, 5, 5).npu()
515+
>>> offset = torch.rand(16, 75, 32, 32).npu()
516+
>>> output, _ = torch_npu.npu_deformable_conv2d(x, weight, offset, None, kernel_size=[5, 5], stride = [1, 1, 1, 1], padding = [2, 2, 2, 2])
517+
>>> output.shape
518+
torch.Size([16, 32, 32, 32])

0 commit comments

Comments
 (0)