forked from mindspore-Ecosystem/mindspore
!687 Fix bug: Summary tage type checking and exception throwing
Merge pull request !687 from candanzg/summary_tag_check
This commit is contained in:
commit
e213f2a435
|
@ -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,7 +181,8 @@ 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)
|
||||
run_case(net)
|
||||
with pytest.raises(TypeError):
|
||||
run_case(net)
|
||||
log.debug("finished test_summary_use_invalid_tag_Bool")
|
||||
|
||||
|
||||
|
@ -196,7 +198,8 @@ 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)
|
||||
run_case(net)
|
||||
with pytest.raises(TypeError):
|
||||
run_case(net)
|
||||
log.debug("finished test_summary_use_invalid_tag_Int")
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue