menoh
menoh copied to clipboard
Non-deterministic and suspicious errors
I ran the following program with the attached ggnn.onnx
in ggnn.zip.
#include <menoh/menoh.h>
#include <stdio.h>
#define ERROR_CHECK(statement) \
{ \
menoh_error_code ec = statement; \
if(ec) { \
printf("%s\n", menoh_get_last_error_message()); \
return 1; \
} \
}
int main()
{
menoh_model_data_handle model_data;
ERROR_CHECK(
menoh_make_model_data_from_onnx("ggnn.onnx", &model_data));
menoh_variable_profile_table_builder_handle vpt_builder;
ERROR_CHECK(menoh_make_variable_profile_table_builder(&vpt_builder));
ERROR_CHECK(menoh_variable_profile_table_builder_add_input_profile_dims_4(
vpt_builder, "111980687600", menoh_dtype_float, 32, 4, 51, 51));
ERROR_CHECK(menoh_variable_profile_table_builder_add_input_profile_dims_4(
vpt_builder, "111980687712", menoh_dtype_float, 32, 51, 16, 1));
ERROR_CHECK(menoh_variable_profile_table_builder_add_output_profile(
vpt_builder, "112043339960", menoh_dtype_float));
menoh_variable_profile_table_handle variable_profile_table;
ERROR_CHECK(menoh_build_variable_profile_table(vpt_builder, model_data,
&variable_profile_table));
return 0;
}
The results are non-deterministic and the "menoh variable not found error" errors raise the doubt of bug.
$ gcc `pkg-config menoh --libs --cflags` test.c
$ ./a.out
menoh unsupported operator error: Transpose
$ ./a.out
menoh variable not found error: 112043186328
$ ./a.out
menoh variable not found error: 112043186328
$ ./a.out
menoh variable not found error: 112043244120
$ ./a.out
menoh variable not found error: 112043244400
$ ./a.out
menoh unsupported operator error: Identity
$ ./a.out
menoh unsupported operator error: Transpose
$ ./a.out
menoh unsupported operator error: Identity
$ ./a.out
menoh unsupported operator error: Transpose
$ ./a.out
menoh unsupported operator error: Transpose
$ ./a.out
menoh unsupported operator error: Transpose
$ ./a.out
menoh unsupported operator error: Identity
$ ./a.out
menoh unsupported operator error: Transpose
$ ./a.out
menoh unsupported operator error: Transpose
$
I dumped the model using following script with modified version of onnx-chainer https://github.com/msakai/onnx-chainer/tree/94baaf4294c7e8ae1a255cc5823535fe1e1dd9e7 :
import numpy as np
import chainer
import chainer_chemistry
from chainer_chemistry.models import GGNN
import onnx_chainer
mb = 32
edge_type = 4
atom = 51
n_atom_types = chainer_chemistry.config.MAX_ATOMIC_NUM # 117
n_unit = 16
conv_layers = 4
#atom_array = chainer.Variable(np.arange(mb * atom, dtype=np.int32).reshape(mb, atom) % n_atom_types)
atom_array2 = chainer.Variable(np.zeros((32,51,16,1), dtype=np.float32))
adj = chainer.Variable(np.ones((mb, edge_type, atom, atom), dtype=np.float32))
class Dummy(chainer.Chain):
def __init__(self):
super().__init__()
with self.init_scope():
self.m = GGNN(out_dim=n_unit, hidden_dim=n_unit, n_layers=conv_layers)
def __call__(self, atom_array2, adj):
return self.m(atom_array2.reshape((32,51,16)), adj)
onnx_chainer.export(Dummy(), [atom_array2, adj], filename='ggnn.onnx')
The non-deterministic results may be occured from this line. I made PR #90 to remove it. Whould you try it?
That menoh variable not found error
may relate to #42.
With #90 it always fails with menoh unsupported operator error: Identity
.