diff --git a/mace/ops/eltwise.h b/mace/ops/eltwise.h index 66c505fa2e4f75d4070672cd3f9f8a2b1e90a7a5..9cc800bfb40c2db88a28c4b4e0a3c2daeb60eb97 100644 --- a/mace/ops/eltwise.h +++ b/mace/ops/eltwise.h @@ -30,7 +30,7 @@ class EltwiseOp : public Operator { static_cast(OperatorBase::GetOptionalArg( "type", static_cast(kernels::EltwiseType::NONE))), OperatorBase::GetRepeatedArgs("coeff"), - OperatorBase::GetOptionalArg("x", 1.0)) {} + OperatorBase::GetOptionalArg("value", 1.0)) {} MaceStatus Run(StatsFuture *future) override { const Tensor *input0 = this->Input(0); diff --git a/mace/ops/eltwise_test.cc b/mace/ops/eltwise_test.cc index e3cbb2debd97c16abeef2481972e89ab1eda3f74..e8fd81cf7fdad1b948c5537925795b472ec4b98d 100644 --- a/mace/ops/eltwise_test.cc +++ b/mace/ops/eltwise_test.cc @@ -40,7 +40,7 @@ void SimpleTensorScalar(const kernels::EltwiseType type, OpDefBuilder("Eltwise", "EltwiseTest") .Input("TInput") .AddIntArg("type", static_cast(type)) - .AddFloatArg("x", x) + .AddFloatArg("value", x) .Output("TOutput") .Finalize(net.NewOperatorDef()); // Run @@ -52,7 +52,7 @@ void SimpleTensorScalar(const kernels::EltwiseType type, OpDefBuilder("Eltwise", "EltwiseTest") .Input("InputImg") .AddIntArg("type", static_cast(type)) - .AddFloatArg("x", x) + .AddFloatArg("value", x) .Output("OutputImg") .Finalize(net.NewOperatorDef()); @@ -321,7 +321,7 @@ void RandomTensorScalar(const kernels::EltwiseType type, OpDefBuilder("Eltwise", "EltwiseTest") .Input("TInput") .AddIntArg("type", static_cast(type)) - .AddFloatArg("x", 0.1) + .AddFloatArg("value", 0.1) .Output("TOutput") .Finalize(net.NewOperatorDef()); // Run @@ -336,7 +336,7 @@ void RandomTensorScalar(const kernels::EltwiseType type, OpDefBuilder("Eltwise", "EltwiseTest") .Input("InputImg") .AddIntArg("type", static_cast(type)) - .AddFloatArg("x", 0.1) + .AddFloatArg("value", 0.1) .Output("OutputImg") .AddIntArg("T", static_cast(DataTypeToEnum::value)) .Finalize(net.NewOperatorDef()); diff --git a/mace/python/tools/converter_tool/base_converter.py b/mace/python/tools/converter_tool/base_converter.py index be6e67529166d6678df326af14c369124fff7e08..0a56239eace1c825752556ebad9d01a3479f8679 100644 --- a/mace/python/tools/converter_tool/base_converter.py +++ b/mace/python/tools/converter_tool/base_converter.py @@ -139,6 +139,7 @@ class MaceKeyword(object): mace_shape_str = 'shape' mace_winograd_filter_transformed = 'is_filter_transformed' mace_device = 'device' + mace_value_str = 'value' class TransformerRule(Enum): diff --git a/mace/python/tools/converter_tool/tensorflow_converter.py b/mace/python/tools/converter_tool/tensorflow_converter.py index 19674f376999aba31172be2c4cdecce27b578c31..0eea81c079cb26b9e1e84d09877f2912436057ba 100644 --- a/mace/python/tools/converter_tool/tensorflow_converter.py +++ b/mace/python/tools/converter_tool/tensorflow_converter.py @@ -309,6 +309,19 @@ class TensorflowConverter(base_converter.ConverterInterface): type_arg.name = MaceKeyword.mace_element_type_str type_arg.i = self.eltwise_type[tf_op.type].value + if len(tf_op.inputs[0].shape) == 0: + value_arg = op.arg.add() + value_arg.name = MaceKeyword.mace_value_str + value_arg.f = tf_op.inputs[0].eval().astype(np.float32) + self._skip_tensor.add(tf_op.inputs[0].name) + del op.input[0] + elif len(tf_op.inputs[1].shape) == 0: + value_arg = op.arg.add() + value_arg.name = MaceKeyword.mace_value_str + value_arg.f = tf_op.inputs[1].eval().astype(np.float32) + self._skip_tensor.add(tf_op.inputs[1].name) + del op.input[1] + def convert_biasadd(self, tf_op): op = self.convert_general_op(tf_op) op.type = MaceOp.BiasAdd.name