ONE - On-device Neural Engine
Loading...
Searching...
No Matches
validate_onnx2circle Namespace Reference

Data Structures

class  OnnxRunner
 

Functions

 to_numpy (tensor)
 
 to_nhwc (tensor)
 

Variables

 parser = argparse.ArgumentParser()
 
 type
 
 str
 
 required
 
 args = parser.parse_args()
 
 driver = args.driver
 
 onnx_filepath = args.onnx
 
 circle_filepath = args.circle
 
 onnx_runner = OnnxRunner(onnx_filepath)
 
 process
 
int rtolerance = 1e-03
 
int atolerance = 1e-04
 
bool result_compare = True
 
 output_shape = onnx_runner.outputs[idx].shape
 
 output_type = onnx_runner.outputs[idx].type
 
 output_np_type = np.float32
 
 output_data = np.fromfile(circle_filepath + ".output" + str(idx), output_np_type)
 
 shape_file = open(circle_filepath + ".output" + str(idx) + ".shape", 'r')
 
 luci_output_data = np.reshape(output_data, output_shape)
 
 output_nchw = onnx_runner.outs[idx]
 
 output_nhwc = to_nhwc(output_nchw)
 
 diff = np.isclose(output_nhwc, luci_output_data, rtol=rtolerance, atol=atolerance)
 
 result_compare_one = np.all(diff)
 
 diff_val = np.subtract(output_nhwc, luci_output_data)
 

Detailed Description

'export SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"                  # 

Function Documentation

◆ to_nhwc()

validate_onnx2circle.to_nhwc (   tensor)

Definition at line 48 of file validate_onnx2circle.py.

48def to_nhwc(tensor):
49 if (tensor.ndim == 4):
50 return np.transpose(tensor, (0, 2, 3, 1))
51 return tensor
52
53

Referenced by validate_onnx2circle.OnnxRunner.feed_random_inputs().

◆ to_numpy()

validate_onnx2circle.to_numpy (   tensor)

Definition at line 44 of file validate_onnx2circle.py.

44def to_numpy(tensor):
45 return tensor.cpu().numpy()
46
47

Referenced by validate_onnx2circle.OnnxRunner.feed_random_inputs().

Variable Documentation

◆ args

validate_onnx2circle.args = parser.parse_args()

Definition at line 37 of file validate_onnx2circle.py.

◆ atolerance

int validate_onnx2circle.atolerance = 1e-04

Definition at line 125 of file validate_onnx2circle.py.

◆ circle_filepath

validate_onnx2circle.circle_filepath = args.circle

Definition at line 41 of file validate_onnx2circle.py.

◆ diff

validate_onnx2circle.diff = np.isclose(output_nhwc, luci_output_data, rtol=rtolerance, atol=atolerance)

Definition at line 147 of file validate_onnx2circle.py.

◆ diff_val

validate_onnx2circle.diff_val = np.subtract(output_nhwc, luci_output_data)

Definition at line 152 of file validate_onnx2circle.py.

◆ driver

validate_onnx2circle.driver = args.driver

Definition at line 39 of file validate_onnx2circle.py.

◆ luci_output_data

validate_onnx2circle.luci_output_data = np.reshape(output_data, output_shape)

Definition at line 140 of file validate_onnx2circle.py.

◆ onnx_filepath

validate_onnx2circle.onnx_filepath = args.onnx

Definition at line 40 of file validate_onnx2circle.py.

◆ onnx_runner

validate_onnx2circle.onnx_runner = OnnxRunner(onnx_filepath)

Definition at line 109 of file validate_onnx2circle.py.

◆ output_data

validate_onnx2circle.output_data = np.fromfile(circle_filepath + ".output" + str(idx), output_np_type)

Definition at line 137 of file validate_onnx2circle.py.

◆ output_nchw

validate_onnx2circle.output_nchw = onnx_runner.outs[idx]

Definition at line 143 of file validate_onnx2circle.py.

◆ output_nhwc

validate_onnx2circle.output_nhwc = to_nhwc(output_nchw)

Definition at line 144 of file validate_onnx2circle.py.

◆ output_np_type

validate_onnx2circle.output_np_type = np.float32

Definition at line 131 of file validate_onnx2circle.py.

◆ output_shape

list validate_onnx2circle.output_shape = onnx_runner.outputs[idx].shape

Definition at line 128 of file validate_onnx2circle.py.

◆ output_type

validate_onnx2circle.output_type = onnx_runner.outputs[idx].type

Definition at line 129 of file validate_onnx2circle.py.

◆ parser

validate_onnx2circle.parser = argparse.ArgumentParser()

Definition at line 33 of file validate_onnx2circle.py.

◆ process

validate_onnx2circle.process
Initial value:
1= subprocess.run([
2 driver, circle_filepath,
3 str(onnx_runner.inputs_size), circle_filepath + ".input", circle_filepath + ".output"
4],
5 check=True)

Definition at line 117 of file validate_onnx2circle.py.

◆ required

validate_onnx2circle.required

Definition at line 34 of file validate_onnx2circle.py.

◆ result_compare

bool validate_onnx2circle.result_compare = True

Definition at line 126 of file validate_onnx2circle.py.

◆ result_compare_one

validate_onnx2circle.result_compare_one = np.all(diff)

Definition at line 149 of file validate_onnx2circle.py.

◆ rtolerance

int validate_onnx2circle.rtolerance = 1e-03

Definition at line 124 of file validate_onnx2circle.py.

◆ shape_file

validate_onnx2circle.shape_file = open(circle_filepath + ".output" + str(idx) + ".shape", 'r')

Definition at line 138 of file validate_onnx2circle.py.

◆ str

validate_onnx2circle.str

◆ type

validate_onnx2circle.type

Definition at line 34 of file validate_onnx2circle.py.