forked from OSchip/llvm-project
GetMemRefType failed on 0-D tensors. Loosened check to allow tensors with shape
{}. -- PiperOrigin-RevId: 245104548
This commit is contained in:
parent
ce12875333
commit
69cdceae73
|
@ -678,8 +678,8 @@ of tensor type.
|
|||
Note: hexadecimal integer literals are not allowed in tensor type declarations
|
||||
to avoid confusion between `0xf32` and `0 x f32`. Zero sizes are allowed in
|
||||
tensors and treated as other sizes, e.g., `tensor<0 x 1 x i32>` and `tensor<1 x
|
||||
0 x i32>` are different types. Since zero sizes are not allowed in other types,
|
||||
such tensors should be optimized away before lowering tensors to memrefs.
|
||||
0 x i32>` are different types. Since zero sizes are not allowed in some other
|
||||
types, such tensors should be optimized away before lowering tensors to vectors.
|
||||
|
||||
Examples:
|
||||
|
||||
|
@ -722,7 +722,9 @@ A `memref` type is a reference to a region of memory (similar to a buffer
|
|||
pointer, but more powerful). The buffer pointed to by a memref can be allocated,
|
||||
aliased and deallocated. A memref can be used to read and write data from/to the
|
||||
memory region which it references. Memref types use the same shape specifier as
|
||||
tensor types, but do not allow unknown rank nor zero sizes.
|
||||
tensor types, but do not allow unknown rank. Note that `memref<f32>`, `memref<0
|
||||
x f32>`, `memref<1 x 0 x f32>`, and `memref<0 x 1 x f32>` are all different
|
||||
types.
|
||||
|
||||
The memory space of a memref is specified by a target-specific integer index. If
|
||||
no memory space is specified, then the default memory space (0) is used. The
|
||||
|
|
|
@ -353,7 +353,7 @@ public:
|
|||
};
|
||||
|
||||
/// MemRef types represent a region of memory that have a shape with a fixed
|
||||
/// number of dimensions. Each shape element can be a positive integer or
|
||||
/// number of dimensions. Each shape element can be a non-negative integer or
|
||||
/// unknown (represented by any negative integer). MemRef types also have an
|
||||
/// affine map composition, represented as an array AffineMap pointers.
|
||||
class MemRefType
|
||||
|
|
|
@ -314,7 +314,7 @@ MemRefType MemRefType::getImpl(ArrayRef<int64_t> shape, Type elementType,
|
|||
|
||||
for (int64_t s : shape) {
|
||||
// Negative sizes are not allowed except for `-1` that means dynamic size.
|
||||
if (s <= 0 && s != -1) {
|
||||
if (s < -1) {
|
||||
if (location)
|
||||
context->emitError(*location, "invalid memref size");
|
||||
return {};
|
||||
|
|
|
@ -871,16 +871,6 @@ func @zero_in_vector_type() -> vector<1x0xi32>
|
|||
|
||||
// -----
|
||||
|
||||
// expected-error @+1 {{invalid memref size}}
|
||||
func @zero_memref_type() -> memref<0xi32>
|
||||
|
||||
// -----
|
||||
|
||||
// expected-error @+1 {{invalid memref size}}
|
||||
func @zero_in_memref_type() -> memref<1x0xi32>
|
||||
|
||||
// -----
|
||||
|
||||
// expected-error @+1 {{expected dimension size in vector type}}
|
||||
func @negative_vector_size() -> vector<-1xi32>
|
||||
|
||||
|
|
Loading…
Reference in New Issue