c-api

python 3.x C extension module and submodule

谁都会走 提交于 2021-02-07 04:20:19
问题 How do I make a C extension for python 3.x when a module has sub-modules? For example, I have a file called pet.c: #include <Python.h> PyObject* CatMeow(PyObject* self) { return PyUnicode_FromString( ">*<" ); } static PyMethodDef CatFunctions[] = { {(char*) "meow", (PyCFunction) CatMeow, METH_NOARGS, NULL}, {NULL, NULL, 0, NULL} }; static PyModuleDef CatDef = { PyModuleDef_HEAD_INIT, "cat", "cat ext", -1, CatFunctions, NULL, NULL, NULL, NULL }; PyMODINIT_FUNC PyInit_cat(void) { return

Is there a way to supress TensorFlow logging in C-API

喜夏-厌秋 提交于 2021-01-28 12:12:27
问题 I managed to run my SavedModel generated by Python using C-API. Now I want to suppress all the verbose from TensorFlow as below: 2020-07-17 13:44:45.358903: I tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: /home/philgun/tf-C-API/my_model 2020-07-17 13:44:45.360075: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve } 2020-07-17 13:44:45.361381: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow

TensorFlow C API Logging Setting

安稳与你 提交于 2021-01-04 07:55:38
问题 I am trying to suppress the logging of the tensorflow in C-API when it loads a saved model. The logging looks like this 2020-07-24 13:06:39.805191: I tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: /home/philgun/tf-C-API/my_model 2020-07-24 13:06:39.806627: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve } 2020-07-24 13:06:39.819994: I tensorflow/cc/saved_model/loader.cc:202] Restoring SavedModel bundle. 2020-07-24 13:06:39.875249: I tensorflow

TensorFlow C API Logging Setting

泪湿孤枕 提交于 2021-01-04 07:53:46
问题 I am trying to suppress the logging of the tensorflow in C-API when it loads a saved model. The logging looks like this 2020-07-24 13:06:39.805191: I tensorflow/cc/saved_model/reader.cc:31] Reading SavedModel from: /home/philgun/tf-C-API/my_model 2020-07-24 13:06:39.806627: I tensorflow/cc/saved_model/reader.cc:54] Reading meta graph with tags { serve } 2020-07-24 13:06:39.819994: I tensorflow/cc/saved_model/loader.cc:202] Restoring SavedModel bundle. 2020-07-24 13:06:39.875249: I tensorflow

How does Python allocate memory for objects of classes derived from C types?

倖福魔咒の 提交于 2020-01-17 06:24:14
问题 Suppose we have created a Python module in C _xxx that contains an extension object xxx , and we do following: import _xxx class derived(_xxx.xxx): # ... d = derived() How does Python allocate memory for d behind the scenes? Eli Bendersky's article Python object creation sequence is the closest I've found, but it doesn't appear to cover this scenario. NOTE: there is already an answer HERE: I'm going to ask the author if he will consider migrating his answer here, as it is a good answer to a

Segmentation fault in PyArray_SimpleNewFromData

只愿长相守 提交于 2019-12-30 10:36:17
问题 I am looking to pass an array from C++ to Python using C-API. By looking at various topics here, I came to know that I should be using PyArray_SimpleNewFromData method. When I am trying to implement on a very small array, I am getiing a segmentation fault in my code which I am not able to detect. Can anyone help me with this issue? C++ code : void init_numpy() { import_array(); } int main(int argc, char *argv[]) { PyObject *pName, *pModule, *pDict, *pFunc, *pValue, *pArgs, *pXVec, *xarr1;

what dbus performance issue could prevent it from embedded system?

*爱你&永不变心* 提交于 2019-12-30 06:12:31
问题 From my reading dbus performance should be twice slower than other messaging ipc mechanisms due to existence of a daemon. In the discussion of the so question which Linux IPC technique to use someones mention performance issues. Do you see performance issues other than the twice slower factor? Do you see the issue that prevent dbus from being used in embedded system? To my understanding if dbus is intended for small messages. If large amount of data need to be passed around, one of the

SQLite/AutoHotkey, I have problem with Encoding of sqlite3_result_text return function

不羁的心 提交于 2019-12-24 06:37:17
问题 I am writing a User Define Function with SQLite in AutoHotkey. It works well as I intended when I use (return) English only. But, If I use (return) any character with NonEnglish, it makes broken result. The broken result has, for me, some rules - its length is exctly realted with NonEnglish character. Does any body heard about it ? I guess it is problem with " sqlite3_result_text " function of SQLite. If so, I'd like to use it properly. Thanks [EDIT] I have tested with " sqlite3_result_text64

“Hello TensorFlow!” using the C API

我怕爱的太早我们不能终老 提交于 2019-12-20 23:27:46
问题 For learning purposes, how to code this Python example using the TensorFlow C API ? import tensorflow as tf hello = tf.constant("hello TensorFlow!") sess=tf.Session() print(sess.run(hello)) I have tried it this way: #include <string.h> #include <iostream.h> #include "c_api.h" int main( int argc, char ** argv ) { TF_Graph * graph = TF_NewGraph(); TF_SessionOptions * options = TF_NewSessionOptions(); TF_Status * status = TF_NewStatus(); TF_Session * session = TF_NewSession( graph, options,

“Hello TensorFlow!” using the C API

陌路散爱 提交于 2019-12-03 08:11:41
For learning purposes, how to code this Python example using the TensorFlow C API ? import tensorflow as tf hello = tf.constant("hello TensorFlow!") sess=tf.Session() print(sess.run(hello)) I have tried it this way: #include <string.h> #include <iostream.h> #include "c_api.h" int main( int argc, char ** argv ) { TF_Graph * graph = TF_NewGraph(); TF_SessionOptions * options = TF_NewSessionOptions(); TF_Status * status = TF_NewStatus(); TF_Session * session = TF_NewSession( graph, options, status ); char hello[] = "Hello TensorFlow!"; TF_Tensor * tensor = TF_AllocateTensor( TF_STRING, 0, 0, 8 +