@@ -19,14 +19,16 @@ auto bitwisenot TORCHTRT_UNUSED =
1919
2020 if (in->getType () == nvinfer1::DataType::kINT32 ) {
2121 // Integer case
22- auto one = torch::tensor ({1 }, util::TRTDataTypeToScalarType (in->getType ()));
23- auto one_const = tensor_to_const (ctx, one);
24- auto neg = ctx->net ->addUnary (*in, nvinfer1::UnaryOperation::kNEG );
25- TORCHTRT_CHECK (neg, " Unable to create neg unary layer from node: " << *n);
22+ auto neg_one = torch::tensor ({-1 }, util::TRTDataTypeToScalarType (in->getType ()));
23+ auto neg_one_const = tensor_to_const (ctx, neg_one);
24+ auto neg = add_elementwise (
25+ ctx, nvinfer1::ElementWiseOperation::kPROD , in,
26+ neg_one_const, util::node_info (n) + std::string (" _Negation" ));
27+ TORCHTRT_CHECK (neg, " Unable to create prod layer from node: " << *n);
2628 out = add_elementwise (
27- ctx, nvinfer1::ElementWiseOperation::kSUB , neg->getOutput (0 ),
28- one_const , util::node_info (n));
29- TORCHTRT_CHECK (out, " Unable to create sub layer from node: " << *n);
29+ ctx, nvinfer1::ElementWiseOperation::kSUM , neg->getOutput (0 ),
30+ neg_one_const , util::node_info (n) + std::string ( " _SubOne " ));
31+ TORCHTRT_CHECK (out, " Unable to create sum layer from node: " << *n);
3032 } else if (in->getType () == nvinfer1::DataType::kBOOL ) {
3133 // Boolean case
3234 out = ctx->net ->addUnary (*in, nvinfer1::UnaryOperation::kNOT );
0 commit comments