You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_ops.py 66 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793
  1. # Copyright 2020 Huawei Technologies Co., Ltd
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. # ============================================================================
  15. """ test ops """
  16. import functools
  17. import numpy as np
  18. import mindspore.nn as nn
  19. import mindspore.ops.composite as C
  20. from mindspore import Tensor
  21. from mindspore import ops, Parameter, context
  22. from mindspore.common import dtype as mstype
  23. from mindspore.ops import functional as F
  24. from mindspore.ops import operations as P
  25. from mindspore.ops.operations import _grad_ops as G
  26. from mindspore.ops.operations import _inner_ops as inner
  27. from ..ut_filter import non_graph_engine
  28. from ....mindspore_test_framework.mindspore_test import mindspore_test
  29. from ....mindspore_test_framework.pipeline.forward.compile_forward \
  30. import (pipeline_for_compile_forward_ge_graph_for_case_by_case_config,
  31. pipeline_for_compile_forward_ge_graph_for_case_by_case_config_exception)
  32. from ....mindspore_test_framework.pipeline.gradient.compile_gradient \
  33. import pipeline_for_compile_grad_ge_graph_for_case_by_case_config
  34. def test_tensor_scatter_update():
  35. class TensorScatterUpdateNet(nn.Cell):
  36. """TensorScatterUpdate net definition"""
  37. def __init__(self):
  38. super(TensorScatterUpdateNet, self).__init__()
  39. self.tensor_scatter_update = P.TensorScatterUpdate()
  40. def construct(self, x, i, u):
  41. out = self.tensor_scatter_update(x, i, u)
  42. return out
  43. net = TensorScatterUpdateNet()
  44. context.set_context(mode=context.GRAPH_MODE, save_graphs=True)
  45. x = Tensor(np.arange(3 * 4 * 5).reshape((3, 4, 5)), mstype.float32)
  46. indices = Tensor(np.array([[0, 0], [1, 1]], np.int32))
  47. updates = Tensor(np.ones([2, 5], np.float32))
  48. net(x, indices, updates)
  49. class InputBackward(nn.Cell):
  50. def __init__(self, network):
  51. super(InputBackward, self).__init__()
  52. self.network = network
  53. self.network.set_train()
  54. self.grad = C.grad_all_with_sens
  55. def construct(self, x1, x2, x3, sens):
  56. return self.grad(self.network)(x1, x2, x3, sens)
  57. class NetForTupleInput(nn.Cell):
  58. def __init__(self, op):
  59. super(NetForTupleInput, self).__init__()
  60. self.op = op
  61. def construct(self, x1, x2):
  62. return self.op((x1, x2))
  63. class StridedSlicessdNet(nn.Cell):
  64. def __init__(self):
  65. super(StridedSlicessdNet, self).__init__()
  66. self.rank = P.Rank()
  67. def construct(self, x1):
  68. return P.StridedSlice(1, 1, 0, self.rank(x1), 0)(x1, (0, 0), (0, 0), (1, 1))
  69. class NetForConcat(nn.Cell):
  70. def __init__(self):
  71. super(NetForConcat, self).__init__()
  72. self.concat = P.Concat()
  73. def construct(self, x1):
  74. return self.concat((x1, x1))
  75. class NetForConcat1(nn.Cell):
  76. def __init__(self):
  77. super(NetForConcat1, self).__init__()
  78. self.concat = P.Concat()
  79. def construct(self, x1, x2):
  80. return self.concat((x1, x2))
  81. class NetForPackInput(nn.Cell):
  82. def __init__(self, op):
  83. super(NetForPackInput, self).__init__()
  84. self.op = op
  85. self.mul = P.Mul()
  86. def construct(self, *args):
  87. t = ()
  88. for element in args:
  89. t = t + (self.mul(element, element),)
  90. return self.op(t)
  91. class NetForUnpackInput(nn.Cell):
  92. def __init__(self, op):
  93. super(NetForUnpackInput, self).__init__()
  94. self.op = op
  95. self.mul = P.Mul()
  96. def construct(self, x1):
  97. return self.op((self.mul(x1, x1)))
  98. class NetForFlatten(nn.Cell):
  99. def __init__(self):
  100. super(NetForFlatten, self).__init__()
  101. self.flatten = P.Flatten()
  102. def construct(self, x, y):
  103. return self.flatten(x) + y
  104. class NetForFlatten0D(nn.Cell):
  105. def __init__(self):
  106. super(NetForFlatten0D, self).__init__()
  107. self.flatten = P.Flatten()
  108. def construct(self, x):
  109. return self.flatten(x)
  110. class NetForFlattenComposed(nn.Cell):
  111. # make flatten op together with other ops for testing flatten grad
  112. def __init__(self):
  113. super(NetForFlattenComposed, self).__init__()
  114. self.flatten = P.Flatten()
  115. def construct(self, x, y):
  116. return self.flatten(x + x) + y
  117. class ArgmaxNet(nn.Cell):
  118. def __init__(self):
  119. super(ArgmaxNet, self).__init__()
  120. self.argmax = P.Argmax(axis=1)
  121. def construct(self, input_):
  122. return self.argmax(input_)
  123. class ArgminNet(nn.Cell):
  124. def __init__(self):
  125. super(ArgminNet, self).__init__()
  126. self.argmin = P.Argmin(axis=1)
  127. def construct(self, input_):
  128. return self.argmin(input_)
  129. class CumSumNet(nn.Cell):
  130. def __init__(self):
  131. super(CumSumNet, self).__init__()
  132. self.cumsum = P.CumSum()
  133. self.axis = 1
  134. def construct(self, input_):
  135. return self.cumsum(input_, self.axis)
  136. class SummaryNet(nn.Cell):
  137. def __init__(self):
  138. super(SummaryNet, self).__init__()
  139. self.s = P.ScalarSummary()
  140. self.add = P.TensorAdd()
  141. def construct(self, x, y):
  142. self.s("x1", x)
  143. return self.add(x, y)
  144. class HistogramSummaryNet(nn.Cell):
  145. def __init__(self):
  146. super(HistogramSummaryNet, self).__init__()
  147. self.summary = P.HistogramSummary()
  148. self.add = P.TensorAdd()
  149. def construct(self, x, y):
  150. out = self.add(x, y)
  151. string_in = "out"
  152. self.summary(string_in, out)
  153. return out
  154. class ScatterMax(nn.Cell):
  155. """ScatterMax net definition"""
  156. def __init__(self):
  157. super(ScatterMax, self).__init__()
  158. self.scatter_max = P.ScatterMax()
  159. self.ref = Parameter(Tensor(np.array([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], np.float32)), name="ref")
  160. def construct(self, indices, updates):
  161. out = self.scatter_max(self.ref, indices, updates)
  162. return out
  163. class ScatterAdd(nn.Cell):
  164. """ScatterAdd net definition"""
  165. def __init__(self, ref_shape):
  166. super(ScatterAdd, self).__init__()
  167. self.scatter_add = P.ScatterAdd()
  168. self.ref = Parameter(Tensor(np.ones(ref_shape, np.float32)), name="ref")
  169. def construct(self, indices, updates):
  170. out = self.scatter_add(self.ref, indices, updates)
  171. return out
  172. class ApplyFtrlNet(nn.Cell):
  173. def __init__(self):
  174. super(ApplyFtrlNet, self).__init__()
  175. self.apply_ftrl = P.ApplyFtrl()
  176. self.lr = 0.001
  177. self.l1 = 0.0
  178. self.l2 = 0.0
  179. self.lr_power = -0.5
  180. self.var = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="var")
  181. self.accum = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="accum")
  182. self.linear = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="linear")
  183. def construct(self, grad):
  184. out = self.apply_ftrl(self.var, self.accum, self.linear, grad, self.lr, self.l1, self.l2, self.lr_power)
  185. return out
  186. class SparseApplyFtrlNet(nn.Cell):
  187. def __init__(self):
  188. super(SparseApplyFtrlNet, self).__init__()
  189. self.sparse_apply_ftrl = P.SparseApplyFtrl(lr=0.001, l1=0.0, l2=0.0, lr_power=-0.5)
  190. self.var = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="var")
  191. self.accum = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="accum")
  192. self.linear = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="linear")
  193. def construct(self, grad, indices):
  194. out = self.sparse_apply_ftrl(self.var, self.accum, self.linear, grad, indices)
  195. return out
  196. class SparseApplyProximalAdagradNet(nn.Cell):
  197. def __init__(self):
  198. super(SparseApplyProximalAdagradNet, self).__init__()
  199. self.sparse_apply_proximal_adagrad = P.SparseApplyProximalAdagrad()
  200. self.var = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="var")
  201. self.accum = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="accum")
  202. self.lr = 0.01
  203. self.l1 = 0.0
  204. self.l2 = 0.0
  205. def construct(self, grad, indices):
  206. out = self.sparse_apply_proximal_adagrad(self.var, self.accum, self.lr, self.l1, self.l2, grad, indices)
  207. return out
  208. class ApplyProximalAdagradNet(nn.Cell):
  209. def __init__(self):
  210. super(ApplyProximalAdagradNet, self).__init__()
  211. self.apply_proximal_adagrad = P.ApplyProximalAdagrad()
  212. self.var = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="var")
  213. self.accum = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="accum")
  214. self.lr = 0.01
  215. self.l1 = 0.0
  216. self.l2 = 0.0
  217. def construct(self, grad):
  218. out = self.apply_proximal_adagrad(self.var, self.accum, self.lr, self.l1, self.l2, grad)
  219. return out
  220. class ApplyAdaMaxNet(nn.Cell):
  221. def __init__(self):
  222. super(ApplyAdaMaxNet, self).__init__()
  223. self.apply_ada_max = P.ApplyAdaMax()
  224. self.beta1_power = 0.9
  225. self.lr = 0.001
  226. self.beta1 = 0.9
  227. self.beta2 = 0.99
  228. self.epsilon = 1e-10
  229. self.var = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="var")
  230. self.m = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="m")
  231. self.v = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="v")
  232. def construct(self, grad):
  233. out = self.apply_ada_max(self.var, self.m, self.v, self.beta1_power, self.lr,
  234. self.beta1, self.beta2, self.epsilon, grad)
  235. return out
  236. class ApplyAdadeltaNet(nn.Cell):
  237. def __init__(self):
  238. super(ApplyAdadeltaNet, self).__init__()
  239. self.apply_adadelta = P.ApplyAdadelta()
  240. self.lr = 0.001
  241. self.rho = 0.0
  242. self.epsilon = 1e-6
  243. self.var = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="var")
  244. self.accum = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="accum")
  245. self.accum_update = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="accum_update")
  246. def construct(self, grad):
  247. out = self.apply_adadelta(self.var, self.accum, self.accum_update, self.lr, self.rho, self.epsilon, grad)
  248. return out
  249. class ApplyAdagradNet(nn.Cell):
  250. def __init__(self):
  251. super(ApplyAdagradNet, self).__init__()
  252. self.apply_adagrad = P.ApplyAdagrad()
  253. self.lr = 0.001
  254. self.var = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="var")
  255. self.accum = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="accum")
  256. def construct(self, grad):
  257. out = self.apply_adagrad(self.var, self.accum, self.lr, grad)
  258. return out
  259. class ApplyAdagradV2Net(nn.Cell):
  260. def __init__(self):
  261. super(ApplyAdagradV2Net, self).__init__()
  262. self.apply_adagrad_v2 = P.ApplyAdagradV2(epsilon=1e-6)
  263. self.lr = 0.001
  264. self.var = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="var")
  265. self.accum = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="accum")
  266. def construct(self, grad):
  267. out = self.apply_adagrad_v2(self.var, self.accum, self.lr, grad)
  268. return out
  269. class SparseApplyAdagradNet(nn.Cell):
  270. def __init__(self):
  271. super(SparseApplyAdagradNet, self).__init__()
  272. self.sparse_apply_adagrad = P.SparseApplyAdagrad(lr=0.01)
  273. self.var = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="var")
  274. self.accum = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="accum")
  275. def construct(self, grad, indices):
  276. out = self.sparse_apply_adagrad(self.var, self.accum, grad, indices)
  277. return out
  278. class ApplyRMSNet(nn.Cell):
  279. def __init__(self):
  280. super(ApplyRMSNet, self).__init__()
  281. self.apply_rms = P.ApplyRMSProp()
  282. self.lr = 0.001
  283. self.rho = 0.0
  284. self.momentum = 0.0
  285. self.epsilon = 1e-10
  286. self.var = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="var")
  287. self.ms = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="ms")
  288. self.moment = Parameter(Tensor(np.random.rand(3, 3).astype(np.float32)), name="moment")
  289. def construct(self, grad):
  290. out = self.apply_rms(self.var, self.ms, self.moment, self.lr, grad, self.rho, self.momentum, self.epsilon)
  291. return out
  292. class InplaceAddNet(nn.Cell):
  293. def __init__(self):
  294. super(InplaceAddNet, self).__init__()
  295. self.inplace_add = P.InplaceAdd(indices=(0, 1))
  296. def construct(self, x, v):
  297. out = self.inplace_add(x, v)
  298. return out
  299. class InplaceSubNet(nn.Cell):
  300. def __init__(self):
  301. super(InplaceSubNet, self).__init__()
  302. self.inplace_sub = P.InplaceSub(indices=(0, 1))
  303. def construct(self, x, v):
  304. out = self.inplace_sub(x, v)
  305. return out
  306. class NormalNet(nn.Cell):
  307. def __init__(self, shape=None, mean=0.0, stddev=1.0, seed=0):
  308. super(NormalNet, self).__init__()
  309. self.normal = P.Normal(seed=seed)
  310. self.shape = shape
  311. self.mean = Tensor(mean, mstype.float32)
  312. self.stddev = Tensor(stddev, mstype.float32)
  313. def construct(self):
  314. out = self.normal(self.shape, self.mean, self.stddev)
  315. return out
  316. test_case_math_ops = [
  317. ('BitwiseAnd', {
  318. 'block': P.BitwiseAnd(),
  319. 'desc_inputs': [Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mstype.int16),
  320. Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mstype.int16)],
  321. 'skip': ['backward']}),
  322. ('BitwiseAnd_1', {
  323. 'block': P.BitwiseAnd(),
  324. 'desc_inputs': [Tensor(np.array([[1, 2, 3], [-1, -2, -3]]), mstype.int16),
  325. Tensor(np.array([1, 1, 1]), mstype.int16)],
  326. 'skip': ['backward']}),
  327. ('BitwiseOr', {
  328. 'block': P.BitwiseOr(),
  329. 'desc_inputs': [Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mstype.int16),
  330. Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mstype.int16)],
  331. 'skip': ['backward']}),
  332. ('BitwiseOr_1', {
  333. 'block': P.BitwiseOr(),
  334. 'desc_inputs': [Tensor(np.array([[1, 2, 3], [-1, -2, -3]]), mstype.int16),
  335. Tensor(np.array([1, 1, 1]), mstype.int16)],
  336. 'skip': ['backward']}),
  337. ('BitwiseXor', {
  338. 'block': P.BitwiseXor(),
  339. 'desc_inputs': [Tensor(np.array([0, 0, 1, -1, 1, 1, 1]), mstype.int16),
  340. Tensor(np.array([0, 1, 1, -1, -1, 2, 3]), mstype.int16)],
  341. 'skip': ['backward']}),
  342. ('BitwiseXor_1', {
  343. 'block': P.BitwiseXor(),
  344. 'desc_inputs': [Tensor(np.array([[1, 2, 3], [-1, -2, -3]]), mstype.int16),
  345. Tensor(np.array([1, 1, 1]), mstype.int16)],
  346. 'skip': ['backward']}),
  347. ('Neg', {
  348. 'block': P.Neg(),
  349. 'desc_inputs': [[1, 3, 4, 4]],
  350. 'desc_bprop': [[1, 3, 4, 4]]}),
  351. ('Sub', {
  352. 'block': P.Sub(),
  353. 'desc_inputs': [[3, 5], [2, 3, 3, 5]],
  354. 'desc_bprop': [[2, 3, 3, 5]]}),
  355. ('TensorAdd', {
  356. 'block': P.TensorAdd(),
  357. 'desc_inputs': [[3, 5], [2, 3, 3, 5]],
  358. 'desc_bprop': [[2, 3, 3, 5]]}),
  359. ('Mul0', {
  360. 'block': P.Mul(),
  361. 'desc_inputs': [[2, 3, 3, 5], [2, 3, 3, 5]],
  362. 'desc_bprop': [[2, 3, 3, 5]]}),
  363. ('Mul1', {
  364. 'block': P.Mul(),
  365. 'desc_inputs': [[2, 3, 1, 1], [2, 3, 3, 5]],
  366. 'desc_bprop': [[2, 3, 3, 5]]}),
  367. ('Mul2', {
  368. 'block': P.Mul(),
  369. 'desc_inputs': [[2, 3, 3, 5], [2, 3, 1, 1]],
  370. 'desc_bprop': [[2, 3, 3, 5]],
  371. 'skip': ['backward']}),
  372. ('Mul3', {
  373. 'block': P.Mul(),
  374. 'desc_inputs': [[3, 5], [2, 3, 3, 5]],
  375. 'desc_bprop': [[2, 3, 3, 5]],
  376. 'skip': ['backward']}),
  377. ('Mul4', {
  378. 'block': P.Mul(),
  379. 'desc_inputs': [[2, 3, 3, 5], [3, 5]],
  380. 'desc_bprop': [[2, 3, 3, 5]],
  381. 'skip': ['backward']}),
  382. ('Add0', {
  383. 'block': P.TensorAdd(),
  384. 'desc_inputs': [[2, 3, 3, 5], [2, 3, 3, 5]],
  385. 'desc_bprop': [[2, 3, 3, 5]]}),
  386. ('Add1', {
  387. 'block': P.TensorAdd(),
  388. 'desc_inputs': [[3, 5], [2, 3, 3, 5]],
  389. 'desc_bprop': [[2, 3, 3, 5]],
  390. 'skip': ['backward']}),
  391. ('Add2', {
  392. 'block': P.TensorAdd(),
  393. 'desc_inputs': [[2, 3, 3, 5], [3, 5]],
  394. 'desc_bprop': [[2, 3, 3, 5]],
  395. 'skip': ['backward']}),
  396. ('Add3', {
  397. 'block': P.TensorAdd(),
  398. 'desc_inputs': [[2, 3, 1, 1], [2, 3, 3, 5]],
  399. 'desc_bprop': [[2, 3, 3, 5]],
  400. 'skip': ['backward']}),
  401. ('Add4', {
  402. 'block': P.TensorAdd(),
  403. 'desc_inputs': [[2, 3, 3, 5], [2, 3, 1, 1]],
  404. 'desc_bprop': [[2, 3, 3, 5]],
  405. 'skip': ['backward']}),
  406. ('Minimum', {
  407. 'block': P.Minimum(),
  408. 'desc_inputs': [[2, 3, 3, 5], [2, 3, 3, 5]],
  409. 'desc_bprop': [[2, 3, 3, 5]]}),
  410. ('Pow_0', {
  411. 'block': P.Pow(),
  412. 'desc_const': [2.0],
  413. 'desc_inputs': [[2, 3, 3, 5]],
  414. 'desc_bprop': [[2, 3, 3, 5]]}),
  415. ('Pow_1', {
  416. 'block': P.Pow(),
  417. 'desc_inputs': [[3, 5], [2, 3, 3, 5]],
  418. 'desc_bprop': [[2, 3, 3, 5]]}),
  419. ('Exp', {
  420. 'block': P.Exp(),
  421. 'desc_inputs': [[2, 3]],
  422. 'desc_bprop': [[2, 3]]}),
  423. ('Expm1', {
  424. 'block': P.Expm1(),
  425. 'desc_inputs': [[2, 3]],
  426. 'desc_bprop': [[2, 3]]}),
  427. ('Erf', {
  428. 'block': P.Erf(),
  429. 'desc_inputs': [Tensor(np.array([-2, -1, 0, 1, 2]).astype(np.float16))],
  430. 'desc_bprop': [Tensor(np.array([-2, -1, 0, 1, 2]).astype(np.float16))]}),
  431. ('Floor', {
  432. 'block': P.Floor(),
  433. 'desc_inputs': [[2, 512, 56, 56]],
  434. 'desc_bprop': [[2, 512, 56, 56]],
  435. 'skip': ['backward']}),
  436. ('Ceil', {
  437. 'block': P.Ceil(),
  438. 'desc_inputs': [[2, 512, 56, 56]],
  439. 'desc_bprop': [[2, 512, 56, 56]],
  440. 'skip': ['backward']}),
  441. ('InplaceAdd', {
  442. 'block': InplaceAddNet(),
  443. 'desc_inputs': [Tensor(np.array([[1, 2], [3, 4], [5, 6]]).astype(np.float32)),
  444. Tensor(np.array([[0.5, 1], [1, 1.5]]).astype(np.float32))],
  445. 'skip': ['backward']}),
  446. ('InplaceSub', {
  447. 'block': InplaceSubNet(),
  448. 'desc_inputs': [Tensor(np.array([[1, 2], [3, 4], [5, 6]]).astype(np.float32)),
  449. Tensor(np.array([[0.5, 1], [1, 1.5]]).astype(np.float32))],
  450. 'skip': ['backward']}),
  451. ('ACos', {
  452. 'block': P.ACos(),
  453. 'desc_inputs': [Tensor(np.array([2., 3.]).astype(np.float32))],
  454. 'desc_bprop': [Tensor(np.array([2., 3.]).astype(np.float32))]}),
  455. ('ACosGrad', {
  456. 'block': G.ACosGrad(),
  457. 'desc_inputs': [[2, 3], [2, 3]],
  458. 'skip': ['backward']}),
  459. ('Acosh', {
  460. 'block': P.Acosh(),
  461. 'desc_inputs': [Tensor(np.array([2., 3.]).astype(np.float32))],
  462. 'desc_bprop': [Tensor(np.array([2., 3.]).astype(np.float32))]}),
  463. ('AcoshGrad', {
  464. 'block': G.AcoshGrad(),
  465. 'desc_inputs': [[2, 3], [2, 3]],
  466. 'skip': ['backward']}),
  467. ('Sin', {
  468. 'block': P.Sin(),
  469. 'desc_inputs': [[2, 3]],
  470. 'desc_bprop': [[2, 3]]}),
  471. ('Asin', {
  472. 'block': P.Asin(),
  473. 'desc_inputs': [[2, 3]],
  474. 'desc_bprop': [[2, 3]]}),
  475. ('Asinh', {
  476. 'block': P.Asinh(),
  477. 'desc_inputs': [[3, 4, 5]],
  478. 'desc_bprop': [[3, 4, 5]]}),
  479. ('Reciprocal', {
  480. 'block': P.Reciprocal(),
  481. 'desc_inputs': [[2, 3, 3, 5]],
  482. 'desc_bprop': [[2, 3, 3, 5]]}),
  483. ('Minimum_0', {
  484. 'block': P.Minimum(),
  485. 'desc_inputs': [[2, 3, 3, 5], [3, 3, 5]],
  486. 'desc_bprop': [[2, 3, 3, 5]]}),
  487. ('Maximum', {
  488. 'block': P.Maximum(),
  489. 'desc_inputs': [[2, 3, 3, 5], [2, 3, 3, 5]],
  490. 'desc_bprop': [[2, 3, 3, 5]]}),
  491. ('Maximum_0', {
  492. 'block': P.Maximum(),
  493. 'desc_inputs': [[3, 5], [2, 3, 3, 5]],
  494. 'desc_bprop': [[2, 3, 3, 5]]}),
  495. ('MaximumGrad', {
  496. 'block': G.MaximumGrad(),
  497. 'desc_inputs': [[2, 3, 3, 5], [2, 3, 3, 5], [2, 3, 3, 5]],
  498. 'skip': ['backward']}),
  499. ('MinimumGrad', {
  500. 'block': G.MinimumGrad(),
  501. 'desc_inputs': [[2, 3, 3, 5], [2, 3, 3, 5], [2, 3, 3, 5]],
  502. 'skip': ['backward']}),
  503. ('StridedSlice', {
  504. 'block': P.StridedSlice(),
  505. 'desc_const': [(0, 1, 2, 1),
  506. (2, 3, 3, 4),
  507. (1, 1, 1, 1)],
  508. 'desc_inputs': [[2, 3, 3, 5]],
  509. 'desc_bprop': [[2, 2, 1, 3]]}),
  510. ('Slice_1', {
  511. 'block': P.Slice(),
  512. 'desc_const': [(0, 1, 2, 1),
  513. (1, 1, 1, 2)],
  514. 'desc_inputs': [[2, 3, 3, 5]],
  515. 'desc_bprop': [[1, 1, 1, 2]]}),
  516. ('StridedSliceGrad', {
  517. 'block': G.StridedSliceGrad(),
  518. 'desc_const': [(64, 1, 1024),
  519. (0, 1, 0),
  520. (64, 2, 1024),
  521. (1, 1, 1)],
  522. 'desc_inputs': [[64, 128, 1024]],
  523. 'skip': ['backward']}),
  524. ('RandomChoiceWithMask', {
  525. 'block': P.RandomChoiceWithMask(256),
  526. 'desc_inputs': [Tensor(np.random.rand(24000, 4).astype(np.bool_))],
  527. 'desc_bprop': [[256, 4], [256, 4]],
  528. 'skip': ['backward']}),
  529. ('LessEqual', {
  530. 'block': P.LessEqual(),
  531. 'desc_inputs': [Tensor(np.random.rand(4).astype(np.float16)),
  532. Tensor(np.random.rand(4).astype(np.float16))],
  533. 'skip': ['backward']}),
  534. ('Less', {
  535. 'block': P.Less(),
  536. 'desc_inputs': [[2, 1, 4, 5], [2, 1, 4, 5]],
  537. 'desc_bprop': [Tensor(np.zeros((2, 1, 4, 5), np.bool_))],
  538. 'skip': ['backward']}),
  539. ('RealDiv_0', {
  540. 'block': P.RealDiv(),
  541. 'desc_const': [Tensor(2048.0), Tensor(0.0)],
  542. 'desc_inputs': [],
  543. 'skip': ['backward']}),
  544. ('RealDiv', {
  545. 'block': P.RealDiv(),
  546. 'desc_inputs': [[4], Tensor(np.ones(4).astype(np.float32))],
  547. 'desc_bprop': [[4]]}),
  548. ('RealDiv_1', {
  549. 'block': P.RealDiv(),
  550. 'desc_inputs': [[512, 1024], [512, 1024]],
  551. 'desc_bprop': [[512, 1024]]}),
  552. ('FloorDiv', {
  553. 'block': P.FloorDiv(),
  554. 'desc_inputs': [Tensor(np.random.rand(4).astype(np.float16)),
  555. Tensor(np.random.rand(4).astype(np.float16))],
  556. 'skip': ['backward']}),
  557. ('FloorMod', {
  558. 'block': P.FloorMod(),
  559. 'desc_inputs': [[3, 4, 5], [2, 3, 4, 5]],
  560. 'desc_bprop': [[2, 3, 4, 5]]}),
  561. ('identity', {
  562. 'block': ops.functional.identity,
  563. 'desc_inputs': [[2, 2]],
  564. 'skip': ['backward']}),
  565. ('MatMul_1', {
  566. 'block': P.MatMul(transpose_a=False, transpose_b=False),
  567. 'desc_inputs': [[1024, 160], [160, 1024]],
  568. 'desc_bprop': [[1024, 1024]]}),
  569. ('MatMul_2', {
  570. 'block': P.MatMul(transpose_a=True, transpose_b=True),
  571. 'desc_inputs': [[160, 1024], [1024, 160]],
  572. 'desc_bprop': [[1024, 1024]]}),
  573. ('Sub', {
  574. 'block': P.Sub(),
  575. 'desc_inputs': [[3], [3]],
  576. 'desc_bprop': [[3]]}),
  577. ('TruncatedNormal', {
  578. 'block': P.TruncatedNormal(),
  579. 'desc_const': [(1, 2, 3)],
  580. 'desc_inputs': [],
  581. 'skip': ['backward'],
  582. 'add_fake_input': True}),
  583. ('Select', {
  584. 'block': P.Select(),
  585. 'desc_inputs': [Tensor(np.array([[True, False, False], [False, True, True]])),
  586. [2, 3], [2, 3]],
  587. 'desc_bprop': [[2, 3]]}),
  588. ('Rank', {
  589. 'block': P.Rank(),
  590. 'desc_inputs': [[2, 3]],
  591. 'skip': ['backward']}),
  592. ('InvertPermutation', {
  593. 'block': P.InvertPermutation(),
  594. 'desc_const': [(0, 3, 1, 2)],
  595. 'desc_inputs': [],
  596. 'skip': ['backward']}),
  597. ('Square', {
  598. 'block': P.Square(),
  599. 'desc_inputs': [[4]],
  600. 'desc_bprop': [[4]]}),
  601. ('Rsqrt', {
  602. 'block': P.Rsqrt(),
  603. 'desc_inputs': [[4]],
  604. 'desc_bprop': [[4]]}),
  605. ('Sqrt', {
  606. 'block': P.Sqrt(),
  607. 'desc_inputs': [[4]],
  608. 'desc_bprop': [[4]]}),
  609. ('RealDiv', {
  610. 'block': P.RealDiv(),
  611. 'desc_inputs': [[4, 5], [2, 3, 4, 5]],
  612. 'desc_bprop': [[2, 3, 4, 5]]}),
  613. ('Div', {
  614. 'block': P.Div(),
  615. 'desc_inputs': [[4, 5], [2, 3, 4, 5]],
  616. 'desc_bprop': [[2, 3, 4, 5]]}),
  617. ('Equal', {
  618. 'block': P.Equal(),
  619. 'desc_inputs': [[3, 4, 5], [4, 5]],
  620. 'desc_bprop': [Tensor(np.zeros((3, 4, 5), np.bool_))]}),
  621. ('NotEqual', {
  622. 'block': P.NotEqual(),
  623. 'desc_inputs': [[4, 1], [2, 3, 4, 5]],
  624. 'desc_bprop': [Tensor(np.ones((2, 3, 4, 5), np.bool_))]}),
  625. ('NotEqual_0', {
  626. 'block': P.NotEqual(),
  627. 'desc_inputs': [1, [2, 3, 4, 5]],
  628. 'desc_bprop': [Tensor(np.ones((2, 3, 4, 5), np.bool_))],
  629. 'skip': ['backward']}),
  630. ('ApproximateEqual', {
  631. 'block': P.ApproximateEqual(),
  632. 'desc_inputs': [[3, 4, 5], [3, 4, 5]],
  633. 'desc_bprop': [Tensor(np.zeros((3, 4, 5), np.bool_))]}),
  634. ('Greater', {
  635. 'block': P.Greater(),
  636. 'desc_inputs': [[2, 3, 4, 1], [4, 5]],
  637. 'desc_bprop': [Tensor(np.ones((2, 3, 4, 5), np.bool_))]}),
  638. ('GreaterEqual', {
  639. 'block': P.GreaterEqual(),
  640. 'desc_inputs': [[2, 3, 4, 1], [4, 5]],
  641. 'desc_bprop': [Tensor(np.ones((2, 3, 4, 5), np.bool_))]}),
  642. ('LogicalNot', {
  643. 'block': P.LogicalNot(),
  644. 'desc_inputs': [Tensor(np.zeros((3, 4, 5), np.bool_))],
  645. 'desc_bprop': [Tensor(np.ones((3, 4, 5), np.bool_))]}),
  646. ('LogicalAnd', {
  647. 'block': P.LogicalAnd(),
  648. 'desc_inputs': [Tensor(np.zeros((2, 3, 4), np.bool_)), Tensor(np.ones((1), np.bool_))],
  649. 'desc_bprop': [Tensor(np.zeros((2, 3, 4), np.bool_))]}),
  650. ('LogicalOr', {
  651. 'block': P.LogicalOr(),
  652. 'desc_inputs': [Tensor(np.zeros((3, 4, 5), np.bool_)), Tensor(np.ones((3, 1, 1), np.bool_))],
  653. 'desc_bprop': [Tensor(np.zeros((3, 4, 5), np.bool_))]}),
  654. ('NpuAllocFloatStatus', {
  655. 'block': P.NPUAllocFloatStatus(),
  656. 'desc_inputs': [],
  657. 'add_fack_input': True,
  658. 'fack_input_type': np.float32,
  659. 'desc_bprop': [Tensor(np.zeros([8]).astype(np.float32))],
  660. 'skip': ['backward']}),
  661. ('NpuGetFloatStatus', {
  662. 'block': P.NPUGetFloatStatus(),
  663. 'desc_inputs': [Tensor(np.zeros([8]).astype(np.float32))],
  664. 'desc_bprop': [Tensor(np.zeros([8]).astype(np.float32))],
  665. 'skip': ['backward']}),
  666. ('NpuClearFloatStatus', {
  667. 'block': P.NPUClearFloatStatus(),
  668. 'desc_inputs': [Tensor(np.zeros([8]).astype(np.float32))],
  669. 'desc_bprop': [Tensor(np.zeros([8]).astype(np.float32))],
  670. 'skip': ['backward']}),
  671. ('CheckValid', {
  672. 'block': P.CheckValid(),
  673. 'desc_inputs': [[20000, 4], [3]],
  674. 'desc_bprop': [[20000]],
  675. 'skip': ['backward']}),
  676. ('NMSWithMask', {
  677. 'block': P.NMSWithMask(0.5),
  678. 'desc_inputs': [[128, 5]],
  679. 'desc_bprop': [[128, 5], [128], [128]],
  680. 'skip': ['backward']}),
  681. ('Abs', {
  682. 'block': P.Abs(),
  683. 'desc_inputs': [[4]],
  684. 'desc_bprop': [[4]]}),
  685. ('CumSum', {
  686. 'block': CumSumNet(),
  687. 'desc_inputs': [Tensor(np.array([[3, 4, 6, 10], [1, 6, 7, 9], [4, 3, 8, 7], [1, 3, 7, 9]]).astype(np.float32))],
  688. 'desc_bprop': [Tensor(np.array([[3, 4, 6, 10], [1, 6, 7, 9], [4, 3, 8, 7],
  689. [1, 3, 7, 9]]).astype(np.float32))]}),
  690. ('ReduceSum_3', {
  691. 'block': P.ReduceSum(),
  692. 'desc_const': [0],
  693. 'desc_inputs': [[3, 2]],
  694. 'desc_bprop': [[2]]}),
  695. ('ReduceSum_4', {
  696. 'block': P.ReduceSum(keep_dims=True),
  697. 'desc_const': [0],
  698. 'desc_inputs': [[3, 2]],
  699. 'desc_bprop': [[1, 2]]}),
  700. ('ReduceSum_5', {
  701. 'block': P.ReduceSum(keep_dims=True),
  702. 'desc_inputs': [[2, 3, 4]],
  703. 'desc_bprop': [[1, 1, 1]]}),
  704. ('ReduceSum_6', {
  705. 'block': P.ReduceSum(),
  706. 'desc_inputs': [[2, 3, 4]],
  707. 'desc_bprop': [[1]]}),
  708. ('Sum_0', {
  709. 'block': P.ReduceSum(),
  710. 'desc_const': [(1,)],
  711. 'desc_inputs': [[3, 2]],
  712. 'desc_bprop': [[3]]}),
  713. ('Sum_1', {
  714. 'block': P.ReduceSum(keep_dims=True),
  715. 'desc_const': [(1,)],
  716. 'desc_inputs': [[3, 2]],
  717. 'desc_bprop': [[3, 1]]}),
  718. ('Sum_2', {
  719. 'block': P.ReduceSum(),
  720. 'desc_const': [(0, 1)],
  721. 'desc_inputs': [[3, 2]],
  722. 'desc_bprop': [[1]]}),
  723. ('Sum_3', {
  724. 'block': P.ReduceSum(),
  725. 'desc_const': [0],
  726. 'desc_inputs': [[3, 2]],
  727. 'desc_bprop': [[2]]}),
  728. ('Sum_4', {
  729. 'block': P.ReduceSum(keep_dims=True),
  730. 'desc_const': [0],
  731. 'desc_inputs': [[3, 2]],
  732. 'desc_bprop': [[1, 2]]}),
  733. ('Sum_5', {
  734. 'block': P.ReduceSum(keep_dims=True),
  735. 'desc_const': [()],
  736. 'desc_inputs': [[2, 3, 4]],
  737. 'desc_bprop': [[1, 1, 1]]}),
  738. ('Sum_6', {
  739. 'block': P.ReduceSum(),
  740. 'desc_const': [()],
  741. 'desc_inputs': [[2, 3, 4]],
  742. 'desc_bprop': [[1]]}),
  743. ('Sign', {
  744. 'block': P.Sign(),
  745. 'desc_inputs': [[3]],
  746. 'desc_bprop': [[3]]}),
  747. ('Round', {
  748. 'block': P.Round(),
  749. 'desc_inputs': [[3]],
  750. 'desc_bprop': [[3]]}),
  751. ('Atan2', {
  752. 'block': P.Atan2(),
  753. 'desc_inputs': [Tensor(np.array([0, 1]).astype(np.float32)),
  754. Tensor(np.array([1, 1]).astype(np.float32))],
  755. 'desc_bprop': [[2]]}),
  756. ('SquareSumAll', {
  757. 'block': P.SquareSumAll(),
  758. 'desc_inputs': [Tensor(np.array([0, 1, 4, 5]).astype(np.float32)),
  759. Tensor(np.array([1, 1, 3, 7]).astype(np.float32))],
  760. 'skip': ['backward']}),
  761. ('Cos', {
  762. 'block': P.Cos(),
  763. 'desc_inputs': [[2, 3]],
  764. 'desc_bprop': [[2, 3]]}),
  765. ('ReduceAll', {
  766. 'block': P.ReduceAll(),
  767. 'desc_const': [1],
  768. 'desc_inputs': [Tensor(np.array([[True, False], [True, True]]))],
  769. 'desc_bprop': []}),
  770. ('BesselI0e', {
  771. 'block': P.BesselI0e(),
  772. 'desc_inputs': [[2, 3]],
  773. 'desc_bprop': [[2, 3]]}),
  774. ('BesselI1e', {
  775. 'block': P.BesselI1e(),
  776. 'desc_inputs': [[2, 3]],
  777. 'desc_bprop': [[2, 3]]}),
  778. ('Atan', {
  779. 'block': P.Atan(),
  780. 'desc_inputs': [[2, 3]],
  781. 'desc_bprop': [[2, 3]]}),
  782. ('AtanGrad', {
  783. 'block': G.AtanGrad(),
  784. 'desc_inputs': [[2, 3], [2, 3]],
  785. 'skip': ['backward']}),
  786. ('Atanh', {
  787. 'block': P.Atanh(),
  788. 'desc_inputs': [[2, 3]],
  789. 'desc_bprop': [[2, 3]]}),
  790. ('Cosh', {
  791. 'block': P.Cosh(),
  792. 'desc_inputs': [[3, 4, 5]],
  793. 'desc_bprop': [[3, 4, 5]]}),
  794. ('Sinh', {
  795. 'block': P.Sinh(),
  796. 'desc_inputs': [[3, 4, 5]],
  797. 'desc_bprop': [[3, 4, 5]]}),
  798. ('Inv', {
  799. 'block': P.Inv(),
  800. 'desc_inputs': [[21, 9, 12, 5]],
  801. 'desc_bprop': [[21, 9, 12, 5]]}),
  802. ('Invert', {
  803. 'block': P.Invert(),
  804. 'desc_inputs': [Tensor(np.array([[24, 4, 13, 9], [1, 5, 10, 8]]).astype(np.int16))],
  805. 'desc_bprop': [],
  806. 'skip': ['backward']}),
  807. ('HistogramFixedWidth', {
  808. 'block': P.HistogramFixedWidth(5),
  809. 'desc_inputs': [Tensor([-1.0, 0.0, 1.5, 2.0, 5.0, 15], mstype.float16), Tensor([0.0, 5.0], mstype.float16)],
  810. 'desc_bprop': [],
  811. 'skip': ['backward']}),
  812. ('Normal', {
  813. 'block': NormalNet((3, 2, 4), 0.0, 1.0, 0),
  814. 'desc_inputs': [],
  815. 'skip': ['backward']}),
  816. ]
  817. test_case_nn_ops = [
  818. ('BiasAdd', {
  819. 'block': P.BiasAdd(),
  820. 'desc_inputs': [[1, 3, 3, 3], [3]],
  821. 'desc_bprop': [[1, 3, 3, 3]]}),
  822. ('BiasAddGrad', {
  823. 'block': G.BiasAddGrad(),
  824. 'desc_inputs': [[1, 3, 3, 3]],
  825. 'skip': ['backward']}),
  826. ('Gelu', {
  827. 'block': P.Gelu(),
  828. 'desc_inputs': [[1, 3, 4, 4]],
  829. 'desc_bprop': [[1, 3, 4, 4]]}),
  830. ('GeluGrad', {
  831. 'block': G.GeluGrad(),
  832. 'desc_inputs': [[2, 2], [2, 2], [2, 2]],
  833. 'desc_bprop': [[2, 2]],
  834. 'skip': ['backward']}),
  835. ('Tanh', {
  836. 'block': P.Tanh(),
  837. 'desc_inputs': [[1, 3, 4, 4]],
  838. 'desc_bprop': [[1, 3, 4, 4]]}),
  839. ('TanhGrad', {
  840. 'block': G.TanhGrad(),
  841. 'desc_inputs': [[1, 3, 4, 4], [1, 3, 4, 4]],
  842. 'desc_bprop': [[1, 3, 4, 4]],
  843. 'skip': ['backward']}),
  844. ('ReLU', {
  845. 'block': P.ReLU(),
  846. 'desc_inputs': [[1, 3, 4, 4]],
  847. 'desc_bprop': [[1, 3, 4, 4]]}),
  848. ('ReLU6', {
  849. 'block': P.ReLU6(),
  850. 'desc_inputs': [[1, 3, 4, 4]],
  851. 'desc_bprop': [[1, 3, 4, 4]]}),
  852. ('ReLUV2', {
  853. 'block': P.ReLUV2(),
  854. 'desc_inputs': [[1, 3, 4, 4]],
  855. 'desc_bprop': [[1, 3, 4, 4], ([1, 1, 4, 4, 2], {'dtype': np.uint8})]}),
  856. ('ReLUGrad', {
  857. 'block': G.ReluGrad(),
  858. 'desc_inputs': [[1, 3, 4, 4], [1, 3, 4, 4]],
  859. 'skip': ['backward']}),
  860. ('Softplus', {
  861. 'block': P.Softplus(),
  862. 'desc_inputs': [[1, 3, 4, 4]],
  863. 'desc_bprop': [[1, 3, 4, 4]]}),
  864. ('SoftplusGrad', {
  865. 'block': G.SoftplusGrad(),
  866. 'desc_inputs': [[1, 3, 4, 4], [1, 3, 4, 4]],
  867. 'skip': ['backward']}),
  868. ('Elu', {
  869. 'block': P.Elu(),
  870. 'desc_inputs': [[2, 3, 4]],
  871. 'desc_bprop': [[2, 3, 4]]}),
  872. ('EluGrad', {
  873. 'block': G.EluGrad(),
  874. 'desc_inputs': [[2, 3, 4], [2, 3, 4]],
  875. 'desc_bprop': [[2, 3, 4]],
  876. 'skip': ['backward']}),
  877. ('Sigmoid', {
  878. 'block': P.Sigmoid(),
  879. 'desc_inputs': [[1, 3, 4, 4]],
  880. 'desc_bprop': [[1, 3, 4, 4]]}),
  881. ('MaxPool', {
  882. 'block': P.MaxPool(ksize=(2, 2), strides=(2, 2), padding="VALID"),
  883. 'desc_inputs': [[100, 3, 28, 28]],
  884. 'desc_bprop': [[100, 3, 14, 14]]}),
  885. ('MaxPoolGrad', {
  886. 'block': G.MaxPoolGrad(ksize=(2, 2), strides=(2, 2), padding="VALID"),
  887. 'desc_inputs': [[3, 4, 6, 6], [3, 4, 3, 3], [3, 4, 3, 3]],
  888. 'desc_bprop': [[3, 4, 6, 6]],
  889. 'skip': ['backward']}),
  890. ('AvgPool', {
  891. 'block': P.AvgPool(ksize=(2, 2), strides=(2, 2), padding="VALID"),
  892. 'desc_inputs': [[100, 3, 28, 28]],
  893. 'desc_bprop': [[100, 3, 14, 14]]}),
  894. ('AvgPoolGrad', {
  895. 'block': G.AvgPoolGrad(ksize=(2, 2), strides=(2, 2), padding="VALID"),
  896. 'desc_const': [(3, 4, 6, 6)],
  897. 'const_first': True,
  898. 'desc_inputs': [[3, 4, 6, 6]],
  899. 'desc_bprop': [[3, 4, 6, 6]],
  900. 'skip': ['backward']}),
  901. ('MaxPoolWithArgmax', {
  902. 'block': P.MaxPoolWithArgmax(ksize=2, strides=2),
  903. 'desc_inputs': [[128, 32, 32, 64]],
  904. 'desc_bprop': [[128, 32, 16, 32], ([128, 32, 4, 33], {'dtype': np.uint16})]}),
  905. ('SoftmaxCrossEntropyWithLogits', {
  906. 'block': P.SoftmaxCrossEntropyWithLogits(),
  907. 'desc_inputs': [[1, 10], [1, 10]],
  908. 'desc_bprop': [[1], [1, 10]],
  909. 'skip': ['backward_exec']}),
  910. ('Flatten', {
  911. 'block': P.Flatten(),
  912. 'desc_inputs': [[128, 32, 32, 64]],
  913. 'desc_bprop': [[128, 65536]]}),
  914. ('LogSoftmax', {
  915. 'block': P.LogSoftmax(),
  916. 'desc_inputs': [[64, 2]],
  917. 'desc_bprop': [[64, 2]]}),
  918. ('LogSoftmaxGrad', {
  919. 'block': G.LogSoftmaxGrad(),
  920. 'desc_inputs': [[16, 1234], [16, 1234]],
  921. 'desc_bprop': [[64, 2]],
  922. 'skip': ['backward']}),
  923. ('L2Normalize', {
  924. 'block': P.L2Normalize(),
  925. 'desc_inputs': [[2, 2]],
  926. 'desc_bprop': [[2, 2]]}),
  927. ('L2NormalizeGrad', {
  928. 'block': G.L2NormalizeGrad(),
  929. 'desc_inputs': [[2, 2], [2, 2], [2, 2]],
  930. 'desc_bprop': [[2, 2]],
  931. 'skip': ['backward']}),
  932. ('LayerNorm', {
  933. 'block': P.LayerNorm(),
  934. 'desc_inputs': [[2, 16], [16], [16]],
  935. 'desc_bprop': [[2, 16], [2, 1], [2, 1]]}),
  936. ('LayerNormGrad', {
  937. 'block': G.LayerNormGrad(),
  938. 'desc_inputs': [[2, 16], [2, 16], [2, 16], [2, 16], [16]],
  939. 'desc_bprop': [[2, 16], [16], [16]],
  940. 'skip': ['backward']}),
  941. ('FusedBatchNorm', {
  942. 'block': P.FusedBatchNorm(),
  943. 'desc_inputs': [[128, 64, 32, 64], [64], [64], [64], [64]],
  944. 'desc_bprop': [[128, 64, 32, 64], [64], [64], [64], [64]],
  945. 'skip': []}),
  946. ('FusedBatchNormGrad', {
  947. 'block': G.FusedBatchNormGrad(),
  948. 'desc_inputs': [[128, 64, 32, 64], [128, 64, 32, 64], [64], [64], [64]],
  949. 'desc_bprop': [[128, 64, 32, 64], [64], [64], [64], [64]],
  950. 'skip': ['backward']}),
  951. ('BatchNorm', {
  952. 'block': P.BatchNorm(),
  953. 'desc_inputs': [[128, 64, 32, 32], [64], [64], [64], [64]],
  954. 'desc_bprop': [[128, 64, 32, 32], [64], [64], [64], [64]],
  955. 'skip': []}),
  956. ('BatchNormGrad', {
  957. 'block': G.BatchNormGrad(),
  958. 'desc_inputs': [[128, 64, 32, 32], [128, 64, 32, 32], [64], [64], [64]],
  959. 'desc_bprop': [[128, 64, 32, 32], [64], [64], [64], [64]],
  960. 'skip': ['backward']}),
  961. ('BasicLSTMCell', {
  962. 'block': P.BasicLSTMCell(keep_prob=1.0, forget_bias=1.0, state_is_tuple=True, activation='tanh'),
  963. 'desc_inputs': [[128, 128], [128, 128], [128, 128], [512, 256, 1, 1], [512, 1, 1, 1]],
  964. 'desc_bprop': [[128, 128], [128, 128], [128, 128], [128, 128], [128, 128], [128, 128], [128, 128]],
  965. 'skip': []}),
  966. ('TopK', {
  967. 'block': P.TopK(),
  968. 'desc_const': [5],
  969. 'desc_inputs': [[20, 20, 10]],
  970. 'desc_bprop': [[20, 20, 5]],
  971. 'skip': ['backward']}),
  972. ('GatherV2_0', {
  973. 'block': P.GatherV2(),
  974. 'desc_const': [0],
  975. 'desc_inputs': [[3, 1, 2], Tensor(np.array([0, 1]).astype(np.int32))],
  976. 'desc_bprop': [[2, 1, 2]]}),
  977. ('GatherV2_1', {
  978. 'block': P.GatherV2(),
  979. 'desc_const': [2],
  980. 'desc_inputs': [[3, 1, 3], Tensor(np.array([0, 1]).astype(np.int32))],
  981. 'desc_bprop': [[3, 1, 2]]}),
  982. ('GatherV2_2', {
  983. 'block': P.GatherV2(),
  984. 'desc_const': [0],
  985. 'desc_inputs': [[3, 1, 3], Tensor(np.array([[0, 1], [0, 1], [0, 1]]).astype(np.int32))],
  986. 'desc_bprop': [[3, 2, 1, 3]]}),
  987. ('GatherV2_3', {
  988. 'block': P.GatherV2(),
  989. 'desc_const': [2],
  990. 'desc_inputs': [[3, 1, 3], Tensor(np.array([[0, 1], [0, 1], [0, 1]]).astype(np.int32))],
  991. 'desc_bprop': [[3, 1, 3, 2]]}),
  992. ('GatherV2_4', {
  993. 'block': P.GatherV2(),
  994. 'desc_const': [1],
  995. 'desc_inputs': [[32, 5, 1024], Tensor(np.array([3]).astype(np.int32))],
  996. 'desc_bprop': [[32, 1, 1024]]}),
  997. ('GatherV2_5', {
  998. 'block': P.GatherV2(),
  999. 'desc_const': [-1],
  1000. 'desc_inputs': [[3, 1, 3], Tensor(np.array([0, 1]).astype(np.int32))],
  1001. 'desc_bprop': [[3, 1, 2]]}),
  1002. ('GatherV2_6', {
  1003. 'block': P.GatherV2(),
  1004. 'desc_const': [0],
  1005. 'desc_inputs': [[1152], Tensor(np.array(10).astype(np.int32))],
  1006. 'desc_bprop': [Tensor(np.array(10).astype(np.float32))]}),
  1007. ('SparseGatherV2_0', {
  1008. 'block': P.SparseGatherV2(),
  1009. 'desc_const': [0],
  1010. 'desc_inputs': [[3, 1, 2], Tensor(np.array([0, 1]).astype(np.int32))],
  1011. 'desc_bprop': [[2, 1, 2]]}),
  1012. ('Range', {
  1013. 'block': inner.Range(1.0, 5.0),
  1014. 'desc_inputs': [Tensor(np.ones([10]).astype(np.float32))],
  1015. 'desc_bprop': [[10]]}),
  1016. ('UnsortedSegmentSum', {
  1017. 'block': P.UnsortedSegmentSum(),
  1018. 'desc_const': [1280],
  1019. 'desc_inputs': [[1280, 1024], Tensor(np.ones(1280).astype(np.int32))],
  1020. 'desc_bprop': [[8192, 1024]],
  1021. 'skip': ['backward']}),
  1022. ('UnsortedSegmentSum_1', {
  1023. 'block': P.UnsortedSegmentSum(),
  1024. 'desc_const': [4],
  1025. 'desc_inputs': [[3, 2, 1, 3], Tensor(np.array([[0, 1], [0, 1], [0, 1]]).astype(np.int32))],
  1026. 'desc_bprop': [[4, 1, 3]],
  1027. 'skip': ['backward']}),
  1028. ('UnsortedSegmentMin', {
  1029. 'block': P.UnsortedSegmentMin(),
  1030. 'desc_const': [4],
  1031. 'desc_inputs': [[3, 2, 1, 3], Tensor(np.array([1, 2, 3]).astype(np.int32))],
  1032. 'desc_bprop': [[4, 2, 1, 3]]}),
  1033. ('DropoutGenMask', {
  1034. 'block': P.DropoutGenMask(),
  1035. 'desc_const': [(2, 2), Tensor(0.5, mstype.float32)],
  1036. 'desc_inputs': [],
  1037. 'desc_bprop': [Tensor(np.ones(1).astype(np.int8))],
  1038. 'skip': ['backward']}),
  1039. ('DropoutDoMask', {
  1040. 'block': P.DropoutDoMask(),
  1041. 'desc_const': [Tensor(0.5)],
  1042. 'desc_inputs': [[64, 12, 128, 128], Tensor(np.ones(1572864).astype(np.uint8))],
  1043. 'desc_bprop': [[64, 12, 128, 128]]}),
  1044. ('Dropout', {
  1045. 'block': nn.Dropout(0.5),
  1046. 'desc_inputs': [[64, 12, 128, 128]],
  1047. 'desc_bprop': [[64, 12, 128, 128]]}),
  1048. ('ReduceMean0', {
  1049. 'block': P.ReduceMean(),
  1050. 'desc_const': [(2,)],
  1051. 'desc_inputs': [[3, 2, 2]],
  1052. 'desc_bprop': [[3, 2]]}),
  1053. ('ReduceMean1', {
  1054. 'block': P.ReduceMean(),
  1055. 'desc_const': [2],
  1056. 'desc_inputs': [[3, 2, 2]],
  1057. 'desc_bprop': [[3, 2]]}),
  1058. ('All', {
  1059. 'block': P.ReduceAll(),
  1060. 'desc_const': [(1,)],
  1061. 'desc_inputs': [Tensor(np.ones([3, 2]).astype(np.bool_))],
  1062. 'desc_bprop': [[3]],
  1063. 'skip': ['backward']}),
  1064. ('DescConst', {
  1065. 'block': Tensor(np.array([2], np.float32)),
  1066. 'desc_inputs': [],
  1067. 'desc_bprop': [[1]],
  1068. 'skip': ['backward'],
  1069. 'add_fake_input': True}),
  1070. ('Fill', {
  1071. 'block': P.Fill(),
  1072. 'desc_const': [mstype.float32, (2, 3), 1.0],
  1073. 'desc_inputs': [],
  1074. 'desc_bprop': [[2, 3]],
  1075. 'skip': ['backward'],
  1076. 'add_fake_input': True}),
  1077. ('OnesLike', {
  1078. 'block': P.OnesLike(),
  1079. 'desc_inputs': [Tensor(np.array([[0, 1], [2, 1]]).astype(np.int32))],
  1080. 'desc_bprop': [Tensor(np.array([[1, 1], [1, 1]]).astype(np.int32))]
  1081. }),
  1082. ('ZerosLike', {
  1083. 'block': P.ZerosLike(),
  1084. 'desc_inputs': [Tensor(np.array([[0, 1], [2, 1]]).astype(np.int32))],
  1085. 'desc_bprop': [Tensor(np.array([[1, 1], [1, 1]]).astype(np.int32))]
  1086. }),
  1087. ('Softmax', {
  1088. 'block': P.Softmax(),
  1089. 'desc_inputs': [[5, 5]],
  1090. 'desc_bprop': [[5, 5]]}),
  1091. ('DepthwiseConv2dNative_1', {
  1092. 'block': P.DepthwiseConv2dNative(3, (3, 3), pad_mode="pad", pad=1, stride=2),
  1093. 'desc_inputs': [[10, 32, 32, 32], [1, 32, 3, 3]],
  1094. 'desc_bprop': [[10, 32, 16, 16]]}),
  1095. ('DepthwiseConv2dNative_2', {
  1096. 'block': P.DepthwiseConv2dNative(1, (3, 3), pad_mode="same", pad=0, stride=1),
  1097. 'desc_inputs': [[2592, 2048, 4, 4], [1, 2048, 3, 3]],
  1098. 'desc_bprop': [[2592, 2048, 4, 4]]}),
  1099. ('SigmoidCrossEntropyWithLogits', {
  1100. 'block': P.SigmoidCrossEntropyWithLogits(),
  1101. 'desc_inputs': [[128, 10], [128, 10]],
  1102. 'desc_bprop': [[128, 10]]}),
  1103. ('Pad', {
  1104. 'block': P.Pad(((1, 2), (2, 3))),
  1105. 'desc_inputs': [[7, 7]],
  1106. 'desc_bprop': [[10, 12]]}),
  1107. ('BinaryCrossEntropy', {
  1108. 'block': P.BinaryCrossEntropy(),
  1109. 'desc_inputs': [[1, 2, 3], [1, 2, 3], [1, 2, 3]],
  1110. 'desc_bprop': []}),
  1111. ('SparseApplyAdagrad', {
  1112. 'block': SparseApplyAdagradNet(),
  1113. 'desc_inputs': [[3, 3], Tensor(np.ones((3,), np.int32))],
  1114. 'desc_bprop': [[3, 3], [3, 3]],
  1115. 'skip': ['backward']}),
  1116. ('SparseApplyFtrl', {
  1117. 'block': SparseApplyFtrlNet(),
  1118. 'desc_inputs': [[3, 3], Tensor(np.ones((3,), np.int32))],
  1119. 'skip': ['backward']}),
  1120. ('ApplyProximalAdagrad', {
  1121. 'block': ApplyProximalAdagradNet(),
  1122. 'desc_inputs': [[3, 3]],
  1123. 'skip': ['backward']}),
  1124. ('SparseApplyProximalAdagrad', {
  1125. 'block': SparseApplyProximalAdagradNet(),
  1126. 'desc_inputs': [[3, 3], Tensor(np.ones((3,), np.int32))],
  1127. 'skip': ['backward']}),
  1128. ('ApplyAdaMax', {
  1129. 'block': ApplyAdaMaxNet(),
  1130. 'desc_inputs': [[3, 3]],
  1131. 'skip': ['backward']}),
  1132. ('ApplyAdadelta', {
  1133. 'block': ApplyAdadeltaNet(),
  1134. 'desc_inputs': [[3, 3]],
  1135. 'skip': ['backward']}),
  1136. ('ApplyAdagrad', {
  1137. 'block': ApplyAdagradNet(),
  1138. 'desc_inputs': [[3, 3]],
  1139. 'skip': ['backward']}),
  1140. ('ApplyAdagradV2', {
  1141. 'block': ApplyAdagradV2Net(),
  1142. 'desc_inputs': [[3, 3]],
  1143. 'skip': ['backward']}),
  1144. ('Flatten_1', {
  1145. 'block': NetForFlatten(),
  1146. 'desc_inputs': [Tensor(np.ones([2, 3, 4]).astype(np.int32)), Tensor(np.ones([2, 12]).astype(np.int32))],
  1147. 'desc_bprop': [Tensor(np.ones([2, 12]).astype(np.int32))],
  1148. 'skip': ['backward']}),
  1149. ('Flatten_2', {
  1150. 'block': NetForFlatten(),
  1151. 'desc_inputs': [Tensor(np.ones([8]).astype(np.int32)), Tensor(np.ones([8, 3]).astype(np.int32))],
  1152. 'desc_bprop': [Tensor(np.ones([8, 3]).astype(np.int32))],
  1153. 'skip': ['backward']}),
  1154. ('Flatten_3', {
  1155. 'block': NetForFlattenComposed(),
  1156. 'desc_inputs': [Tensor(np.ones([2, 3, 4]).astype(np.int32)), Tensor(np.ones([2, 12]).astype(np.int32))],
  1157. 'desc_bprop': [Tensor(np.ones([2, 12]).astype(np.int32))],
  1158. 'skip': []}),
  1159. ('ArgmaxNet', {
  1160. 'block': ArgmaxNet(),
  1161. 'desc_inputs': [Tensor(np.array([[128, 32, 32, 64], [128, 32, 32, 64]]).astype(np.float16))],
  1162. 'desc_bprop': [Tensor(np.array([[128, 32, 32, 64], [128, 32, 32, 64]]).astype(np.float16))],
  1163. 'skip': ['backward']}),
  1164. ('ArgminNet', {
  1165. 'block': ArgminNet(),
  1166. 'desc_inputs': [Tensor(np.array([[128, 32, 32, 64], [128, 32, 32, 64]]).astype(np.float16))],
  1167. 'desc_bprop': [Tensor(np.array([[128, 32, 32, 64], [128, 32, 32, 64]]).astype(np.float16))],
  1168. 'skip': ['backward']}),
  1169. ('OneHot', {
  1170. 'block': P.OneHot(),
  1171. 'desc_const': [3, Tensor(1.0, mstype.float32), Tensor(0.0, mstype.float32)],
  1172. 'desc_inputs': [Tensor(np.array([64]).astype(np.int32))],
  1173. 'desc_bprop': [[1, 3]]}),
  1174. ('ReduceProd_0', {
  1175. 'block': P.ReduceProd(),
  1176. 'desc_const': [0],
  1177. 'desc_inputs': [[3, 2]],
  1178. 'desc_bprop': [[2]]}),
  1179. ('ReduceProd_1', {
  1180. 'block': P.ReduceProd(keep_dims=True),
  1181. 'desc_const': [0],
  1182. 'desc_inputs': [[3, 2]],
  1183. 'desc_bprop': [[1, 2]]}),
  1184. ('CumProd', {
  1185. 'block': P.CumProd(),
  1186. 'desc_const': [0],
  1187. 'desc_inputs': [[3, 2]],
  1188. 'desc_bprop': [[3, 2]]}),
  1189. ('ApplyFtrl', {
  1190. 'block': ApplyFtrlNet(),
  1191. 'desc_inputs': [[3, 3]],
  1192. 'desc_bprop': [3, 3],
  1193. 'skip': ['backward']}),
  1194. ('ApplyRMSProp', {
  1195. 'block': ApplyRMSNet(),
  1196. 'desc_inputs': [[3, 3]],
  1197. 'desc_bprop': [3, 3],
  1198. 'skip': ['backward']}),
  1199. ('ApplyCenteredRMSProp', {
  1200. 'block': P.ApplyCenteredRMSProp(),
  1201. 'desc_const': [0.9, 0.0, 1e-10, 0.001],
  1202. 'desc_inputs': [Tensor(1., mstype.float32), Tensor(2., mstype.float32), Tensor(1., mstype.float32),
  1203. Tensor(2., mstype.float32), Tensor(1., mstype.float32)],
  1204. 'desc_bprop': [1],
  1205. 'skip': ['backward']}),
  1206. ('CTCLoss', {
  1207. 'block': P.CTCLoss(),
  1208. 'desc_inputs': [Tensor(np.ones([6, 4, 6]).astype(np.float32)),
  1209. Tensor(np.array([[0, 1], [1, 0], [2, 3], [3, 2]]).astype(np.int64)),
  1210. Tensor(np.array([1, 2, 3, 4]).astype(np.int32)),
  1211. Tensor(np.array([6, 6, 6, 6]).astype(np.int32))],
  1212. 'desc_bprop': [[4], [6, 4, 6]]}),
  1213. ('L2Loss_1', {
  1214. 'block': P.L2Loss(),
  1215. 'desc_inputs': [Tensor(np.array([1, 2, 3, 4]), mstype.float32)],
  1216. 'desc_bprop': []}),
  1217. ('L2Loss_2', {
  1218. 'block': P.L2Loss(),
  1219. 'desc_inputs': [Tensor(np.array([[1, 1], [2, 2], [3, 3], [4, 4]]), mstype.float16)],
  1220. 'desc_bprop': []}),
  1221. ('ResizeBilinear', {
  1222. 'block': P.ResizeBilinear((5, 5)),
  1223. 'desc_inputs': [Tensor([[[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]]], mstype.float16)],
  1224. 'desc_bprop': [Tensor([[[[1, 2, 3, 4, 5], [1, 2, 3, 4, 5]]]], mstype.float16)]}),
  1225. ('ResizeBilinearGrad', {
  1226. 'block': G.ResizeBilinearGrad(),
  1227. 'desc_inputs': [Tensor([[[[1, 2, 3, 4, 5]]]], mstype.float32), Tensor([[[[1, 2, 3, 4, 5]]]], mstype.float32)],
  1228. 'desc_bprop': [Tensor([[[[1, 2, 3, 4, 5]]]], mstype.float32)],
  1229. 'skip': ['backward']}),
  1230. ('ROIAlign', {
  1231. 'block': P.ROIAlign(7, 7, 0.03125, 2),
  1232. 'desc_inputs': [[2, 256, 192, 320], [1024, 5]],
  1233. 'desc_bprop': [[7, 7]]}),
  1234. ('ROIAlignGrad', {
  1235. 'block': G.ROIAlignGrad((1, 1, 1, 1), 2, 2, 0.5, 2),
  1236. 'desc_inputs': [[1, 1, 2, 2], [1, 5]],
  1237. 'desc_bprop': [[1, 1, 2, 2]],
  1238. 'skip': ['backward']}),
  1239. ('LARSUpdate', {
  1240. 'block': P.LARSUpdate(1e-05, 0.001, False),
  1241. 'desc_const': [0.0, 0.001],
  1242. 'desc_inputs': [[3, 3], [3, 3], [3, 3], [3, 3]],
  1243. 'desc_bprop': [3, 3],
  1244. 'skip': ['backward']}),
  1245. ('SGD', {
  1246. 'block': P.SGD(0.0, 0.0, False),
  1247. 'desc_inputs': [[3, 3], [3, 3], Tensor(0.001, mstype.float32), [3, 3], Tensor(0.1, mstype.float32), [3, 3]],
  1248. 'desc_bprop': [3, 3],
  1249. 'skip': ['backward']}),
  1250. ('BinaryCrossEntropy', {
  1251. 'block': P.BinaryCrossEntropy(),
  1252. 'desc_inputs': [Tensor([[0.3, 0.8], [0.4, 0.3]], mstype.float16),
  1253. Tensor([[0.4, 1.2], [-0.4, -0.9]], mstype.float16),
  1254. Tensor([[-1.4, -0.7], [0.9, 0.7]], mstype.float16)],
  1255. 'desc_bprop': []}),
  1256. ('BinaryCrossEntropyGrad', {
  1257. 'block': G.BinaryCrossEntropyGrad(),
  1258. 'desc_inputs': [Tensor([[0.3, 0.8], [0.4, 0.3]], mstype.float16),
  1259. Tensor([[0.4, 1.2], [-0.4, -0.9]], mstype.float16), Tensor(0.85, mstype.float16),
  1260. Tensor([[-1.4, -0.7], [0.9, 0.7]], mstype.float16)],
  1261. 'desc_bprop': [],
  1262. 'skip': ['backward']}),
  1263. ('DataFormatDimMap', {
  1264. 'block': P.DataFormatDimMap(),
  1265. 'desc_inputs': [Tensor([0, 1, 2, 3], mstype.int32)],
  1266. 'desc_bprop': [],
  1267. 'skip': ['backward']}),
  1268. ]
  1269. test_case_array_ops = [
  1270. ('SpaceToDepth', {
  1271. 'block': P.SpaceToDepth(2),
  1272. 'desc_inputs': [[1, 3, 2, 2]],
  1273. 'desc_bprop': [[1, 12, 1, 1]]}),
  1274. ('DepthToSpace', {
  1275. 'block': P.DepthToSpace(2),
  1276. 'desc_inputs': [[1, 12, 1, 1]],
  1277. 'desc_bprop': [[1, 3, 2, 2]]}),
  1278. ('Split', {
  1279. 'block': P.Split(1, 2),
  1280. 'desc_inputs': [Tensor(np.array([[1, 1, 1, 1], [2, 2, 2, 2]]))],
  1281. 'skip': ['backward']}),
  1282. ('Argmax', {
  1283. 'block': P.Argmax(),
  1284. 'desc_inputs': [[128, 32, 32, 64]],
  1285. 'desc_bprop': [0],
  1286. 'skip': ['backward']}),
  1287. ('Argmin', {
  1288. 'block': P.Argmin(),
  1289. 'desc_inputs': [[128, 32, 32, 64]],
  1290. 'desc_bprop': [1],
  1291. 'skip': ['backward']}),
  1292. ('ArgMaxWithValue', {
  1293. 'block': P.ArgMaxWithValue(),
  1294. 'desc_inputs': [[128, 32, 32, 64]],
  1295. 'desc_bprop': [[1], [1]],
  1296. 'skip': ['backward']}),
  1297. ('ArgMinWithValue', {
  1298. 'block': P.ArgMinWithValue(),
  1299. 'desc_inputs': [[128, 32, 32, 64]],
  1300. 'desc_bprop': [[1], [1]],
  1301. 'skip': ['backward']}),
  1302. ('Transpose_dim3', {
  1303. 'block': P.Transpose(),
  1304. 'desc_const': [(0, 2, 1)],
  1305. 'desc_inputs': [[1, 2, 3]],
  1306. 'desc_bprop': [[1, 3, 2]]}),
  1307. ('Transpose_dim4', {
  1308. 'block': P.Transpose(),
  1309. 'desc_const': [(0, 1, 2, 3)],
  1310. 'desc_inputs': [[1, 2, 3, 4]],
  1311. 'desc_bprop': [[1, 2, 4, 3]]}),
  1312. ('AddN', {
  1313. 'block': NetForTupleInput(P.AddN()),
  1314. 'desc_inputs': [[2, 3, 3, 5], [2, 3, 3, 5]],
  1315. 'desc_bprop': [[2, 3, 3, 5]],
  1316. 'skip': ['backward']}),
  1317. ('Shape', {
  1318. 'block': P.Shape(),
  1319. 'desc_inputs': [[3, 3, 2, 2]],
  1320. 'skip': ['backward']}),
  1321. ('Reshape', {
  1322. 'block': P.Reshape(),
  1323. 'desc_const': [(64,)],
  1324. 'desc_inputs': [[64, 1]],
  1325. 'desc_bprop': [[64]]}),
  1326. ('Cast', {
  1327. 'block': P.Cast(),
  1328. 'desc_const': [mstype.int32],
  1329. 'desc_inputs': [[2, 3, 4, 5]],
  1330. 'desc_bprop': [Tensor(np.ones((2, 3, 4, 5)).astype(np.int32))]}),
  1331. ('ExpandDims', {
  1332. 'block': P.ExpandDims(),
  1333. 'desc_const': [0],
  1334. 'desc_inputs': [[2, 2]],
  1335. 'desc_bprop': [[1, 2, 2]]}),
  1336. ('ExpandDims_1', {
  1337. 'block': P.ExpandDims(),
  1338. 'desc_const': [-1],
  1339. 'desc_inputs': [[2, 2]],
  1340. 'desc_bprop': [[2, 2, 1]]}),
  1341. ('Squeeze', {
  1342. 'block': P.Squeeze(2),
  1343. 'desc_inputs': [[3, 2, 1]],
  1344. 'desc_bprop': [[3, 2]]}),
  1345. ('Squeeze_0', {
  1346. 'block': P.Squeeze(),
  1347. 'desc_inputs': [[3, 1, 2, 1]],
  1348. 'desc_bprop': [[3, 2]]}),
  1349. ('Squeeze_1', {
  1350. 'block': P.Squeeze(),
  1351. 'desc_inputs': [[1, 1, 1, 1]],
  1352. 'desc_bprop': [1.0],
  1353. 'skip': ['backward']}),
  1354. ('Squeeze_2', {
  1355. 'block': P.Squeeze((2, 3)),
  1356. 'desc_inputs': [[3, 2, 1, 1]],
  1357. 'desc_bprop': [[3, 2]]}),
  1358. ('Size', {
  1359. 'block': P.Size(),
  1360. 'desc_inputs': [[2, 3, 5]],
  1361. 'skip': ['backward']}),
  1362. ('Tile_0', {
  1363. 'block': P.Tile(),
  1364. 'desc_const': [(1, 2)],
  1365. 'desc_inputs': [[64, 1]],
  1366. 'desc_bprop': [[64, 2]]}),
  1367. ('Tile_1', {
  1368. 'block': P.Tile(),
  1369. 'desc_const': [(1, 1)],
  1370. 'desc_inputs': [[64, 1]],
  1371. 'desc_bprop': [[64, 1]]}),
  1372. ('Tile_2', {
  1373. 'block': P.Tile(),
  1374. 'desc_const': [(2, 1, 1, 2)],
  1375. 'desc_inputs': [[2, 2, 2]],
  1376. 'desc_bprop': [[2, 2, 2, 4]]}),
  1377. ('ConcatV2_0', {
  1378. 'block': P.Concat(),
  1379. 'desc_inputs': [
  1380. (Tensor(np.array([[0, 1], [2, 1]]).astype(np.int32)),
  1381. Tensor(np.array([[0, 1], [2, 1]]).astype(np.int32)))],
  1382. 'desc_bprop': [([4, 2], {'dtype': np.int32})]}),
  1383. ('ConcatV2_1', {
  1384. 'block': P.Concat(axis=2),
  1385. 'desc_inputs': [(Tensor(np.array([[[0, 1, 2]], [[2, 1, 2]]]).astype(np.int32)),
  1386. Tensor(np.array([[[0, 1]], [[2, 1]]]).astype(np.int32)))],
  1387. 'desc_bprop': [([2, 1, 5], {'dtype': np.int32})]}),
  1388. ('ConcatV2_2', {
  1389. 'block': NetForConcat(),
  1390. 'desc_inputs': [[2, 2]],
  1391. 'desc_bprop': [[4, 2]]}),
  1392. ('ConcatV2_3', {
  1393. 'block': NetForConcat1(),
  1394. 'desc_inputs': [[2, 2], [2, 2]],
  1395. 'desc_bprop': [[4, 2]]}),
  1396. ('ConcatV2_4', {
  1397. 'block': P.Concat(axis=0),
  1398. 'desc_inputs': [
  1399. (Tensor(np.ones((3, 2, 3), np.float32)),
  1400. Tensor(np.ones((5, 2, 3), np.float32)),
  1401. Tensor(np.ones((6, 2, 3), np.float32)))],
  1402. 'desc_bprop': [[14, 2, 3]]}),
  1403. ('ConcatV2_5', {
  1404. 'block': P.Concat(axis=-1),
  1405. 'desc_inputs': [(Tensor(np.array([1], np.float32)),
  1406. Tensor(np.array([1], np.float32)),
  1407. Tensor(np.array([1], np.float32)))],
  1408. 'desc_bprop': [[3, ]]}),
  1409. ('Pack_0', {
  1410. 'block': NetForPackInput(P.Pack()),
  1411. 'desc_inputs': [[2, 2], [2, 2], [2, 2]],
  1412. 'desc_bprop': [[3, 2, 2]],
  1413. }),
  1414. ('Pack_1', {
  1415. 'block': NetForPackInput(P.Pack(axis=-2)),
  1416. 'desc_inputs': [[3, 2, 3], [3, 2, 3], [3, 2, 3]],
  1417. 'desc_bprop': [[3, 2, 3, 3]],
  1418. }),
  1419. ('Pack_2', {
  1420. 'block': NetForPackInput(P.Pack()),
  1421. 'desc_inputs': [[128, 128], [128, 128]],
  1422. 'desc_bprop': [[2, 128, 128]],
  1423. }),
  1424. ('Unpack_0', {
  1425. 'block': NetForUnpackInput(P.Unpack(axis=0)),
  1426. 'desc_inputs': [[2, 4]],
  1427. 'desc_bprop': [[4], [4]],
  1428. }),
  1429. ('Unpack_1', {
  1430. 'block': NetForUnpackInput(P.Unpack(axis=-1)),
  1431. 'desc_inputs': [Tensor(np.array([[1, 1, 1]], np.float32))],
  1432. 'desc_bprop': [[1], [1], [1]],
  1433. }),
  1434. ('Diag_1', {
  1435. 'block': P.Diag(),
  1436. 'desc_inputs': [[4]],
  1437. 'desc_bprop': [[4, 4]],
  1438. }),
  1439. ('Diag_2', {
  1440. 'block': P.Diag(),
  1441. 'desc_inputs': [[4, 4]],
  1442. 'desc_bprop': [[4, 4, 4, 4]],
  1443. }),
  1444. ('DiagPart_1', {
  1445. 'block': P.DiagPart(),
  1446. 'desc_inputs': [[4, 4]],
  1447. 'desc_bprop': [[4]],
  1448. }),
  1449. ('DiagPart_2', {
  1450. 'block': P.DiagPart(),
  1451. 'desc_inputs': [[4, 4, 4, 4]],
  1452. 'desc_bprop': [[4, 4]],
  1453. }),
  1454. ('SpaceToBatch_1', {
  1455. 'block': P.SpaceToBatch(2, [[0, 0], [0, 0]]),
  1456. 'desc_inputs': [[1, 3, 2, 2]],
  1457. 'desc_bprop': [[4, 3, 1, 1]],
  1458. }),
  1459. ('SpaceToBatch_2', {
  1460. 'block': P.SpaceToBatch(2, [[1, 1], [0, 4]]),
  1461. 'desc_inputs': [[1, 3, 2, 2]],
  1462. 'desc_bprop': [[4, 3, 2, 3]],
  1463. }),
  1464. ('BatchToSpace_1', {
  1465. 'block': P.BatchToSpace(2, [[0, 0], [0, 0]]),
  1466. 'desc_inputs': [[4, 3, 1, 1]],
  1467. 'desc_bprop': [[1, 3, 2, 2]],
  1468. }),
  1469. ('BatchToSpace_2', {
  1470. 'block': P.BatchToSpace(2, [[0, 0], [0, 1]]),
  1471. 'desc_inputs': [[4, 3, 1, 1]],
  1472. 'desc_bprop': [[1, 3, 2, 1]],
  1473. }),
  1474. ('UnsortedSegmentMin_1', {
  1475. 'block': P.UnsortedSegmentMin(),
  1476. 'desc_const': [2],
  1477. 'desc_inputs': [Tensor(np.array([[1, 2, 3], [4, 5, 6], [4, 2, 1]]).astype(np.float32)),
  1478. Tensor(np.array([0, 1, 1]).astype(np.int32))],
  1479. 'desc_bprop': [Tensor(np.array([[1, 2, 3], [4, 2, 1]]).astype(np.float32))]}),
  1480. ('BroadcastTo', {
  1481. 'block': P.BroadcastTo((2, 3)),
  1482. 'desc_inputs': [Tensor(np.array([1, 2, 3]).astype(np.float32))],
  1483. 'desc_bprop': [Tensor(np.array([[1, 2, 3], [1, 2, 3]]).astype(np.float32))]}),
  1484. ('InTopK', {
  1485. 'block': P.InTopK(2),
  1486. 'desc_inputs': [Tensor(np.array([[1, 2, 3], [2, 3, 6], [4, 2, 1]]).astype(np.float32)),
  1487. Tensor(np.array([2, 1, 2]).astype(np.int32))],
  1488. 'skip': ['backward'],
  1489. }),
  1490. ('InplaceUpdate', {
  1491. 'block': P.InplaceUpdate((0, 2)),
  1492. 'desc_inputs': [Tensor(np.arange(24).reshape(3, 4, 2).astype(np.float32)),
  1493. Tensor(np.arange(16).reshape(2, 4, 2).astype(np.float32))],
  1494. 'skip': ['backward'],
  1495. }),
  1496. ('ReverseSequence', {
  1497. 'block': P.ReverseSequence(1, 0),
  1498. 'desc_inputs': [Tensor(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]).astype(np.float32)),
  1499. Tensor(np.array([1, 2, 3]).astype(np.int32))],
  1500. 'desc_bprop': [[3, 3]]}),
  1501. ]
  1502. test_case_other_ops = [
  1503. ('ScalarLog', {
  1504. 'block': F.scalar_log,
  1505. 'desc_const': [0.0],
  1506. 'desc_inputs': [],
  1507. 'desc_bprop': [1],
  1508. 'skip': ['backward']}),
  1509. ('BoundingBoxEncode', {
  1510. 'block': P.BoundingBoxEncode(means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0)),
  1511. 'desc_inputs': [[256, 4], [256, 4]],
  1512. 'desc_bprop': [[256, 4]],
  1513. 'skip': ['backward']}),
  1514. ('BoundingBoxDecode', {
  1515. 'block': P.BoundingBoxDecode(means=(0.0, 0.0, 0.0, 0.0), stds=(1.0, 1.0, 1.0, 1.0), max_shape=(768, 1280)),
  1516. 'desc_inputs': [[256, 4], [256, 4]],
  1517. 'desc_bprop': [[256, 4]],
  1518. 'skip': ['backward']}),
  1519. ('GatherNd', {
  1520. 'block': P.GatherNd(),
  1521. 'desc_inputs': (Tensor(np.ones((1, 3, 6, 6), np.float32)),
  1522. Tensor(np.ones((2, 4), np.int32))),
  1523. 'desc_bprop': [[2]]}),
  1524. ('ScatterNd', {
  1525. 'block': P.ScatterNd(),
  1526. 'desc_const': [(3, 3)],
  1527. 'desc_inputs': (Tensor(np.ones((2, 2), np.int32)),
  1528. Tensor(np.ones((2,), np.int32))),
  1529. 'desc_bprop': [([3, 3], {'dtype': np.int32})]}),
  1530. ('TensorScatterUpdate', {
  1531. 'block': P.TensorScatterUpdate(),
  1532. 'desc_inputs': (Tensor(np.arange(3 * 4 * 5).reshape((3, 4, 5)), mstype.float32),
  1533. Tensor(np.array([[0, 1], [1, 2]], np.int32)),
  1534. Tensor(np.ones([2, 5], np.float32) * 99)),
  1535. 'desc_bprop': [([3, 4, 5], {'dtype': np.float32})]}),
  1536. ('ScatterMax', {
  1537. 'block': ScatterMax(),
  1538. 'desc_inputs': (Tensor(np.array([[0, 0], [1, 1]], np.int32)),
  1539. Tensor(np.ones([2, 2, 3], np.float32) * 99)),
  1540. 'skip': ['backward']}),
  1541. ('ScatterAdd', {
  1542. 'block': ScatterAdd((6,)),
  1543. 'desc_inputs': (Tensor(np.array([2, 0, 5], np.int32)),
  1544. Tensor(np.array([2.0, 3.0, 4.0], np.float32))),
  1545. 'skip': ['backward']}),
  1546. ('ScatterAdd2d', {
  1547. 'block': ScatterAdd((3, 4)),
  1548. 'desc_inputs': (Tensor(np.array([[0, 1], [1, 2]], np.int32)),
  1549. Tensor(np.array([[[1, 1, 1, 1], [2, 2, 2, 2]],
  1550. [[3, 3, 3, 3], [4, 4, 4, 4]]], np.float32))),
  1551. 'skip': ['backward']}),
  1552. ('SmoothL1Loss', {
  1553. 'block': P.SmoothL1Loss(),
  1554. 'desc_inputs': [[256, 4], [256, 4]],
  1555. 'desc_bprop': [[256, 4]]}),
  1556. ('IOU', {
  1557. 'block': P.IOU(),
  1558. 'desc_inputs': [Tensor(np.ones((256, 4), np.float16)), Tensor(np.ones((128, 4), np.float16))],
  1559. 'desc_bprop': [[128, 256]]}),
  1560. ('Summary', {
  1561. 'block': SummaryNet(),
  1562. 'desc_inputs': [Tensor(np.array([1.1]).astype(np.float32)),
  1563. Tensor(np.array([1.2]).astype(np.float32))],
  1564. 'skip': ['backward']}),
  1565. ('ConfusionMulGrad_1', {
  1566. 'block': P.ConfusionMulGrad(axis=[0], keep_dims=False),
  1567. 'desc_inputs': [[3, 2], [3, 2], [3, 2]],
  1568. 'desc_bprop': [[3, 2], [2]],
  1569. 'skip': ['backward']}),
  1570. ('ConfusionMulGrad_2', {
  1571. 'block': P.ConfusionMulGrad(axis=[0], keep_dims=True),
  1572. 'desc_inputs': [[3, 2], [3, 2], [3, 2]],
  1573. 'desc_bprop': [[3, 2], [1, 2]],
  1574. 'skip': ['backward']}),
  1575. ('ConfusionMulGrad_3', {
  1576. 'block': P.ConfusionMulGrad(axis=(), keep_dims=True),
  1577. 'desc_inputs': [[2, 3, 4], [2, 3, 4], [2, 3, 4]],
  1578. 'desc_bprop': [[2, 3, 4], [1, 1, 1]],
  1579. 'skip': ['backward']}),
  1580. ('HistogramSummary', {
  1581. 'block': HistogramSummaryNet(),
  1582. 'desc_inputs': [Tensor(np.array([1.1]).astype(np.float32)),
  1583. Tensor(np.array([1.2]).astype(np.float32))],
  1584. 'skip': ['backward']}),
  1585. ]
  1586. test_case_quant_ops = [
  1587. ('AscendQuant_1', {
  1588. 'block': inner.AscendQuant(0.5, 0.0, False, "Round"),
  1589. 'desc_inputs': [Tensor(np.random.rand(1,2,4,4), mstype.float32)],
  1590. 'skip': ['backward']}),
  1591. ('AscendQuant_2', {
  1592. 'block': inner.AscendQuant(80.0, 10.0, True, "Round"),
  1593. 'desc_inputs': [Tensor([100.0, 200.0], mstype.float32)],
  1594. 'skip': ['backward']}),
  1595. ('AscendQuant_3', {
  1596. 'block': inner.AscendQuant(80.0, 0.0, False, "Floor"),
  1597. 'desc_inputs': [Tensor([100.0, 200.0], mstype.float32)],
  1598. 'skip': ['backward']}),
  1599. ('AscendQuant_4', {
  1600. 'block': inner.AscendQuant(80.0, 0.0, False, "Ceil"),
  1601. 'desc_inputs': [Tensor([100.0, 200.0], mstype.float32)],
  1602. 'skip': ['backward']}),
  1603. ('AscendQuant_5', {
  1604. 'block': inner.AscendQuant(80.0, 0.0, False, "Trunc"),
  1605. 'desc_inputs': [Tensor([100.0, 200.0], mstype.float32)],
  1606. 'skip': ['backward']}),
  1607. ('AscendQuant_6', {
  1608. 'block': inner.AscendQuant(-80.0, 10.0, False, "Round"),
  1609. 'desc_inputs': [Tensor([100.0, 200.0], mstype.float32)],
  1610. 'skip': ['backward']}),
  1611. ('AscendQuant_7', {
  1612. 'block': inner.AscendQuant(80.0, -10.0, False, "Round"),
  1613. 'desc_inputs': [Tensor([100.0, 200.0], mstype.float32)],
  1614. 'skip': ['backward']}),
  1615. ('AscendQuant_8', {
  1616. 'block': inner.AscendQuant(80.0, 10.0, False, "Round"),
  1617. 'desc_inputs': [Tensor([100.0, 200.0], mstype.float16)],
  1618. 'skip': ['backward']}),
  1619. ]
  1620. test_case_lists = [test_case_nn_ops, test_case_math_ops, test_case_array_ops, test_case_other_ops, test_case_quant_ops]
  1621. test_case = functools.reduce(lambda x, y: x + y, test_case_lists)
  1622. # use -k to select certain testcast
  1623. # pytest tests/python/ops/test_ops.py::test_backward -k LayerNorm
  1624. test_exec_case = test_case
  1625. test_backward_exec_case = filter(lambda x: 'skip' not in x[1] or 'backward' not in x[1]['skip'], test_case)
  1626. @non_graph_engine
  1627. @mindspore_test(pipeline_for_compile_forward_ge_graph_for_case_by_case_config)
  1628. def test_exec():
  1629. context.set_context(mode=context.GRAPH_MODE)
  1630. return test_exec_case
  1631. @mindspore_test(pipeline_for_compile_grad_ge_graph_for_case_by_case_config)
  1632. def test_backward_exec():
  1633. context.set_context(mode=context.GRAPH_MODE)
  1634. return test_backward_exec_case
  1635. raise_set = [
  1636. ('Cast_Error', {
  1637. 'block': (P.Cast(), {'exception': TypeError}),
  1638. 'desc_const': [mstype.int32],
  1639. 'desc_inputs': ['wrong input'],
  1640. 'desc_bprop': [Tensor(np.ones((2, 3, 3, 5)).astype(np.int32))]}),
  1641. ('Maximum_Error', {
  1642. 'block': (P.Maximum(), {'exception': TypeError}),
  1643. 'desc_const': [(1, 2, 3)],
  1644. 'desc_inputs': [[2, 3, 3, 5]],
  1645. 'desc_bprop': [[2, 3, 3, 5]]}),
  1646. ('Shape_error', {
  1647. 'block': (P.Shape(), {'exception': TypeError}),
  1648. 'desc_inputs': [(64, 1)],
  1649. 'desc_bprop': [[64]]}),
  1650. ('Flatten_Error', {
  1651. 'block': (NetForFlatten0D(), {'exception': ValueError}),
  1652. 'desc_inputs': [Tensor(np.array(0).astype(np.int32))],
  1653. 'desc_bprop': [Tensor(np.array(0).astype(np.int32))]}),
  1654. ('ScatterNdUpdate', {
  1655. 'block': (P.ScatterNdUpdate(), {'exception': TypeError}),
  1656. 'desc_inputs': (Tensor(np.ones((2, 3), np.float32)),
  1657. Tensor(np.ones((2, 2), np.float32)),
  1658. Tensor(np.ones((2,), np.float32))),
  1659. 'desc_bprop': [[2, 3]]}),
  1660. ('Pack', {
  1661. 'block': (NetForPackInput(P.Pack()), {'exception': ValueError}),
  1662. 'desc_inputs': [[2, 2]],
  1663. 'desc_bprop': [[1, 2, 2]]}),
  1664. ('PReLU', {
  1665. 'block': (P.PReLU(), {'exception': ValueError}),
  1666. 'desc_inputs': [[2], [1]],
  1667. 'desc_bprop': [[1]]}),
  1668. ('SSIM', {
  1669. 'block': (nn.SSIM(), {'exception': ValueError}),
  1670. 'desc_inputs': [Tensor(np.ones((1, 3, 8, 8)), mstype.float32),
  1671. Tensor(np.ones((1, 3, 8, 8)), mstype.float32)]}),
  1672. ]
  1673. @mindspore_test(pipeline_for_compile_forward_ge_graph_for_case_by_case_config_exception)
  1674. def test_check_exception():
  1675. return raise_set