Ejemplo n.º 1
0
 def test_version_exists(self):
     model = ModelProto()
     # When we create it, graph should not have a version string.
     self.assertFalse(model.HasField('ir_version'))
     # We should touch the version so it is annotated with the current
     # ir version of the running ONNX
     model.ir_version = IR_VERSION
     model_string = model.SerializeToString()
     model.ParseFromString(model_string)
     self.assertTrue(model.HasField('ir_version'))
     # Check if the version is correct.
     self.assertEqual(model.ir_version, IR_VERSION)
Ejemplo n.º 2
0
loaded_model = onnx.load(f)
assert model == loaded_model
 
# Test if input is a file name
f = tempfile.NamedTemporaryFile(delete=False)
f.write(model_string)
f.close()
loaded_model = onnx.load(f.name)
assert model == loaded_model
os.remove(f.name)
 
try:
    AttributeProto
    NodeProto
    GraphProto
    ModelProto
except Exception as e:
    assert False, 'Did not find proper onnx protobufs. Error is: {}'.format(e)
 
model = ModelProto()
# When we create it, graph should not have a version string.
assert not model.HasField('ir_version')
# We should touch the version so it is annotated with the current
# ir version of the running ONNX
model.ir_version = IR_VERSION
model_string = model.SerializeToString()
model.ParseFromString(model_string)
assert model.HasField('ir_version')
# Check if the version is correct.
assert model.ir_version == IR_VERSION