Add missing return post parse failure for the indices of a sparse attribute.

PiperOrigin-RevId: 229231462
This commit is contained in:
River Riddle 2019-01-14 12:23:38 -08:00 committed by jpienaar
parent 38c2fe3158
commit e0594ce732
2 changed files with 8 additions and 0 deletions

View File

@ -1102,6 +1102,8 @@ Attribute Parser::parseAttribute(Type type) {
auto indicesEltType = builder.getIntegerType(32);
auto indices =
parseDenseElementsAttr(indicesEltType, type.isa<VectorType>());
if (!indices)
return nullptr;
if (parseToken(Token::comma, "expected ','"))
return nullptr;

View File

@ -867,3 +867,9 @@ func @mi() {
func @invalid_tensor_literal() {
// expected-error @+1 {{expected '[' in tensor literal list}}
"foof16"(){bar: sparse<vector<1x1x1xf16>, [[0, 0, 0]], -2.0]>} : () -> ()
// -----
func @invalid_tensor_literal() {
// expected-error @+1 {{expected '[' or scalar constant inside tensor literal}}
"fooi16"(){bar: sparse<tensor<2x2x2xi16>, [[1, 1, 0], [0, 1, 0], [0,, [[0, 0, 0]], [-2.0]>} : () -> ()