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.

This class is deprecated from version 1.3 and will be removed in a future version, use Cell instead.

GraphKernel is not supported user-defined cells anymore, the GraphKernel objects will be treated as normal Cell objects.

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

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

Supported Platforms:

Ascend GPU CPU

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)