Heavy log crashes the iOS app when running Pytorch model on iOS

Hello everyone. Recently I have learned to export pytorch model (either by torch,jit.trace or torch.jit.script) into a .pt file for android and iOS. The model ran well with no logging on linux or android. But on iOS it generates 145MB worth of .txt log that starts with:
[W TensorImpl.h:1408] Warning: Named tensors and all their associated APIs are an experimental feature and subject to change. Please do not use them for anything important until they are released as stable. (function operator())
the remaining of the log is filled with odd symbols, such as:
\321 \322 \323 \324 \325 \326 \327 \330 \331 \332 \333 \334 \335 \336 \337 \340 \341 \342 \343 \344 \345 \346 \347 \350 \351 \352 \353 \354 \355 \356 \357 \360 \361 \362 \363 \364 \365 \366 \367 \370 \371 \372 \373 \374 \375 \376 \377 \377\377\377\377\377\377\377\377C _\363 \377 \213\363 \377 \226\363 \377 \364 \377 7\364 \377 \360 RuneMagANONE \375\377 B B B B B @ ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( a ( ( ( ( ( ( ( \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 \211 ( ( ( ( ( ( ( ( ( ( a e ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ a b c d e f g h i j k l m n o p q r s t u v w x y z [ \ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~  \200 \201 \202 \203 \204 \205 \206 \207 \210 \211 \212 \213 \214 \215 \216 \217 \220 \221 \222 \223 \224 \225 \226 \227 \230 \231 \232 \233 \234 \235 \236 \237 \240 \241 \242 \243 \244 \245 \246 \247 \250 \251 \252 \253 \254 \255 \256 \257 \260 \261 \262 \263 \264 \265 \266 \267 \270 \271 \272 \273 \274 \275 \276 \277 \300 \301 \302 \303 \304 \305 \306 \307 \310 \311 \312 \313 \314 \315 \316 \317 \320 \321 \322 \323 \324 \325 \326 \327 \330 \331 \332 \333 \334 \335 \336 \337 \340 \341 \342 \343 \344 \345 \346 \347 \350 \351 \352 \353 \354 \355 \356 \357 \360 \361 \362 \363 \364 \365 \366 \367 \370 \371 \372 \373 \374 \375 \376 \377 a e ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \ ] ^ _ ` A B C D E F G H I J K L M N O P Q R S T U V W X Y Z { | } ~  \200
, so much so that the log .txt file is 145MB, which sometimes crashes the app. I have used the latest Pytorch version but this warning still appears.
Does anyone know how to avoid this log on iOS device?

You could try:

  1. avoid using named tensor in your model, as it suggested.
  2. add this guard before any pytorch API in iOS
c10::Warning::WarnAlways guard(false);

Thank you. I will look more into this.
Can you explain how to find out if the variable used in iOS is a named tensor or not?
Do you know what the main part of the log (the numbers, characters and signs,…) is, beside the Warning? Where do they come from?

for named tensor, see Named Tensors — PyTorch 1.10 documentation
I don’t know where these logs came from.