2.5K Star 8.4K Fork 4.7K

GVPMindSpore/mindspore

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
mindspore.ops.PrimitiveWithInfer.rst 804 Bytes
一键复制 编辑 原始数据 按行查看 历史
俞涵 提交于 2024-04-23 09:58 . modify error html links

mindspore.ops.PrimitiveWithInfer

.. py:class:: mindspore.ops.PrimitiveWithInfer(name)

    PrimitiveWithInfer是Python中的原语基类,在python中定义了跟踪推理的函数。

    可以重写四个方法来定义Primitive的推断逻辑:__infer__()、infer_shape()、infer_dtype()和infer_value()。如果在Primitive中定义了__infer__(),则__infer__()的优先级最高。

    如果未定义__infer__(),则可以定义infer_shape()和infer_dtype()来描述shape和类型的推断逻辑。infer_value()用于常量传播。

    关于如何自定义算子,请查看 `自定义算子 <https://www.mindspore.cn/tutorials/experts/zh-CN/r2.3.0rc1/operation/op_custom.html>`_ 。

    参数:
        - **name** (str) - 当前Primitive的名称。
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/mindspore/mindspore.git
git@gitee.com:mindspore/mindspore.git
mindspore
mindspore
mindspore
r2.3.q1

搜索帮助