Remove special casing of "None" as a dim_param (#1482)

* Remove special casing of "None" as a dim_param
This commit is contained in:
Scott McKay 2019-07-25 17:18:14 +10:00 committed by GitHub
parent a8e3ff47fd
commit f052966972
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 4 deletions

View file

@ -59,8 +59,7 @@ static void RemoveInvalidValues(ONNX_NAMESPACE::TypeProto& type) {
for (int i = 0, end = shape->dim_size(); i < end; ++i) {
auto& dim = *shape->mutable_dim(i);
if (dim.has_dim_param()) {
auto dim_param = dim.dim_param();
if (dim_param.empty() || dim_param == "None") {
if (dim.dim_param().empty()) {
dim.clear_dim_param();
}
} else if (dim.has_dim_value()) {

View file

@ -114,12 +114,12 @@ class TestInferenceSession(unittest.TestCase):
self.assertEqual(input_name, "X")
input_shape = sess.get_inputs()[0].shape
# Input X has an unknown dimension.
self.assertEqual(input_shape, [None, 2])
self.assertEqual(input_shape, ['None', 2])
output_name = sess.get_outputs()[0].name
self.assertEqual(output_name, "Y")
output_shape = sess.get_outputs()[0].shape
# Output X has an unknown dimension.
self.assertEqual(output_shape, [None, 1])
self.assertEqual(output_shape, ['None', 1])
res = sess.run([output_name], {input_name: x})
output_expected = np.array([[5.0], [11.0], [17.0]], dtype=np.float32)
np.testing.assert_allclose(