iree: tensor.cast not working
Describe the bug
tensor.cast
op doesn’t seem to be supported
To Reproduce
Compile the following IR:
func @forward(%arg0: tensor<4x4xf32>) -> tensor<?x?xf32> {
%5 = tensor.cast %arg0 : tensor<4x4xf32> to tensor<?x?xf32>
return %5 : tensor<?x?xf32>
}
I see the error:
<stdin>:2:8: error: 'tensor.cast' op operand type '!hal.buffer_view' and result type 'tensor<?x?xf32>' are cast incompatible
%5 = tensor.cast %arg0 : tensor<4x4xf32> to tensor<?x?xf32>
^
<stdin>:1:1: note: called from
func @forward(%arg0: tensor<4x4xf32>, %arg1: tensor<4x4xf32>) -> tensor<?x?xf32> {
^
<stdin>:0:0: error: conversion from source -> vm failed
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 17 (8 by maintainers)
Commits related to this issue
- Add a pattern to convert tensor<->tensor static information casts to hal.tensor.cast. * This tweaks hal.tensor.cast to be buildable for this case and clarifies the use case. * Adds a common input con... — committed to iree-org/iree by stellaraccident 3 years ago
- Add a pattern to convert tensor<->tensor static information casts to flow.tensor.reshape. * Adds a common input conversion pipeline for this sort of thing (previously, the default was to do no input ... — committed to iree-org/iree by stellaraccident 3 years ago
- Add a pattern to convert tensor<->tensor static information casts to flow.tensor.reshape. * Adds a common input conversion pipeline for this sort of thing (previously, the default was to do no input ... — committed to iree-org/iree by stellaraccident 3 years ago
- Add a pattern to convert tensor<->tensor static information casts to flow.tensor.reshape. * Adds a common input conversion pipeline for this sort of thing (previously, the default was to do no input ... — committed to cathyzhyi/iree by stellaraccident 3 years ago
- Add a pattern to convert tensor<->tensor static information casts to flow.tensor.reshape. * Adds a common input conversion pipeline for this sort of thing (previously, the default was to do no input ... — committed to cathyzhyi/iree by stellaraccident 3 years ago
- Add a pattern to convert tensor<->tensor static information casts to flow.tensor.reshape. * Adds a common input conversion pipeline for this sort of thing (previously, the default was to do no input ... — committed to cathyzhyi/iree by stellaraccident 3 years ago
- Add a pattern to convert tensor<->tensor static information casts to flow.tensor.reshape. (#6407) * Adds a common input conversion pipeline for this sort of thing (previously, the default was to do n... — committed to iree-org/iree by cathyzhyi 3 years ago
These boundary conditions drive me nuts and need some more rigor.
While not how
hal.tensor.cast
is defined now (i.e. it lacks builders for generically constructing this form), I’m not sure that the following is an incorrect use of the op (i.e. if we convertedtensor.cast
->hal.tensor.cast
). Like Ben said, it isn’t great because as non-shape-carrying, it has to use local shape resolution (i.e. memref.dim and looking up the chain), but for these kind of widening cases, I’m not sure it is wrong (although, likely missing canonicalizations to be good).To:
I’m not an expert on this, though.