Skip to content

Commit

Permalink
logical not
Browse files Browse the repository at this point in the history
  • Loading branch information
kali committed Sep 20, 2023
1 parent efa6c62 commit d2e5a39
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
9 changes: 5 additions & 4 deletions test-rt/test-tflite/suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,11 @@ fn ignore_onnx(t: &[String]) -> bool {
test_slice
test_split
where
less
greater
equal
test_where
test_less
test_greater
test_equal
test_not
test_add
test_mul
Expand Down
12 changes: 11 additions & 1 deletion tflite/src/ops/element_wise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ use crate::ser::{BuiltinOp, SubgraphBuilder};
use crate::tflite::{
AbsOptions, AbsOptionsArgs, BuiltinOperator, BuiltinOptions, CosOptions, CosOptionsArgs,
ExpOptions, ExpOptionsArgs, HardSwishOptions, HardSwishOptionsArgs, LeakyReluOptions,
LeakyReluOptionsArgs, SquareOptions, SquareOptionsArgs,
LeakyReluOptionsArgs, LogicalNotOptionsArgs, SquareOptions, SquareOptionsArgs, LogicalNotOptions,
};
use tract_core::internal::*;
use tract_core::ops::element_wise::ElementWiseOp;
use tract_core::ops::logic::{ Not, not };
use tract_core::ops::math::*;
use tract_core::ops::nn::{hard_swish, leaky_relu, HardSwish, LeakyRelu};

Expand All @@ -19,6 +20,7 @@ pub fn register_all(reg: &mut Registry) {
reg.reg_to_tract(BuiltinOperator::HARD_SWISH, |op| deser(op, hard_swish()));
reg.reg_to_tract(BuiltinOperator::LEAKY_RELU, de_leaky_relu);
reg.reg_to_tract(BuiltinOperator::LOG, |op| deser(op, ln()));
reg.reg_to_tract(BuiltinOperator::LOGICAL_NOT, |op| deser(op, not()));
reg.reg_to_tract(BuiltinOperator::SIN, |op| deser(op, sin()));
reg.reg_to_tract(BuiltinOperator::SQRT, |op| deser(op, sqrt()));
reg.reg_to_tract(BuiltinOperator::SQUARE, |op| deser(op, square()));
Expand Down Expand Up @@ -83,6 +85,14 @@ fn ser(
BuiltinOp::new(98, 1, BuiltinOperator::LEAKY_RELU, BuiltinOptions::LeakyReluOptions),
options.as_union_value(),
)
} else if (*op.0).is::<Not>() {
let options = LogicalNotOptions::create(builder.fb(), &LogicalNotOptionsArgs {});
builder.write_op_with_options(
&[input],
&[output],
BuiltinOp::new(87, 1, BuiltinOperator::LOGICAL_NOT, BuiltinOptions::LogicalNotOptions),
options.as_union_value(),
)
} else if (*op.0).is::<Square>() {
let options = SquareOptions::create(builder.fb(), &SquareOptionsArgs {});
builder.write_op_with_options(
Expand Down

0 comments on commit d2e5a39

Please sign in to comment.