Skip to content

About GCOV #10

@BiophiliaSWDA

Description

@BiophiliaSWDA

Hi,
I am wondering how you relate GCOV to TensorFlow or Pytorch, because I am also currently experimenting with code coverage for deep learning networks, but I can't get operator coverage (or line coverage) for a TensorFlow network model after calling it from a C++ program.

I did this by calling the encapsulated network model from a C++ program and then using GCOV on the C++ program, but that didn't associate it with the source code.

#include <iostream>
#include "Python.h"


int main() {
    callModel();
    return 0;
}


// call python program
void callModel(){
    Py_Initialize();
    const char *init_call = "import sys\n"
                            "import os\n"
                            "sys.path.append('/'.join(os.getcwd().split('/')[:-1]))\n";
    PyRun_SimpleString(init_call);

    PyObject* pModule = PyImport_ImportModule("torch_.lenet");

    if (pModule != nullptr) {
        PyObject* pFunc = PyObject_GetAttrString(pModule, "go");
        PyObject_CallObject(pFunc, nullptr);
    }
    else{
        printf("Fail");
    }

    Py_Finalize();

}
g++ -fprofile-arcs -ftest-coverage main.cpp -o main
./main
gcov -n main.cpp
gcovr -v --html-details main.html    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions