Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 10:05:44

0001 // Copyright (c) ONNX Project Contributors
0002 //
0003 // SPDX-License-Identifier: Apache-2.0
0004 
0005 #pragma once
0006 
0007 #include <pybind11/pybind11.h>
0008 
0009 #include "onnx/proto_utils.h"
0010 
0011 namespace ONNX_NAMESPACE {
0012 namespace py = pybind11;
0013 
0014 template <typename Proto>
0015 bool ParseProtoFromPyBytes(Proto* proto, const py::bytes& bytes) {
0016   // Get the buffer from Python bytes object
0017   char* buffer = nullptr;
0018   Py_ssize_t length;
0019   PyBytes_AsStringAndSize(bytes.ptr(), &buffer, &length);
0020 
0021   return ParseProtoFromBytes(proto, buffer, length);
0022 }
0023 } // namespace ONNX_NAMESPACE