mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-04 23:59:56 +00:00
Description: Format all python files under onnxruntime with black and isort. After checking in, we can use .git-blame-ignore-revs to ignore the formatting PR in git blame. #11315, #11316
22 lines
719 B
Python
22 lines
719 B
Python
# Copyright (c) Microsoft Corporation. All rights reserved.
|
|
# Licensed under the MIT License.
|
|
|
|
import sqlite3
|
|
import onnx
|
|
from onnx import numpy_helper
|
|
|
|
connection = sqlite3.connect("<path-to-sqldb-from-tracing>", detect_types=sqlite3.PARSE_DECLTYPES)
|
|
|
|
|
|
def convert_tensor_proto_to_numpy_array(blob):
|
|
tensor_proto = onnx.TensorProto()
|
|
tensor_proto.ParseFromString(blob)
|
|
return numpy_helper.to_array(tensor_proto)
|
|
|
|
|
|
sqlite3.register_converter("TensorProto", convert_tensor_proto_to_numpy_array)
|
|
|
|
for step, name, value, device, producer, consumers in connection.execute(
|
|
"Select Step, Name, Value, DeviceType, TracedProducer, TracedConsumers from Tensors"
|
|
):
|
|
print(step, name, value.shape, consumers)
|