@@ -35,7 +35,7 @@ Status SoftmaxOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,
3535 NodeAttrHelper helper (node);
3636 int32_t axis_default_value = (node.SinceVersion () < 13 ) ? 1 : -1 ;
3737 const auto axis = helper.Get (" axis" , axis_default_value);
38- auto axis_nonnegative = HandleNegativeAxis (axis, data_shape.size ());
38+ auto axis_nonnegative = HandleNegativeAxis (axis, data_shape.size ());
3939
4040#if defined(COREML_ENABLE_MLPROGRAM)
4141 // CoreML's softmax match onnx's softmax behavior since opset 13.
@@ -47,15 +47,15 @@ Status SoftmaxOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,
4747 const int32_t elem_type = static_cast <int32_t >(input_dtype);
4848
4949 std::string_view layer_input_name_x = node.InputDefs ()[0 ]->Name ();
50- const bool need_reshape = node.SinceVersion () < 13 && axis_nonnegative != static_cast <int64_t >(data_shape.size ()) - 1 ;
50+ const bool need_reshape = node.SinceVersion () < 13 && axis_nonnegative != static_cast <int64_t >(data_shape.size ()) - 1 ;
5151 std::vector<int64_t > target_shape;
5252 if (need_reshape) {
5353 // reshape to 2D to simulate onnx softmax behavior
5454 auto reshape1 = model_builder.CreateOperation (node, " reshape" , " pre" );
5555 TensorShape input_shape (data_shape);
56- target_shape.push_back (input_shape.SizeToDimension (axis_nonnegative ));
57- target_shape.push_back (input_shape.SizeFromDimension (axis_nonnegative ));
58- axis_nonnegative = 1 ;
56+ target_shape.push_back (input_shape.SizeToDimension (axis_nonnegative));
57+ target_shape.push_back (input_shape.SizeFromDimension (axis_nonnegative));
58+ axis_nonnegative = 1 ;
5959 AddOperationInput (*reshape1, " x" , layer_input_name_x);
6060 AddOperationInput (*reshape1, " shape" , model_builder.AddConstant (reshape1->type (), " shape1" , target_shape));
6161 layer_input_name_x = model_builder.GetUniqueName (node, " ln_reshape1_" );
@@ -64,7 +64,7 @@ Status SoftmaxOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,
6464 }
6565 std::unique_ptr<Operation> op = model_builder.CreateOperation (node, " softmax" );
6666 AddOperationInput (*op, " x" , layer_input_name_x);
67- AddOperationInput (*op, " axis" , model_builder.AddScalarConstant (op->type (), " axis" , axis_nonnegative ));
67+ AddOperationInput (*op, " axis" , model_builder.AddScalarConstant (op->type (), " axis" , axis_nonnegative));
6868 if (!need_reshape) {
6969 AddOperationOutput (*op, *node.OutputDefs ()[0 ]);
7070 model_builder.AddOperation (std::move (op));
@@ -91,8 +91,8 @@ Status SoftmaxOpBuilder::AddToModelBuilderImpl(ModelBuilder& model_builder,
9191 // note: if opsets < 13, onnx Softmax coerces the input shape to be 2D based on axis.
9292 // we need to manually reshape to 2D and apply SoftmaxND to axis -1 to achieve equivalent results for CoreML.
9393 TensorShape input_shape (data_shape);
94- const auto size_to_dimension = input_shape.SizeToDimension (axis_nonnegative );
95- const auto size_from_dimension = input_shape.SizeFromDimension (axis_nonnegative );
94+ const auto size_to_dimension = input_shape.SizeToDimension (axis_nonnegative);
95+ const auto size_from_dimension = input_shape.SizeFromDimension (axis_nonnegative);
9696
9797 TensorShapeVector target_shape;
9898 target_shape.push_back (size_to_dimension);
0 commit comments