MCPcopy Create free account
hub / github.com/OpenPPL/ppl.nn / SaveInputsOneByOne

Function SaveInputsOneByOne

tools/pplnn.py:492–508  ·  view source on GitHub ↗
(save_data_dir, runtime)

Source from the content-addressed store, hash-verified

490 return count
491
492def SaveInputsOneByOne(save_data_dir, runtime):
493 for i in range(runtime.GetInputCount()):
494 tensor = runtime.GetInputTensor(i)
495 shape = tensor.GetShape()
496 dims = shape.GetDims()
497 out_file_name = save_data_dir + "/pplnn_input_" + str(i) + "_" + tensor.GetName() + "-" + GenDimsStr(dims) + "-" + g_data_type_str[shape.GetDataType()] + ".dat"
498 element_count = CalcElementCount(dims)
499 if element_count > 0:
500 tensor_data = tensor.ConvertToHost()
501 if not tensor_data:
502 logging.error("copy data from tensor[" + tensor.GetName() + "] failed.")
503 sys.exit(-1)
504
505 in_data = np.array(tensor_data, copy=False)
506 in_data.tofile(out_file_name)
507 else:
508 open(out_file_name, 'a').close()
509
510# ---------------------------------------------------------------------------- #
511

Callers 1

pplnn.pyFile · 0.70

Calls 7

GenDimsStrFunction · 0.85
CalcElementCountFunction · 0.85
GetInputTensorMethod · 0.80
GetInputCountMethod · 0.45
GetShapeMethod · 0.45
GetNameMethod · 0.45
ConvertToHostMethod · 0.45

Tested by

no test coverage detected