@@ -27,13 +27,15 @@ def get_client(self):
27
27
28
28
def test_set_tensor (self ):
29
29
con = self .get_client ()
30
- con .tensorset ('x' , Tensor . scalar ( DType . float , 2 , 3 ))
30
+ con .tensorset ('x' , ( 2 , 3 ), dtype = DType . float )
31
31
values = con .tensorget ('x' , as_type = Tensor )
32
32
self .assertEqual ([2 , 3 ], values .value )
33
33
34
34
con .tensorset ('x' , Tensor .scalar (DType .int32 , 2 , 3 ))
35
35
values = con .tensorget ('x' , as_type = Tensor ).value
36
36
self .assertEqual ([2 , 3 ], values )
37
+ meta = con .tensorget ('x' , meta_only = True )
38
+ self .assertTrue ('<Tensor(shape=[2] type=DType.int32) at ' in repr (meta ))
37
39
38
40
self .assertRaises (Exception , con .tensorset , 1 )
39
41
self .assertRaises (Exception , con .tensorset , 'x' )
@@ -86,15 +88,21 @@ def test_run_tf_model(self):
86
88
con .modelrun ('m' , ['a' , 'b' ], 'c' )
87
89
tensor = con .tensorget ('c' )
88
90
self .assertTrue (np .allclose ([4 , 9 ], tensor ))
91
+ model_det = con .modelget ('m' )
92
+ self .assertTrue (model_det ['backend' ] == Backend .tf )
93
+ self .assertTrue (model_det ['device' ] == Device .cpu )
94
+ con .modeldel ('m' )
95
+ self .assertRaises (ResponseError , con .modelget , 'm' )
89
96
90
97
def test_scripts (self ):
91
98
con = self .get_client ()
92
99
self .assertRaises (ResponseError , con .scriptset ,
93
100
'ket' , Device .cpu , 'return 1' )
94
- con . scriptset ( 'ket' , Device . cpu , r"""
101
+ script = r"""
95
102
def bar(a, b):
96
103
return a + b
97
- """ )
104
+ """
105
+ con .scriptset ('ket' , Device .cpu , script )
98
106
con .tensorset ('a' , Tensor .scalar (DType .float , 2 , 3 ))
99
107
con .tensorset ('b' , Tensor .scalar (DType .float , 2 , 3 ))
100
108
# try with bad arguments:
@@ -103,6 +111,12 @@ def bar(a, b):
103
111
con .scriptrun ('ket' , 'bar' , inputs = ['a' , 'b' ], outputs = 'c' )
104
112
tensor = con .tensorget ('c' , as_type = Tensor )
105
113
self .assertEqual ([4 , 6 ], tensor .value )
114
+ script_det = con .scriptget ('ket' )
115
+ self .assertTrue (script_det ['device' ] == Device .cpu )
116
+ self .assertTrue (script_det ['script' ] == script )
117
+ self .assertTrue ("def bar(a, b):" in script_det ['script' ])
118
+ con .scriptdel ('ket' )
119
+ self .assertRaises (ResponseError , con .scriptget , 'ket' )
106
120
107
121
def test_run_onnxml_model (self ):
108
122
mlmodel_path = os .path .join (MODEL_DIR , 'boston.onnx' )
0 commit comments