onnx / onnx-mlir

Representation and Reference Lowering of ONNX Models in MLIR Compiler Infrastructure
Apache License 2.0
754 stars 321 forks source link

Error in OMExternalConstants.inc when opening model_name.constants.bin file on z/OS #2987

Open christopherlmunoz opened 4 hours ago

christopherlmunoz commented 4 hours ago

Extra backtick or misc characters get added to file name after converting from ASCII to EBCIDIC.

client/bin/modelzoo --lib mnist-8-with-binary.so --file mnist-8.tests --validate -m VERBOSE --fc-parms 0.01,0.158752,9,10
Saved mnist-8-with-binary.so for debug testing with C clients
Created mnist-8-with-binary.jar for Java clients
Iteration 0 dataset 0: Reading
gen_data_set_lists() loading 1 input tensor(s):
gen_next_tensor() processing tensor with shape ( 1 1 28 28 ) totaling 784 elements of type ONNX_TYPE_FLOAT
gen_data_set_lists() loading 1 expected output tensor(s):
gen_next_tensor() processing tensor with shape ( 1 10 ) totaling 10 elements of type ONNX_TYPE_FLOAT
Iteration 0 dataset 0: Running
Error while opening mnist-8.constants.bin`
Error while opening mnist-8.constants.bin�K������k�K������k`��K�����`
void omMMapBinaryFile(
    void **constAddr, char *filename, int64_t size, int64_t isLE) {
  checkEndianness(isLE);
  char *fname = filename;
#ifdef __MVS__
  // Convert the file name to EBCDIC for the open call.
  char *tPath;
  size_t tLen = strlen(fname);
  tPath = (char *)malloc(tLen);
  if (!tPath) {
    fprintf(stderr, "Error while malloc");
    return;
  }
  memcpy(tPath, fname, tLen);
  __a2e_s(tPath);
  fname = tPath;
  //fname[tLen] = '\0'; --------------------------------------------------->  possible fix. 
#endif
christopherlmunoz commented 4 hours ago

@tungld Hi, please let me know if you need more information. Thank you for taking a look.