@@ -261,7 +261,7 @@ static sd::Pointer _numpyHeaderForNd4j(sd::Pointer data, const sd::Pointer shape
261261 auto npHeader = cnpy::createNpyHeader<T>(npShape, rank, wordSize);
262262 char * ret = new char [npHeader.size () + 1 ];
263263 int count = 0 ;
264- for (int i = 0 ; i < npHeader.size (); i++) {
264+ for (size_t i = 0 ; i < npHeader.size (); i++) {
265265 ret[count] = npHeader[i];
266266 count++;
267267 }
@@ -292,10 +292,6 @@ sd::Pointer loadNpyFromHeader(sd::Pointer data) {
292292
293293 cnpy::NpyArray arr = cnpy::loadNpyFromHeader (header);
294294 cnpy::NpyArray* ret = new cnpy::NpyArray ();
295- int totalLengthOfShape = 1 ;
296- for (int i = 0 ; i < arr.shape .size (); i++) {
297- totalLengthOfShape *= arr.shape [i];
298- }
299295
300296 ret->data = arr.data ;
301297 ret->wordSize = arr.wordSize ;
@@ -539,8 +535,8 @@ void setGraphContextOutputArraysArr(OpaqueContext* ptr, int numArrays,OpaqueNDAr
539535 errorMessage += " was null!" ;
540536 THROW_EXCEPTION (errorMessage.c_str ());
541537 }
542- for (int i = 0 ; i < numArrays; i ++) {
543- ptr->setOutputArray (i , *arr[i ], false );
538+ for (int j = 0 ; j < numArrays; j ++) {
539+ ptr->setOutputArray (j , *arr[j ], false );
544540 }
545541 }
546542}
@@ -625,12 +621,12 @@ sd::LongType *mmapFile(sd::Pointer *extraPointers, const char *fileName, sd::Lon
625621 THROW_EXCEPTION (" Failed to open file for MMAP" );
626622 }
627623
628- void *ptr = mmap (nullptr , length, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0 );
629- if (ptr == MAP_FAILED) {
624+ void *ptr2 = mmap (nullptr , length, PROT_READ | PROT_WRITE, MAP_FILE | MAP_SHARED, fd, 0 );
625+ if (ptr2 == MAP_FAILED) {
630626 sd_printf (" Errno: %i\n " , errno);
631627 THROW_EXCEPTION (" Failed to mmap file" );
632628 }
633- hZ[0 ] = (sd::LongType)ptr ;
629+ hZ[0 ] = (sd::LongType)ptr2 ;
634630 hZ[1 ] = fd;
635631
636632#endif
@@ -666,7 +662,7 @@ OpaqueShapeList *calculateOutputShapes2(sd::Pointer *extraPointers, sd::LongType
666662 fflush (stdout);
667663 sd::ShapeList inShapes;
668664
669- for (int e = 0 ; e < context->width (); e++) {
665+ for (size_t e = 0 ; e < context->width (); e++) {
670666 if (context->array (e) == nullptr ) {
671667 std::string errorMessage = " Input array at index " + std::to_string (e) + " was null!" ;
672668 THROW_EXCEPTION (errorMessage.c_str ());
@@ -738,7 +734,7 @@ void purgeOpTrace() { sd::ops::OpRegistrator::getInstance().purgeOpExecs();
738734
739735void printOpTrace () {
740736 auto execTrace = *sd::ops::OpRegistrator::getInstance ().execTrace ();
741- for (int i = 0 ; i < execTrace.size (); i++) {
737+ for (size_t i = 0 ; i < execTrace.size (); i++) {
742738 auto curr = execTrace[i];
743739 if (curr->opName != nullptr ) {
744740 sd_printf (" Op name: %s\n " , curr->opName ->c_str ());
@@ -749,7 +745,7 @@ void printOpTrace() {
749745 continue ;
750746 } else {
751747 auto currInputShapeBuffers = *(curr->inputShapeBuffers );
752- for (int j = 0 ; j < currInputShapeBuffers.size (); j++) {
748+ for (size_t j = 0 ; j < currInputShapeBuffers.size (); j++) {
753749 auto buff = currInputShapeBuffers[j];
754750 shape::printShapeInfo (buff);
755751 sd_printf (" \n " ,0 );
@@ -761,7 +757,7 @@ void printOpTrace() {
761757 continue ;
762758 } else {
763759 auto currOutputShapeBuffers = *(curr->outputShapeBuffers );
764- for (int j = 0 ; j < curr->outputShapeBuffers ->size (); j++) {
760+ for (size_t j = 0 ; j < curr->outputShapeBuffers ->size (); j++) {
765761 shape::printShapeInfo (currOutputShapeBuffers[j]);
766762 sd_printf (" \n " ,0 );
767763 }
@@ -887,7 +883,7 @@ std::vector<double> * tArgs(void *execTrace) {
887883std::vector<int > * dArgs (void *execTrace) {
888884 ExecTrace *trace = (ExecTrace *) execTrace;
889885 std::vector<int > *dArgs = new std::vector<int >();
890- for (int e = 0 ; e < trace->dArgs .size (); e++) {
886+ for (size_t e = 0 ; e < trace->dArgs .size (); e++) {
891887 dArgs->push_back (trace->dArgs [e]);
892888 }
893889 return dArgs;
@@ -965,7 +961,8 @@ static VariablesSet *executeStoredGraphT(sd::Pointer *extraPointers, sd::LongTyp
965961 if (hZ == sd::Status::OK) {
966962 // pull back results, and provide them
967963 auto outputs = graph->fetchOutputs ();
968- for (int e = 0 ; e < outputs->size (); e++) {
964+ int size = static_cast <int >(outputs->size ());
965+ for (int e = 0 ; e < size; e++) {
969966 // we're only getting variable ID/Index from original grap. values will be taken from cloned workspace
970967 std::pair<int , int > varId (outputs->at (e)->id (), outputs->at (e)->index ());
971968
@@ -1121,24 +1118,9 @@ sd::Status execCustomOpWithScope_(sd::Pointer *extraPointers, sd::graph::GraphSt
11211118 varSpace->dropVariable (0 , e);
11221119 }
11231120
1124- // after some bla-bla-bla we should have Graph and Node for current op
11251121 return sd::Status::OK;
11261122}
11271123
1128- sd::Status execCustomOpWithScope (sd::Pointer *extraPointers, sd::Pointer state, sd::LongType opHash, sd::LongType *scopes, int numScopes,
1129- sd::Pointer *inputBuffers, sd::Pointer *inputShapes, int numInputs, sd::Pointer *outputBuffers,
1130- sd::Pointer *outputShapes, int numOutputs) {
1131- try {
1132- return execCustomOpWithScope (extraPointers, reinterpret_cast <GraphState *>(state), opHash, scopes,
1133- numScopes, inputBuffers, inputShapes, numInputs, outputBuffers, outputShapes,
1134- numOutputs);
1135- } catch (std::exception &e) {
1136- sd::LaunchContext::defaultContext ()->errorReference ()->setErrorCode (1 );
1137- sd::LaunchContext::defaultContext ()->errorReference ()->setErrorMessage (e.what ());
1138- return sd::Status::BAD_INPUT;
1139- }
1140- }
1141-
11421124void deleteResultWrapper (sd::Pointer ptr) {
11431125 auto p = reinterpret_cast <ResultWrapper *>(ptr);
11441126 delete p;
0 commit comments