Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions coremltools/models/neural_network/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,9 @@ def _check_fp16_weight_param_exists(self, layers):

# uniDirectionalLSTM Layers
elif layer_type == "uniDirectionalLSTM":
return self._check_fp16_weight_params_lstms(lstm_wp=layer.uniDirectionalLSTM.weightParams,
has_peephole=layer.uniDirectionalLSTM.params.hasPeepholeVectors)
if self._check_fp16_weight_params_lstms(lstm_wp=layer.uniDirectionalLSTM.weightParams,
has_peephole=layer.uniDirectionalLSTM.params.hasPeepholeVectors):
return True

# biDirectionalLSTM Layers
elif layer_type == "biDirectionalLSTM":
Expand All @@ -878,19 +879,19 @@ def _check_fp16_weight_param_exists(self, layers):

# branch Layers
elif layer_type == "branch":
if len(layer.branch.ifBranch.float16Value) > 0:
if self._check_fp16_weight_param_exists(layer.branch.ifBranch.layers):
return True
if len(layer.branch.elseBranch.float16Value) > 0:
if self._check_fp16_weight_param_exists(layer.branch.elseBranch.layers):
return True

# loop Layers
elif layer_type == "loop":
if len(layer.loop.conditionNetwork.float16Value) > 0:
if self._check_fp16_weight_param_exists(layer.loop.conditionNetwork.layers):
return True
if len(layer.loop.bodyNetwork.float16Value) > 0:
if self._check_fp16_weight_param_exists(layer.loop.bodyNetwork.layers):
return True

return False
return False

def make_updatable(self, trainables):
"""
Expand Down
2 changes: 1 addition & 1 deletion coremltools/test/pipeline/test_model_updatable.py
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ def test_nn_partial_fp16_make_updatable_quantized_layer_fail(self):
with self.assertRaises(ValueError):
q_nn_builder.make_updatable(["ip2"])

def test_nn_partial_fp16_make_updatable_fail(self):
def test_nn_updatable_fp16_quantize_fail(self):
nn_builder = self.create_base_builder()
model_path = os.path.join(self.model_dir, "updatable_creation.mlmodel")
print(model_path)
Expand Down