I am a beginner and I write a quite simple pytorch net to test the whole process.
class TensorSumModel(nn.Module):
def init(self):
super(TensorSumModel, self).init()
def forward(self, x, y):
return x + y
Instantiate the model
model = TensorSumModel()
model.eval()
Example dummy inputs (size [1, 3] in this case)
x = torch.randn(1, 3)
y = torch.randn(1, 3)
Export the model to ONNX
torch.onnx.export(
model,
(x, y),
“tensor_sum_model.onnx”,
input_names=[‘x’, ‘y’],
output_names=[‘output’],
opset_version=12
)
after that, I try to convert the onnx to hef file with DFC tool.
onnx_path=“tensor_sum_model.onnx”
har_path=“tensor_sum_model.har”
quantized_har_path=“tensor_sum_quantized_model.har”
hef_path=“tensor_sum_model.hef”
runner=ClientRunner(hw_arch=“hailo8”)
runner.translate_onnx_model(model=onnx_path,start_node_names=[“x”, “y”],end_node_names=[“output”],net_input_shapes={“x”:[1,3],“y”:[1,3]})
runner=ClientRunner(har=har_path)
dataset_x = np.zeros((1, 3)).astype(np.float32)
dataset_y = np.zeros((1, 3)).astype(np.float32)
calibration_data = [{“x”: dataset_x, “y”: dataset_y}]
runner.optimize(calibration_data)
runner.save_har(quantized_har_path)
runner=ClientRunner(har=quantized_har_path)
compiled_hef = runner.compile()
with open(hef_path, “wb”) as f:
f.write(compiled_hef)
it throws “ValueError: Couldn’t detect CalibrationDataType”.
is there anything wrong?