nod-ai / SHARK-Turbine

Unified compiler/runtime for interfacing with PyTorch Dynamo.
Apache License 2.0
82 stars 41 forks source link

how to lowering 'dense_resource' via "demote-i64-to-i32" pass of iree-opt. #712

Open bailuan opened 1 month ago

bailuan commented 1 month ago

I export clip torchIR by turbine, there is a line ir looks like: "%2 = torch.vtensor.literal(dense_resource : tensor<1x77xsi64>) : !torch.vtensor<[1,77],si64>", I use iree-opt's "torch-to-iree" pass to lower the torchIR to linalgIR. this line ir looks like: "%cst_9 = arith.constant dense_resource : tensor<1x77xi64>"

I try to use iree-opt's "demote-i64-to-i32" to lowering the linalgIR from torchIR, but failed. i want to know where the dense_resource come from? Is any way to set the data type to i32, but not i64(i have tried to set up the model's data type to torch.int32, but it didn't work).

Could someone have idea?

bailuan commented 1 month ago

at the bottom of the ir, there is something like this: {-# dialect_resources: { builtin: { torch_tensor_1_77_torch.int64: "0x0800000000000000000000000100000000000000020000000000000003000000000000000400000000000000050000000000000006000000000000000700000000000000080000000000000009000000000000000A000000000000000B000000000000000C000000000000000D000000000000000E000000000000000F0000000000000010000000000000001100000000000000120000000000000013000000000000001400000000000000150000000000000016000000000000001700000000000000180000000000000019000000000000001A000000000000001B000000000000001C000000000000001D000000000000001E000000000000001F0000000000000020000000000000002100000000000000220000000000000023000000000000002400000000000000250000000000000026000000000000002700000000000000280000000000000029000000000000002A000000000000002B000000000000002C000000000000002D000000000000002E000000000000002F0000000000000030000000000000003100000000000000320000000000000033000000000000003400000000000000350000000000000036000000000000003700000000000000380000000000000039000000000000003A000000000000003B000000000000003C000000000000003D000000000000003E000000000000003F0000000000000040000000000000004100000000000000420000000000000043000000000000004400000000000000450000000000000046000000000000004700000000000000480000000000000049000000000000004A000000000000004B000000000000004C00000000000000" } }

-}

I know this means 77 i64 numbers, where it is from when the turbine produce this ir?