forked from mindspore-Ecosystem/mindspore
!20377 Delete unused files in offline debugger ccsrc
Merge pull request !20377 from TinaMengtingZhang/del_dbg_files
This commit is contained in:
commit
63c91062f4
|
@ -1,28 +0,0 @@
|
|||
-----------------------------------------------------------
|
||||
tensor_info_1 attributes:
|
||||
node name = Default/network-TrainOneStepCell/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op169
|
||||
slot = 0
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 1
|
||||
is_parameter = False
|
||||
|
||||
tensor_data_1 attributes:
|
||||
data (printed in uint8) = [149 167 124 ... 158 212 164]
|
||||
size in bytes = 2076672
|
||||
debugger dtype = 10
|
||||
shape = [32, 192, 13, 13]
|
||||
-----------------------------------------------------------
|
||||
tensor_info_2 attributes:
|
||||
node name = Default/network-TrainOneStepCell/network-WithLossCell/_backbone-AlexNet/ReLUV2-op348
|
||||
slot = 1
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 1
|
||||
is_parameter = False
|
||||
|
||||
tensor_data_2 attributes:
|
||||
data (printed in uint8) = [ 20 21 18 ... 126 98 25]
|
||||
size in bytes = 129792
|
||||
debugger dtype = 6
|
||||
shape = [32, 12, 13, 13, 2]
|
|
@ -1,72 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
Read tensor test script for offline debugger APIs.
|
||||
"""
|
||||
|
||||
import mindspore.offline_debug.dbg_services as d
|
||||
import numpy as np
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
debugger_backend = d.DbgServices(
|
||||
dump_file_path="/opt/nvme2n1/j00455527/dumps/async_sink_true/032421")
|
||||
|
||||
_ = debugger_backend.initialize(net_name="alexnet", is_sync_mode=False)
|
||||
|
||||
# output tensor with zero slot
|
||||
info1 = d.TensorInfo(node_name="Default/network-TrainOneStepCell/network-WithLossCell/_backbone-AlexNet/"
|
||||
"conv3-Conv2d/Conv2D-op169",
|
||||
slot=0, iteration=2, device_id=0, root_graph_id=1, is_parameter=False)
|
||||
# output tensor with non-zero slot
|
||||
info2 = d.TensorInfo(node_name="Default/network-TrainOneStepCell/network-WithLossCell/_backbone-AlexNet/"
|
||||
"ReLUV2-op348",
|
||||
slot=1, iteration=2, device_id=0, root_graph_id=1, is_parameter=False)
|
||||
|
||||
tensor_info = [info1, info2]
|
||||
|
||||
tensor_data = debugger_backend.read_tensors(tensor_info)
|
||||
|
||||
print_read_tensors(tensor_info, tensor_data)
|
||||
|
||||
|
||||
def print_read_tensors(tensor_info, tensor_data):
|
||||
"""Print read tensors."""
|
||||
for x, _ in enumerate(tensor_info):
|
||||
print("-----------------------------------------------------------")
|
||||
print("tensor_info_" + str(x+1) + " attributes:")
|
||||
print("node name = ", tensor_info[x].node_name)
|
||||
print("slot = ", tensor_info[x].slot)
|
||||
print("iteration = ", tensor_info[x].iteration)
|
||||
print("device_id = ", tensor_info[x].device_id)
|
||||
print("root_graph_id = ", tensor_info[x].root_graph_id)
|
||||
print("is_parameter = ", tensor_info[x].is_parameter)
|
||||
print()
|
||||
print("tensor_data_" + str(x+1) + " attributes:")
|
||||
print("data (printed in uint8) = ", np.frombuffer(
|
||||
tensor_data[x].data_ptr, np.uint8, tensor_data[x].data_size))
|
||||
py_byte_size = len(tensor_data[x].data_ptr)
|
||||
c_byte_size = tensor_data[x].data_size
|
||||
if c_byte_size != py_byte_size:
|
||||
print("The python byte size of ", py_byte_size,
|
||||
" does not match the C++ byte size of ", c_byte_size)
|
||||
print("size in bytes = ", tensor_data[x].data_size)
|
||||
print("debugger dtype = ", tensor_data[x].dtype)
|
||||
print("shape = ", tensor_data[x].shape)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,14 +0,0 @@
|
|||
-----------------------------------------------------------
|
||||
watchpoint_hit for test_1 attributes:
|
||||
name = Default/network-TrainOneStepCell/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op169
|
||||
slot = 0
|
||||
condition = 6
|
||||
watchpoint_id = 1
|
||||
parameter 0 name = param
|
||||
parameter 0 disabled = False
|
||||
parameter 0 value = 0.0
|
||||
parameter 0 hit = True
|
||||
parameter 0 actual_value = -0.1417236328125
|
||||
error code = 0
|
||||
device_id = 0
|
||||
root_graph_id = 1
|
|
@ -1,92 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
Watchpoints test script for offline debugger APIs.
|
||||
"""
|
||||
|
||||
import mindspore.offline_debug.dbg_services as d
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
debugger_backend = d.DbgServices(
|
||||
dump_file_path="/opt/nvme2n1/j00455527/dumps/async_sink_true/032421")
|
||||
|
||||
_ = debugger_backend.initialize(net_name="alexnet", is_sync_mode=False)
|
||||
|
||||
# NOTES:
|
||||
# -> watch_condition=6 is MIN_LT
|
||||
# -> watch_condition=18 is CHANGE_TOO_LARGE
|
||||
|
||||
# test 1: watchpoint set and hit (watch_condition=6)
|
||||
param1 = d.Parameter(name="param", disabled=False, value=0.0)
|
||||
_ = debugger_backend.add_watchpoint(watchpoint_id=1, watch_condition=6,
|
||||
check_node_list={"Default/network-TrainOneStepCell/network-WithLossCell/"
|
||||
"_backbone-AlexNet/conv3-Conv2d/Conv2D-op169":
|
||||
{"device_id": [0], "root_graph_id": [1], "is_parameter": False
|
||||
}}, parameter_list=[param1])
|
||||
|
||||
watchpoint_hits_test_1 = debugger_backend.check_watchpoints(iteration=2)
|
||||
if len(watchpoint_hits_test_1) != 1:
|
||||
print("ERROR -> test 1: watchpoint set but not hit just once")
|
||||
print_watchpoint_hits(watchpoint_hits_test_1, 1)
|
||||
|
||||
# test 2: watchpoint remove and ensure it's not hit
|
||||
_ = debugger_backend.remove_watchpoint(watchpoint_id=1)
|
||||
watchpoint_hits_test_2 = debugger_backend.check_watchpoints(iteration=2)
|
||||
if watchpoint_hits_test_2:
|
||||
print("ERROR -> test 2: watchpoint removed but hit")
|
||||
|
||||
# test 3: watchpoint set and not hit, then remove
|
||||
param2 = d.Parameter(name="param", disabled=False, value=-1000.0)
|
||||
_ = debugger_backend.add_watchpoint(watchpoint_id=2, watch_condition=6,
|
||||
check_node_list={"Default/network-TrainOneStepCell/network-WithLossCell/"
|
||||
"_backbone-AlexNet/conv3-Conv2d/Conv2D-op169":
|
||||
{"device_id": [0], "root_graph_id": [1], "is_parameter": False
|
||||
}}, parameter_list=[param2])
|
||||
|
||||
watchpoint_hits_test_3 = debugger_backend.check_watchpoints(iteration=2)
|
||||
if watchpoint_hits_test_3:
|
||||
print("ERROR -> test 3: watchpoint set but not supposed to be hit")
|
||||
_ = debugger_backend.remove_watchpoint(watchpoint_id=2)
|
||||
|
||||
|
||||
def print_watchpoint_hits(watchpoint_hits, test_id):
|
||||
"""Print watchpoint hits."""
|
||||
for x, _ in enumerate(watchpoint_hits):
|
||||
print("-----------------------------------------------------------")
|
||||
print("watchpoint_hit for test_%u attributes:" % test_id)
|
||||
print("name = ", watchpoint_hits[x].name)
|
||||
print("slot = ", watchpoint_hits[x].slot)
|
||||
print("condition = ", watchpoint_hits[x].condition)
|
||||
print("watchpoint_id = ", watchpoint_hits[x].watchpoint_id)
|
||||
for p, _ in enumerate(watchpoint_hits[x].parameters):
|
||||
print("parameter ", p, " name = ",
|
||||
watchpoint_hits[x].parameters[p].name)
|
||||
print("parameter ", p, " disabled = ",
|
||||
watchpoint_hits[x].parameters[p].disabled)
|
||||
print("parameter ", p, " value = ",
|
||||
watchpoint_hits[x].parameters[p].value)
|
||||
print("parameter ", p, " hit = ",
|
||||
watchpoint_hits[x].parameters[p].hit)
|
||||
print("parameter ", p, " actual_value = ",
|
||||
watchpoint_hits[x].parameters[p].actual_value)
|
||||
print("error code = ", watchpoint_hits[x].error_code)
|
||||
print("device_id = ", watchpoint_hits[x].device_id)
|
||||
print("root_graph_id = ", watchpoint_hits[x].root_graph_id)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,49 +0,0 @@
|
|||
python sync_trans_false_read_tensors.py > sync_trans_false_read_tensors.actual
|
||||
sed -i '/\[WARNING\]/d' sync_trans_false_read_tensors.actual
|
||||
sed -i '/Deprecated/d' sync_trans_false_read_tensors.actual
|
||||
diff sync_trans_false_read_tensors.actual sync_trans_false_read_tensors.expected
|
||||
if [ $? -eq 0 ]; then
|
||||
echo sync_trans_false_read_tensors PASSED
|
||||
else
|
||||
echo sync_trans_false_read_tensors FAILED
|
||||
fi
|
||||
|
||||
python sync_trans_true_read_tensors.py > sync_trans_true_read_tensors.actual
|
||||
sed -i '/\[WARNING\]/d' sync_trans_true_read_tensors.actual
|
||||
sed -i '/Deprecated/d' sync_trans_true_read_tensors.actual
|
||||
diff sync_trans_true_read_tensors.actual sync_trans_true_read_tensors.expected
|
||||
if [ $? -eq 0 ]; then
|
||||
echo sync_trans_true_read_tensors PASSED
|
||||
else
|
||||
echo sync_trans_true_read_tensors FAILED
|
||||
fi
|
||||
|
||||
python sync_trans_false_watchpoints.py > sync_trans_false_watchpoints.actual
|
||||
sed -i '/\[WARNING\]/d' sync_trans_false_watchpoints.actual
|
||||
sed -i '/Deprecated/d' sync_trans_false_watchpoints.actual
|
||||
diff sync_trans_false_watchpoints.actual sync_trans_false_watchpoints.expected
|
||||
if [ $? -eq 0 ]; then
|
||||
echo sync_trans_false_watchpoints PASSED
|
||||
else
|
||||
echo sync_trans_false_watchpoints FAILED
|
||||
fi
|
||||
|
||||
python async_sink_mode_true_read_tensors.py > async_sink_mode_true_read_tensors.actual
|
||||
sed -i '/\[WARNING\]/d' async_sink_mode_true_read_tensors.actual
|
||||
sed -i '/Deprecated/d' async_sink_mode_true_read_tensors.actual
|
||||
diff async_sink_mode_true_read_tensors.actual async_sink_mode_true_read_tensors.expected
|
||||
if [ $? -eq 0 ]; then
|
||||
echo async_sink_mode_true_read_tensors PASSED
|
||||
else
|
||||
echo async_sink_mode_true_read_tensors FAILED
|
||||
fi
|
||||
|
||||
python async_sink_mode_true_watchpoints.py > async_sink_mode_true_watchpoints.actual
|
||||
sed -i '/\[WARNING\]/d' async_sink_mode_true_watchpoints.actual
|
||||
sed -i '/Deprecated/d' async_sink_mode_true_watchpoints.actual
|
||||
diff async_sink_mode_true_watchpoints.actual async_sink_mode_true_watchpoints.expected
|
||||
if [ $? -eq 0 ]; then
|
||||
echo async_sink_mode_true_watchpoints PASSED
|
||||
else
|
||||
echo async_sink_mode_true_watchpoints FAILED
|
||||
fi
|
|
@ -1,70 +0,0 @@
|
|||
-----------------------------------------------------------
|
||||
tensor_info_1 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/conv2-Conv2d/conv2.bias
|
||||
slot = 0
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = True
|
||||
|
||||
tensor_data_1 attributes:
|
||||
data (printed in uint8) = [170 19 44 181 254 212 16 52 52 162 148 180 130 115 226 180 183 243
|
||||
101 52 224 79 189 51 10 70 69 51 199 75 159 52 79 98 104 52
|
||||
106 77 19 52 129 183 8 180 252 58 48 180 35 219 9 52 240 201
|
||||
179 51 142 151 158 51 210 145 182 53 140 219 0 53 140 219 22 181
|
||||
46 33 87 180 238 90 122 180 166 10 38 179 202 195 4 53 166 10
|
||||
150 51 214 120 209 52 235 115 37 180 92 177 215 180 0 136 84 51
|
||||
72 114 145 180 43 169 255 180 114 27 61 52 76 225 122 50 126 72
|
||||
159 51 58 35 202 51 114 61 106 51 60 223 63 52 209 179 1 52
|
||||
232 217 44 178 130 158 109 179 213 231 10 179 37 40 94 179 208 68
|
||||
64 53 6 52 249 52 162 35 1 181 231 29 155 52 30 201 69 180
|
||||
229 131 126 51 18 165 109 180 164 112 163 181 116 172 11 178 6 129
|
||||
37 52 54 205 203 180 115 104 145 52 232 106 219 179 36 40 214 52
|
||||
202 50 204 52 76 89 38 179 230 140 232 178 168 53 77 52 180 191
|
||||
108 51 128 183 64 51 56 137 161 180 247 6 143 180 126 63 197 180
|
||||
198 177 94 52 140 185 139 51 150 178 228 180 255 67 150 52 134 201
|
||||
164 52 107 43 14 53 174 216 63 179 40 160 41 53 120 88 72 179
|
||||
218 172 234 52 234 38 25 52 85 159 155 180 254 67 138 180 34 253
|
||||
118 180 218 61 17 52 242 133 253 52 175 37 180 52 171 62 163 52
|
||||
202 195 86 53 160 171 45 52 34 31 176 180 156 85 5 53 178 191
|
||||
68 180 42 203 140 52 248 117 72 52 248 253 212 176 195 100 202 51
|
||||
87 14 141 52 91 100 235 51 48 221 136 52 143 117 17 180 51 196
|
||||
25 52 127 29 112 180 152 144 207 178 219 104 64 52 21 174 251 52
|
||||
164 78 138 181 20 63 6 52 10 249 96 179 163 146 18 53 200 186
|
||||
236 52 2 188 85 52 124 140 121 179 246 185 22 181 246 74 249 51
|
||||
70 182 135 53 189 227 76 52 249 160 159 180 134 235 65 53 64 164
|
||||
255 51 224 156 41 53 142 117 69 181 247 151 101 53 185 175 35 52
|
||||
164 112 21 53 30 31 212 179 142 151 110 179 176 148 29 181 206 204
|
||||
88 53 116 215 214 180 172 173 216 51 106 222 153 180 200 152 19 181
|
||||
176 3 7 52 215 52 87 52]
|
||||
size in bytes = 512
|
||||
debugger dtype = 11
|
||||
shape = [128]
|
||||
-----------------------------------------------------------
|
||||
tensor_info_2 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op168
|
||||
slot = 0
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = False
|
||||
|
||||
tensor_data_2 attributes:
|
||||
data (printed in uint8) = [181 167 46 ... 12 204 164]
|
||||
size in bytes = 2076672
|
||||
debugger dtype = 10
|
||||
shape = [32, 12, 13, 13, 16]
|
||||
-----------------------------------------------------------
|
||||
tensor_info_3 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/ReLUV2-op346
|
||||
slot = 1
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = False
|
||||
|
||||
tensor_data_3 attributes:
|
||||
data (printed in uint8) = [ 50 17 122 ... 94 42 90]
|
||||
size in bytes = 129792
|
||||
debugger dtype = 6
|
||||
shape = [32, 12, 13, 13, 2]
|
|
@ -1,74 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
Read tensor test script for offline debugger APIs.
|
||||
"""
|
||||
|
||||
import mindspore.offline_debug.dbg_services as d
|
||||
import numpy as np
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
debugger_backend = d.DbgServices(
|
||||
dump_file_path="/opt/nvme2n1/j00455527/dumps/sync_trans_false/032421/alexnet")
|
||||
|
||||
_ = debugger_backend.initialize(
|
||||
net_name="Network Name goes here!", is_sync_mode=True)
|
||||
|
||||
# parameter
|
||||
info1 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/conv2-Conv2d/conv2.bias",
|
||||
slot=0, iteration=2, device_id=0, root_graph_id=0, is_parameter=True)
|
||||
# output tensor with zero slot
|
||||
info2 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op168",
|
||||
slot=0, iteration=2, device_id=0, root_graph_id=0, is_parameter=False)
|
||||
# output tensor with non-zero slot
|
||||
info3 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/ReLUV2-op346",
|
||||
slot=1, iteration=2, device_id=0, root_graph_id=0, is_parameter=False)
|
||||
|
||||
tensor_info = [info1, info2, info3]
|
||||
|
||||
tensor_data = debugger_backend.read_tensors(tensor_info)
|
||||
|
||||
print_read_tensors(tensor_info, tensor_data)
|
||||
|
||||
|
||||
def print_read_tensors(tensor_info, tensor_data):
|
||||
"""Print read tensors."""
|
||||
for x, _ in enumerate(tensor_info):
|
||||
print("-----------------------------------------------------------")
|
||||
print("tensor_info_" + str(x+1) + " attributes:")
|
||||
print("node name = ", tensor_info[x].node_name)
|
||||
print("slot = ", tensor_info[x].slot)
|
||||
print("iteration = ", tensor_info[x].iteration)
|
||||
print("device_id = ", tensor_info[x].device_id)
|
||||
print("root_graph_id = ", tensor_info[x].root_graph_id)
|
||||
print("is_parameter = ", tensor_info[x].is_parameter)
|
||||
print()
|
||||
print("tensor_data_" + str(x+1) + " attributes:")
|
||||
print("data (printed in uint8) = ", np.frombuffer(
|
||||
tensor_data[x].data_ptr, np.uint8, tensor_data[x].data_size))
|
||||
py_byte_size = len(tensor_data[x].data_ptr)
|
||||
c_byte_size = tensor_data[x].data_size
|
||||
if c_byte_size != py_byte_size:
|
||||
print("The python byte size of ", py_byte_size,
|
||||
" does not match the C++ byte size of ", c_byte_size)
|
||||
print("size in bytes = ", tensor_data[x].data_size)
|
||||
print("debugger dtype = ", tensor_data[x].dtype)
|
||||
print("shape = ", tensor_data[x].shape)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,33 +0,0 @@
|
|||
-----------------------------------------------------------
|
||||
watchpoint_hit for test_1 attributes:
|
||||
name = Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op168
|
||||
slot = 0
|
||||
condition = 6
|
||||
watchpoint_id = 1
|
||||
parameter 0 name = param
|
||||
parameter 0 disabled = False
|
||||
parameter 0 value = 0.0
|
||||
parameter 0 hit = True
|
||||
parameter 0 actual_value = -0.14013671875
|
||||
error code = 0
|
||||
device_id = 0
|
||||
root_graph_id = 0
|
||||
-----------------------------------------------------------
|
||||
watchpoint_hit for test_4 attributes:
|
||||
name = Default/network-WithLossCell/_backbone-AlexNet/fc3-Dense/Parameter[6]_11/fc3.bias
|
||||
slot = 0
|
||||
condition = 18
|
||||
watchpoint_id = 3
|
||||
parameter 0 name = abs_mean_update_ratio_gt
|
||||
parameter 0 disabled = False
|
||||
parameter 0 value = 0.0
|
||||
parameter 0 hit = True
|
||||
parameter 0 actual_value = 0.5243796973599475
|
||||
parameter 1 name = epsilon
|
||||
parameter 1 disabled = True
|
||||
parameter 1 value = 0.0
|
||||
parameter 1 hit = False
|
||||
parameter 1 actual_value = 0.0
|
||||
error code = 0
|
||||
device_id = 0
|
||||
root_graph_id = 0
|
|
@ -1,109 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
Watchpoints test script for offline debugger APIs.
|
||||
"""
|
||||
|
||||
import mindspore.offline_debug.dbg_services as d
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
debugger_backend = d.DbgServices(
|
||||
dump_file_path="/opt/nvme2n1/j00455527/dumps/sync_trans_false/032421/alexnet")
|
||||
|
||||
_ = debugger_backend.initialize(
|
||||
net_name="Network Name goes here!", is_sync_mode=True)
|
||||
|
||||
# NOTES:
|
||||
# -> watch_condition=6 is MIN_LT
|
||||
# -> watch_condition=18 is CHANGE_TOO_LARGE
|
||||
|
||||
# test 1: watchpoint set and hit (watch_condition=6)
|
||||
param1 = d.Parameter(name="param", disabled=False, value=0.0)
|
||||
_ = debugger_backend.add_watchpoint(watchpoint_id=1, watch_condition=6,
|
||||
check_node_list={"Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/"
|
||||
"Conv2D-op168":
|
||||
{"device_id": [0], "root_graph_id": [0], "is_parameter": False
|
||||
}}, parameter_list=[param1])
|
||||
|
||||
watchpoint_hits_test_1 = debugger_backend.check_watchpoints(iteration=2)
|
||||
if len(watchpoint_hits_test_1) != 1:
|
||||
print("ERROR -> test 1: watchpoint set but not hit just once")
|
||||
print_watchpoint_hits(watchpoint_hits_test_1, 1)
|
||||
|
||||
# test 2: watchpoint remove and ensure it's not hit
|
||||
_ = debugger_backend.remove_watchpoint(watchpoint_id=1)
|
||||
watchpoint_hits_test_2 = debugger_backend.check_watchpoints(iteration=2)
|
||||
if watchpoint_hits_test_2:
|
||||
print("ERROR -> test 2: watchpoint removed but hit")
|
||||
|
||||
# test 3: watchpoint set and not hit, then remove
|
||||
param2 = d.Parameter(name="param", disabled=False, value=-1000.0)
|
||||
_ = debugger_backend.add_watchpoint(watchpoint_id=2, watch_condition=6,
|
||||
check_node_list={"Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/"
|
||||
"Conv2D-op308":
|
||||
{"device_id": [0], "root_graph_id": [0], "is_parameter": False
|
||||
}}, parameter_list=[param2])
|
||||
|
||||
watchpoint_hits_test_3 = debugger_backend.check_watchpoints(iteration=2)
|
||||
if watchpoint_hits_test_3:
|
||||
print("ERROR -> test 3: watchpoint set but not supposed to be hit")
|
||||
_ = debugger_backend.remove_watchpoint(watchpoint_id=2)
|
||||
|
||||
# test 4: weight change watchpoint set and hit
|
||||
param_abs_mean_update_ratio_gt = d.Parameter(
|
||||
name="abs_mean_update_ratio_gt", disabled=False, value=0.0)
|
||||
param_epsilon = d.Parameter(name="epsilon", disabled=True, value=0.0)
|
||||
_ = debugger_backend.add_watchpoint(watchpoint_id=3, watch_condition=18,
|
||||
check_node_list={"Default/network-WithLossCell/_backbone-AlexNet/fc3-Dense/"
|
||||
"Parameter[6]_11/fc3.bias":
|
||||
{"device_id": [0], "root_graph_id": [0], "is_parameter": True
|
||||
}}, parameter_list=[param_abs_mean_update_ratio_gt,
|
||||
param_epsilon])
|
||||
|
||||
watchpoint_hits_test_4 = debugger_backend.check_watchpoints(iteration=3)
|
||||
if len(watchpoint_hits_test_4) != 1:
|
||||
print("ERROR -> test 4: watchpoint weight change set but not hit just once")
|
||||
print_watchpoint_hits(watchpoint_hits_test_4, 4)
|
||||
|
||||
|
||||
def print_watchpoint_hits(watchpoint_hits, test_id):
|
||||
"""Print watchpoint hits."""
|
||||
for x, _ in enumerate(watchpoint_hits):
|
||||
print("-----------------------------------------------------------")
|
||||
print("watchpoint_hit for test_%u attributes:" % test_id)
|
||||
print("name = ", watchpoint_hits[x].name)
|
||||
print("slot = ", watchpoint_hits[x].slot)
|
||||
print("condition = ", watchpoint_hits[x].condition)
|
||||
print("watchpoint_id = ", watchpoint_hits[x].watchpoint_id)
|
||||
for p, _ in enumerate(watchpoint_hits[x].parameters):
|
||||
print("parameter ", p, " name = ",
|
||||
watchpoint_hits[x].parameters[p].name)
|
||||
print("parameter ", p, " disabled = ",
|
||||
watchpoint_hits[x].parameters[p].disabled)
|
||||
print("parameter ", p, " value = ",
|
||||
watchpoint_hits[x].parameters[p].value)
|
||||
print("parameter ", p, " hit = ",
|
||||
watchpoint_hits[x].parameters[p].hit)
|
||||
print("parameter ", p, " actual_value = ",
|
||||
watchpoint_hits[x].parameters[p].actual_value)
|
||||
print("error code = ", watchpoint_hits[x].error_code)
|
||||
print("device_id = ", watchpoint_hits[x].device_id)
|
||||
print("root_graph_id = ", watchpoint_hits[x].root_graph_id)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,70 +0,0 @@
|
|||
-----------------------------------------------------------
|
||||
tensor_info_1 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/conv2-Conv2d/conv2.bias
|
||||
slot = 0
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = True
|
||||
|
||||
tensor_data_1 attributes:
|
||||
data (printed in uint8) = [230 208 10 52 104 34 252 52 4 231 144 52 188 150 64 180 88 236
|
||||
15 180 254 135 180 51 131 226 147 52 88 202 62 53 2 43 55 53
|
||||
231 29 87 180 220 249 30 180 157 17 177 180 81 107 140 181 8 95
|
||||
192 180 89 134 112 180 96 238 90 178 156 196 212 180 206 25 15 181
|
||||
212 154 6 180 91 211 116 52 191 14 140 51 128 106 124 53 28 158
|
||||
70 181 182 21 251 50 100 204 157 179 88 202 42 180 7 95 8 53
|
||||
128 251 238 52 241 133 241 52 111 86 157 179 48 221 148 180 200 7
|
||||
141 180 236 226 182 51 190 82 158 180 140 108 179 180 195 134 215 179
|
||||
103 213 39 179 89 168 149 180 42 58 58 180 64 53 62 179 250 126
|
||||
158 52 38 83 117 52 0 0 136 180 136 133 122 51 110 18 131 179
|
||||
238 13 94 51 102 136 15 181 134 90 227 180 16 11 117 180 35 74
|
||||
163 52 105 0 87 181 112 18 131 50 226 233 67 181 217 172 10 52
|
||||
206 25 217 52 208 213 22 52 146 203 87 180 74 46 207 52 178 191
|
||||
4 180 100 93 216 52 119 190 171 180 223 2 5 181 128 72 207 179
|
||||
58 146 11 179 224 79 137 52 143 228 154 180 246 219 215 179 14 79
|
||||
195 52 126 29 64 52 132 192 42 51 94 220 86 52 94 109 1 181
|
||||
72 37 117 178 110 197 94 180 160 94 153 179 118 224 80 181 156 17
|
||||
37 50 120 156 162 53 26 115 135 180 228 20 29 53 145 126 147 52
|
||||
99 16 48 180 211 188 199 180 52 51 99 180 93 254 227 52 152 126
|
||||
123 49 6 18 16 181 5 163 130 51 27 158 98 53 134 235 189 52
|
||||
119 45 9 180 130 115 110 52 158 128 162 52 232 251 197 180 178 46
|
||||
158 179 57 214 157 52 172 207 161 180 208 0 222 49 242 99 32 53
|
||||
20 174 135 50 247 117 176 52 194 57 43 180 140 108 135 51 243 65
|
||||
175 51 187 73 156 51 63 232 217 50 180 234 115 52 194 168 148 52
|
||||
27 192 183 180 45 178 157 52 125 208 17 53 236 192 65 53 190 193
|
||||
7 53 254 246 57 53 3 43 199 51 64 164 215 180 220 104 240 51
|
||||
23 72 24 180 68 173 9 51 72 114 29 53 105 0 57 181 188 150
|
||||
8 53 229 97 131 53 0 34 189 51 163 146 74 53 31 244 204 51
|
||||
86 193 220 180 156 51 146 179]
|
||||
size in bytes = 512
|
||||
debugger dtype = 11
|
||||
shape = [128]
|
||||
-----------------------------------------------------------
|
||||
tensor_info_2 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op171
|
||||
slot = 0
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = False
|
||||
|
||||
tensor_data_2 attributes:
|
||||
data (printed in uint8) = [ 99 26 69 ... 154 218 164]
|
||||
size in bytes = 2076672
|
||||
debugger dtype = 10
|
||||
shape = [32, 192, 13, 13]
|
||||
-----------------------------------------------------------
|
||||
tensor_info_3 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/ReLUV2-op353
|
||||
slot = 1
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = False
|
||||
|
||||
tensor_data_3 attributes:
|
||||
data (printed in uint8) = [19 17 27 ... 94 42 90]
|
||||
size in bytes = 129792
|
||||
debugger dtype = 6
|
||||
shape = [32, 12, 13, 13, 2]
|
|
@ -1,74 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
Read tensor test script for offline debugger APIs.
|
||||
"""
|
||||
|
||||
import mindspore.offline_debug.dbg_services as d
|
||||
import numpy as np
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
debugger_backend = d.DbgServices(
|
||||
dump_file_path="/opt/nvme2n1/j00455527/dumps/sync_trans_true/032421/alexnet")
|
||||
|
||||
_ = debugger_backend.initialize(
|
||||
net_name="Network Name goes here!", is_sync_mode=True)
|
||||
|
||||
# parameter
|
||||
info1 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/conv2-Conv2d/conv2.bias",
|
||||
slot=0, iteration=2, device_id=0, root_graph_id=0, is_parameter=True)
|
||||
# output tensor with zero slot
|
||||
info2 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op171",
|
||||
slot=0, iteration=2, device_id=0, root_graph_id=0, is_parameter=False)
|
||||
# output tensor with non-zero slot
|
||||
info3 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/ReLUV2-op353",
|
||||
slot=1, iteration=2, device_id=0, root_graph_id=0, is_parameter=False)
|
||||
|
||||
tensor_info = [info1, info2, info3]
|
||||
|
||||
tensor_data = debugger_backend.read_tensors(tensor_info)
|
||||
|
||||
print_read_tensors(tensor_info, tensor_data)
|
||||
|
||||
|
||||
def print_read_tensors(tensor_info, tensor_data):
|
||||
"""Print read tensors."""
|
||||
for x, _ in enumerate(tensor_info):
|
||||
print("-----------------------------------------------------------")
|
||||
print("tensor_info_" + str(x+1) + " attributes:")
|
||||
print("node name = ", tensor_info[x].node_name)
|
||||
print("slot = ", tensor_info[x].slot)
|
||||
print("iteration = ", tensor_info[x].iteration)
|
||||
print("device_id = ", tensor_info[x].device_id)
|
||||
print("root_graph_id = ", tensor_info[x].root_graph_id)
|
||||
print("is_parameter = ", tensor_info[x].is_parameter)
|
||||
print()
|
||||
print("tensor_data_" + str(x+1) + " attributes:")
|
||||
print("data (printed in uint8) = ", np.frombuffer(
|
||||
tensor_data[x].data_ptr, np.uint8, tensor_data[x].data_size))
|
||||
py_byte_size = len(tensor_data[x].data_ptr)
|
||||
c_byte_size = tensor_data[x].data_size
|
||||
if c_byte_size != py_byte_size:
|
||||
print("The python byte size of ", py_byte_size,
|
||||
" does not match the C++ byte size of ", c_byte_size)
|
||||
print("size in bytes = ", tensor_data[x].data_size)
|
||||
print("debugger dtype = ", tensor_data[x].dtype)
|
||||
print("shape = ", tensor_data[x].shape)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,865 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
The module DbgServices provides offline debugger APIs.
|
||||
"""
|
||||
|
||||
import mindspore._mindspore_offline_debug as cds
|
||||
from mi_validators import check_init, check_initialize, check_add_watchpoint, check_remove_watchpoint, check_check_watchpoints, check_read_tensors, check_initialize_done, check_tensor_info_init, check_tensor_data_init, check_watchpoint_hit_init, check_parameter_init
|
||||
|
||||
|
||||
def get_version():
|
||||
"""
|
||||
Function to return offline Debug Services version.
|
||||
|
||||
Returns:
|
||||
version (str): dbgServices version.
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> version = dbg_services.get_version()
|
||||
"""
|
||||
return cds.DbgServices(False).GetVersion()
|
||||
|
||||
class DbgLogger:
|
||||
"""
|
||||
Offline Debug Services Logger
|
||||
|
||||
Args:
|
||||
verbose (bool): whether to print logs.
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> version = dbg_services.DbgLogger(verbose=False)
|
||||
"""
|
||||
def __init__(self, verbose):
|
||||
self.verbose = verbose
|
||||
|
||||
def __call__(self, *logs):
|
||||
if self.verbose:
|
||||
print(logs)
|
||||
|
||||
|
||||
log = DbgLogger(False)
|
||||
|
||||
|
||||
class DbgServices():
|
||||
"""
|
||||
Offline Debug Services class.
|
||||
|
||||
Args:
|
||||
dump_file_path (str): directory where the dump files are saved.
|
||||
verbose (bool): whether to print logs (default: False)..
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> d = dbg_services.DbgServices(dump_file_path="dump_file_path",
|
||||
>>> verbose=True)
|
||||
"""
|
||||
|
||||
@check_init
|
||||
def __init__(self, dump_file_path, verbose=False):
|
||||
log.verbose = verbose
|
||||
log("in Python __init__, file path is ", dump_file_path)
|
||||
self.dump_file_path = dump_file_path
|
||||
self.dbg_instance = cds.DbgServices(verbose)
|
||||
self.version = self.dbg_instance.GetVersion()
|
||||
self.verbose = verbose
|
||||
self.initialized = False
|
||||
|
||||
@check_initialize
|
||||
def initialize(self, net_name, is_sync_mode=True):
|
||||
"""
|
||||
Initialize Debug Service.
|
||||
|
||||
Args:
|
||||
net_name (str): Network name.
|
||||
is_sync_mode (bool): Whether to process synchronous or asynchronous dump files mode
|
||||
(default: True (synchronous)).
|
||||
|
||||
Returns:
|
||||
Initialized Debug Service instance.
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> d = dbg_services.DbgServices(dump_file_path="dump_file_path",
|
||||
>>> verbose=True)
|
||||
>>> d_init = d.initialize(net_name="network name", is_sync_mode=True)
|
||||
"""
|
||||
|
||||
log("in Python Initialize dump_file_path ", self.dump_file_path)
|
||||
self.initialized = True
|
||||
return self.dbg_instance.Initialize(net_name, self.dump_file_path, is_sync_mode)
|
||||
|
||||
@check_initialize_done
|
||||
@check_add_watchpoint
|
||||
def add_watchpoint(self, watchpoint_id, watch_condition, check_node_list, parameter_list):
|
||||
"""
|
||||
Adding watchpoint to Debug Service instance.
|
||||
|
||||
Args:
|
||||
watchpoint_id (int): Watchpoint id
|
||||
watch_condition (int): A representation of the condition to be checked.
|
||||
check_node_list (dict): Dictionary of node names (str) as key,
|
||||
mapping to device_id (list of ints), root_graph_id (list of ints) and is_parameter
|
||||
(bool).
|
||||
parameter_list (list): List of parameters in watchpoint. Parameters should be instances of Parameter class.
|
||||
Each parameter describes the value to be checked in watchpoint.
|
||||
|
||||
Returns:
|
||||
Debug Service instance with added watchpoint.
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> d = dbg_services.DbgServices(dump_file_path="dump_file_path",
|
||||
>>> verbose=True)
|
||||
>>> d_init = d.initialize(is_sync_mode=True)
|
||||
>>> d_wp = d_init.add_watchpoint(watchpoint_id=1,
|
||||
>>> watch_condition=6,
|
||||
>>> check_node_list={"conv2.bias" : {"device_id": [0],
|
||||
root_graph_id: [0], "is_parameter": True}},
|
||||
>>> parameter_list=[dbg_services.Parameter(name="param",
|
||||
>>> disabled=False,
|
||||
>>> value=0.0,
|
||||
>>> hit=False,
|
||||
>>> actual_value=0.0)])
|
||||
"""
|
||||
|
||||
print("Amir: ", check_node_list)
|
||||
|
||||
log("in Python AddWatchpoint")
|
||||
parameter_list_inst = []
|
||||
for elem in parameter_list:
|
||||
parameter_list_inst.append(elem.instance)
|
||||
return self.dbg_instance.AddWatchpoint(watchpoint_id, watch_condition, check_node_list, parameter_list_inst)
|
||||
|
||||
@check_initialize_done
|
||||
@check_remove_watchpoint
|
||||
def remove_watchpoint(self, watchpoint_id):
|
||||
"""
|
||||
Removing watchpoint from Debug Service instance.
|
||||
|
||||
Args:
|
||||
watchpoint_id (int): Watchpoint id
|
||||
|
||||
Returns:
|
||||
Debug Service instance with removed watchpoint.
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> d = dbg_services.DbgServices(dump_file_path="dump_file_path",
|
||||
>>> verbose=True)
|
||||
>>> d_init = d.initialize(is_sync_mode=True)
|
||||
>>> d_wp = d_init.add_watchpoint(watchpoint_id=1,
|
||||
>>> watch_condition=6,
|
||||
>>> check_node_list={"conv2.bias" : {"device_id": [5],
|
||||
root_graph_id: [0], "is_parameter": True}},
|
||||
>>> parameter_list=[dbg_services.Parameter(name="param",
|
||||
>>> disabled=False,
|
||||
>>> value=0.0,
|
||||
>>> hit=False,
|
||||
>>> actual_value=0.0)])
|
||||
>>> d_wp = d_wp.remove_watchpoint(watchpoint_id=1)
|
||||
"""
|
||||
|
||||
log("in Python Remove Watchpoint id ", watchpoint_id)
|
||||
return self.dbg_instance.RemoveWatchpoint(watchpoint_id)
|
||||
|
||||
@check_initialize_done
|
||||
@check_check_watchpoints
|
||||
def check_watchpoints(self, iteration):
|
||||
"""
|
||||
Checking watchpoint at given iteration.
|
||||
|
||||
Args:
|
||||
iteration (int): Watchpoint check iteration.
|
||||
|
||||
Returns:
|
||||
Watchpoint hit list.
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> d = dbg_services.DbgServices(dump_file_path="dump_file_path",
|
||||
>>> verbose=True)
|
||||
>>> d_init = d.initialize(is_sync_mode=True)
|
||||
>>> d_wp = d_init.add_watchpoint(id=1,
|
||||
>>> watch_condition=6,
|
||||
>>> check_node_list={"conv2.bias" : {"device_id": [5],
|
||||
root_graph_id: [0], "is_parameter": True}},
|
||||
>>> parameter_list=[dbg_services.Parameter(name="param",
|
||||
>>> disabled=False,
|
||||
>>> value=0.0,
|
||||
>>> hit=False,
|
||||
>>> actual_value=0.0)])
|
||||
>>> watchpoints = d_wp.check_watchpoints(iteration=8)
|
||||
"""
|
||||
|
||||
log("in Python CheckWatchpoints iteration ", iteration)
|
||||
watchpoint_list = self.dbg_instance.CheckWatchpoints(iteration)
|
||||
watchpoint_hit_list = []
|
||||
for watchpoint in watchpoint_list:
|
||||
name = watchpoint.get_name()
|
||||
slot = watchpoint.get_slot()
|
||||
condition = watchpoint.get_condition()
|
||||
watchpoint_id = watchpoint.get_watchpoint_id()
|
||||
parameters = watchpoint.get_parameters()
|
||||
error_code = watchpoint.get_error_code()
|
||||
device_id = watchpoint.get_device_id()
|
||||
root_graph_id = watchpoint.get_root_graph_id()
|
||||
param_list = []
|
||||
for param in parameters:
|
||||
p_name = param.get_name()
|
||||
disabled = param.get_disabled()
|
||||
value = param.get_value()
|
||||
hit = param.get_hit()
|
||||
actual_value = param.get_actual_value()
|
||||
param_list.append(Parameter(p_name, disabled, value, hit, actual_value))
|
||||
watchpoint_hit_list.append(WatchpointHit(name, slot, condition, watchpoint_id,
|
||||
param_list, error_code, device_id, root_graph_id))
|
||||
return watchpoint_hit_list
|
||||
|
||||
@check_initialize_done
|
||||
@check_read_tensors
|
||||
def read_tensors(self, info):
|
||||
"""
|
||||
Returning tensor data object describing the tensor requested tensor.
|
||||
|
||||
Args:
|
||||
info (list): List of TensorInfo objects.
|
||||
|
||||
Returns:
|
||||
TensorData list (list).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> d = dbg_services.DbgServices(dump_file_path="dump_file_path",
|
||||
>>> verbose=True)
|
||||
>>> d_init = d.initialize(is_sync_mode=True)
|
||||
>>> tensor_data_list = d_init.read_tensors([dbg_services.TensorInfo(node_name="conv2.bias",
|
||||
>>> slot=0,
|
||||
>>> iteration=8,
|
||||
>>> device_id=5,
|
||||
>>> root_graph_id=0,
|
||||
>>> is_parameter=True)])
|
||||
"""
|
||||
|
||||
log("in Python ReadTensors info ", info)
|
||||
info_list_inst = []
|
||||
for elem in info:
|
||||
log("in Python ReadTensors info ", info)
|
||||
info_list_inst.append(elem.instance)
|
||||
tensor_data_list = self.dbg_instance.ReadTensors(info_list_inst)
|
||||
tensor_data_list_ret = []
|
||||
for elem in tensor_data_list:
|
||||
if elem.get_data_size() == 0:
|
||||
tensor_data = TensorData(b'', elem.get_data_size(), elem.get_dtype(), elem.get_shape())
|
||||
else:
|
||||
tensor_data = TensorData(elem.get_data_ptr(), elem.get_data_size(), elem.get_dtype(), elem.get_shape())
|
||||
tensor_data_list_ret.append(tensor_data)
|
||||
return tensor_data_list_ret
|
||||
|
||||
class TensorInfo():
|
||||
"""
|
||||
Tensor Information class.
|
||||
|
||||
Args:
|
||||
node_name (str): Fully qualified name of the desired node.
|
||||
slot (int): The particular output for the requested node.
|
||||
iteration (int): The desired itraretion to gather tensor information.
|
||||
device_id (int): The desired device id to gather tensor information.
|
||||
is_parameter (bool): Whether node is a parameter (input, constant, bias, parameter).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_info = dbg_services.TensorInfo(node_name="conv2.bias",
|
||||
>>> slot=0,
|
||||
>>> iteration=8,
|
||||
>>> device_id=5,
|
||||
>>> root_graph_id=0,
|
||||
>>> is_parameter=True)
|
||||
"""
|
||||
|
||||
@check_tensor_info_init
|
||||
def __init__(self, node_name, slot, iteration, device_id, root_graph_id, is_parameter):
|
||||
self.instance = cds.tensor_info(node_name, slot, iteration, device_id, root_graph_id, is_parameter)
|
||||
|
||||
@property
|
||||
def node_name(self):
|
||||
"""
|
||||
Function to receive TensorInfo node_name.
|
||||
|
||||
Returns:
|
||||
node_name of TensorInfo instance (str).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_info = dbg_services.TensorInfo(node_name="conv2.bias",
|
||||
>>> slot=0,
|
||||
>>> iteration=8,
|
||||
>>> device_id=5,
|
||||
>>> root_graph_id=0,
|
||||
>>> is_parameter=True)
|
||||
>>> name = tensor_info.node_name
|
||||
"""
|
||||
|
||||
return self.instance.get_node_name()
|
||||
|
||||
@property
|
||||
def slot(self):
|
||||
"""
|
||||
Function to receive TensorInfo slot.
|
||||
|
||||
Returns:
|
||||
slot of TensorInfo instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_info = dbg_services.TensorInfo(node_name="conv2.bias",
|
||||
>>> slot=0,
|
||||
>>> iteration=8,
|
||||
>>> device_id=5,
|
||||
>>> root_graph_id=0,
|
||||
>>> is_parameter=True)
|
||||
>>> slot = tensor_info.slot
|
||||
"""
|
||||
|
||||
return self.instance.get_slot()
|
||||
|
||||
@property
|
||||
def iteration(self):
|
||||
"""
|
||||
Function to receive TensorInfo iteration.
|
||||
|
||||
Returns:
|
||||
iteration of TensorInfo instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_info = dbg_services.TensorInfo(node_name="conv2.bias",
|
||||
>>> slot=0,
|
||||
>>> iteration=8,
|
||||
>>> device_id=5,
|
||||
>>> root_graph_id=0,
|
||||
>>> is_parameter=True)
|
||||
>>> iteration = tensor_info.iteration
|
||||
"""
|
||||
|
||||
return self.instance.get_iteration()
|
||||
|
||||
@property
|
||||
def device_id(self):
|
||||
"""
|
||||
Function to receive TensorInfo device_id.
|
||||
|
||||
Returns:
|
||||
device_id of TensorInfo instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_info = dbg_services.TensorInfo(node_name="conv2.bias",
|
||||
>>> slot=0,
|
||||
>>> iteration=8,
|
||||
>>> device_id=5,
|
||||
>>> root_graph_id=0,
|
||||
>>> is_parameter=True)
|
||||
>>> device_id = tensor_info.device_id
|
||||
"""
|
||||
|
||||
@property
|
||||
def root_graph_id(self):
|
||||
"""
|
||||
Function to receive TensorInfo root_graph_id.
|
||||
|
||||
Returns:
|
||||
root_graph_id of TensorInfo instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_info = dbg_services.TensorInfo(node_name="conv2.bias",
|
||||
>>> slot=0,
|
||||
>>> iteration=8,
|
||||
>>> device_id=5,
|
||||
>>> root_graph_id=0,
|
||||
>>> is_parameter=True)
|
||||
>>> device_id = tensor_info.root_graph_id
|
||||
"""
|
||||
|
||||
return self.instance.get_root_graph_id()
|
||||
|
||||
@property
|
||||
def is_parameter(self):
|
||||
"""
|
||||
Function to receive TensorInfo is_parameter.
|
||||
|
||||
Returns:
|
||||
is_parameter of TensorInfo instance (bool).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_info = dbg_services.TensorInfo(node_name="conv2.bias",
|
||||
>>> slot=0,
|
||||
>>> iteration=8,
|
||||
>>> device_id=5,
|
||||
>>> root_graph_id=0,
|
||||
>>> is_parameter=True)
|
||||
>>> is_parameter = tensor_info.is_parameter
|
||||
"""
|
||||
|
||||
return self.instance.get_is_parameter()
|
||||
|
||||
class TensorData():
|
||||
"""
|
||||
TensorData class.
|
||||
|
||||
Args:
|
||||
data_ptr (byte): Data pointer.
|
||||
data_size (int): Size of data in bytes.
|
||||
dtype (int): An encoding representing the type of TensorData.
|
||||
shape (list): Shape of tensor.
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_data = dbg_services.TensorData(data_ptr=b'\xba\xd0\xba\xd0',
|
||||
>>> data_size=4,
|
||||
>>> dtype=0,
|
||||
>>> shape=[2, 2])
|
||||
"""
|
||||
|
||||
@check_tensor_data_init
|
||||
def __init__(self, data_ptr, data_size, dtype, shape):
|
||||
self.instance = cds.tensor_data(data_ptr, data_size, dtype, shape)
|
||||
|
||||
@property
|
||||
def data_ptr(self):
|
||||
"""
|
||||
Function to receive TensorData data_ptr.
|
||||
|
||||
Returns:
|
||||
data_ptr of TensorData instance (byte).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_data = dbg_services.TensorData(data_ptr=b'\xba\xd0\xba\xd0',
|
||||
>>> data_size=4,
|
||||
>>> dtype=0,
|
||||
>>> shape=[2, 2])
|
||||
>>> data_ptr = tensor_data.data_ptr
|
||||
"""
|
||||
|
||||
return self.instance.get_data_ptr()
|
||||
|
||||
@property
|
||||
def data_size(self):
|
||||
"""
|
||||
Function to receive TensorData data_size.
|
||||
|
||||
Returns:
|
||||
data_size of TensorData instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_data = dbg_services.TensorData(data_ptr=b'\xba\xd0\xba\xd0',
|
||||
>>> data_size=4,
|
||||
>>> dtype=0,
|
||||
>>> shape=[2, 2])
|
||||
>>> data_size = tensor_data.data_size
|
||||
"""
|
||||
|
||||
return self.instance.get_data_size()
|
||||
|
||||
@property
|
||||
def dtype(self):
|
||||
"""
|
||||
Function to receive TensorData dtype.
|
||||
|
||||
Returns:
|
||||
dtype of TensorData instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_data = dbg_services.TensorData(data_ptr=b'\xba\xd0\xba\xd0',
|
||||
>>> data_size=4,
|
||||
>>> dtype=0,
|
||||
>>> shape=[2, 2])
|
||||
>>> dtype = tensor_data.dtype
|
||||
"""
|
||||
|
||||
return self.instance.get_dtype()
|
||||
|
||||
@property
|
||||
def shape(self):
|
||||
"""
|
||||
Function to receive TensorData shape.
|
||||
|
||||
Returns:
|
||||
shape of TensorData instance (list).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> tensor_data = dbg_services.TensorData(data_ptr=b'\xba\xd0\xba\xd0',
|
||||
>>> data_size=4,
|
||||
>>> dtype=0,
|
||||
>>> shape=[2, 2])
|
||||
>>> shape = tensor_data.shape
|
||||
"""
|
||||
|
||||
return self.instance.get_shape()
|
||||
|
||||
class WatchpointHit():
|
||||
"""
|
||||
WatchpointHit class.
|
||||
|
||||
Args:
|
||||
name (str): Name of WatchpointHit instance.
|
||||
slot (int): The numerical label of an output.
|
||||
condition (int): A representation of the condition to be checked.
|
||||
watchpoint_id (int): Watchpoint id.
|
||||
parameters (list): A list of all parameters for WatchpointHit instance.
|
||||
Parameters have to be instances of Parameter class.
|
||||
error_code (int): An explanation of certain scenarios where watchpoint could not be checked.
|
||||
device_id (int): Device id where the watchpoint is hit.
|
||||
root_graph_id (int): Root graph id where the watchpoint is hit.
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> watchpoint_hit = dbg_services.WatchpointHit(name="hit1",
|
||||
>>> slot=1,
|
||||
>>> condition=2,
|
||||
>>> watchpoint_id=3,
|
||||
>>> parameters=[param1, param2],
|
||||
>>> error_code=0,
|
||||
>>> device_id=1,
|
||||
>>> root_graph_id=1)
|
||||
"""
|
||||
|
||||
@check_watchpoint_hit_init
|
||||
def __init__(self, name, slot, condition, watchpoint_id, parameters, error_code, device_id, root_graph_id):
|
||||
parameter_list_inst = []
|
||||
for elem in parameters:
|
||||
parameter_list_inst.append(elem.instance)
|
||||
self.instance = cds.watchpoint_hit(name, slot, condition, watchpoint_id,
|
||||
parameter_list_inst, error_code, device_id, root_graph_id)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
Function to receive WatchpointHit name.
|
||||
|
||||
Returns:
|
||||
name of WatchpointHit instance (str).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> watchpoint_hit = dbg_services.WatchpointHit(name="hit1",
|
||||
>>> slot=1,
|
||||
>>> condition=2,
|
||||
>>> watchpoint_id=3,
|
||||
>>> parameters=[param1, param2],
|
||||
>>> error_code=0,
|
||||
>>> device_id=1,
|
||||
>>> root_graph_id=1)
|
||||
>>> name = watchpoint_hit.name
|
||||
"""
|
||||
|
||||
return self.instance.get_name()
|
||||
|
||||
@property
|
||||
def slot(self):
|
||||
"""
|
||||
Function to receive WatchpointHit slot.
|
||||
|
||||
Returns:
|
||||
slot of WatchpointHit instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> watchpoint_hit = dbg_services.WatchpointHit(name="hit1",
|
||||
>>> slot=1,
|
||||
>>> condition=2,
|
||||
>>> watchpoint_id=3,
|
||||
>>> parameters=[param1, param2],
|
||||
>>> error_code=0,
|
||||
>>> device_id=1,
|
||||
>>> root_graph_id=1)
|
||||
>>> slot = watchpoint_hit.slot
|
||||
"""
|
||||
|
||||
return self.instance.get_slot()
|
||||
|
||||
@property
|
||||
def condition(self):
|
||||
"""
|
||||
Function to receive WatchpointHit condition.
|
||||
|
||||
Returns:
|
||||
condition of WatchpointHit instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> watchpoint_hit = dbg_services.WatchpointHit(name="hit1",
|
||||
>>> slot=1,
|
||||
>>> condition=2,
|
||||
>>> watchpoint_id=3,
|
||||
>>> parameters=[param1, param2],
|
||||
>>> error_code=0,
|
||||
>>> device_id=1,
|
||||
>>> root_graph_id=1)
|
||||
>>> condition = watchpoint_hit.condition
|
||||
"""
|
||||
|
||||
return self.instance.get_condition()
|
||||
|
||||
@property
|
||||
def watchpoint_id(self):
|
||||
"""
|
||||
Function to receive WatchpointHit watchpoint_id.
|
||||
|
||||
Returns:
|
||||
watchpoint_id of WatchpointHit instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> watchpoint_hit = dbg_services.WatchpointHit(name="hit1",
|
||||
>>> slot=1,
|
||||
>>> condition=2,
|
||||
>>> watchpoint_id=3,
|
||||
>>> parameters=[param1, param2],
|
||||
>>> error_code=0,
|
||||
>>> device_id=1,
|
||||
>>> root_graph_id=1)
|
||||
>>> watchpoint_id = watchpoint_hit.watchpoint_id
|
||||
"""
|
||||
|
||||
return self.instance.get_watchpoint_id()
|
||||
|
||||
@property
|
||||
def parameters(self):
|
||||
"""
|
||||
Function to receive WatchpointHit parameters.
|
||||
|
||||
Returns:
|
||||
List of parameters of WatchpointHit instance (list).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> watchpoint_hit = dbg_services.WatchpointHit(name="hit1",
|
||||
>>> slot=1,
|
||||
>>> condition=2,
|
||||
>>> watchpoint_id=3,
|
||||
>>> parameters=[param1, param2],
|
||||
>>> error_code=0,
|
||||
>>> device_id=1,
|
||||
>>> root_graph_id=1)
|
||||
>>> parameters = watchpoint_hit.parameters
|
||||
"""
|
||||
|
||||
params = self.instance.get_parameters()
|
||||
param_list = []
|
||||
for elem in params:
|
||||
tmp = Parameter(elem.get_name(),
|
||||
elem.get_disabled(),
|
||||
elem.get_value(),
|
||||
elem.get_hit(),
|
||||
elem.get_actual_value())
|
||||
param_list.append(tmp)
|
||||
return param_list
|
||||
|
||||
@property
|
||||
def error_code(self):
|
||||
"""
|
||||
Function to receive WatchpointHit error_code.
|
||||
|
||||
Returns:
|
||||
error_code of WatchpointHit instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> watchpoint_hit = dbg_services.WatchpointHit(name="hit1",
|
||||
>>> slot=1,
|
||||
>>> condition=2,
|
||||
>>> watchpoint_id=3,
|
||||
>>> parameters=[param1, param2],
|
||||
>>> error_code=0,
|
||||
>>> device_id=1,
|
||||
>>> root_graph_id=1)
|
||||
>>> error_code = watchpoint_hit.error_code
|
||||
"""
|
||||
|
||||
return self.instance.get_error_code()
|
||||
|
||||
@property
|
||||
def device_id(self):
|
||||
"""
|
||||
Function to receive WatchpointHit device_id.
|
||||
|
||||
Returns:
|
||||
device_id of WatchpointHit instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> watchpoint_hit = dbg_services.WatchpointHit(name="hit1",
|
||||
>>> slot=1,
|
||||
>>> condition=2,
|
||||
>>> watchpoint_id=3,
|
||||
>>> parameters=[param1, param2],
|
||||
>>> error_code=0,
|
||||
>>> device_id=1,
|
||||
>>> root_graph_id=1)
|
||||
>>> device_id = watchpoint_hit.device_id
|
||||
"""
|
||||
|
||||
return self.instance.get_device_id()
|
||||
|
||||
@property
|
||||
def root_graph_id(self):
|
||||
"""
|
||||
Function to receive WatchpointHit root_graph_id.
|
||||
|
||||
Returns:
|
||||
root_graph_id of WatchpointHit instance (int).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> watchpoint_hit = dbg_services.WatchpointHit(name="hit1",
|
||||
>>> slot=1,
|
||||
>>> condition=2,
|
||||
>>> watchpoint_id=3,
|
||||
>>> parameters=[param1, param2],
|
||||
>>> error_code=0,
|
||||
>>> device_id=1,
|
||||
>>> root_graph_id=1)
|
||||
>>> root_graph_id = watchpoint_hit.root_graph_id
|
||||
"""
|
||||
|
||||
return self.instance.get_root_graph_id()
|
||||
|
||||
class Parameter():
|
||||
"""
|
||||
Parameter class.
|
||||
|
||||
Args:
|
||||
name (str): Name of the parameter.
|
||||
disabled (bool): Whether parameter is used in backend.
|
||||
value (float): Threshold value of the parameter.
|
||||
hit (bool): Whether this parameter triggered watchpoint (default is False).
|
||||
actual_value (float): Actual value of the parameter (default is 0.0).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> parameter = dbg_services.Parameter(name="param",
|
||||
>>> disabled=False,
|
||||
>>> value=0.0,
|
||||
>>> hit=False,
|
||||
>>> actual_value=0.0)
|
||||
"""
|
||||
|
||||
@check_parameter_init
|
||||
def __init__(self, name, disabled, value, hit=False, actual_value=0.0):
|
||||
self.instance = cds.parameter(name, disabled, value, hit, actual_value)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""
|
||||
Function to receive Parameter name.
|
||||
|
||||
Returns:
|
||||
name of Parameter instance (str).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> parameter = dbg_services.Parameter(name="param",
|
||||
>>> disabled=False,
|
||||
>>> value=0.0,
|
||||
>>> hit=False,
|
||||
>>> name = watchpoint_hit.name
|
||||
"""
|
||||
|
||||
return self.instance.get_name()
|
||||
|
||||
@property
|
||||
def disabled(self):
|
||||
"""
|
||||
Function to receive Parameter disabled value.
|
||||
|
||||
Returns:
|
||||
disabled of Parameter instance (bool).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> parameter = dbg_services.Parameter(name="param",
|
||||
>>> disabled=False,
|
||||
>>> value=0.0,
|
||||
>>> hit=False,
|
||||
>>> disabled = watchpoint_hit.disabled
|
||||
"""
|
||||
|
||||
return self.instance.get_disabled()
|
||||
|
||||
@property
|
||||
def value(self):
|
||||
"""
|
||||
Function to receive Parameter value.
|
||||
|
||||
Returns:
|
||||
value of Parameter instance (float).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> parameter = dbg_services.Parameter(name="param",
|
||||
>>> disabled=False,
|
||||
>>> value=0.0,
|
||||
>>> hit=False,
|
||||
>>> value = watchpoint_hit.value
|
||||
"""
|
||||
|
||||
return self.instance.get_value()
|
||||
|
||||
@property
|
||||
def hit(self):
|
||||
"""
|
||||
Function to receive Parameter hit value.
|
||||
|
||||
Returns:
|
||||
hit of Parameter instance (bool).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> parameter = dbg_services.Parameter(name="param",
|
||||
>>> disabled=False,
|
||||
>>> value=0.0,
|
||||
>>> hit=False,
|
||||
>>> hit = watchpoint_hit.hit
|
||||
"""
|
||||
|
||||
return self.instance.get_hit()
|
||||
|
||||
@property
|
||||
def actual_value(self):
|
||||
"""
|
||||
Function to receive Parameter actual_value value.
|
||||
|
||||
Returns:
|
||||
actual_value of Parameter instance (float).
|
||||
|
||||
Examples:
|
||||
>>> from mindspore.ccsrc.debug.debugger.offline_debug import dbg_services
|
||||
>>> parameter = dbg_services.Parameter(name="param",
|
||||
>>> disabled=False,
|
||||
>>> value=0.0,
|
||||
>>> hit=False,
|
||||
>>> actual_value = watchpoint_hit.actual_value
|
||||
"""
|
||||
|
||||
return self.instance.get_actual_value()
|
|
@ -1,24 +0,0 @@
|
|||
python sync_trans_false_read_tensors.py > sync_trans_false_read_tensors.actual
|
||||
diff sync_trans_false_read_tensors.actual sync_trans_false_read_tensors.expected
|
||||
if [ $? -eq 0 ]; then
|
||||
echo sync_trans_false_read_tensors PASSED
|
||||
else
|
||||
echo sync_trans_false_read_tensors FAILED
|
||||
fi
|
||||
|
||||
python sync_trans_true_read_tensors.py > sync_trans_true_read_tensors.actual
|
||||
diff sync_trans_true_read_tensors.actual sync_trans_true_read_tensors.expected
|
||||
if [ $? -eq 0 ]; then
|
||||
echo sync_trans_true_read_tensors PASSED
|
||||
else
|
||||
echo sync_trans_true_read_tensors FAILED
|
||||
fi
|
||||
|
||||
python sync_trans_false_watchpoints.py > sync_trans_false_watchpoints.actual
|
||||
diff sync_trans_false_watchpoints.actual sync_trans_false_watchpoints.expected
|
||||
if [ $? -eq 0 ]; then
|
||||
echo sync_trans_false_watchpoints PASSED
|
||||
else
|
||||
echo sync_trans_false_watchpoints FAILED
|
||||
fi
|
||||
|
|
@ -1,70 +0,0 @@
|
|||
-----------------------------------------------------------
|
||||
tensor_info_1 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/conv2-Conv2d/conv2.bias
|
||||
slot = 0
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = True
|
||||
|
||||
tensor_data_1 attributes:
|
||||
data (printed in uint8) = [ 0 0 0 0 195 127 0 0 176 202 195 248 194 127 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 8 58 196 248
|
||||
194 127 0 0 17 0 0 0 0 0 0 0 160 76 6 140 195 127
|
||||
0 0 69 0 0 0 0 0 0 0 1 0 0 0 195 127 0 0
|
||||
64 195 195 248 194 127 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 88 1 196 248 194 127 0 0 18 0 0 0
|
||||
0 0 0 0 160 47 6 140 195 127 0 0 69 0 0 0 0 0
|
||||
0 0 1 0 0 0 195 127 0 0 176 203 195 248 194 127 0 0
|
||||
176 204 195 248 194 127 0 0 0 0 0 0 0 0 0 0 216 241
|
||||
195 248 194 127 0 0 19 0 0 0 0 0 0 0 96 39 6 140
|
||||
195 127 0 0 69 0 0 0 0 0 0 0 1 0 0 0 195 127
|
||||
0 0 112 52 196 248 194 127 0 0 176 52 196 248 194 127 0 0
|
||||
0 0 0 0 0 0 0 0 88 250 195 248 194 127 0 0 20 0
|
||||
0 0 0 0 0 0 128 130 5 140 195 127 0 0 69 0 0 0
|
||||
0 0 0 0 0 0 0 0 195 127 0 0 208 136 195 248 194 127
|
||||
0 0 176 202 195 248 194 127 0 0 48 52 196 248 194 127 0 0
|
||||
184 247 195 248 194 127 0 0 21 0 0 0 0 0 0 0 176 213
|
||||
4 140 195 127 0 0 69 0 0 0 0 0 0 0 0 0 0 0
|
||||
195 127 0 0 48 52 196 248 194 127 0 0 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 8 249 195 248 194 127 0 0
|
||||
22 0 0 0 0 0 0 0 16 46 4 140 195 127 0 0 69 0
|
||||
0 0 0 0 0 0 1 0 0 0 195 127 0 0 64 137 195 248
|
||||
194 127 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
|
||||
0 0 88 12 196 248 194 127 0 0 23 0 0 0 0 0 0 0
|
||||
32 137 3 140 195 127 0 0 85 0 0 0 0 0 0 0 0 0
|
||||
0 0 195 127 0 0 176 202 195 248 194 127 0 0 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 104 246 195 248 194 127
|
||||
0 0 24 0 0 0 0 0 0 0 48 104 15 140 195 127 0 0
|
||||
32 104 15 140 195 127 0 0]
|
||||
size in bytes = 512
|
||||
debugger dtype = 11
|
||||
shape = [128]
|
||||
-----------------------------------------------------------
|
||||
tensor_info_2 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op308
|
||||
slot = 0
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = False
|
||||
|
||||
tensor_data_2 attributes:
|
||||
data (printed in uint8) = [ 0 169 0 ... 152 242 63]
|
||||
size in bytes = 4153344
|
||||
debugger dtype = 11
|
||||
shape = [32, 192, 13, 13]
|
||||
-----------------------------------------------------------
|
||||
tensor_info_3 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/ReLUV2-op300
|
||||
slot = 1
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = False
|
||||
|
||||
tensor_data_3 attributes:
|
||||
data (printed in uint8) = [ 0 169 0 ... 217 4 52]
|
||||
size in bytes = 831744
|
||||
debugger dtype = 8
|
||||
shape = [207936]
|
|
@ -1,74 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
Read tensor test script for offline debugger APIs.
|
||||
"""
|
||||
|
||||
import mindspore.offline_debug.dbg_services as d
|
||||
import numpy as np
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
debugger_backend = d.DbgServices(
|
||||
dump_file_path="/home/jtzanaka/dumps/sync_trans_false/032421/alexnet")
|
||||
|
||||
_ = debugger_backend.initialize(
|
||||
net_name="Network Name goes here!", is_sync_mode=True)
|
||||
|
||||
# parameter
|
||||
info1 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/conv2-Conv2d/conv2.bias",
|
||||
slot=0, iteration=2, device_id=0, root_graph_id=0, is_parameter=True)
|
||||
# output tensor with zero slot
|
||||
info2 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op308",
|
||||
slot=0, iteration=2, device_id=0, root_graph_id=0, is_parameter=False)
|
||||
# output tensor with non-zero slot
|
||||
info3 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/ReLUV2-op300",
|
||||
slot=1, iteration=2, device_id=0, root_graph_id=0, is_parameter=False)
|
||||
|
||||
tensor_info = [info1, info2, info3]
|
||||
|
||||
tensor_data = debugger_backend.read_tensors(tensor_info)
|
||||
|
||||
print_read_tensors(tensor_info, tensor_data)
|
||||
|
||||
|
||||
def print_read_tensors(tensor_info, tensor_data):
|
||||
"""Print read tensors."""
|
||||
for x, _ in enumerate(tensor_info):
|
||||
print("-----------------------------------------------------------")
|
||||
print("tensor_info_" + str(x+1) + " attributes:")
|
||||
print("node name = ", tensor_info[x].node_name)
|
||||
print("slot = ", tensor_info[x].slot)
|
||||
print("iteration = ", tensor_info[x].iteration)
|
||||
print("device_id = ", tensor_info[x].device_id)
|
||||
print("root_graph_id = ", tensor_info[x].root_graph_id)
|
||||
print("is_parameter = ", tensor_info[x].is_parameter)
|
||||
print()
|
||||
print("tensor_data_" + str(x+1) + " attributes:")
|
||||
print("data (printed in uint8) = ", np.frombuffer(
|
||||
tensor_data[x].data_ptr, np.uint8, tensor_data[x].data_size))
|
||||
py_byte_size = len(tensor_data[x].data_ptr)
|
||||
c_byte_size = tensor_data[x].data_size
|
||||
if c_byte_size != py_byte_size:
|
||||
print("The python byte size of ", py_byte_size,
|
||||
" does not match the C++ byte size of ", c_byte_size)
|
||||
print("size in bytes = ", tensor_data[x].data_size)
|
||||
print("debugger dtype = ", tensor_data[x].dtype)
|
||||
print("shape = ", tensor_data[x].shape)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,33 +0,0 @@
|
|||
-----------------------------------------------------------
|
||||
watchpoint_hit for test_1 attributes:
|
||||
name = Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op308
|
||||
slot = 0
|
||||
condition = 6
|
||||
watchpoint_id = 1
|
||||
parameter 0 name = param
|
||||
parameter 0 disabled = False
|
||||
parameter 0 value = 0.0
|
||||
parameter 0 hit = True
|
||||
parameter 0 actual_value = -2.429065704345703
|
||||
error code = 0
|
||||
device_id = 0
|
||||
root_graph_id = 0
|
||||
-----------------------------------------------------------
|
||||
watchpoint_hit for test_4 attributes:
|
||||
name = Default/network-WithLossCell/_backbone-AlexNet/fc3-Dense/Parameter[6]_11/fc3.bias
|
||||
slot = 0
|
||||
condition = 18
|
||||
watchpoint_id = 3
|
||||
parameter 0 name = abs_mean_update_ratio_gt
|
||||
parameter 0 disabled = False
|
||||
parameter 0 value = 0.0
|
||||
parameter 0 hit = True
|
||||
parameter 0 actual_value = 1.793662034335766e-35
|
||||
parameter 1 name = epsilon
|
||||
parameter 1 disabled = True
|
||||
parameter 1 value = 0.0
|
||||
parameter 1 hit = False
|
||||
parameter 1 actual_value = 0.0
|
||||
error code = 0
|
||||
device_id = 0
|
||||
root_graph_id = 0
|
|
@ -1,109 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
Watchpoints test script for offline debugger APIs.
|
||||
"""
|
||||
|
||||
import mindspore.offline_debug.dbg_services as d
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
debugger_backend = d.DbgServices(
|
||||
dump_file_path="/home/jtzanaka/dumps/sync_trans_false/032421/alexnet")
|
||||
|
||||
_ = debugger_backend.initialize(
|
||||
net_name="Network Name goes here!", is_sync_mode=True)
|
||||
|
||||
# NOTES:
|
||||
# -> watch_condition=6 is MIN_LT
|
||||
# -> watch_condition=18 is CHANGE_TOO_LARGE
|
||||
|
||||
# test 1: watchpoint set and hit (watch_condition=6)
|
||||
param1 = d.Parameter(name="param", disabled=False, value=0.0)
|
||||
_ = debugger_backend.add_watchpoint(watchpoint_id=1, watch_condition=6,
|
||||
check_node_list={"Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/"
|
||||
"Conv2D-op308":
|
||||
{"device_id": [0], "root_graph_id": [0], "is_parameter": False
|
||||
}}, parameter_list=[param1])
|
||||
|
||||
watchpoint_hits_test_1 = debugger_backend.check_watchpoints(iteration=2)
|
||||
if len(watchpoint_hits_test_1) != 1:
|
||||
print("ERROR -> test 1: watchpoint set but not hit just once")
|
||||
print_watchpoint_hits(watchpoint_hits_test_1, 1)
|
||||
|
||||
# test 2: watchpoint remove and ensure it's not hit
|
||||
_ = debugger_backend.remove_watchpoint(watchpoint_id=1)
|
||||
watchpoint_hits_test_2 = debugger_backend.check_watchpoints(iteration=2)
|
||||
if watchpoint_hits_test_2:
|
||||
print("ERROR -> test 2: watchpoint removed but hit")
|
||||
|
||||
# test 3: watchpoint set and not hit, then remove
|
||||
param2 = d.Parameter(name="param", disabled=False, value=-1000.0)
|
||||
_ = debugger_backend.add_watchpoint(watchpoint_id=2, watch_condition=6,
|
||||
check_node_list={"Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/"
|
||||
"Conv2D-op308":
|
||||
{"device_id": [0], "root_graph_id": [0], "is_parameter": False
|
||||
}}, parameter_list=[param2])
|
||||
|
||||
watchpoint_hits_test_3 = debugger_backend.check_watchpoints(iteration=2)
|
||||
if watchpoint_hits_test_3:
|
||||
print("ERROR -> test 3: watchpoint set but not supposed to be hit")
|
||||
_ = debugger_backend.remove_watchpoint(watchpoint_id=2)
|
||||
|
||||
# test 4: weight change watchpoint set and hit
|
||||
param_abs_mean_update_ratio_gt = d.Parameter(
|
||||
name="abs_mean_update_ratio_gt", disabled=False, value=0.0)
|
||||
param_epsilon = d.Parameter(name="epsilon", disabled=True, value=0.0)
|
||||
_ = debugger_backend.add_watchpoint(watchpoint_id=3, watch_condition=18,
|
||||
check_node_list={"Default/network-WithLossCell/_backbone-AlexNet/fc3-Dense/"
|
||||
"Parameter[6]_11/fc3.bias":
|
||||
{"device_id": [0], "root_graph_id": [0], "is_parameter": True
|
||||
}}, parameter_list=[param_abs_mean_update_ratio_gt,
|
||||
param_epsilon])
|
||||
|
||||
watchpoint_hits_test_4 = debugger_backend.check_watchpoints(iteration=3)
|
||||
if len(watchpoint_hits_test_4) != 1:
|
||||
print("ERROR -> test 4: watchpoint weight change set but not hit just once")
|
||||
print_watchpoint_hits(watchpoint_hits_test_4, 4)
|
||||
|
||||
|
||||
def print_watchpoint_hits(watchpoint_hits, test_id):
|
||||
"""Print watchpoint hits."""
|
||||
for x, _ in enumerate(watchpoint_hits):
|
||||
print("-----------------------------------------------------------")
|
||||
print("watchpoint_hit for test_%u attributes:" % test_id)
|
||||
print("name = ", watchpoint_hits[x].name)
|
||||
print("slot = ", watchpoint_hits[x].slot)
|
||||
print("condition = ", watchpoint_hits[x].condition)
|
||||
print("watchpoint_id = ", watchpoint_hits[x].watchpoint_id)
|
||||
for p, _ in enumerate(watchpoint_hits[x].parameters):
|
||||
print("parameter ", p, " name = ",
|
||||
watchpoint_hits[x].parameters[p].name)
|
||||
print("parameter ", p, " disabled = ",
|
||||
watchpoint_hits[x].parameters[p].disabled)
|
||||
print("parameter ", p, " value = ",
|
||||
watchpoint_hits[x].parameters[p].value)
|
||||
print("parameter ", p, " hit = ",
|
||||
watchpoint_hits[x].parameters[p].hit)
|
||||
print("parameter ", p, " actual_value = ",
|
||||
watchpoint_hits[x].parameters[p].actual_value)
|
||||
print("error code = ", watchpoint_hits[x].error_code)
|
||||
print("device_id = ", watchpoint_hits[x].device_id)
|
||||
print("root_graph_id = ", watchpoint_hits[x].root_graph_id)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,70 +0,0 @@
|
|||
-----------------------------------------------------------
|
||||
tensor_info_1 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/conv2-Conv2d/conv2.bias
|
||||
slot = 0
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = True
|
||||
|
||||
tensor_data_1 attributes:
|
||||
data (printed in uint8) = [ 1 0 0 0 195 127 0 0 80 58 118 65 195 127 0 0 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 40 186 117 65
|
||||
195 127 0 0 5 0 0 0 0 0 0 0 160 76 6 204 195 127
|
||||
0 0 69 0 0 0 0 0 0 0 1 0 0 0 195 127 0 0
|
||||
48 135 117 65 195 127 0 0 16 58 118 65 195 127 0 0 144 58
|
||||
118 65 195 127 0 0 168 186 117 65 195 127 0 0 6 0 0 0
|
||||
0 0 0 0 160 47 6 204 195 127 0 0 69 0 0 0 0 0
|
||||
0 0 1 0 0 0 195 127 0 0 80 58 118 65 195 127 0 0
|
||||
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 184 249
|
||||
117 65 195 127 0 0 7 0 0 0 0 0 0 0 96 39 6 204
|
||||
195 127 0 0 69 0 0 0 0 0 0 0 1 0 0 0 195 127
|
||||
0 0 224 218 117 65 195 127 0 0 0 0 0 0 0 0 0 0
|
||||
224 219 117 65 195 127 0 0 200 17 118 65 195 127 0 0 8 0
|
||||
0 0 0 0 0 0 128 130 5 204 195 127 0 0 69 0 0 0
|
||||
0 0 0 0 1 0 0 0 195 127 0 0 120 233 255 59 196 127
|
||||
0 0 224 217 117 65 195 127 0 0 224 214 117 65 195 127 0 0
|
||||
120 250 117 65 195 127 0 0 9 0 0 0 0 0 0 0 176 213
|
||||
4 204 195 127 0 0 69 0 0 0 0 0 0 0 1 0 0 0
|
||||
195 127 0 0 240 66 118 65 195 127 0 0 160 218 117 65 195 127
|
||||
0 0 224 215 117 65 195 127 0 0 40 9 118 65 195 127 0 0
|
||||
10 0 0 0 0 0 0 0 16 46 4 204 195 127 0 0 69 0
|
||||
0 0 0 0 0 0 1 0 0 0 195 127 0 0 208 59 118 65
|
||||
195 127 0 0 0 0 0 0 0 0 0 0 96 218 117 65 195 127
|
||||
0 0 56 251 117 65 195 127 0 0 11 0 0 0 0 0 0 0
|
||||
32 137 3 204 195 127 0 0 85 0 0 0 0 0 0 0 1 0
|
||||
0 0 195 127 0 0 224 214 117 65 195 127 0 0 144 59 118 65
|
||||
195 127 0 0 160 214 117 65 195 127 0 0 136 62 118 65 195 127
|
||||
0 0 12 0 0 0 0 0 0 0 48 104 15 204 195 127 0 0
|
||||
32 104 15 204 195 127 0 0]
|
||||
size in bytes = 512
|
||||
debugger dtype = 11
|
||||
shape = [128]
|
||||
-----------------------------------------------------------
|
||||
tensor_info_2 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op308
|
||||
slot = 0
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = False
|
||||
|
||||
tensor_data_2 attributes:
|
||||
data (printed in uint8) = [206 239 74 ... 53 201 62]
|
||||
size in bytes = 4153344
|
||||
debugger dtype = 11
|
||||
shape = [32, 192, 13, 13]
|
||||
-----------------------------------------------------------
|
||||
tensor_info_3 attributes:
|
||||
node name = Default/network-WithLossCell/_backbone-AlexNet/ReLUV2-op300
|
||||
slot = 1
|
||||
iteration = 2
|
||||
device_id = None
|
||||
root_graph_id = 0
|
||||
is_parameter = False
|
||||
|
||||
tensor_data_3 attributes:
|
||||
data (printed in uint8) = [206 239 74 ... 16 239 51]
|
||||
size in bytes = 831744
|
||||
debugger dtype = 8
|
||||
shape = [207936]
|
|
@ -1,74 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
Read tensor test script for offline debugger APIs.
|
||||
"""
|
||||
|
||||
import mindspore.offline_debug.dbg_services as d
|
||||
import numpy as np
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
debugger_backend = d.DbgServices(
|
||||
dump_file_path="/home/jtzanaka/dumps/sync_trans_true/032421/alexnet")
|
||||
|
||||
_ = debugger_backend.initialize(
|
||||
net_name="Network Name goes here!", is_sync_mode=True)
|
||||
|
||||
# parameter
|
||||
info1 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/conv2-Conv2d/conv2.bias",
|
||||
slot=0, iteration=2, device_id=0, root_graph_id=0, is_parameter=True)
|
||||
# output tensor with zero slot
|
||||
info2 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/conv3-Conv2d/Conv2D-op308",
|
||||
slot=0, iteration=2, device_id=0, root_graph_id=0, is_parameter=False)
|
||||
# output tensor with non-zero slot
|
||||
info3 = d.TensorInfo(node_name="Default/network-WithLossCell/_backbone-AlexNet/ReLUV2-op300",
|
||||
slot=1, iteration=2, device_id=0, root_graph_id=0, is_parameter=False)
|
||||
|
||||
tensor_info = [info1, info2, info3]
|
||||
|
||||
tensor_data = debugger_backend.read_tensors(tensor_info)
|
||||
|
||||
print_read_tensors(tensor_info, tensor_data)
|
||||
|
||||
|
||||
def print_read_tensors(tensor_info, tensor_data):
|
||||
"""Print read tensors."""
|
||||
for x, _ in enumerate(tensor_info):
|
||||
print("-----------------------------------------------------------")
|
||||
print("tensor_info_" + str(x+1) + " attributes:")
|
||||
print("node name = ", tensor_info[x].node_name)
|
||||
print("slot = ", tensor_info[x].slot)
|
||||
print("iteration = ", tensor_info[x].iteration)
|
||||
print("device_id = ", tensor_info[x].device_id)
|
||||
print("root_graph_id = ", tensor_info[x].root_graph_id)
|
||||
print("is_parameter = ", tensor_info[x].is_parameter)
|
||||
print()
|
||||
print("tensor_data_" + str(x+1) + " attributes:")
|
||||
print("data (printed in uint8) = ", np.frombuffer(
|
||||
tensor_data[x].data_ptr, np.uint8, tensor_data[x].data_size))
|
||||
py_byte_size = len(tensor_data[x].data_ptr)
|
||||
c_byte_size = tensor_data[x].data_size
|
||||
if c_byte_size != py_byte_size:
|
||||
print("The python byte size of ", py_byte_size,
|
||||
" does not match the C++ byte size of ", c_byte_size)
|
||||
print("size in bytes = ", tensor_data[x].data_size)
|
||||
print("debugger dtype = ", tensor_data[x].dtype)
|
||||
print("shape = ", tensor_data[x].shape)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -1,123 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
General Validator Helper Functions.
|
||||
"""
|
||||
import os
|
||||
import inspect
|
||||
|
||||
UINT32_MAX = 4294967295
|
||||
UINT32_MIN = 0
|
||||
UINT64_MAX = 18446744073709551615
|
||||
UINT64_MIN = 0
|
||||
|
||||
|
||||
def pad_arg_name(arg_name):
|
||||
if arg_name != "":
|
||||
arg_name = arg_name + " "
|
||||
return arg_name
|
||||
|
||||
|
||||
def check_value(arg, valid_range, arg_name=""):
|
||||
arg_name = pad_arg_name(arg_name)
|
||||
if arg < valid_range[0] or arg > valid_range[1]:
|
||||
raise ValueError(
|
||||
"Input {0}is not within the required interval of ({1} to {2}).".format(arg_name,
|
||||
valid_range[0], valid_range[1]))
|
||||
|
||||
|
||||
def check_uint32(arg, arg_name=""):
|
||||
type_check(arg, (int,), arg_name)
|
||||
check_value(arg, [UINT32_MIN, UINT32_MAX])
|
||||
|
||||
|
||||
def check_uint64(arg, arg_name=""):
|
||||
type_check(arg, (int,), arg_name)
|
||||
check_value(arg, [UINT64_MIN, UINT64_MAX])
|
||||
|
||||
|
||||
def check_dir(dataset_dir):
|
||||
if not os.path.isdir(dataset_dir) or not os.access(dataset_dir, os.R_OK):
|
||||
raise ValueError("The folder {} does not exist or permission denied!".format(dataset_dir))
|
||||
|
||||
|
||||
def parse_user_args(method, *args, **kwargs):
|
||||
"""
|
||||
Parse user arguments in a function.
|
||||
|
||||
Args:
|
||||
method (method): a callable function.
|
||||
args: user passed args.
|
||||
kwargs: user passed kwargs.
|
||||
|
||||
Returns:
|
||||
user_filled_args (list): values of what the user passed in for the arguments.
|
||||
ba.arguments (Ordered Dict): ordered dict of parameter and argument for what the user has passed.
|
||||
"""
|
||||
sig = inspect.signature(method)
|
||||
if 'self' in sig.parameters or 'cls' in sig.parameters:
|
||||
ba = sig.bind(method, *args, **kwargs)
|
||||
ba.apply_defaults()
|
||||
params = list(sig.parameters.keys())[1:]
|
||||
else:
|
||||
ba = sig.bind(*args, **kwargs)
|
||||
ba.apply_defaults()
|
||||
params = list(sig.parameters.keys())
|
||||
|
||||
user_filled_args = [ba.arguments.get(arg_value) for arg_value in params]
|
||||
return user_filled_args, ba.arguments
|
||||
|
||||
|
||||
def type_check(arg, types, arg_name):
|
||||
"""
|
||||
Check the type of the parameter.
|
||||
|
||||
Args:
|
||||
arg (Any) : any variable.
|
||||
types (tuple): tuple of all valid types for arg.
|
||||
arg_name (str): the name of arg.
|
||||
|
||||
Returns:
|
||||
Exception: when the type is not correct, otherwise nothing.
|
||||
"""
|
||||
# handle special case of booleans being a subclass of ints
|
||||
print_value = '\"\"' if repr(arg) == repr('') else arg
|
||||
|
||||
if int in types and bool not in types:
|
||||
if isinstance(arg, bool):
|
||||
raise TypeError("Argument {0} with value {1} is not of type {2}.".format(arg_name, print_value, types))
|
||||
if not isinstance(arg, types):
|
||||
raise TypeError("Argument {0} with value {1} is not of type {2}.".format(arg_name, print_value, types))
|
||||
|
||||
|
||||
def type_check_list(args, types, arg_names):
|
||||
"""
|
||||
Check the type of each parameter in the list.
|
||||
|
||||
Args:
|
||||
args (Union[list, tuple]): a list or tuple of any variable.
|
||||
types (tuple): tuple of all valid types for arg.
|
||||
arg_names (Union[list, tuple of str]): the names of args.
|
||||
|
||||
Returns:
|
||||
Exception: when the type is not correct, otherwise nothing.
|
||||
"""
|
||||
type_check(args, (list, tuple,), arg_names)
|
||||
if len(args) != len(arg_names) and not isinstance(arg_names, str):
|
||||
raise ValueError("List of arguments is not the same length as argument_names.")
|
||||
if isinstance(arg_names, str):
|
||||
arg_names = ["{0}[{1}]".format(arg_names, i) for i in range(len(args))]
|
||||
for arg, arg_name in zip(args, arg_names):
|
||||
type_check(arg, types, arg_name)
|
|
@ -1,223 +0,0 @@
|
|||
# Copyright 2021 Huawei Technologies Co., Ltd
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
# ==============================================================================
|
||||
"""
|
||||
Validator Functions for Offline Debugger APIs.
|
||||
"""
|
||||
from functools import wraps
|
||||
|
||||
import dbg_services as cds
|
||||
from mi_validator_helpers import parse_user_args, type_check, type_check_list, check_dir, check_uint32, check_uint64
|
||||
|
||||
|
||||
def check_init(method):
|
||||
"""Wrapper method to check the parameters of DbgServices init."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
[dump_file_path, verbose], _ = parse_user_args(method, *args, **kwargs)
|
||||
|
||||
type_check(dump_file_path, (str,), "dump_file_path")
|
||||
type_check(verbose, (bool,), "verbose")
|
||||
check_dir(dump_file_path)
|
||||
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
||||
|
||||
def check_initialize(method):
|
||||
"""Wrapper method to check the parameters of DbgServices Initialize method."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
[net_name, is_sync_mode], _ = parse_user_args(method, *args, **kwargs)
|
||||
|
||||
type_check(net_name, (str,), "net_name")
|
||||
type_check(is_sync_mode, (bool,), "is_sync_mode")
|
||||
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
||||
|
||||
def check_add_watchpoint(method):
|
||||
"""Wrapper method to check the parameters of DbgServices AddWatchpoint."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
[id_value, watch_condition, check_node_list, parameter_list], _ = parse_user_args(method, *args, **kwargs)
|
||||
|
||||
check_uint32(id_value, "id")
|
||||
check_uint32(watch_condition, "watch_condition")
|
||||
type_check(check_node_list, (dict,), "check_node_list")
|
||||
for node_name, node_info in check_node_list.items():
|
||||
type_check(node_name, (str,), "node_name")
|
||||
type_check(node_info, (dict,), "node_info")
|
||||
for info_name, info_param in node_info.items():
|
||||
type_check(info_name, (str,), "node parameter name")
|
||||
if info_name in ["device_id"]:
|
||||
for param in info_param:
|
||||
check_uint32(param, "device_id")
|
||||
elif info_name in ["root_graph_id"]:
|
||||
for param in info_param:
|
||||
check_uint32(param, "root_graph_id")
|
||||
elif info_name in ["is_parameter"]:
|
||||
type_check(info_param, (bool,), "is_parameter")
|
||||
else:
|
||||
raise ValueError("Node parameter {} is not defined.".format(info_name))
|
||||
param_names = ["param_{0}".format(i) for i in range(len(parameter_list))]
|
||||
type_check_list(parameter_list, (cds.Parameter,), param_names)
|
||||
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
||||
|
||||
def check_remove_watchpoint(method):
|
||||
"""Wrapper method to check the parameters of DbgServices RemoveWatchpoint."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
[id_value], _ = parse_user_args(method, *args, **kwargs)
|
||||
|
||||
check_uint32(id_value, "id")
|
||||
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
||||
|
||||
def check_check_watchpoints(method):
|
||||
"""Wrapper method to check the parameters of DbgServices CheckWatchpoint."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
[iteration], _ = parse_user_args(method, *args, **kwargs)
|
||||
|
||||
check_uint32(iteration, "iteration")
|
||||
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
||||
|
||||
def check_read_tensors(method):
|
||||
"""Wrapper method to check the parameters of DbgServices ReadTensors."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
[info_list], _ = parse_user_args(method, *args, **kwargs)
|
||||
|
||||
info_names = ["info_{0}".format(i) for i in range(len(info_list))]
|
||||
type_check_list(info_list, (cds.TensorInfo,), info_names)
|
||||
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
||||
|
||||
def check_initialize_done(method):
|
||||
"""Wrapper method to check if initlize is done for DbgServices."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
|
||||
if not self.initialized:
|
||||
raise RuntimeError("Inilize should be called before any other methods of DbgServices!")
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
||||
|
||||
def check_tensor_info_init(method):
|
||||
"""Wrapper method to check the parameters of DbgServices TensorInfo init."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
[node_name, slot, iteration, device_id, root_graph_id,
|
||||
is_parameter], _ = parse_user_args(method, *args, **kwargs)
|
||||
|
||||
type_check(node_name, (str,), "node_name")
|
||||
check_uint32(slot, "slot")
|
||||
check_uint32(iteration, "iteration")
|
||||
check_uint32(device_id, "device_id")
|
||||
check_uint32(root_graph_id, "root_graph_id")
|
||||
type_check(is_parameter, (bool,), "is_parameter")
|
||||
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
||||
|
||||
def check_tensor_data_init(method):
|
||||
"""Wrapper method to check the parameters of DbgServices TensorData init."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
[data_ptr, data_size, dtype, shape], _ = parse_user_args(method, *args, **kwargs)
|
||||
|
||||
type_check(data_ptr, (bytes,), "data_ptr")
|
||||
check_uint64(data_size, "data_size")
|
||||
type_check(dtype, (int,), "dtype")
|
||||
shape_names = ["shape_{0}".format(i) for i in range(len(shape))]
|
||||
type_check_list(shape, (int,), shape_names)
|
||||
|
||||
if len(data_ptr) != data_size:
|
||||
raise ValueError("data_ptr length ({0}) is not equal to data_size ({1}).".format(len(data_ptr), data_size))
|
||||
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
||||
|
||||
def check_watchpoint_hit_init(method):
|
||||
"""Wrapper method to check the parameters of DbgServices WatchpointHit init."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
[name, slot, condition, watchpoint_id,
|
||||
parameters, error_code, device_id, root_graph_id], _ = parse_user_args(method, *args, **kwargs)
|
||||
|
||||
type_check(name, (str,), "name")
|
||||
check_uint32(slot, "slot")
|
||||
type_check(condition, (int,), "condition")
|
||||
check_uint32(watchpoint_id, "watchpoint_id")
|
||||
param_names = ["param_{0}".format(i) for i in range(len(parameters))]
|
||||
type_check_list(parameters, (cds.Parameter,), param_names)
|
||||
type_check(error_code, (int,), "error_code")
|
||||
check_uint32(device_id, "device_id")
|
||||
check_uint32(root_graph_id, "root_graph_id")
|
||||
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
||||
|
||||
|
||||
def check_parameter_init(method):
|
||||
"""Wrapper method to check the parameters of DbgServices Parameter init."""
|
||||
|
||||
@wraps(method)
|
||||
def new_method(self, *args, **kwargs):
|
||||
[name, disabled, value, hit, actual_value], _ = parse_user_args(method, *args, **kwargs)
|
||||
|
||||
type_check(name, (str,), "name")
|
||||
type_check(disabled, (bool,), "disabled")
|
||||
type_check(value, (float,), "value")
|
||||
type_check(hit, (bool,), "hit")
|
||||
type_check(actual_value, (float,), "actual_value")
|
||||
|
||||
return method(self, *args, **kwargs)
|
||||
|
||||
return new_method
|
Loading…
Reference in New Issue