提交 e213f2a4 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!687 Fix bug: Summary tage type checking and exception throwing

Merge pull request !687 from candanzg/summary_tag_check
......@@ -51,7 +51,7 @@ AbstractBasePtr InferImplScalarSummary(const AnalysisEnginePtr &, const Primitiv
// Reomve the force check to support batch set summary use 'for' loop
auto item_v = descriptions->BuildValue();
if (!item_v->isa<StringImm>()) {
MS_LOG(ERROR) << "First parameter shoule be string";
MS_EXCEPTION(TypeError) << "Summary first parameter should be string";
}
return std::make_shared<AbstractScalar>(kAnyValue, kBool);
......@@ -75,7 +75,7 @@ AbstractBasePtr InferImplTensorSummary(const AnalysisEnginePtr &, const Primitiv
// Reomve the force check to support batch set summary use 'for' loop
auto item_v = descriptions->BuildValue();
if (!item_v->isa<StringImm>()) {
MS_LOG(WARNING) << "Summary first parameter must be string";
MS_EXCEPTION(TypeError) << "Summary first parameter should be string";
}
return std::make_shared<AbstractScalar>(kAnyValue, std::make_shared<Bool>());
......
......@@ -22,6 +22,7 @@ import os
import logging
import random
import numpy as np
import pytest
from mindspore.train.summary.summary_record import SummaryRecord
from mindspore.common.tensor import Tensor
import mindspore.nn as nn
......@@ -180,6 +181,7 @@ def test_summary_use_invalid_tag_None():
def test_summary_use_invalid_tag_Bool():
log.debug("begin test_summary_use_invalid_tag_Bool")
net = SummaryDemoTag(True, True, True)
with pytest.raises(TypeError):
run_case(net)
log.debug("finished test_summary_use_invalid_tag_Bool")
......@@ -196,6 +198,7 @@ def test_summary_use_invalid_tag_null():
def test_summary_use_invalid_tag_Int():
log.debug("begin test_summary_use_invalid_tag_Int")
net = SummaryDemoTag(1, 2, 3)
with pytest.raises(TypeError):
run_case(net)
log.debug("finished test_summary_use_invalid_tag_Int")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册