mindspore.mint.empty_like ========================= .. image:: https://mindspore-website.obs.cn-north-4.myhuaweicloud.com/website-images/br_base/resource/_static/logo_source.svg :target: https://gitee.com/mindspore/mindspore/blob/br_base/docs/api/api_python/mint/mindspore.mint.func_empty_like.rst :alt: 查看源文件 .. py:function:: mindspore.mint.empty_like(input, *, dtype=None, device=None) -> Tensor 创建一个未初始化的Tesnor,shape和 `input` 相同,dtype由 `dtype` 决定,Tensor使用的内存由 `device` 决定。 .. warning:: 这是一个实验性API,后续可能修改或删除。 参数: - **input** (Tensor) - 任意维度的Tensor。 关键字参数: - **dtype** (:class:`mindspore.dtype`, 可选) - 用来描述所创建的Tensor的 `dtype` 。如果为 ``None`` ,那么将会使\ 用 `input` 的dtype。默认值: ``None`` 。 - **device** (string, 可选) - 指定Tensor使用的内存来源。PyNative模式下支持 ``"Ascend"`` 、 ``"npu"`` 、 ``"cpu"`` 和 ``"CPU"``。 图模式O0下支持 ``"Ascend"`` 和 ``"npu"``。如果为 ``None`` ,那么将会使用 :func:`mindspore.set_device` 设置的值。默认值 ``None`` 。 返回: Tensor,具有与 `input` 相同的shape,但是数据内容没有初始化(可能是任意值)。 异常: - **TypeError** - `input` 不是Tensor。