Spaces:
Sleeping
Sleeping
File size: 568 Bytes
dc2106c |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
// Copyright (c) ONNX Project Contributors
//
// SPDX-License-Identifier: Apache-2.0
#pragma once
#include <pybind11/pybind11.h>
#include "onnx/proto_utils.h"
namespace ONNX_NAMESPACE {
namespace py = pybind11;
template <typename Proto>
bool ParseProtoFromPyBytes(Proto* proto, const py::bytes& bytes) {
// Get the buffer from Python bytes object
char* buffer = nullptr;
Py_ssize_t length;
PyBytes_AsStringAndSize(bytes.ptr(), &buffer, &length);
return ParseProtoFromBytes(proto, buffer, length);
}
} // namespace ONNX_NAMESPACE
|