Skip to content

Instantly share code, notes, and snippets.

View stellaraccident's full-sized avatar

Stella Laurenzo stellaraccident

  • Amd
  • Seattle Washington, US
View GitHub Profile
lists:
- &BACKENDS
- iree_llvmaot
- iree_vulkan
- &REF_BACKENDS
- tf
- &MATH_FUNCTIONS
- abs
- accumulate_n
- acos
@stellaraccident
stellaraccident / kws_after_linalg.mlir
Created June 1, 2021 21:17
keyword_spotting numerical regression
#map0 = affine_map<(d0, d1, d2, d3) -> (d1, d2)>
#map1 = affine_map<(d0, d1, d2, d3) -> (d0, d1, d2, d3)>
#map2 = affine_map<(d0, d1, d2) -> (d2)>
#map3 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
#map4 = affine_map<(d0, d1, d2) -> (d1, d2)>
#map5 = affine_map<(d0, d1, d2) -> ()>
#map6 = affine_map<(d0, d1, d2, d3) -> ()>
#map7 = affine_map<() -> ()>
#map8 = affine_map<(d0, d1) -> (d0, d1)>
#map9 = affine_map<(d0, d1) -> ()>
func @dynamicUpdateSlice(%arg0: tensor<2x4xi32>, %arg1: tensor<1x1xi32>, %arg2: tensor<i32>, %arg3: tensor<i32>) -> tensor<2x4xi32> {
%c2 = constant 2 : index
%c4 = constant 4 : index
%c1 = constant 1 : index
%0 = flow.tensor.reshape %arg1 : tensor<1x1xi32> -> tensor<i32>
%1 = flow.dispatch.workgroups[%c4, %c2, %c1](%0, %arg0, %arg2, %arg3) : (tensor<i32>, tensor<2x4xi32>, tensor<i32>, tensor<i32>) -> %arg0 =
(%arg4: !flow.dispatch.tensor<readonly:i32>, %arg5: !flow.dispatch.tensor<readwrite:2x4xi32>, %arg6: !flow.dispatch.tensor<readonly:i32>, %arg7: !flow.dispatch.tensor<readonly:i32>) {
%c0_i32 = constant 0 : i32
%c3_i32 = constant 3 : i32
%c1_i32 = constant 1 : i32
from mlir.ir import *
from mlir.dialects.builtin import *
from mlir.dialects.tosa import *
from mlir.passmanager import *
import mlir.dialects.sparse_tensor as st
import mlir.conversions
def sparse_tensor(shape, levels=None, ordering=None, dtype=None):
rank = len(shape)
graph(%self : __torch__.pytorch_translate.ensemble_export.BeamSearchAndDecode,
%src_tokens.1 : Tensor,
%src_lengths.1 : Tensor,
%prev_token.1 : Tensor,
%prev_scores.1 : Tensor,
%attn_weights.1 : Tensor,
%prev_hypos_indices.1 : Tensor,
%num_steps.1 : int):
%8 : None = prim::Constant()
%9 : __torch__.pytorch_translate.ensemble_export.BeamSearch = prim::GetAttr[name="beam_search"](%self)
module {
flow.variable @counter mutable dense<0.000000e+00> : tensor<f32> attributes {sym_visibility = "private"} loc(#loc0)
func @add_assign(%arg0: tensor<f32>) -> tensor<f32> attributes {iree.abi = "{\22a\22:[[\22ndarray\22,\22f32\22,0]],\22r\22:[[\22ndarray\22,\22f32\22,0]],\22v\22:1}"} {
%0 = flow.variable.load @counter : tensor<f32> loc(#loc1)
%1 = mhlo.add %0, %arg0 : tensor<f32> loc(#loc1)
flow.variable.store %1, @counter : tensor<f32> loc(#loc1)
%2 = flow.variable.load @counter : tensor<f32> loc(#loc2)
return %2 : tensor<f32> loc(#loc0)
} loc(#loc0)
} loc(#loc0)
/usr/local/google/home/laurenzo/src/iree/iree.venv/lib/python3.9/site-packages/tensorflow/python/saved_model/save.py:1081:0: error: failed to materialize conversion for result #0 of operation 'hal.constant.subspan' that remained live after conversion                          
/usr/local/google/home/laurenzo/src/iree/iree.venv/lib/python3.9/site-packages/tensorflow/python/saved_model/save.py:1043:0: note: called from                                                                                                                                      
/usr/local/google/home/laurenzo/src/iree-build/bindings/python/iree/compiler/tf.py:212:0: note: called from                                                                                                                                                                         
/usr/local/google/home/laurenzo/src/iree-build/bindings/python/iree/compiler/tf.py:216:0: note: called from                                                                                  
import circt.esi
import mlir.ir
with mlir.ir.Context() as ctx:
circt.register_dialects(ctx)
ChannelType = circt.esi.ChannelType
print(ChannelType.__mro__)
print(ChannelType.__bases__)
i32 = mlir.ir.Type.parse("i32")
vm.func @dict_nest(%arg0: !vm.list<?>, %arg1: !vm.ref<!hal.buffer_view>) -> !vm.list<?> attributes {iree.reflection = {iree.abi = "{\22a\22:[[\22sdict\22,[\22dict\22,[\22sdict\22,[\22a\22,[\22ndarray\22,\22f32
\22,1,16]],[\22b\22,[\22ndarray\22,\22f32\22,1,16]]]],[\22list\22,[\22slist\22,[\22ndarray\22,\22f32\22,1,16],[\22ndarray\22,\22f32\22,1,16]]]],[\22ndarray\22,\22f32\22,0]],\22r\22:[[\22sdict\22,[\22dict\22,[\22
sdict\22,[\22a\22,[\22ndarray\22,\22f32\22,1,16]],[\22b\22,[\22ndarray\22,\22f32\22,1,16]]]],[\22list\22,[\22slist\22,[\22ndarray\22,\22f32\22,1,16],[\22ndarray\22,\22f32\22,1,16]]]]],\22v\22:1}"}, ordinal = 1 :
i32} {
%c2 = vm.const.i32 2 : i32 {block_defined = ["%arg0", "%arg1", "%c1", "%c2", "%list", "%list_0", "%list_2", "%ref", "%ref_1", "%ref_3", "%ref_4", "%zero"], block_live = ["%arg0", "%c1", "%c2", "%list", "%lis
t_0", "%list_2", "%ref", "%ref_1", "%ref_3", "%ref_4", "%zero"], block_live_in = [], block_live_out = [], block_registers = ["r0", "r1"], live = ["%arg0", "%arg1", "%c2
@stellaraccident
stellaraccident / dynamic.mlir
Last active April 24, 2021 00:45
TF import with dyn shapes
module {
func @binary_func(%arg0: tensor<16xf32>, %arg1: tensor<16xf32>) -> (tensor<16xf32>, tensor<16xf32>) attributes {iree.abi = "{\22a\22:[[\22ndarray\22,\22f32\22,1,16],[\22ndarray\22,\22f32\22,1,16]],\22r\22:[[\22ndarray\22,\22f32\22,1,16],[\22ndarray\22,\22f32\22,1,16]],\22v\22:1}", iree.module.export} {
return %arg0, %arg1 : tensor<16xf32>, tensor<16xf32>
}
func @dict_nest(%arg0: !iree.list<?>, %arg1: tensor<f32>) -> !iree.list<?> attributes {iree.abi = "{\22a\22:[[\22sdict\22,[\22dict\22,[\22sdict\22,[\22a\22,[\22ndarray\22,\22f32\22,1,16]],[\22b\22,[\22ndarray\22,\22f32\22,1,16]]]],[\22list\22,[\22slist\22,[\22ndarray\22,\22f32\22,1,16],[\22ndarray\22,\22f32\22,1,16]]]],[\22ndarray\22,\22f32\22,0]],\22r\22:[[\22sdict\22,[\22dict\22,[\22sdict\22,[\22a\22,[\22ndarray\22,\22f32\22,1,16]],[\22b\22,[\22ndarray\22,\22f32\22,1,16]]]],[\22list\22,[\22slist\22,[\22ndarray\22,\22f32\22,1,16],[\22ndarray\22,\22f32\22,1,16]]]]],\22v\22:1}", iree.module.export} {
%c2 = constant 2 : index
%c0 =