LookupSubgraphSlicerHook

Searches for a specified operator type in the subgraph of KeyTensor, and then executes the operator of a target type and its minimum dependency subgraph in the CPU prefetch phase. If no operator of the target type is found, no splitting is performed.

This hook is used when automatic graph modification is enabled in NPUEstimator mode. It must be called before GraphModifierHook is called for automatic graph modification.

Parameter

Data Type

Mandatory/Optional

Description

op_types

list[str]

Mandatory

Type of the operator to be split. Currently, only the list format is supported.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
from mx_rec.graph import LookupSubgraphSlicerHook, GraphModifierHook


def input_fn():
    """
    Define an Estimator input function yourself.
    """

lookup_slicer_hook = LookupSubgraphSlicerHook(op_types=["StringToNumber"] )
modifier_hook = GraphModifierHook(modify_graph=params.modify_graph)
hooks_list = [lookup_slicer_hook, modifier_hook]

est = NPUEstimator(...)
est.train(input_fn=lambda: input_fn, hooks=npu_hooks_append(hooks_list))