Skip to content

Commit a43ed6a

Browse files
committed
Don't generate denseResource
1 parent cb7b206 commit a43ed6a

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

python/torch_mlir/extras/fx_importer.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2127,25 +2127,25 @@ def _make_vtensor_literal_op(
21272127
# One element constants are more optimizable as splat DenseElementsAttr. DenseResourceElementsAttr does not
21282128
# support splats, so don't use it for that case. In addition, at the time of writing, it has bugs with handling
21292129
# 0d tensors.
2130-
if np_tensor.size == 1:
2131-
try:
2132-
dtype = tensor.dtype
2133-
element_type = TORCH_DTYPE_TO_MLIR_TYPE[dtype]()
2134-
except KeyError:
2135-
raise TypeError(f"Could not map Torch dtype {dtype} to an MLIR type")
2136-
elements_attr = DenseElementsAttr.get(
2137-
type=element_type, array=np_tensor, shape=np_tensor.shape
2138-
)
2139-
else:
2140-
bytes_view = np_tensor.view(npy_dtype)
2141-
tensor_type = create_mlir_tensor_type(tensor)
2142-
shape_desc = "_".join([str(d) for d in tensor.shape])
2143-
blob_name = f"torch_tensor_{shape_desc}_{str(tensor.dtype)}"
2144-
elements_attr = DenseResourceElementsAttr.get_from_buffer(
2145-
bytes_view,
2146-
blob_name,
2147-
tensor_type,
2148-
)
2130+
# if np_tensor.size == 1:
2131+
try:
2132+
dtype = tensor.dtype
2133+
element_type = TORCH_DTYPE_TO_MLIR_TYPE[dtype]()
2134+
except KeyError:
2135+
raise TypeError(f"Could not map Torch dtype {dtype} to an MLIR type")
2136+
elements_attr = DenseElementsAttr.get(
2137+
type=element_type, array=np_tensor, shape=np_tensor.shape
2138+
)
2139+
# else:
2140+
# bytes_view = np_tensor.view(npy_dtype)
2141+
# tensor_type = create_mlir_tensor_type(tensor)
2142+
# shape_desc = "_".join([str(d) for d in tensor.shape])
2143+
# blob_name = f"torch_tensor_{shape_desc}_{str(tensor.dtype)}"
2144+
# elements_attr = DenseResourceElementsAttr.get_from_buffer(
2145+
# bytes_view,
2146+
# blob_name,
2147+
# tensor_type,
2148+
# )
21492149
mapping.value = elements_attr
21502150
else:
21512151
elements_attr = mapping.value

0 commit comments

Comments
 (0)