mindspore/docs/api/api_python/ops/mindspore.ops.PrimitiveWith...

15 lines
651 B
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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()用于常量传播。
**参数:**
- **name** (str) - 当前Primitive的名称。