a
    ==icv                     @   sn   d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	 d dl
Z
dd Zdd	 Zd
d ZG dd de
jZdS )    )net_printer)Job)ops)Taskfinal_outputWorkspaceTypeNc            	      C   s  t   td} td}td}td}tdR}t| tdg}t| }t|| g}tt|tdg"}t||g|g W d    n1 s0    Y  |	t|tdg"}t||g|g W d    n1 s0    Y  |
 " t||g|g W d    n1 sH0    Y  t| |g|  W d    n1 sx0    Y  W d    n1 s0    Y  W d    n1 s0    Y  d S )Nr   
   P   2   )r   r   ConstloopZMuliterAddIfZGEZElifZElse)	totalZtotal_largeZtotal_smallZ
total_tinyr   outerinnervalc r   o/home/droni/.local/share/virtualenvs/DPS-5Je3_V2c/lib/python3.9/site-packages/caffe2/python/net_printer_test.pyexample_loop   s     




02
2r   c               	   C   s  t   t  td} W d    n1 s20    Y  t| | g}t  td}W d    n1 sr0    Y  t||g}t  t|| g}W d    n1 s0    Y  t|| g}t|| g|g t|| g}t|}t|}t|}	W d    n1 s0    Y  t dd t  td} W d    n1 s\0    Y  t  td}
W d    n1 s0    Y  t| |
g| g td W d    n1 s0    Y  |||	fS )N         )Znum_instancesZble)	r   r   Z	task_initr   r   Z	task_exitr   Ztask_instance_initZLogInfo)onetwothreeaccumZseven_1sixZseven_2Zo6Zo7_1Zo7_2localr   r   r   example_task    s.    

(
(
,(
*
**r!   c               	   C   s\   t  B} | j t  W d    n1 s*0    Y  t  W d    n1 sN0    Y  | S )N)r   Z
init_groupr   r!   )jobr   r   r   example_job=   s
    $$r#   c                   @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
TestNetPrinterc                 C   s   |  ttt dk d S )Nr   )
assertTruelenr   	to_stringr#   )selfr   r   r   
test_printF   s    zTestNetPrinter.test_printc              	   C   sr   t  }|D t  tddg W d    n1 s60    Y  W d    n1 sT0    Y  ttt   d S )NZdistributed_ctx_init_aZdistributed_ctx_init_b)r#   r   r   r   printr   r'   r(   r"   r   r   r   test_valid_jobI   s
    JzTestNetPrinter.test_valid_jobc              	   C   s   t  }|D t  tddg W d    n1 s60    Y  W d    n1 sT0    Y  | t}t| W d    n1 s0    Y  | dt	|j
 d S )NabzBlob undefined: a)r#   r   r   r   assertRaisesAssertionErrorr   analyzeassertEqualstr	exception)r(   r"   er   r   r   test_undefined_blobR   s    J(z"TestNetPrinter.test_undefined_blobc              	   C   s   t  }| ttjd, ttdtdgd W d    n1 sJ0    Y  ttjd, ttdtdgd W d    n1 s0    Y  W d    n1 s0    Y  | t t	
| W d    n1 s0    Y  d S )N)Zworkspace_typer   r   Zout1r   r   )r#   r   r   GLOBALr   r   r   r/   r0   r   r1   r+   r   r   r   test_multiple_definition[   s    :Xz'TestNetPrinter.test_multiple_definitionN)__name__
__module____qualname__r)   r,   r6   r8   r   r   r   r   r$   E   s   		r$   )Zcaffe2.pythonr   Zcaffe2.python.checkpointr   Zcaffe2.python.net_builderr   Zcaffe2.python.taskr   r   r   Zunittestr   r!   r#   ZTestCaser$   r   r   r   r   <module>   s   