mindspore.nn.GraphKernel

class mindspore.nn.GraphKernel(auto_prefix=True, flags=None)[source]

Base class for GraphKernel.

A GraphKernel a composite of basic primitives and can be compiled into a fused kernel automatically when enable_graph_kernel in context is set to True.

Parameters
  • auto_prefix (bool) – Recursively generate namespaces. Default: True.

  • flags (dict) – Set graph flags. Default: None.

Supported Platforms:

Ascend GPU

Examples

>>> class Relu(nn.GraphKernel):
...    def __init__(self):
...        super(Relu, self).__init__()
...        self.max = P.Maximum()
...
...    def construct(self, x):
...        return self.max(P.Fill()(P.DType()(x), P.Shape()(x), 0.0), x)