文档
注册

beta)torch_npu.npu_min

该接口计划废弃,可以使用torch.min接口进行替换。

接口原型

torch_npu.npu_min(self, dim, keepdim=False) -> (Tensor, Tensor)

功能描述

使用dim对最小结果进行计数。类似于torch.min, 优化NPU设备实现。

参数说明

  • self (Tensor) - 输入张量。
  • dim (Int) - 待降低维度。
  • keepdim (Bool) - 输出张量是否保留dim。

输出说明

  • values (Tensor) - 输入张量中的最小值。
  • indices (Tensor) - 输入张量中最小值的index。

调用示例

>>> input = torch.randn(2, 2, 2, 2, dtype = torch.float32).npu()
>>> input
tensor([[[[-0.9909, -0.2369],
          [-0.9569, -0.6223]],

        [[ 0.1157, -0.3147],
          [-0.7761,  0.1344]]],

        [[[ 1.6292,  0.5953],
          [ 0.6940, -0.6367]],

        [[-1.2335,  0.2131],
          [ 1.0748, -0.7046]]]], device='npu:0')
>>> outputs, indices = torch_npu.npu_min(input, 2)
>>> outputs
tensor([[[-0.9909, -0.6223],
        [-0.7761, -0.3147]],

        [[ 0.6940, -0.6367],
        [-1.2335, -0.7046]]], device='npu:0')
>>> indices
tensor([[[0, 1],
        [1, 0]],

        [[1, 1],
        [0, 1]]], device='npu:0', dtype=torch.int32)
搜索结果
找到“0”个结果

当前产品无相关内容

未找到相关内容,请尝试其他搜索词