cppflow
cppflow copied to clipboard
There is an unhandled exception: Microsoft C++ exception: std::runtime_error
This code breaks in Model.cpp at : TF_SessionRun(this->session, nullptr, io.data(), iv.data(), inputs.size(), oo.data(), ov, outputs.size(), nullptr, 0, nullptr, this->status); this->status_check(true);
The interrupted content is:Microsoft C++ exception: std::runtime_error
I don't have any idea of that
#include
using namespace std; int main() {
Model model("D:/no_chinese_language/model2.pb");
//model.init();
Tensor input_a{ model, "cond/Merge" };
Tensor input_b{ model, "m_64" };
Tensor input_c{ model, "m_32" };
Tensor output{ model, "output" };
int pi0[16 * 16];
for (int i = 0; i < 16 * 16; i++)
{
pi0[i] = 106;
}
int width = 16;
float mean = 0;
float std = 0;
float sum = 0;
int stride = 16;
int abe = width*width;
for (int i = 0; i < width; i++)
{
for (int j = 0; j < width; j++)
{
//ofsinfo << pi0[i*stride + j] << endl;
mean += pi0[i*stride + j];
sum += pi0[i*stride + j] * pi0[i*stride + j];
}
}
mean = mean / (abe);
std = sum / (abe)-mean*mean;
std = sqrt(std);
std::vector<float> data(width*width);
if (std == 0)
{
float a = 0;
for (int i = 0; i < width; i++)
{
for (int j = 0; j < width; j++)
{
a = pi0[i*stride + j] - mean;
data.push_back(a);
}
}
}
else
{
float a = 0;
for (int i = 0; i < width; i++)
{
for (int j = 0; j < width; j++)
{
a = (pi0[i*stride + j] - mean) / std;
data.push_back(a);
}
}
}
vector<int16_t> data64;
data64.push_back(0);
vector<int16_t> data32;
data32.push_back(0);
input_a.set_data(data, { 1, 16, 16, 1 });
input_b.set_data(data64, {1,1});
input_c.set_data(data32,{1,1});
model.run({ &input_a, &input_b, &input_c }, output );
for (float f : output.get_data<float>()) {
std::cout << (int)f << " ";
}
input_a.clean();
input_b.clean();
input_c.clean();
output.clean();
return 0;
}