|
|
@@ -23,7 +23,7 @@ class MatMulMapper(ONNXToMindSporeMapper): |
|
|
|
|
|
|
|
|
@staticmethod |
|
|
@staticmethod |
|
|
def _operation_name_in_ms(*args, **kwargs): |
|
|
def _operation_name_in_ms(*args, **kwargs): |
|
|
return "P.matmul" |
|
|
|
|
|
|
|
|
return "nn.MatMul" |
|
|
|
|
|
|
|
|
@staticmethod |
|
|
@staticmethod |
|
|
def _convert_params(**kwargs): |
|
|
def _convert_params(**kwargs): |
|
|
@@ -50,19 +50,19 @@ class MatMulMapper(ONNXToMindSporeMapper): |
|
|
variable_slot = "var_0" |
|
|
variable_slot = "var_0" |
|
|
|
|
|
|
|
|
w_location = MatMulMapper._find_location_by_index(0, weights) |
|
|
w_location = MatMulMapper._find_location_by_index(0, weights) |
|
|
init_tensor_list = list() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init_template_list = [f"self.{{{variable_slot}}} = {op}()"] |
|
|
inputs_in_construct = [f"{{{ExchangeMessageKeywords.VariableScope.value.INPUTS.value}}}"] |
|
|
inputs_in_construct = [f"{{{ExchangeMessageKeywords.VariableScope.value.INPUTS.value}}}"] |
|
|
if w_location != -1: |
|
|
if w_location != -1: |
|
|
# Note: adding weight shape to args is now deprecated due to conflict of partial weights share processing. |
|
|
# Note: adding weight shape to args is now deprecated due to conflict of partial weights share processing. |
|
|
variable_slot_param_name = f"{variable_slot}/w" |
|
|
variable_slot_param_name = f"{variable_slot}/w" |
|
|
init_tensor_list.append(f"self.{{{variable_slot}}}_w = {{{variable_slot_param_name}}}") |
|
|
|
|
|
|
|
|
init_template_list.append(f"self.{{{variable_slot}}}_w = {{{variable_slot_param_name}}}") |
|
|
inputs_in_construct.insert(w_location, f"self.{{{variable_slot}}}_w") |
|
|
inputs_in_construct.insert(w_location, f"self.{{{variable_slot}}}_w") |
|
|
construct_template = f"opt_{{{variable_slot}}} = {op}({', '.join(inputs_in_construct)})" |
|
|
|
|
|
|
|
|
construct_template = f"opt_{{{variable_slot}}} = self.{{{variable_slot}}}({', '.join(inputs_in_construct)})" |
|
|
|
|
|
|
|
|
template = { |
|
|
template = { |
|
|
variable_slot: { |
|
|
variable_slot: { |
|
|
TemplateKeywords.INIT.value: init_tensor_list, |
|
|
|
|
|
|
|
|
TemplateKeywords.INIT.value: init_template_list, |
|
|
TemplateKeywords.CONSTRUCT.value: [construct_template] |
|
|
TemplateKeywords.CONSTRUCT.value: [construct_template] |
|
|
} |
|
|
} |
|
|
} |
|
|
} |