npu_onnx_graph_op

Applicability

Product

Supported

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Description

Loads an ONNX model as an operator and executes it on the Ascend AI Processor through the TensorFlow framework.

Prototype

1
def npu_onnx_graph_op(inputs, tout, model_path, name=None)

Parameters

Parameter

Input/Output

Description

inputs

Input

Input tensor of the ONNX model.

tout

Input

Output data type of the ONNX model, for example, tf.float32.

model_path

Input

A string for the path (including the file name) of the ONNX model, for example, /test/test.onnx.

name

Input

A string for the name of the operator on the graph.

Returns

Operator output list.

Example

1
2
3
4
from npu_bridge.estimator.npu_ops import npu_onnx_graph_op

input = tf.placeholder(dtype=tf.float32, shape=(1, 1, 5, 5), name="conv_input")
output = npu_onnx_graph_op([input], [tf.float32], model_path="conv2d.onnx", name="conv2d")