Commit 497262b4 authored by Ted Themistokleous's avatar Ted Themistokleous
Browse files

Add test case to parse in empty constant int64 proto buffer

I think the previous test case was aliasing an issue where we default to float but need to actually read in int64 instead of int32
parent a1ef8caf
......@@ -31,6 +31,7 @@ from onnx import TensorProto
def onnx_test(op_test):
def run_test():
op_info = op_test()
if len(op_info) > 3:
......@@ -626,6 +627,26 @@ def constant_scalar_test():
return ([node], [], [y])
@onnx_test
def constant_scalar_test2():
x = np.array([]).astype(np.int64)
y = helper.make_tensor_value_info('0', TensorProto.INT64, [1])
node = onnx.helper.make_node(
'Constant',
inputs=[],
outputs=['0'],
value=onnx.helper.make_tensor(
name='empty_tensor',
data_type=TensorProto.INT64,
dims=x.shape,
vals=x.flatten().astype(np.int64),
),
)
return ([node], [], [y])
@onnx_test
def const_of_shape_empty_input_test():
tensor_val = onnx.helper.make_tensor('value', onnx.TensorProto.INT64, [1],
......
......@@ -636,6 +636,16 @@ TEST_CASE(constant_scalar_test)
EXPECT(p == prog);
}
TEST_CASE(constant_scalar_test2)
{
migraphx::program p;
auto* mm = p.get_main_module();
mm->add_literal(migraphx::literal{migraphx::shape{migraphx::shape::int64_type, {1}}, {0}});
auto prog = optimize_onnx("constant_scalar_test2.onnx");
EXPECT(p == prog);
}
TEST_CASE(const_of_shape_empty_input_test)
{
migraphx::program p;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment