Skip to content

Commit

Permalink
add recipes and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Artem Balyshev committed Apr 25, 2024
1 parent 8974450 commit faf419e
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 1 deletion.
2 changes: 2 additions & 0 deletions compiler/circle2circle-dredd-recipe-test/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Add(Net_Mul_Div_001 PASS fuse_mul_with_div)
Add(Net_Preactivation_BN_000 PASS fuse_preactivation_batchnorm)
Add(Net_Reshape_Reshape_000 PASS remove_redundant_reshape)
Add(Net_Shape_Add_000 PASS fold_shape)
Add(Net_StriedSlices_Neg_000 PASS fuse_strided_slices_neg_as_mul_pattern)
Add(Net_FullyConnected_Mul_000 PASS fuse_mul_with_fully_connected)
Add(Net_Squeeze_Squeeze_000 PASS substitute_squeeze_to_reshape)
Add(Net_TConv_Add_000 PASS fuse_add_with_tconv)
Add(Net_TConv_Add_001 PASS fuse_add_with_tconv)
Expand Down
2 changes: 2 additions & 0 deletions compiler/luci-pass-value-test/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ addeval(Net_InstanceNorm_001 fuse_instnorm)
addeval(Net_InstanceNorm_002 fuse_instnorm)
addeval(Net_InstanceNorm_003 fuse_instnorm)
addeval(Net_StridedSlice_StridedSlice_000 remove_unnecessary_strided_slice)
addeval(Net_StriedSlices_Neg_000 fuse_strided_slices_neg_as_mul_pattern)
addeval(Net_FullyConnected_Mul_000 fuse_mul_with_fully_connected)
addeval(FullyConnected_007 replace_non_const_fc_with_batch_matmul)
addeval(Net_Transpose_Add_000 forward_transpose_op)
addeval(Net_Transpose_Abs_000 forward_transpose_op)
Expand Down
2 changes: 1 addition & 1 deletion compiler/luci/pass/src/FuseMulWithFullyConnectedPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ bool fuse_mul_with_fully_connected(luci::CircleMul *mul)
// Configure new FullyConnected operation.
auto *fused_fc =
loco::must_cast<luci::CircleFullyConnected *>(luci::clone_node(fc, mul->graph()));
fused_fc->input(fc->input());
fused_fc->input(fc_input);
fused_fc->weights(fused_fc_weight);
if (fused_fc_bias != nullptr)
{
Expand Down
66 changes: 66 additions & 0 deletions res/TensorFlowLiteRecipes/Net_FullyConnected_Mul_000/test.recipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
operand {
name: "ifm"
type: FLOAT32
shape { dim: 1 dim: 8 }
}
operand {
name: "mul_ifm"
type: FLOAT32
shape { dim: 1 dim: 16 }
filler {
tag: "gaussian"
arg: "0.0"
arg: "1.0"
}
}
operand {
name: "fc_wgt"
type: FLOAT32
shape { dim: 16 dim: 8 }
filler {
tag: "gaussian"
arg: "0.0"
arg: "1.0"
}
}
operand {
name: "fc_bias"
type: FLOAT32
shape { dim: 16 }
filler {
tag: "gaussian"
arg: "0.0"
arg: "1.0"
}
}
operand {
name: "fc"
type: FLOAT32
shape { dim: 1 dim: 16 }
}
operand {
name: "ofm"
type: FLOAT32
shape { dim: 1 dim: 16 }
}
operation {
type: "FullyConnected"
fullyconnected_options {
activation: NONE
}
input: "ifm"
input: "fc_wgt"
input: "fc_bias"
output: "fc"
}
operation {
type: "Mul"
input: "mul_ifm"
input: "fc"
output: "ofm"
mul_options {
activation: NONE
}
}
input: "ifm"
output: "ofm"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# To check if Mul is fused

RULE "VERIFY_FILE_FORMAT" $(verify_file_format) '=' 1

RULE "FC_EXIST" $(op_count FULLY_CONNECTED) '=' 1
RULE "NO_MUL" $(op_count MUL) '=' 0
102 changes: 102 additions & 0 deletions res/TensorFlowLiteRecipes/Net_StridedSlices_Neg_000/test.recipe
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
operand {
name: "ifm"
type: FLOAT32
shape { dim: 1 dim: 1 dim: 4 }
}
operand {
name: "begin"
type: INT32
shape { dim: 3 }
filler { tag: "explicit" arg: "0" arg: "0" arg: "0" }
}
operand {
name: "end"
type: INT32
shape { dim: 3 }
filler { tag: "explicit" arg: "1" arg: "1" arg: "2" }
}
operand {
name: "strides"
type: INT32
shape { dim: 3 }
filler { tag: "explicit" arg: "1" arg: "1" arg: "1" }
}
operand {
name: "output_1"
type: FLOAT32
shape { dim: 1 dim: 1 dim: 2 }
}
operation {
type: "StridedSlice"
strided_slice_options {
begin_mask: 0
end_mask: 0
ellipsis_mask: 0
new_axis_mask: 0
shrink_axis_mask: 0
}
input: "ifm"
input: "begin"
input: "end"
input: "strides"
output: "output_1"
}
operand {
name: "begin_2"
type: INT32
shape { dim: 3 }
filler { tag: "explicit" arg: "0" arg: "0" arg: "2" }
}
operand {
name: "end_2"
type: INT32
shape { dim: 3 }
filler { tag: "explicit" arg: "1" arg: "1" arg: "4" }
}
operand {
name: "output_2"
type: FLOAT32
shape { dim: 1 dim:1 dim: 2 }
}
operation {
type: "StridedSlice"
strided_slice_options {
begin_mask: 0
end_mask: 0
ellipsis_mask: 0
new_axis_mask: 0
shrink_axis_mask: 0
}
input: "ifm"
input: "begin_2"
input: "end_2"
input: "strides"
output: "output_2"
}
operand {
name: "output_neg"
type: FLOAT32
shape { dim: 1 dim: 1 dim: 2 }
}
operation {
type: "Neg"
input: "output_2"
output: "output_neg"
}
operand {
name: "ofm"
type: FLOAT32
shape { dim: 1 dim: 1 dim: 4 }
}
operation {
type: "Concatenation"
concatenation_options {
axis: -1
activation: NONE
}
input: "output_1"
input: "output_neg"
output: "ofm"
}
input: "ifm"
output: "ofm"
5 changes: 5 additions & 0 deletions res/TensorFlowLiteRecipes/Net_StridedSlices_Neg_000/test.rule
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# To check if StridedSlicesNeg pattern fused as mul.

RULE "VERIFY_FILE_FORMAT" $(verify_file_format) '=' 1
RULE "MUL_EXIST" $(op_count MUL) '=' 1
RULE "NO_STRIDEDSLICES" $(op_count STRIDEDSLICE) '=' 0

0 comments on commit faf419e

Please sign in to comment.