diff
stringlengths 41
2.03M
| msg
stringlengths 1
1.5k
⌀ | repo
stringlengths 5
40
| sha
stringlengths 40
40
| time
stringlengths 20
20
|
---|---|---|---|---|
mmm a / utils / SwiftBuildSupport . py <nl> ppp b / utils / SwiftBuildSupport . py <nl> def _get_default_swift_repo_name ( ) : <nl> return result <nl> if not os . path . exists ( os . path . join ( swift_path , ' CMakeLists . txt ' ) ) : <nl> return result <nl> - return swift_path <nl> + ( _ , swift_repo_name ) = os . path . split ( swift_path ) <nl> + return swift_repo_name <nl> <nl> <nl> # Set SWIFT_REPO_NAME in your environment to control the name of the swift <nl>
|
Use the directory name , not full directory in SwiftBuildSupport . SWIFT_REPO_NAME
|
apple/swift
|
12af0a51dc5cea062c9646e601e29092bd6c488b
|
2017-03-31T02:46:54Z
|
mmm a / include / v8 . h <nl> ppp b / include / v8 . h <nl> class V8_EXPORT Object : public Value { <nl> V8_DEPRECATED ( " Use maybe version " , bool HasOwnProperty ( Local < String > key ) ) ; <nl> V8_WARN_UNUSED_RESULT Maybe < bool > HasOwnProperty ( Local < Context > context , <nl> Local < Name > key ) ; <nl> + V8_WARN_UNUSED_RESULT Maybe < bool > HasOwnProperty ( Local < Context > context , <nl> + uint32_t index ) ; <nl> V8_DEPRECATE_SOON ( " Use maybe version " , <nl> bool HasRealNamedProperty ( Local < String > key ) ) ; <nl> V8_WARN_UNUSED_RESULT Maybe < bool > HasRealNamedProperty ( Local < Context > context , <nl> mmm a / src / api . cc <nl> ppp b / src / api . cc <nl> Maybe < bool > v8 : : Object : : HasOwnProperty ( Local < Context > context , <nl> return result ; <nl> } <nl> <nl> + Maybe < bool > v8 : : Object : : HasOwnProperty ( Local < Context > context , uint32_t index ) { <nl> + PREPARE_FOR_EXECUTION_PRIMITIVE ( context , Object , HasOwnProperty , bool ) ; <nl> + auto self = Utils : : OpenHandle ( this ) ; <nl> + auto result = i : : JSReceiver : : HasOwnProperty ( self , index ) ; <nl> + has_pending_exception = result . IsNothing ( ) ; <nl> + RETURN_ON_FAILED_EXECUTION_PRIMITIVE ( bool ) ; <nl> + return result ; <nl> + } <nl> <nl> bool v8 : : Object : : HasOwnProperty ( Local < String > key ) { <nl> auto context = ContextFromHeapObject ( Utils : : OpenHandle ( this ) ) ; <nl> mmm a / src / objects - inl . h <nl> ppp b / src / objects - inl . h <nl> Maybe < bool > JSReceiver : : HasOwnProperty ( Handle < JSReceiver > object , <nl> return Just ( attributes . FromJust ( ) ! = ABSENT ) ; <nl> } <nl> <nl> + Maybe < bool > JSReceiver : : HasOwnProperty ( Handle < JSReceiver > object , <nl> + uint32_t index ) { <nl> + if ( object - > IsJSObject ( ) ) { / / Shortcut <nl> + LookupIterator it ( object - > GetIsolate ( ) , object , index , object , <nl> + LookupIterator : : OWN ) ; <nl> + return HasProperty ( & it ) ; <nl> + } <nl> + <nl> + Maybe < PropertyAttributes > attributes = <nl> + JSReceiver : : GetOwnPropertyAttributes ( object , index ) ; <nl> + MAYBE_RETURN ( attributes , Nothing < bool > ( ) ) ; <nl> + return Just ( attributes . FromJust ( ) ! = ABSENT ) ; <nl> + } <nl> <nl> Maybe < PropertyAttributes > JSReceiver : : GetPropertyAttributes ( <nl> Handle < JSReceiver > object , Handle < Name > name ) { <nl> Maybe < PropertyAttributes > JSReceiver : : GetOwnPropertyAttributes ( <nl> return GetPropertyAttributes ( & it ) ; <nl> } <nl> <nl> + Maybe < PropertyAttributes > JSReceiver : : GetOwnPropertyAttributes ( <nl> + Handle < JSReceiver > object , uint32_t index ) { <nl> + LookupIterator it ( object - > GetIsolate ( ) , object , index , object , <nl> + LookupIterator : : OWN ) ; <nl> + return GetPropertyAttributes ( & it ) ; <nl> + } <nl> <nl> Maybe < bool > JSReceiver : : HasElement ( Handle < JSReceiver > object , uint32_t index ) { <nl> LookupIterator it ( object - > GetIsolate ( ) , object , index , object ) ; <nl> mmm a / src / objects . h <nl> ppp b / src / objects . h <nl> class JSReceiver : public HeapObject { <nl> <nl> MUST_USE_RESULT static inline Maybe < bool > HasOwnProperty ( <nl> Handle < JSReceiver > object , Handle < Name > name ) ; <nl> + MUST_USE_RESULT static inline Maybe < bool > HasOwnProperty ( <nl> + Handle < JSReceiver > object , uint32_t index ) ; <nl> <nl> MUST_USE_RESULT static inline MaybeHandle < Object > GetProperty ( <nl> Isolate * isolate , Handle < JSReceiver > receiver , const char * key ) ; <nl> class JSReceiver : public HeapObject { <nl> Handle < JSReceiver > object , Handle < Name > name ) ; <nl> MUST_USE_RESULT static inline Maybe < PropertyAttributes > <nl> GetOwnPropertyAttributes ( Handle < JSReceiver > object , Handle < Name > name ) ; <nl> + MUST_USE_RESULT static inline Maybe < PropertyAttributes > <nl> + GetOwnPropertyAttributes ( Handle < JSReceiver > object , uint32_t index ) ; <nl> <nl> MUST_USE_RESULT static inline Maybe < PropertyAttributes > GetElementAttributes ( <nl> Handle < JSReceiver > object , uint32_t index ) ; <nl> mmm a / test / cctest / test - api . cc <nl> ppp b / test / cctest / test - api . cc <nl> TEST ( HasOwnProperty ) { <nl> HasOwnPropertyNamedPropertyGetter ) ) ; <nl> Local < Object > instance = templ - > NewInstance ( env . local ( ) ) . ToLocalChecked ( ) ; <nl> CHECK ( ! instance - > HasOwnProperty ( env . local ( ) , v8_str ( " 42 " ) ) . FromJust ( ) ) ; <nl> + CHECK ( ! instance - > HasOwnProperty ( env . local ( ) , 42 ) . FromJust ( ) ) ; <nl> CHECK ( instance - > HasOwnProperty ( env . local ( ) , v8_str ( " foo " ) ) . FromJust ( ) ) ; <nl> CHECK ( ! instance - > HasOwnProperty ( env . local ( ) , v8_str ( " bar " ) ) . FromJust ( ) ) ; <nl> } <nl> TEST ( HasOwnProperty ) { <nl> HasOwnPropertyIndexedPropertyGetter ) ) ; <nl> Local < Object > instance = templ - > NewInstance ( env . local ( ) ) . ToLocalChecked ( ) ; <nl> CHECK ( instance - > HasOwnProperty ( env . local ( ) , v8_str ( " 42 " ) ) . FromJust ( ) ) ; <nl> + CHECK ( instance - > HasOwnProperty ( env . local ( ) , 42 ) . FromJust ( ) ) ; <nl> CHECK ( ! instance - > HasOwnProperty ( env . local ( ) , v8_str ( " 43 " ) ) . FromJust ( ) ) ; <nl> + CHECK ( ! instance - > HasOwnProperty ( env . local ( ) , 43 ) . FromJust ( ) ) ; <nl> CHECK ( ! instance - > HasOwnProperty ( env . local ( ) , v8_str ( " foo " ) ) . FromJust ( ) ) ; <nl> } <nl> { / / Check named query interceptors . <nl> TEST ( HasOwnProperty ) { <nl> 0 , 0 , HasOwnPropertyIndexedPropertyQuery ) ) ; <nl> Local < Object > instance = templ - > NewInstance ( env . local ( ) ) . ToLocalChecked ( ) ; <nl> CHECK ( instance - > HasOwnProperty ( env . local ( ) , v8_str ( " 42 " ) ) . FromJust ( ) ) ; <nl> + CHECK ( instance - > HasOwnProperty ( env . local ( ) , 42 ) . FromJust ( ) ) ; <nl> CHECK ( ! instance - > HasOwnProperty ( env . local ( ) , v8_str ( " 41 " ) ) . FromJust ( ) ) ; <nl> + CHECK ( ! instance - > HasOwnProperty ( env . local ( ) , 41 ) . FromJust ( ) ) ; <nl> } <nl> { / / Check callbacks . <nl> Local < ObjectTemplate > templ = ObjectTemplate : : New ( isolate ) ; <nl>
|
Add HasOwnProperty with array indexes
|
v8/v8
|
c7715c2fbee025f69acc539f8620b7d423d5c3e8
|
2016-06-22T10:20:45Z
|
mmm a / src / wallet / db . cpp <nl> ppp b / src / wallet / db . cpp <nl> void BerkeleyEnvironment : : Flush ( bool fShutdown ) <nl> if ( ! fMockDb ) { <nl> fs : : remove_all ( fs : : path ( strPath ) / " database " ) ; <nl> } <nl> - g_dbenvs . erase ( strPath ) ; <nl> } <nl> } <nl> } <nl> void BerkeleyDatabase : : Flush ( bool shutdown ) <nl> { <nl> if ( ! IsDummy ( ) ) { <nl> env - > Flush ( shutdown ) ; <nl> - if ( shutdown ) env = nullptr ; <nl> + if ( shutdown ) { <nl> + LOCK ( cs_db ) ; <nl> + g_dbenvs . erase ( env - > Directory ( ) . string ( ) ) ; <nl> + env = nullptr ; <nl> + } <nl> } <nl> } <nl>
|
Move BerkeleyEnvironment deletion from internal method to callsite
|
bitcoin/bitcoin
|
a769461d5e37ddcb771ae836254fdc69177a28c4
|
2018-08-09T18:27:39Z
|
mmm a / api / baseapi . cpp <nl> ppp b / api / baseapi . cpp <nl> void TessBaseAPI : : GetBlockTextOrientations ( int * * block_orientation , <nl> block_it . move_to_first ( ) ; <nl> int num_blocks = 0 ; <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; block_it . forward ( ) ) { <nl> - if ( ! block_it . data ( ) - > poly_block ( ) - > IsText ( ) ) { <nl> + if ( ! block_it . data ( ) - > pdblk . poly_block ( ) - > IsText ( ) ) { <nl> continue ; <nl> } <nl> + + num_blocks ; <nl> void TessBaseAPI : : GetBlockTextOrientations ( int * * block_orientation , <nl> int i = 0 ; <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; <nl> block_it . forward ( ) ) { <nl> - if ( ! block_it . data ( ) - > poly_block ( ) - > IsText ( ) ) { <nl> + if ( ! block_it . data ( ) - > pdblk . poly_block ( ) - > IsText ( ) ) { <nl> continue ; <nl> } <nl> FCOORD re_rotation = block_it . data ( ) - > re_rotation ( ) ; <nl> ROW * TessBaseAPI : : FindRowForBox ( BLOCK_LIST * blocks , <nl> BLOCK_IT b_it ( blocks ) ; <nl> for ( b_it . mark_cycle_pt ( ) ; ! b_it . cycled_list ( ) ; b_it . forward ( ) ) { <nl> BLOCK * block = b_it . data ( ) ; <nl> - if ( ! box . major_overlap ( block - > bounding_box ( ) ) ) <nl> + if ( ! box . major_overlap ( block - > pdblk . bounding_box ( ) ) ) <nl> continue ; <nl> ROW_IT r_it ( block - > row_list ( ) ) ; <nl> for ( r_it . mark_cycle_pt ( ) ; ! r_it . cycled_list ( ) ; r_it . forward ( ) ) { <nl> mmm a / ccmain / applybox . cpp <nl> ppp b / ccmain / applybox . cpp <nl> PAGE_RES * Tesseract : : ApplyBoxes ( const STRING & fname , <nl> / / Helper computes median xheight in the image . <nl> static double MedianXHeight ( BLOCK_LIST * block_list ) { <nl> BLOCK_IT block_it ( block_list ) ; <nl> - STATS xheights ( 0 , block_it . data ( ) - > bounding_box ( ) . height ( ) ) ; <nl> + STATS xheights ( 0 , block_it . data ( ) - > pdblk . bounding_box ( ) . height ( ) ) ; <nl> for ( block_it . mark_cycle_pt ( ) ; <nl> ! block_it . cycled_list ( ) ; block_it . forward ( ) ) { <nl> ROW_IT row_it ( block_it . data ( ) - > row_list ( ) ) ; <nl> bool Tesseract : : ResegmentWordBox ( BLOCK_LIST * block_list , <nl> BLOCK_IT b_it ( block_list ) ; <nl> for ( b_it . mark_cycle_pt ( ) ; ! b_it . cycled_list ( ) ; b_it . forward ( ) ) { <nl> BLOCK * block = b_it . data ( ) ; <nl> - if ( ! box . major_overlap ( block - > bounding_box ( ) ) ) <nl> + if ( ! box . major_overlap ( block - > pdblk . bounding_box ( ) ) ) <nl> continue ; <nl> ROW_IT r_it ( block - > row_list ( ) ) ; <nl> for ( r_it . mark_cycle_pt ( ) ; ! r_it . cycled_list ( ) ; r_it . forward ( ) ) { <nl> mmm a / ccmain / control . cpp <nl> ppp b / ccmain / control . cpp <nl> bool Tesseract : : recog_all_words ( PAGE_RES * page_res , <nl> page_res_it . forward ( ) ) { <nl> WERD_RES * word = page_res_it . word ( ) ; <nl> POLY_BLOCK * pb = page_res_it . block ( ) - > block ! = NULL <nl> - ? page_res_it . block ( ) - > block - > poly_block ( ) <nl> + ? page_res_it . block ( ) - > block - > pdblk . poly_block ( ) <nl> : NULL ; <nl> if ( word - > best_choice = = NULL | | word - > best_choice - > length ( ) = = 0 | | <nl> ( word - > best_choice - > IsAllSpaces ( ) & & ( pb = = NULL | | pb - > IsText ( ) ) ) ) { <nl> mmm a / ccmain / docqual . cpp <nl> ppp b / ccmain / docqual . cpp <nl> void Tesseract : : doc_and_block_rejection ( / / reject big chunks <nl> WERD_RES * word ; <nl> while ( ( word = page_res_it . word ( ) ) ! = NULL ) { <nl> current_block = page_res_it . block ( ) ; <nl> - block_no = current_block - > block - > index ( ) ; <nl> + block_no = current_block - > block - > pdblk . index ( ) ; <nl> if ( current_block - > char_count > 0 & & <nl> ( current_block - > rej_count * 100 . 0 / current_block - > char_count ) > <nl> tessedit_reject_block_percent ) { <nl> void Tesseract : : tilde_crunch ( PAGE_RES_IT & page_res_it ) { <nl> <nl> page_res_it . restart_page ( ) ; <nl> while ( page_res_it . word ( ) ! = NULL ) { <nl> - POLY_BLOCK * pb = page_res_it . block ( ) - > block - > poly_block ( ) ; <nl> + POLY_BLOCK * pb = page_res_it . block ( ) - > block - > pdblk . poly_block ( ) ; <nl> if ( pb ! = NULL & & ! pb - > IsText ( ) ) { <nl> page_res_it . forward ( ) ; <nl> continue ; <nl> mmm a / ccmain / linerec . cpp <nl> ppp b / ccmain / linerec . cpp <nl> void Tesseract : : TrainFromBoxes ( const GenericVector < TBOX > & boxes , <nl> BLOCK_IT b_it ( block_list ) ; <nl> for ( b_it . mark_cycle_pt ( ) ; ! b_it . cycled_list ( ) ; b_it . forward ( ) ) { <nl> BLOCK * block = b_it . data ( ) ; <nl> - if ( block - > poly_block ( ) ! = NULL & & ! block - > poly_block ( ) - > IsText ( ) ) <nl> + if ( block - > pdblk . poly_block ( ) ! = NULL & & ! block - > pdblk . poly_block ( ) - > IsText ( ) ) <nl> continue ; / / Not a text block . <nl> - TBOX block_box = block - > bounding_box ( ) ; <nl> + TBOX block_box = block - > pdblk . bounding_box ( ) ; <nl> block_box . rotate ( block - > re_rotation ( ) ) ; <nl> if ( block_box . major_overlap ( line_box ) ) { <nl> TBOX overlap_box = line_box . intersection ( block_box ) ; <nl> ImageData * Tesseract : : GetRectImage ( const TBOX & box , const BLOCK & block , <nl> num_rotations = 3 ; <nl> / / Handle two cases automatically : 1 the box came from the block , 2 the box <nl> / / came from a box file , and refers to the image , which the block may not . <nl> - if ( block . bounding_box ( ) . major_overlap ( * revised_box ) ) <nl> + if ( block . pdblk . bounding_box ( ) . major_overlap ( * revised_box ) ) <nl> revised_box - > rotate ( block . re_rotation ( ) ) ; <nl> / / Now revised_box always refers to the image . <nl> / / BestPix is never colormapped , but may be of any depth . <nl> mmm a / ccmain / osdetect . cpp <nl> ppp b / ccmain / osdetect . cpp <nl> int os_detect ( TO_BLOCK_LIST * port_blocks , OSResults * osr , <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; <nl> block_it . forward ( ) ) { <nl> TO_BLOCK * to_block = block_it . data ( ) ; <nl> - if ( to_block - > block - > poly_block ( ) & & <nl> - ! to_block - > block - > poly_block ( ) - > IsText ( ) ) continue ; <nl> + if ( to_block - > block - > pdblk . poly_block ( ) & & <nl> + ! to_block - > block - > pdblk . poly_block ( ) - > IsText ( ) ) continue ; <nl> BLOBNBOX_IT bbox_it ; <nl> bbox_it . set_to_list ( & to_block - > blobs ) ; <nl> for ( bbox_it . mark_cycle_pt ( ) ; ! bbox_it . cycled_list ( ) ; <nl> mmm a / ccmain / output . cpp <nl> ppp b / ccmain / output . cpp <nl> char determine_newline_type ( / / test line ends <nl> return CTRL_HARDLINE ; / / it is tabbed <nl> word_box = word - > bounding_box ( ) ; <nl> next_box = next_word - > bounding_box ( ) ; <nl> - block_box = block - > bounding_box ( ) ; <nl> + block_box = block - > pdblk . bounding_box ( ) ; <nl> / / gap to eol <nl> end_gap = block_box . right ( ) - word_box . right ( ) ; <nl> end_gap - = ( int32_t ) block - > space ( ) ; <nl> mmm a / ccmain / pageiterator . cpp <nl> ppp b / ccmain / pageiterator . cpp <nl> bool PageIterator : : Empty ( PageIteratorLevel level ) const { <nl> PolyBlockType PageIterator : : BlockType ( ) const { <nl> if ( it_ - > block ( ) = = NULL | | it_ - > block ( ) - > block = = NULL ) <nl> return PT_UNKNOWN ; / / Already at the end ! <nl> - if ( it_ - > block ( ) - > block - > poly_block ( ) = = NULL ) <nl> + if ( it_ - > block ( ) - > block - > pdblk . poly_block ( ) = = NULL ) <nl> return PT_FLOWING_TEXT ; / / No layout analysis used - assume text . <nl> - return it_ - > block ( ) - > block - > poly_block ( ) - > isA ( ) ; <nl> + return it_ - > block ( ) - > block - > pdblk . poly_block ( ) - > isA ( ) ; <nl> } <nl> <nl> / * * Returns the polygon outline of the current block . The returned Pta must <nl> PolyBlockType PageIterator : : BlockType ( ) const { <nl> Pta * PageIterator : : BlockPolygon ( ) const { <nl> if ( it_ - > block ( ) = = NULL | | it_ - > block ( ) - > block = = NULL ) <nl> return NULL ; / / Already at the end ! <nl> - if ( it_ - > block ( ) - > block - > poly_block ( ) = = NULL ) <nl> + if ( it_ - > block ( ) - > block - > pdblk . poly_block ( ) = = NULL ) <nl> return NULL ; / / No layout analysis used - no polygon . <nl> - ICOORDELT_IT it ( it_ - > block ( ) - > block - > poly_block ( ) - > points ( ) ) ; <nl> + ICOORDELT_IT it ( it_ - > block ( ) - > block - > pdblk . poly_block ( ) - > points ( ) ) ; <nl> Pta * pta = ptaCreate ( it . length ( ) ) ; <nl> int num_pts = 0 ; <nl> for ( it . mark_cycle_pt ( ) ; ! it . cycled_list ( ) ; it . forward ( ) , + + num_pts ) { <nl> mmm a / ccmain / pagesegmain . cpp <nl> ppp b / ccmain / pagesegmain . cpp <nl> ColumnFinder * Tesseract : : SetupPageSegAndDetectOrientation ( <nl> / / TODO ( rays ) handle new textline finding with a UNLV zone file . <nl> ASSERT_HOST ( to_blocks - > singleton ( ) ) ; <nl> TO_BLOCK * to_block = to_block_it . data ( ) ; <nl> - TBOX blkbox = to_block - > block - > bounding_box ( ) ; <nl> + TBOX blkbox = to_block - > block - > pdblk . bounding_box ( ) ; <nl> ColumnFinder * finder = NULL ; <nl> int estimated_resolution = source_resolution_ ; <nl> if ( source_resolution_ = = kMinCredibleResolution ) { <nl> mmm a / ccmain / paragraphs . cpp <nl> ppp b / ccmain / paragraphs . cpp <nl> void DetectParagraphs ( int debug_level , <nl> } <nl> BLOCK * block = block_start - > PageResIt ( ) - > block ( ) - > block ; <nl> block - > para_list ( ) - > clear ( ) ; <nl> - bool is_image_block = block - > poly_block ( ) & & ! block - > poly_block ( ) - > IsText ( ) ; <nl> + bool is_image_block = block - > pdblk . poly_block ( ) & & ! block - > pdblk . poly_block ( ) - > IsText ( ) ; <nl> <nl> / / Convert the Tesseract structures to RowInfos <nl> / / for the paragraph detection algorithm . <nl> mmm a / ccmain / pgedit . cpp <nl> ppp b / ccmain / pgedit . cpp <nl> void Tesseract : : do_re_display ( <nl> if ( display_baselines & & pr_it . row ( ) ! = pr_it . prev_row ( ) ) <nl> pr_it . row ( ) - > row - > plot_baseline ( image_win , ScrollView : : GREEN ) ; <nl> if ( display_blocks & & pr_it . block ( ) ! = pr_it . prev_block ( ) ) <nl> - pr_it . block ( ) - > block - > plot ( image_win , block_count + + , ScrollView : : RED ) ; <nl> + pr_it . block ( ) - > block - > pdblk . plot ( image_win , block_count + + , ScrollView : : RED ) ; <nl> } <nl> image_win - > Update ( ) ; <nl> } <nl> mmm a / ccstruct / blobbox . h <nl> ppp b / ccstruct / blobbox . h <nl> class TO_BLOCK : public ELIST_LINK <nl> } <nl> } <nl> / / Rotate the block <nl> - ASSERT_HOST ( block - > poly_block ( ) ! = NULL ) ; <nl> + ASSERT_HOST ( block - > pdblk . poly_block ( ) ! = NULL ) ; <nl> block - > rotate ( rotation ) ; <nl> / / Update the median size statistic from the blobs list . <nl> - STATS widths ( 0 , block - > bounding_box ( ) . width ( ) ) ; <nl> - STATS heights ( 0 , block - > bounding_box ( ) . height ( ) ) ; <nl> + STATS widths ( 0 , block - > pdblk . bounding_box ( ) . width ( ) ) ; <nl> + STATS heights ( 0 , block - > pdblk . bounding_box ( ) . height ( ) ) ; <nl> BLOBNBOX_IT blob_it ( & blobs ) ; <nl> for ( blob_it . mark_cycle_pt ( ) ; ! blob_it . cycled_list ( ) ; blob_it . forward ( ) ) { <nl> widths . add ( blob_it . data ( ) - > bounding_box ( ) . width ( ) , 1 ) ; <nl> mmm a / ccstruct / ocrblock . cpp <nl> ppp b / ccstruct / ocrblock . cpp <nl> BLOCK : : BLOCK ( const char * name , / / < filename <nl> int16_t xmin , / / < bottom left <nl> int16_t ymin , int16_t xmax , / / < top right <nl> int16_t ymax ) <nl> - : PDBLK ( xmin , ymin , xmax , ymax ) , <nl> - filename ( name ) , <nl> + : filename ( name ) , <nl> + pdblk ( xmin , ymin , xmax , ymax ) , <nl> re_rotation_ ( 1 . 0f , 0 . 0f ) , <nl> classify_rotation_ ( 1 . 0f , 0 . 0f ) , <nl> skew_ ( 1 . 0f , 0 . 0f ) { <nl> - ICOORDELT_IT left_it = & leftside ; <nl> - ICOORDELT_IT right_it = & rightside ; <nl> + ICOORDELT_IT left_it = & pdblk . leftside ; <nl> + ICOORDELT_IT right_it = & pdblk . rightside ; <nl> <nl> proportional = prop ; <nl> right_to_left_ = false ; <nl> BLOCK : : BLOCK ( const char * name , / / < filename <nl> spacing = space ; <nl> font_class = - 1 ; / / not assigned <nl> cell_over_xheight_ = 2 . 0f ; <nl> - hand_poly = NULL ; <nl> - left_it . set_to_list ( & leftside ) ; <nl> - right_it . set_to_list ( & rightside ) ; <nl> + pdblk . hand_poly = NULL ; <nl> + left_it . set_to_list ( & pdblk . leftside ) ; <nl> + right_it . set_to_list ( & pdblk . rightside ) ; <nl> / / make default box <nl> left_it . add_to_end ( new ICOORDELT ( xmin , ymin ) ) ; <nl> left_it . add_to_end ( new ICOORDELT ( xmin , ymax ) ) ; <nl> int decreasing_top_order ( / / <nl> * Rotate the polygon by the given rotation and recompute the bounding_box . <nl> * / <nl> void BLOCK : : rotate ( const FCOORD & rotation ) { <nl> - poly_block ( ) - > rotate ( rotation ) ; <nl> - box = * poly_block ( ) - > bounding_box ( ) ; <nl> + pdblk . poly_block ( ) - > rotate ( rotation ) ; <nl> + pdblk . box = * pdblk . poly_block ( ) - > bounding_box ( ) ; <nl> } <nl> <nl> / / Returns the bounding box including the desired combination of upper and <nl> TBOX BLOCK : : restricted_bounding_box ( bool upper_dots , bool lower_dots ) const { <nl> * Does nothing to any contained rows / words / blobs etc . <nl> * / <nl> void BLOCK : : reflect_polygon_in_y_axis ( ) { <nl> - poly_block ( ) - > reflect_in_y_axis ( ) ; <nl> - box = * poly_block ( ) - > bounding_box ( ) ; <nl> + pdblk . poly_block ( ) - > reflect_in_y_axis ( ) ; <nl> + pdblk . box = * pdblk . poly_block ( ) - > bounding_box ( ) ; <nl> } <nl> <nl> / * * <nl> void BLOCK : : compress ( ) { / / squash it up <nl> <nl> sort_rows ( ) ; <nl> <nl> - box = TBOX ( box . topleft ( ) , box . topleft ( ) ) ; <nl> - box . move_bottom_edge ( ROW_SPACING ) ; <nl> + pdblk . box = TBOX ( pdblk . box . topleft ( ) , pdblk . box . topleft ( ) ) ; <nl> + pdblk . box . move_bottom_edge ( ROW_SPACING ) ; <nl> for ( row_it . mark_cycle_pt ( ) ; ! row_it . cycled_list ( ) ; row_it . forward ( ) ) { <nl> row = row_it . data ( ) ; <nl> - row - > move ( box . botleft ( ) - row_spacing - <nl> + row - > move ( pdblk . box . botleft ( ) - row_spacing - <nl> row - > bounding_box ( ) . topleft ( ) ) ; <nl> - box + = row - > bounding_box ( ) ; <nl> + pdblk . box + = row - > bounding_box ( ) ; <nl> } <nl> <nl> - leftside . clear ( ) ; <nl> - icoordelt_it . set_to_list ( & leftside ) ; <nl> - icoordelt_it . add_to_end ( new ICOORDELT ( box . left ( ) , box . bottom ( ) ) ) ; <nl> - icoordelt_it . add_to_end ( new ICOORDELT ( box . left ( ) , box . top ( ) ) ) ; <nl> - rightside . clear ( ) ; <nl> - icoordelt_it . set_to_list ( & rightside ) ; <nl> - icoordelt_it . add_to_end ( new ICOORDELT ( box . right ( ) , box . bottom ( ) ) ) ; <nl> - icoordelt_it . add_to_end ( new ICOORDELT ( box . right ( ) , box . top ( ) ) ) ; <nl> + pdblk . leftside . clear ( ) ; <nl> + icoordelt_it . set_to_list ( & pdblk . leftside ) ; <nl> + icoordelt_it . add_to_end ( new ICOORDELT ( pdblk . box . left ( ) , pdblk . box . bottom ( ) ) ) ; <nl> + icoordelt_it . add_to_end ( new ICOORDELT ( pdblk . box . left ( ) , pdblk . box . top ( ) ) ) ; <nl> + pdblk . rightside . clear ( ) ; <nl> + icoordelt_it . set_to_list ( & pdblk . rightside ) ; <nl> + icoordelt_it . add_to_end ( new ICOORDELT ( pdblk . box . right ( ) , pdblk . box . bottom ( ) ) ) ; <nl> + icoordelt_it . add_to_end ( new ICOORDELT ( pdblk . box . right ( ) , pdblk . box . top ( ) ) ) ; <nl> } <nl> <nl> <nl> void BLOCK : : check_pitch ( ) { / / check prop <nl> void BLOCK : : compress ( / / squash it up <nl> const ICOORD vec / / and move <nl> ) { <nl> - box . move ( vec ) ; <nl> + pdblk . box . move ( vec ) ; <nl> compress ( ) ; <nl> } <nl> <nl> void BLOCK : : print ( / / print list of sides <nl> FILE * , / / < file to print on <nl> BOOL8 dump / / < print full detail <nl> ) { <nl> - ICOORDELT_IT it = & leftside ; / / iterator <nl> + ICOORDELT_IT it = & pdblk . leftside ; / / iterator <nl> <nl> - box . print ( ) ; <nl> + pdblk . box . print ( ) ; <nl> tprintf ( " Proportional = % s \ n " , proportional ? " TRUE " : " FALSE " ) ; <nl> tprintf ( " Kerning = % d \ n " , kerning ) ; <nl> tprintf ( " Spacing = % d \ n " , spacing ) ; <nl> void BLOCK : : print ( / / print list of sides <nl> tprintf ( " ( % d , % d ) " , it . data ( ) - > x ( ) , it . data ( ) - > y ( ) ) ; <nl> tprintf ( " \ n " ) ; <nl> tprintf ( " Right side coords are : \ n " ) ; <nl> - it . set_to_list ( & rightside ) ; <nl> + it . set_to_list ( & pdblk . rightside ) ; <nl> for ( it . mark_cycle_pt ( ) ; ! it . cycled_list ( ) ; it . forward ( ) ) <nl> tprintf ( " ( % d , % d ) " , it . data ( ) - > x ( ) , it . data ( ) - > y ( ) ) ; <nl> tprintf ( " \ n " ) ; <nl> BLOCK & BLOCK : : operator = ( / / assignment <nl> const BLOCK & source / / from this <nl> ) { <nl> this - > ELIST_LINK : : operator = ( source ) ; <nl> - this - > PDBLK : : operator = ( source ) ; <nl> + pdblk = source . pdblk ; <nl> proportional = source . proportional ; <nl> kerning = source . kerning ; <nl> spacing = source . spacing ; <nl> void BLOCK : : compute_row_margins ( ) { <nl> } <nl> <nl> / / If Layout analysis was not called , default to this . <nl> - POLY_BLOCK rect_block ( bounding_box ( ) , PT_FLOWING_TEXT ) ; <nl> + POLY_BLOCK rect_block ( pdblk . bounding_box ( ) , PT_FLOWING_TEXT ) ; <nl> POLY_BLOCK * pblock = & rect_block ; <nl> - if ( poly_block ( ) ! = NULL ) { <nl> - pblock = poly_block ( ) ; <nl> + if ( pdblk . poly_block ( ) ! = NULL ) { <nl> + pblock = pdblk . poly_block ( ) ; <nl> } <nl> <nl> / / Step One : Determine if there is a drop - cap . <nl> void RefreshWordBlobsFromNewBlobs ( BLOCK_LIST * block_list , <nl> BLOCK_IT block_it ( block_list ) ; <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; block_it . forward ( ) ) { <nl> BLOCK * block = block_it . data ( ) ; <nl> - if ( block - > poly_block ( ) ! = NULL & & ! block - > poly_block ( ) - > IsText ( ) ) <nl> + if ( block - > pdblk . poly_block ( ) ! = NULL & & ! block - > pdblk . poly_block ( ) - > IsText ( ) ) <nl> continue ; / / Don ' t touch non - text blocks . <nl> / / Iterate over all rows in the block . <nl> ROW_IT row_it ( block - > row_list ( ) ) ; <nl> mmm a / ccstruct / ocrblock . h <nl> ppp b / ccstruct / ocrblock . h <nl> <nl> class BLOCK ; / / forward decl <nl> <nl> ELISTIZEH ( BLOCK ) <nl> - class BLOCK : public ELIST_LINK , public PDBLK <nl> + class BLOCK : public ELIST_LINK <nl> / / page block <nl> { <nl> - friend class BLOCK_RECT_IT ; / / block iterator <nl> - <nl> + friend class BLOCK_RECT_IT ; / / block iterator <nl> public : <nl> BLOCK ( ) <nl> : re_rotation_ ( 1 . 0f , 0 . 0f ) , <nl> classify_rotation_ ( 1 . 0f , 0 . 0f ) , <nl> skew_ ( 1 . 0f , 0 . 0f ) { <nl> right_to_left_ = false ; <nl> - hand_poly = NULL ; <nl> + pdblk . hand_poly = NULL ; <nl> } <nl> BLOCK ( const char * name , / / < filename <nl> BOOL8 prop , / / < proportional <nl> class BLOCK : public ELIST_LINK , public PDBLK <nl> } <nl> <nl> Pix * render_mask ( TBOX * mask_box ) { <nl> - return PDBLK : : render_mask ( re_rotation_ , mask_box ) ; <nl> + return pdblk . render_mask ( re_rotation_ , mask_box ) ; <nl> } <nl> <nl> / / Returns the bounding box including the desired combination of upper and <nl> class BLOCK : public ELIST_LINK , public PDBLK <nl> void print ( FILE * fp , BOOL8 dump ) ; <nl> <nl> BLOCK & operator = ( const BLOCK & source ) ; <nl> + PDBLK pdblk ; / / < Page Description Block <nl> <nl> private : <nl> BOOL8 proportional ; / / < proportional <nl> class BLOCK : public ELIST_LINK , public PDBLK <nl> FCOORD re_rotation_ ; / / < How to transform coords back to image . <nl> FCOORD classify_rotation_ ; / / < Apply this before classifying . <nl> FCOORD skew_ ; / / < Direction of true horizontal . <nl> - ICOORD median_size_ ; / / < Median size of blobs . <nl> + ICOORD median_size_ ; / / < Median size of blobs . <nl> } ; <nl> <nl> int decreasing_top_order ( const void * row1 , const void * row2 ) ; <nl> mmm a / ccstruct / pageres . cpp <nl> ppp b / ccstruct / pageres . cpp <nl> bool WERD_RES : : SetupForRecognition ( const UNICHARSET & unicharset_in , <nl> tesseract : : OcrEngineMode norm_mode_hint = <nl> static_cast < tesseract : : OcrEngineMode > ( norm_mode ) ; <nl> tesseract = tess ; <nl> - POLY_BLOCK * pb = block ! = NULL ? block - > poly_block ( ) : NULL ; <nl> + POLY_BLOCK * pb = block ! = NULL ? block - > pdblk . poly_block ( ) : NULL ; <nl> if ( ( norm_mode_hint ! = tesseract : : OEM_LSTM_ONLY & & <nl> word - > cblob_list ( ) - > empty ( ) ) | | <nl> ( pb ! = NULL & & ! pb - > IsText ( ) ) ) { <nl> mmm a / ccstruct / pdblock . h <nl> ppp b / ccstruct / pdblock . h <nl> CLISTIZEH ( PDBLK ) <nl> / / / page block <nl> class PDBLK { <nl> friend class BLOCK_RECT_IT ; / / < block iterator <nl> + friend class BLOCK ; / / < Page Block <nl> <nl> public : <nl> / / / empty constructor <nl> mmm a / textord / baselinedetect . cpp <nl> ppp b / textord / baselinedetect . cpp <nl> void BaselineBlock : : FitBaselineSplines ( bool enable_splines , <nl> textord - > make_spline_rows ( block_ , gradient , show_final_rows ) ; <nl> } else { <nl> / / Make a fake spline from the existing line . <nl> - TBOX block_box = block_ - > block - > bounding_box ( ) ; <nl> + TBOX block_box = block_ - > block - > pdblk . bounding_box ( ) ; <nl> TO_ROW_IT row_it = block_ - > get_rows ( ) ; <nl> for ( row_it . mark_cycle_pt ( ) ; ! row_it . cycled_list ( ) ; row_it . forward ( ) ) { <nl> TO_ROW * row = row_it . data ( ) ; <nl> void BaselineBlock : : DrawFinalRows ( const ICOORD & page_tr ) { <nl> if ( non_text_block_ ) return ; <nl> double gradient = tan ( skew_angle_ ) ; <nl> FCOORD rotation ( 1 . 0f , 0 . 0f ) ; <nl> - int left_edge = block_ - > block - > bounding_box ( ) . left ( ) ; <nl> + int left_edge = block_ - > block - > pdblk . bounding_box ( ) . left ( ) ; <nl> ScrollView * win = create_to_win ( page_tr ) ; <nl> ScrollView : : Color colour = ScrollView : : RED ; <nl> TO_ROW_IT row_it = block_ - > get_rows ( ) ; <nl> BaselineDetect : : BaselineDetect ( int debug_level , const FCOORD & page_skew , <nl> for ( it . mark_cycle_pt ( ) ; ! it . cycled_list ( ) ; it . forward ( ) ) { <nl> TO_BLOCK * to_block = it . data ( ) ; <nl> BLOCK * block = to_block - > block ; <nl> - POLY_BLOCK * pb = block - > poly_block ( ) ; <nl> + POLY_BLOCK * pb = block - > pdblk . poly_block ( ) ; <nl> / / A note about non - text blocks . <nl> / / On output , non - text blocks are supposed to contain a single empty word <nl> / / in each incoming text line . These mark out the polygonal bounds of the <nl> mmm a / textord / bbgrid . cpp <nl> ppp b / textord / bbgrid . cpp <nl> Pix * TraceOutlineOnReducedPix ( C_OUTLINE * outline , int gridsize , <nl> / / As TraceOutlineOnReducedPix above , but on a BLOCK instead of a C_OUTLINE . <nl> Pix * TraceBlockOnReducedPix ( BLOCK * block , int gridsize , <nl> ICOORD bleft , int * left , int * bottom ) { <nl> - const TBOX & box = block - > bounding_box ( ) ; <nl> + const TBOX & box = block - > pdblk . bounding_box ( ) ; <nl> Pix * pix = GridReducedPix ( box , gridsize , bleft , left , bottom ) ; <nl> int wpl = pixGetWpl ( pix ) ; <nl> l_uint32 * data = pixGetData ( pix ) ; <nl> - ICOORDELT_IT it ( block - > poly_block ( ) - > points ( ) ) ; <nl> + ICOORDELT_IT it ( block - > pdblk . poly_block ( ) - > points ( ) ) ; <nl> for ( it . mark_cycle_pt ( ) ; ! it . cycled_list ( ) ; ) { <nl> ICOORD pos = * it . data ( ) ; <nl> it . forward ( ) ; <nl> mmm a / textord / colfind . cpp <nl> ppp b / textord / colfind . cpp <nl> void ColumnFinder : : DisplayBlocks ( BLOCK_LIST * blocks ) { <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; <nl> block_it . forward ( ) ) { <nl> BLOCK * block = block_it . data ( ) ; <nl> - block - > plot ( blocks_win_ , serial + + , <nl> + block - > pdblk . plot ( blocks_win_ , serial + + , <nl> textord_debug_printable ? ScrollView : : BLUE <nl> : ScrollView : : GREEN ) ; <nl> } <nl> void ColumnFinder : : RotateAndReskewBlocks ( bool input_is_rtl , <nl> block - > set_right_to_left ( input_is_rtl ) ; <nl> / / Save the skew angle in the block for baseline computations . <nl> block - > set_skew ( reskew_ ) ; <nl> - block - > set_index ( block_index + + ) ; <nl> + block - > pdblk . set_index ( block_index + + ) ; <nl> FCOORD blob_rotation = ComputeBlockAndClassifyRotation ( block ) ; <nl> / / Rotate all the blobs if needed and recompute the bounding boxes . <nl> / / Compute the block median blob width and height as we go . <nl> - STATS widths ( 0 , block - > bounding_box ( ) . width ( ) ) ; <nl> - STATS heights ( 0 , block - > bounding_box ( ) . height ( ) ) ; <nl> + STATS widths ( 0 , block - > pdblk . bounding_box ( ) . width ( ) ) ; <nl> + STATS heights ( 0 , block - > pdblk . bounding_box ( ) . height ( ) ) ; <nl> RotateAndExplodeBlobList ( blob_rotation , & to_block - > blobs , <nl> & widths , & heights ) ; <nl> TO_ROW_IT row_it ( to_block - > get_rows ( ) ) ; <nl> FCOORD ColumnFinder : : ComputeBlockAndClassifyRotation ( BLOCK * block ) { <nl> / / and page headings for predominantly vertically written CJK books . <nl> FCOORD classify_rotation ( text_rotation_ ) ; <nl> FCOORD block_rotation ( 1 . 0f , 0 . 0f ) ; <nl> - if ( block - > poly_block ( ) - > isA ( ) = = PT_VERTICAL_TEXT ) { <nl> + if ( block - > pdblk . poly_block ( ) - > isA ( ) = = PT_VERTICAL_TEXT ) { <nl> / / Vertical text needs to be 90 degrees rotated relative to the rest . <nl> / / If the rest has a 90 degree rotation already , use the inverse , making <nl> / / the vertical text the original way up . Otherwise use 90 degrees <nl> FCOORD ColumnFinder : : ComputeBlockAndClassifyRotation ( BLOCK * block ) { <nl> block - > set_classify_rotation ( classify_rotation ) ; <nl> if ( textord_debug_tabfind ) { <nl> tprintf ( " Blk % d , type % d rerotation ( % . 2f , % . 2f ) , char ( % . 2f , % . 2f ) , box : " , <nl> - block - > index ( ) , block - > poly_block ( ) - > isA ( ) , <nl> + block - > pdblk . index ( ) , block - > pdblk . poly_block ( ) - > isA ( ) , <nl> block - > re_rotation ( ) . x ( ) , block - > re_rotation ( ) . y ( ) , <nl> classify_rotation . x ( ) , classify_rotation . y ( ) ) ; <nl> - block - > bounding_box ( ) . print ( ) ; <nl> + block - > pdblk . bounding_box ( ) . print ( ) ; <nl> } <nl> return blob_rotation ; <nl> } <nl> mmm a / textord / colpartition . cpp <nl> ppp b / textord / colpartition . cpp <nl> static TO_BLOCK * MoveBlobsToBlock ( bool vertical_text , int line_spacing , <nl> / / Move all the parts to a done list as they are no longer needed , except <nl> / / that have have to continue to exist until the part grid is deleted . <nl> / / Compute the median blob size as we go , as the block needs to know . <nl> - TBOX block_box ( block - > bounding_box ( ) ) ; <nl> + TBOX block_box ( block - > pdblk . bounding_box ( ) ) ; <nl> STATS sizes ( 0 , MAX ( block_box . width ( ) , block_box . height ( ) ) ) ; <nl> - bool text_type = block - > poly_block ( ) - > IsText ( ) ; <nl> + bool text_type = block - > pdblk . poly_block ( ) - > IsText ( ) ; <nl> ColPartition_IT it ( block_parts ) ; <nl> TO_BLOCK * to_block = new TO_BLOCK ( block ) ; <nl> BLOBNBOX_IT blob_it ( & to_block - > blobs ) ; <nl> static TO_BLOCK * MoveBlobsToBlock ( bool vertical_text , int line_spacing , <nl> } <nl> to_block - > line_size = sizes . median ( ) ; <nl> if ( vertical_text ) { <nl> - int block_width = block - > bounding_box ( ) . width ( ) ; <nl> + int block_width = block - > pdblk . bounding_box ( ) . width ( ) ; <nl> if ( block_width < line_spacing ) <nl> line_spacing = block_width ; <nl> to_block - > line_spacing = static_cast < float > ( line_spacing ) ; <nl> to_block - > max_blob_size = static_cast < float > ( block_width + 1 ) ; <nl> } else { <nl> - int block_height = block - > bounding_box ( ) . height ( ) ; <nl> + int block_height = block - > pdblk . bounding_box ( ) . height ( ) ; <nl> if ( block_height < line_spacing ) <nl> line_spacing = block_height ; <nl> to_block - > line_spacing = static_cast < float > ( line_spacing ) ; <nl> TO_BLOCK * ColPartition : : MakeBlock ( const ICOORD & bleft , const ICOORD & tright , <nl> tprintf ( " Making block at ( % d , % d ) - > ( % d , % d ) \ n " , <nl> min_x , min_y , max_x , max_y ) ; <nl> BLOCK * block = new BLOCK ( " " , true , 0 , 0 , min_x , min_y , max_x , max_y ) ; <nl> - block - > set_poly_block ( new POLY_BLOCK ( & vertices , type ) ) ; <nl> + block - > pdblk . set_poly_block ( new POLY_BLOCK ( & vertices , type ) ) ; <nl> return MoveBlobsToBlock ( false , line_spacing , block , block_parts , used_parts ) ; <nl> } <nl> <nl> TO_BLOCK * ColPartition : : MakeVerticalTextBlock ( const ICOORD & bleft , <nl> } <nl> BLOCK * block = new BLOCK ( " " , true , 0 , 0 , block_box . left ( ) , block_box . bottom ( ) , <nl> block_box . right ( ) , block_box . top ( ) ) ; <nl> - block - > set_poly_block ( new POLY_BLOCK ( block_box , type ) ) ; <nl> + block - > pdblk . set_poly_block ( new POLY_BLOCK ( block_box , type ) ) ; <nl> return MoveBlobsToBlock ( true , line_spacing , block , block_parts , used_parts ) ; <nl> } <nl> <nl> mmm a / textord / colpartitiongrid . cpp <nl> ppp b / textord / colpartitiongrid . cpp <nl> void ColPartitionGrid : : ExtractPartitionsAsBlocks ( BLOCK_LIST * blocks , <nl> } <nl> BLOCK * block = new BLOCK ( " " , true , 0 , 0 , box . left ( ) , box . bottom ( ) , <nl> box . right ( ) , box . top ( ) ) ; <nl> - block - > set_poly_block ( new POLY_BLOCK ( box , type ) ) ; <nl> + block - > pdblk . set_poly_block ( new POLY_BLOCK ( box , type ) ) ; <nl> TO_BLOCK * to_block = new TO_BLOCK ( block ) ; <nl> TO_ROW_IT row_it ( to_block - > get_rows ( ) ) ; <nl> row_it . add_after_then_move ( row ) ; <nl> mmm a / textord / edgblob . cpp <nl> ppp b / textord / edgblob . cpp <nl> void extract_edges ( Pix * pix , / / thresholded image <nl> C_OUTLINE_LIST outlines ; / / outlines in block <nl> C_OUTLINE_IT out_it = & outlines ; <nl> <nl> - block_edges ( pix , block , & out_it ) ; <nl> + block_edges ( pix , & ( block - > pdblk ) , & out_it ) ; <nl> ICOORD bleft ; / / block box <nl> ICOORD tright ; <nl> - block - > bounding_box ( bleft , tright ) ; <nl> + block - > pdblk . bounding_box ( bleft , tright ) ; <nl> / / make blobs <nl> outlines_to_blobs ( block , bleft , tright , & outlines ) ; <nl> } <nl> mmm a / textord / makerow . cpp <nl> ppp b / textord / makerow . cpp <nl> float make_single_row ( ICOORD page_tr , bool allow_sub_blobs , <nl> block - > line_size = size ; <nl> } else if ( block - > blobs . empty ( ) ) { <nl> / / Make a fake blob . <nl> - C_BLOB * blob = C_BLOB : : FakeBlob ( block - > block - > bounding_box ( ) ) ; <nl> + C_BLOB * blob = C_BLOB : : FakeBlob ( block - > block - > pdblk . bounding_box ( ) ) ; <nl> / / The blobnbox owns the blob . <nl> BLOBNBOX * bblob = new BLOBNBOX ( blob ) ; <nl> blob_it . add_after_then_move ( bblob ) ; <nl> float make_rows ( ICOORD page_tr , TO_BLOCK_LIST * port_blocks ) { <nl> block_it . set_to_list ( port_blocks ) ; <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; block_it . forward ( ) ) { <nl> cleanup_rows_making ( page_tr , block_it . data ( ) , port_m , FCOORD ( 1 . 0f , 0 . 0f ) , <nl> - block_it . data ( ) - > block - > bounding_box ( ) . left ( ) , <nl> + block_it . data ( ) - > block - > pdblk . bounding_box ( ) . left ( ) , <nl> ! ( BOOL8 ) textord_test_landscape ) ; <nl> } <nl> return port_m ; / / global skew <nl> void compute_page_skew ( / / get average gradient <nl> blob_count = 0 ; <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; <nl> block_it . forward ( ) ) { <nl> - POLY_BLOCK * pb = block_it . data ( ) - > block - > poly_block ( ) ; <nl> + POLY_BLOCK * pb = block_it . data ( ) - > block - > pdblk . poly_block ( ) ; <nl> if ( pb ! = NULL & & ! pb - > IsText ( ) ) <nl> continue ; / / Pretend non - text blocks don ' t exist . <nl> row_count + = block_it . data ( ) - > get_rows ( ) - > length ( ) ; <nl> void compute_page_skew ( / / get average gradient <nl> row_index = 0 ; <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; <nl> block_it . forward ( ) ) { <nl> - POLY_BLOCK * pb = block_it . data ( ) - > block - > poly_block ( ) ; <nl> + POLY_BLOCK * pb = block_it . data ( ) - > block - > pdblk . poly_block ( ) ; <nl> if ( pb ! = NULL & & ! pb - > IsText ( ) ) <nl> continue ; / / Pretend non - text blocks don ' t exist . <nl> row_it . set_to_list ( block_it . data ( ) - > get_rows ( ) ) ; <nl> void compute_page_skew ( / / get average gradient <nl> / / desperate <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; <nl> block_it . forward ( ) ) { <nl> - POLY_BLOCK * pb = block_it . data ( ) - > block - > poly_block ( ) ; <nl> + POLY_BLOCK * pb = block_it . data ( ) - > block - > pdblk . poly_block ( ) ; <nl> if ( pb ! = NULL & & ! pb - > IsText ( ) ) <nl> continue ; / / Pretend non - text blocks don ' t exist . <nl> row_it . set_to_list ( block_it . data ( ) - > get_rows ( ) ) ; <nl> void delete_non_dropout_rows ( / / find lines <nl> if ( row_it . length ( ) = = 0 ) <nl> return ; / / empty block <nl> block_box = deskew_block_coords ( block , gradient ) ; <nl> - xleft = block - > block - > bounding_box ( ) . left ( ) ; <nl> - ybottom = block - > block - > bounding_box ( ) . bottom ( ) ; <nl> + xleft = block - > block - > pdblk . bounding_box ( ) . left ( ) ; <nl> + ybottom = block - > block - > pdblk . bounding_box ( ) . bottom ( ) ; <nl> min_y = block_box . bottom ( ) - 1 ; <nl> max_y = block_box . top ( ) + 1 ; <nl> for ( row_it . mark_cycle_pt ( ) ; ! row_it . cycled_list ( ) ; row_it . forward ( ) ) { <nl> void adjust_row_limits ( / / tidy limits <nl> <nl> if ( textord_show_expanded_rows ) <nl> tprintf ( " Adjusting row limits for block ( % d , % d ) \ n " , <nl> - block - > block - > bounding_box ( ) . left ( ) , <nl> - block - > block - > bounding_box ( ) . top ( ) ) ; <nl> + block - > block - > pdblk . bounding_box ( ) . left ( ) , <nl> + block - > block - > pdblk . bounding_box ( ) . top ( ) ) ; <nl> for ( row_it . mark_cycle_pt ( ) ; ! row_it . cycled_list ( ) ; row_it . forward ( ) ) { <nl> row = row_it . data ( ) ; <nl> size = row - > max_y ( ) - row - > min_y ( ) ; <nl> void assign_blobs_to_rows ( / / find lines <nl> TO_ROW_IT row_it = block - > get_rows ( ) ; <nl> <nl> ycoord = <nl> - ( block - > block - > bounding_box ( ) . bottom ( ) + <nl> - block - > block - > bounding_box ( ) . top ( ) ) / 2 . 0f ; <nl> + ( block - > block - > pdblk . bounding_box ( ) . bottom ( ) + <nl> + block - > block - > pdblk . bounding_box ( ) . top ( ) ) / 2 . 0f ; <nl> if ( gradient ! = NULL ) <nl> g_length = sqrt ( 1 + * gradient * * gradient ) ; <nl> # ifndef GRAPHICS_DISABLED <nl> if ( drawing_skew ) <nl> - to_win - > SetCursor ( block - > block - > bounding_box ( ) . left ( ) , ycoord ) ; <nl> + to_win - > SetCursor ( block - > block - > pdblk . bounding_box ( ) . left ( ) , ycoord ) ; <nl> # endif <nl> testpt = ICOORD ( textord_test_x , textord_test_y ) ; <nl> blob_it . sort ( blob_x_order ) ; <nl> void assign_blobs_to_rows ( / / find lines <nl> left_x = blob_it . data ( ) - > bounding_box ( ) . left ( ) ; <nl> } <nl> else { <nl> - left_x = block - > block - > bounding_box ( ) . left ( ) ; <nl> + left_x = block - > block - > pdblk . bounding_box ( ) . left ( ) ; <nl> } <nl> last_x = left_x ; <nl> for ( blob_it . mark_cycle_pt ( ) ; ! blob_it . cycled_list ( ) ; blob_it . forward ( ) ) { <nl> mmm a / textord / oldbasel . cpp <nl> ppp b / textord / oldbasel . cpp <nl> void Textord : : find_textlines ( TO_BLOCK * block , / / block row is in <nl> row - > ascrise = 0 . 0f ; <nl> } <nl> row - > baseline . extrapolate ( row - > line_m ( ) , <nl> - block - > block - > bounding_box ( ) . left ( ) , <nl> - block - > block - > bounding_box ( ) . right ( ) ) ; <nl> + block - > block - > pdblk . bounding_box ( ) . left ( ) , <nl> + block - > block - > pdblk . bounding_box ( ) . right ( ) ) ; <nl> <nl> if ( textord_really_old_xheight ) { <nl> old_first_xheight ( row , blobcoords , lineheight , <nl> mmm a / textord / textord . cpp <nl> ppp b / textord / textord . cpp <nl> void Textord : : TextordPage ( PageSegMode pageseg_mode , const FCOORD & reskew , <nl> TO_BLOCK * to_block = it . data ( ) ; <nl> BLOCK * block = to_block - > block ; <nl> / / Create a fake poly_block in block from its bounding box . <nl> - block - > set_poly_block ( new POLY_BLOCK ( block - > bounding_box ( ) , <nl> + block - > pdblk . set_poly_block ( new POLY_BLOCK ( block - > pdblk . bounding_box ( ) , <nl> PT_VERTICAL_TEXT ) ) ; <nl> / / Rotate the to_block along with its contained block and blobnbox lists . <nl> to_block - > rotate ( anticlockwise90 ) ; <nl> mmm a / textord / topitch . cpp <nl> ppp b / textord / topitch . cpp <nl> void compute_fixed_pitch ( ICOORD page_tr , / / top right <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; <nl> block_it . forward ( ) ) { <nl> block = block_it . data ( ) ; <nl> - POLY_BLOCK * pb = block - > block - > poly_block ( ) ; <nl> + POLY_BLOCK * pb = block - > block - > pdblk . poly_block ( ) ; <nl> if ( pb ! = NULL & & ! pb - > IsText ( ) ) continue ; / / Non - text doesn ' t exist ! <nl> row_it . set_to_list ( block - > get_rows ( ) ) ; <nl> row_index = 1 ; <nl> void fix_row_pitch ( TO_ROW * bad_row , / / row to fix <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; <nl> block_it . forward ( ) ) { <nl> block = block_it . data ( ) ; <nl> - POLY_BLOCK * pb = block - > block - > poly_block ( ) ; <nl> + POLY_BLOCK * pb = block - > block - > pdblk . poly_block ( ) ; <nl> if ( pb ! = NULL & & ! pb - > IsText ( ) ) continue ; / / Non text doesn ' t exist ! <nl> row_index = 1 ; <nl> row_it . set_to_list ( block - > get_rows ( ) ) ; <nl> void compute_block_pitch ( TO_BLOCK * block , / / input list <nl> BOOL8 testing_on ) { / / correct orientation <nl> TBOX block_box ; / / bounding box <nl> <nl> - block_box = block - > block - > bounding_box ( ) ; <nl> + block_box = block - > block - > pdblk . bounding_box ( ) ; <nl> if ( testing_on & & textord_debug_pitch_test ) { <nl> tprintf ( " Block % d at ( % d , % d ) - > ( % d , % d ) \ n " , <nl> block_index , <nl> BOOL8 fixed_pitch_row ( TO_ROW * row , / / row to do <nl> non_space = row - > fp_nonsp ; <nl> if ( non_space > row - > fixed_pitch ) <nl> non_space = row - > fixed_pitch ; <nl> - POLY_BLOCK * pb = block ! = NULL ? block - > poly_block ( ) : NULL ; <nl> + POLY_BLOCK * pb = block ! = NULL ? block - > pdblk . poly_block ( ) : NULL ; <nl> if ( textord_all_prop | | ( pb ! = NULL & & ! pb - > IsText ( ) ) ) { <nl> / / Set the decision to definitely proportional . <nl> pitch_sd = textord_words_def_prop * row - > fixed_pitch ; <nl> void print_pitch_sd ( / / find fp cells <nl> * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * / <nl> void find_repeated_chars ( TO_BLOCK * block , / / Block to search . <nl> BOOL8 testing_on ) { / / Debug mode . <nl> - POLY_BLOCK * pb = block - > block - > poly_block ( ) ; <nl> + POLY_BLOCK * pb = block - > block - > pdblk . poly_block ( ) ; <nl> if ( pb ! = NULL & & ! pb - > IsText ( ) ) <nl> return ; / / Don ' t find repeated chars in non - text blocks . <nl> <nl> mmm a / textord / tordmain . cpp <nl> ppp b / textord / tordmain . cpp <nl> void Textord : : find_components ( Pix * pix , BLOCK_LIST * blocks , <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; <nl> block_it . forward ( ) ) { <nl> BLOCK * block = block_it . data ( ) ; <nl> - if ( block - > poly_block ( ) = = NULL | | block - > poly_block ( ) - > IsText ( ) ) { <nl> + if ( block - > pdblk . poly_block ( ) = = NULL | | block - > pdblk . poly_block ( ) - > IsText ( ) ) { <nl> extract_edges ( pix , block ) ; <nl> } <nl> } <nl> void Textord : : cleanup_nontext_block ( BLOCK * block ) { <nl> / / Non - text blocks must contain at least one row . <nl> ROW_IT row_it ( block - > row_list ( ) ) ; <nl> if ( row_it . empty ( ) ) { <nl> - const TBOX & box = block - > bounding_box ( ) ; <nl> + const TBOX & box = block - > pdblk . bounding_box ( ) ; <nl> float height = box . height ( ) ; <nl> int32_t xstarts [ 2 ] = { box . left ( ) , box . right ( ) } ; <nl> double coeffs [ 3 ] = { 0 . 0 , 0 . 0 , static_cast < double > ( box . bottom ( ) ) } ; <nl> void Textord : : cleanup_nontext_block ( BLOCK * block ) { <nl> WERD_IT w_it ( row - > word_list ( ) ) ; <nl> if ( w_it . empty ( ) ) { <nl> / / Make a fake blob to put in the word . <nl> - TBOX box = block - > row_list ( ) - > singleton ( ) ? block - > bounding_box ( ) <nl> + TBOX box = block - > row_list ( ) - > singleton ( ) ? block - > pdblk . bounding_box ( ) <nl> : row - > bounding_box ( ) ; <nl> C_BLOB * blob = C_BLOB : : FakeBlob ( box ) ; <nl> C_BLOB_LIST blobs ; <nl> void Textord : : cleanup_blocks ( bool clean_noise , BLOCK_LIST * blocks ) { <nl> for ( block_it . mark_cycle_pt ( ) ; ! block_it . cycled_list ( ) ; <nl> block_it . forward ( ) ) { <nl> BLOCK * block = block_it . data ( ) ; <nl> - if ( block - > poly_block ( ) ! = NULL & & ! block - > poly_block ( ) - > IsText ( ) ) { <nl> + if ( block - > pdblk . poly_block ( ) ! = NULL & & ! block - > pdblk . poly_block ( ) - > IsText ( ) ) { <nl> cleanup_nontext_block ( block ) ; <nl> continue ; <nl> } <nl> void Textord : : clean_small_noise_from_words ( ROW * row ) { <nl> struct BlockGroup { <nl> BlockGroup ( ) : rotation ( 1 . 0f , 0 . 0f ) , angle ( 0 . 0f ) , min_xheight ( 1 . 0f ) { } <nl> explicit BlockGroup ( BLOCK * block ) <nl> - : bounding_box ( block - > bounding_box ( ) ) , <nl> + : bounding_box ( block - > pdblk . bounding_box ( ) ) , <nl> rotation ( block - > re_rotation ( ) ) , <nl> angle ( block - > re_rotation ( ) . angle ( ) ) , <nl> min_xheight ( block - > x_height ( ) ) { <nl> void Textord : : TransferDiacriticsToBlockGroups ( BLOBNBOX_LIST * diacritic_blobs , <nl> BLOCK_IT bk_it ( blocks ) ; <nl> for ( bk_it . mark_cycle_pt ( ) ; ! bk_it . cycled_list ( ) ; bk_it . forward ( ) ) { <nl> BLOCK * block = bk_it . data ( ) ; <nl> - if ( block - > poly_block ( ) ! = NULL & & ! block - > poly_block ( ) - > IsText ( ) ) { <nl> + if ( block - > pdblk . poly_block ( ) ! = NULL & & ! block - > pdblk . poly_block ( ) - > IsText ( ) ) { <nl> continue ; <nl> } <nl> / / Linear search of the groups to find a matching rotation . <nl> void Textord : : TransferDiacriticsToBlockGroups ( BLOBNBOX_LIST * diacritic_blobs , <nl> groups . push_back ( new BlockGroup ( block ) ) ; <nl> } else { <nl> groups [ best_g ] - > blocks . push_back ( block ) ; <nl> - groups [ best_g ] - > bounding_box + = block - > bounding_box ( ) ; <nl> + groups [ best_g ] - > bounding_box + = block - > pdblk . bounding_box ( ) ; <nl> float x_height = block - > x_height ( ) ; <nl> if ( x_height < groups [ best_g ] - > min_xheight ) <nl> groups [ best_g ] - > min_xheight = x_height ; <nl> mmm a / textord / wordseg . cpp <nl> ppp b / textord / wordseg . cpp <nl> void make_real_words ( <nl> / / For non - space delimited language like CJK , fixed pitch chop always <nl> / / leave the entire line as one word . We can force consistent chopping <nl> / / with force_make_prop_words flag . <nl> - POLY_BLOCK * pb = block - > block - > poly_block ( ) ; <nl> + POLY_BLOCK * pb = block - > block - > pdblk . poly_block ( ) ; <nl> if ( textord_chopper_test ) { <nl> real_row = textord - > make_blob_words ( row , rotation ) ; <nl> } else if ( textord_force_make_prop_words | | <nl>
|
Fixed a resource leak detected by Coverity
|
tesseract-ocr/tesseract
|
34efcd40bef6cdbb1686572607064cd40378f441
|
2018-04-19T11:55:39Z
|
mmm a / stdlib / private / SwiftPrivateLibcExtras / Subprocess . swift <nl> ppp b / stdlib / private / SwiftPrivateLibcExtras / Subprocess . swift <nl> internal func _make_posix_spawn_file_actions_t ( ) <nl> # endif <nl> # endif <nl> <nl> - internal func _readAll ( _ fd : CInt ) - > String { <nl> - var buffer = [ UInt8 ] ( repeating : 0 , count : 1024 ) <nl> - var usedBytes = 0 <nl> - while true { <nl> - let readResult : ssize_t = buffer . withUnsafeMutableBufferPointer { <nl> - ( buffer ) in <nl> - let ptr = UnsafeMutablePointer < Void > ( buffer . baseAddress ! + usedBytes ) <nl> - return read ( fd , ptr , size_t ( buffer . count - usedBytes ) ) <nl> - } <nl> - if readResult > 0 { <nl> - usedBytes + = readResult <nl> - continue <nl> - } <nl> - if readResult = = 0 { <nl> - break <nl> - } <nl> - preconditionFailure ( " read ( ) failed " ) <nl> - } <nl> - return String . _fromCodeUnitSequenceWithRepair ( <nl> - UTF8 . self , input : buffer [ 0 . . < usedBytes ] ) . 0 <nl> - } <nl> - <nl> - <nl> internal func _signalToString ( _ signal : Int ) - > String { <nl> switch CInt ( signal ) { <nl> case SIGILL : return " SIGILL " <nl> public func posixWaitpid ( _ pid : pid_t ) - > ProcessTerminationStatus { <nl> preconditionFailure ( " did not understand what happened to child process " ) <nl> } <nl> <nl> - public func runChild ( _ args : [ String ] ) <nl> - - > ( stdout : String , stderr : String , status : ProcessTerminationStatus ) { <nl> - let ( pid , _ , stdoutFD , stderrFD ) = spawnChild ( args ) <nl> - <nl> - / / FIXME : reading stdout and stderr sequentially can block . Should use <nl> - / / select ( ) . This is not so simple to implement because of : <nl> - / / < rdar : / / problem / 17828358 > Darwin module is missing fd_set - related macros <nl> - let stdout = _readAll ( stdoutFD ) <nl> - let stderr = _readAll ( stderrFD ) <nl> - <nl> - if close ( stdoutFD ) ! = 0 { <nl> - preconditionFailure ( " close ( ) failed " ) <nl> - } <nl> - if close ( stderrFD ) ! = 0 { <nl> - preconditionFailure ( " close ( ) failed " ) <nl> - } <nl> - let status = posixWaitpid ( pid ) <nl> - return ( stdout , stderr , status ) <nl> - } <nl> - <nl> # if os ( OSX ) | | os ( iOS ) | | os ( watchOS ) | | os ( tvOS ) <nl> @ _silgen_name ( " _NSGetEnviron " ) <nl> func _NSGetEnviron ( ) - > UnsafeMutablePointer < UnsafeMutablePointer < UnsafeMutablePointer < CChar > ? > > <nl>
|
Merge pull request from modocache / remove - unused - subprocess
|
apple/swift
|
7aba3c27da61946fdf8c53006607d220a84ed284
|
2016-04-13T08:53:25Z
|
mmm a / Tools / make_binary_drop_windows . ps1 <nl> ppp b / Tools / make_binary_drop_windows . ps1 <nl> Else <nl> { <nl> $ buildPath = " x64 \ Release " <nl> } <nl> - $ sharePath = " \ \ muc - vfs - 01a \ CNTKshare \ CNTK - Binary - Drop " + " \ " + $ buildConfig <nl> + $ sharePath = " \ \ muc - vfs - 01a \ CNTKshare \ CNTK - Binary - Drop " + " \ " + $ targetConfig <nl> <nl> <nl> # Make binary drop folder <nl> Remove - Item $ baseDropPath \ cntk \ * . metagen <nl> Copy - Item Examples - Recurse - Destination $ baseDropPath \ Examples <nl> <nl> # Copy all items from the share <nl> - Copy - Item $ sharePath \ * - Recurse - Destination $ baseDropPath \ cntk <nl> + Copy - Item $ sharePath " \ * " - Recurse - Destination $ baseDropPath <nl> <nl> <nl> # Make ZIP file <nl> $ source = $ PWD . Path + " \ " + $ basePath <nl> - Write - Host $ source <nl> $ destination = $ PWD . Path + " \ " + $ zipFile <nl> - Write - Host $ destination <nl> Add - Type - assembly " system . io . compression . filesystem " <nl> [ io . compression . zipfile ] : : CreateFromDirectory ( $ source , $ destination ) <nl> <nl> # Remove ZIP sources <nl> - If ( Test - Path $ basePath ) { Remove - Item $ basePath - Recurse } <nl> + If ( Test - Path $ basePath ) { Remove - Item $ basePath - Recurse } <nl> \ No newline at end of file <nl>
|
Script . Next iteration
|
microsoft/CNTK
|
b2d5f6515b1e56c57d1fada520a35e9544dcb1db
|
2016-02-24T17:31:10Z
|
mmm a / lib / SILGen / SILGen . cpp <nl> ppp b / lib / SILGen / SILGen . cpp <nl> using namespace Lowering ; <nl> <nl> SILGenFunction : : SILGenFunction ( SILGenModule & SGM , SILFunction & F ) <nl> : SGM ( SGM ) , F ( F ) , LastInsnWithoutScope ( 0 ) , <nl> - B ( new ( F . getModule ( ) ) SILBasicBlock ( & F ) , & InsertedInstrs ) , <nl> + B ( createBasicBlock ( ) , & InsertedInstrs ) , <nl> ReturnDest ( CleanupLocation : : getCleanupLocation ( F . getLocation ( ) ) ) , <nl> CurrentSILLoc ( F . getLocation ( ) ) , Cleanups ( * this ) <nl> { <nl> mmm a / lib / SILGen / SILGen . h <nl> ppp b / lib / SILGen / SILGen . h <nl> class LLVM_LIBRARY_VISIBILITY SILGenFunction <nl> Condition emitCondition ( Expr * E , <nl> bool hasFalseCode = true , bool invertValue = false , <nl> ArrayRef < SILType > contArgs = { } ) ; <nl> + <nl> + SILBasicBlock * createBasicBlock ( ) { <nl> + return new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + } <nl> <nl> <nl> / / = = = mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - - = = = / / <nl> mmm a / lib / SILGen / SILGenDecl . cpp <nl> ppp b / lib / SILGen / SILGenDecl . cpp <nl> SILValue SILGenFunction : : emitDestructorProlog ( ClassDecl * CD , <nl> } <nl> <nl> void SILGenFunction : : prepareEpilog ( Type resultType , CleanupLocation CleanupL ) { <nl> - auto * epilogBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + auto * epilogBB = createBasicBlock ( ) ; <nl> <nl> / / If we have a non - null , non - void , non - address - only return type , receive the <nl> / / return value via a BB argument . <nl> mmm a / lib / SILGen / SILGenPattern . cpp <nl> ppp b / lib / SILGen / SILGenPattern . cpp <nl> static SILBasicBlock * emitDispatchAndDestructure ( SILGenFunction & gen , <nl> destructured . push_back ( cast ) ; <nl> <nl> / / Emit the branch . <nl> - SILBasicBlock * trueBB = new ( gen . F . getModule ( ) ) SILBasicBlock ( & gen . F ) ; <nl> - SILBasicBlock * falseBB = new ( gen . F . getModule ( ) ) SILBasicBlock ( & gen . F ) ; <nl> + SILBasicBlock * trueBB = gen . createBasicBlock ( ) ; <nl> + SILBasicBlock * falseBB = gen . createBasicBlock ( ) ; <nl> <nl> gen . B . createCondBranch ( Loc , didMatch , <nl> trueBB , falseBB ) ; <nl> static SILBasicBlock * emitDispatchAndDestructure ( SILGenFunction & gen , <nl> & & " specializing same union case twice ? ! " ) ; <nl> unmatchedCases . erase ( elt ) ; <nl> <nl> - SILBasicBlock * caseBB = new ( gen . F . getModule ( ) ) SILBasicBlock ( & gen . F ) ; <nl> + SILBasicBlock * caseBB = gen . createBasicBlock ( ) ; <nl> <nl> / / Create a BB argument to receive the union case data if it has any . <nl> SILValue eltValue ; <nl> static SILBasicBlock * emitDispatchAndDestructure ( SILGenFunction & gen , <nl> <nl> / / If we didn ' t cover every case , then we need a default block . <nl> if ( ! unmatchedCases . empty ( ) ) <nl> - defaultBB = new ( gen . F . getModule ( ) ) SILBasicBlock ( & gen . F ) ; <nl> + defaultBB = gen . createBasicBlock ( ) ; <nl> <nl> / / Emit the switch instruction . <nl> if ( addressOnlyUnion ) { <nl> SILBasicBlock * createCaseBlock ( SILGenFunction & gen , CaseMap & caseMap , <nl> } <nl> <nl> / / Set up the basic block for the case . <nl> - dest . entry = new ( gen . F . getModule ( ) ) SILBasicBlock ( & gen . F ) ; <nl> + dest . entry = gen . createBasicBlock ( ) ; <nl> dest . cleanupsDepth = cleanupsDepth ; <nl> dest . cont = contBB ; <nl> <nl> class ClauseMatrix { <nl> SILBasicBlock * falseBB = nullptr ; <nl> auto getFalseBB = [ & ] { <nl> if ( ! falseBB ) <nl> - falseBB = new ( gen . F . getModule ( ) ) SILBasicBlock ( & gen . F ) ; <nl> + falseBB = gen . createBasicBlock ( ) ; <nl> return falseBB ; <nl> } ; <nl> <nl> class ClauseMatrix { <nl> / / Test ExprPatterns from the row in an " and " chain . <nl> for ( const ExprPattern * ep : row . exprGuards ) { <nl> / / The last pattern test jumps to the guard . <nl> - trueBB = new ( gen . F . getModule ( ) ) SILBasicBlock ( & gen . F ) ; <nl> + trueBB = gen . createBasicBlock ( ) ; <nl> <nl> / / Emit the match test . <nl> SILValue testBool ; <nl> class ClauseMatrix { <nl> } <nl> <nl> / / Branch either to the row destination or the new BB . <nl> - trueBB = new ( gen . F . getModule ( ) ) SILBasicBlock ( & gen . F ) ; <nl> + trueBB = gen . createBasicBlock ( ) ; <nl> gen . B . createCondBranch ( row . getCaseBlock ( ) , guardBool , <nl> trueBB , getFalseBB ( ) ) ; <nl> gen . B . emitBlock ( trueBB ) ; <nl> static void emitDecisionTree ( SILGenFunction & gen , <nl> <nl> / / Create a nested scope and cont bb to clean up var bindings exposed by <nl> / / specializing the matrix . <nl> - SILBasicBlock * innerContBB = new ( gen . F . getModule ( ) ) SILBasicBlock ( & gen . F ) ; <nl> + SILBasicBlock * innerContBB = gen . createBasicBlock ( ) ; <nl> <nl> { <nl> Scope patternVarScope ( gen . Cleanups , <nl> void SILGenFunction : : emitSwitchStmt ( SwitchStmt * S ) { <nl> Scope patternVarScope ( Cleanups , CleanupLocation ( S ) ) ; <nl> <nl> / / Create a continuation bb for life after the switch . <nl> - SILBasicBlock * contBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + SILBasicBlock * contBB = createBasicBlock ( ) ; <nl> <nl> / / Set up an initial clause matrix . <nl> ClauseMatrix clauses ( subject , S - > getCases ( ) . size ( ) ) ; <nl> mmm a / lib / SILGen / SILGenStmt . cpp <nl> ppp b / lib / SILGen / SILGenStmt . cpp <nl> Condition SILGenFunction : : emitCondition ( Expr * E , <nl> <nl> SILValue V = emitConditionValue ( * this , E ) ; <nl> <nl> - SILBasicBlock * ContBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> - SILBasicBlock * TrueBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + SILBasicBlock * ContBB = createBasicBlock ( ) ; <nl> + SILBasicBlock * TrueBB = createBasicBlock ( ) ; <nl> <nl> for ( SILType argTy : contArgs ) { <nl> new ( F . getModule ( ) ) SILArgument ( argTy , ContBB ) ; <nl> Condition SILGenFunction : : emitCondition ( Expr * E , <nl> <nl> SILBasicBlock * FalseBB , * FalseDestBB ; <nl> if ( hasFalseCode ) { <nl> - FalseBB = FalseDestBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + FalseBB = FalseDestBB = createBasicBlock ( ) ; <nl> } else { <nl> FalseBB = nullptr ; <nl> FalseDestBB = ContBB ; <nl> void SILGenFunction : : visitIfStmt ( IfStmt * S ) { <nl> <nl> void SILGenFunction : : visitWhileStmt ( WhileStmt * S ) { <nl> / / Create a new basic block and jump into it . <nl> - SILBasicBlock * LoopBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + SILBasicBlock * LoopBB = createBasicBlock ( ) ; <nl> B . emitBlock ( LoopBB , S ) ; <nl> <nl> / / Set the destinations for ' break ' and ' continue ' <nl> - SILBasicBlock * EndBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + SILBasicBlock * EndBB = createBasicBlock ( ) ; <nl> BreakDestStack . emplace_back ( EndBB , getCleanupsDepth ( ) , <nl> CleanupLocation ( S - > getBody ( ) ) ) ; <nl> ContinueDestStack . emplace_back ( LoopBB , getCleanupsDepth ( ) , <nl> void SILGenFunction : : visitWhileStmt ( WhileStmt * S ) { <nl> <nl> void SILGenFunction : : visitDoWhileStmt ( DoWhileStmt * S ) { <nl> / / Create a new basic block and jump into it . <nl> - SILBasicBlock * LoopBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + SILBasicBlock * LoopBB = createBasicBlock ( ) ; <nl> B . emitBlock ( LoopBB , S ) ; <nl> <nl> / / Set the destinations for ' break ' and ' continue ' <nl> - SILBasicBlock * EndBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> - SILBasicBlock * CondBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + SILBasicBlock * EndBB = createBasicBlock ( ) ; <nl> + SILBasicBlock * CondBB = createBasicBlock ( ) ; <nl> BreakDestStack . emplace_back ( EndBB , getCleanupsDepth ( ) , <nl> CleanupLocation ( S - > getBody ( ) ) ) ; <nl> ContinueDestStack . emplace_back ( CondBB , getCleanupsDepth ( ) , <nl> void SILGenFunction : : visitForStmt ( ForStmt * S ) { <nl> if ( ! B . hasValidInsertionPoint ( ) ) return ; <nl> <nl> / / Create a new basic block and jump into it . <nl> - SILBasicBlock * LoopBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + SILBasicBlock * LoopBB = createBasicBlock ( ) ; <nl> B . emitBlock ( LoopBB , S ) ; <nl> <nl> / / Set the destinations for ' break ' and ' continue ' <nl> - SILBasicBlock * IncBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> - SILBasicBlock * EndBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + SILBasicBlock * IncBB = createBasicBlock ( ) ; <nl> + SILBasicBlock * EndBB = createBasicBlock ( ) ; <nl> BreakDestStack . emplace_back ( EndBB , getCleanupsDepth ( ) , <nl> CleanupLocation ( S - > getBody ( ) ) ) ; <nl> ContinueDestStack . emplace_back ( IncBB , getCleanupsDepth ( ) , <nl> void SILGenFunction : : visitForEachStmt ( ForEachStmt * S ) { <nl> if ( ! B . hasValidInsertionPoint ( ) ) return ; <nl> <nl> / / Create a new basic block and jump into it . <nl> - SILBasicBlock * LoopBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + SILBasicBlock * LoopBB = createBasicBlock ( ) ; <nl> B . emitBlock ( LoopBB , S ) ; <nl> <nl> / / Set the destinations for ' break ' and ' continue ' <nl> - SILBasicBlock * EndBB = new ( F . getModule ( ) ) SILBasicBlock ( & F ) ; <nl> + SILBasicBlock * EndBB = createBasicBlock ( ) ; <nl> BreakDestStack . emplace_back ( EndBB , <nl> getCleanupsDepth ( ) , <nl> CleanupLocation ( S - > getBody ( ) ) ) ; <nl>
|
Add a convenient method to create a new basic block .
|
apple/swift
|
6f32a8464fa750e56e73c468b59017b874bc392e
|
2013-09-17T07:22:23Z
|
mmm a / src / execution . cc <nl> ppp b / src / execution . cc <nl> void StackGuard : : InitThread ( const ExecutionAccess & lock ) { <nl> / / mmm C a l l s t o n a t i v e s mmm <nl> <nl> <nl> - void StackGuard : : HandleGCInterrupt ( ) { <nl> - if ( CheckAndClearInterrupt ( GC_REQUEST ) ) { <nl> - isolate_ - > heap ( ) - > HandleGCRequest ( ) ; <nl> - } <nl> - } <nl> - <nl> - <nl> Object * StackGuard : : HandleInterrupts ( ) { <nl> if ( FLAG_verify_predictable ) { <nl> / / Advance synthetic time by making a time request . <nl> mmm a / src / execution . h <nl> ppp b / src / execution . h <nl> class V8_EXPORT_PRIVATE StackGuard final { <nl> / / If the stack guard is triggered , but it is not an actual <nl> / / stack overflow , then handle the interruption accordingly . <nl> Object * HandleInterrupts ( ) ; <nl> - void HandleGCInterrupt ( ) ; <nl> <nl> private : <nl> StackGuard ( ) ; <nl>
|
Remove unused StackGuard : : HandleGCInterrupt API .
|
v8/v8
|
b9c81f51d4c09c28d835b3bd45525e107db430b1
|
2018-05-04T08:48:57Z
|
mmm a / tensorflow / g3doc / how_tos / embedding_viz / index . md <nl> ppp b / tensorflow / g3doc / how_tos / embedding_viz / index . md <nl> concrete example of a sprite , see <nl> [ this sprite image ] ( . . / . . / images / mnist_10k_sprite . png ) of 10 , 000 MNIST digits <nl> ( 100x100 ) . <nl> <nl> - Note : We currently support sprites up to 4096px X 4096px . <nl> - <nl> - <nl> + Note : We currently support sprites up to 8192px X 8192px . <nl> <nl> After constructing the sprite , you need to tell the Embedding Projector where <nl> to find it : <nl> mmm a / tensorflow / tensorboard / components / vz_projector / data - provider . ts <nl> ppp b / tensorflow / tensorboard / components / vz_projector / data - provider . ts <nl> import { runAsyncTask } from ' . / util ' ; <nl> <nl> / * * Maximum number of colors supported in the color map . * / <nl> const NUM_COLORS_COLOR_MAP = 50 ; <nl> + const MAX_SPRITE_IMAGE_SIZE_PX = 8192 ; <nl> <nl> export const METADATA_MSG_ID = ' metadata ' ; <nl> export const TENSORS_MSG_ID = ' tensors ' ; <nl> export function retrieveSpriteAndMetadataInfo ( metadataPath : string , <nl> logging . setModalMessage ( null , spriteMsgId ) ; <nl> } <nl> let [ metadata , spriteImage ] = values ; <nl> - metadata . spriteImage = spriteImage ; <nl> - metadata . spriteMetadata = spriteMetadata ; <nl> - callback ( metadata ) ; <nl> + <nl> + if ( spriteImage & & ( spriteImage . height > MAX_SPRITE_IMAGE_SIZE_PX | | <nl> + spriteImage . width > MAX_SPRITE_IMAGE_SIZE_PX ) ) { <nl> + logging . setModalMessage ( <nl> + ` Error : Sprite image of dimensions $ { spriteImage . width } px x ` + <nl> + ` $ { spriteImage . height } px exceeds maximum dimensions ` + <nl> + ` $ { MAX_SPRITE_IMAGE_SIZE_PX } px x $ { MAX_SPRITE_IMAGE_SIZE_PX } px ` ) ; <nl> + } else { <nl> + metadata . spriteImage = spriteImage ; <nl> + metadata . spriteMetadata = spriteMetadata ; <nl> + callback ( metadata ) ; <nl> + } <nl> } ) ; <nl> } <nl>
|
Add an error message if the sprite image exceeds 8192px , which is empirically the max size
|
tensorflow/tensorflow
|
3b4d10ff780f3fc5147978a6ee804b618b1c3618
|
2016-11-10T02:25:51Z
|
mmm a / CHANGELOG <nl> ppp b / CHANGELOG <nl> devel <nl> The ` padded ` key generator generates keys of a fixed length ( 16 bytes ) in <nl> ascending lexicographical sort order . <nl> <nl> - * The REST API of ` / _admin / status ` changed : Field " mode " is now named " operationMode " , <nl> - field " writeOpsEnabled " no longer exists and is replaced by field " readOnly " with <nl> - the inverted meaning . <nl> + * The REST API of ` / _admin / status ` added : " operationMode " filed with same meaning as <nl> + the " mode " field and field " readOnly " that has the inverted meaning of the field <nl> + " writeOpsEnabled " . The old field names will be deprecated in upcoming versions . <nl> <nl> * added ` COUNT_DISTINCT ` AQL function <nl> <nl> devel <nl> * the existing " fulltext - index - optimizer " optimizer rule has been removed because its <nl> duty is now handled by the " replace - function - with - index " rule . <nl> <nl> - * The ` NEAR ` AQL function now does not default to a limit of 100 documents any more . <nl> - <nl> * added option " - - latency true " option to arangoimport . Lists microsecond latency <nl> statistics on 10 second intervals . <nl> <nl> mmm a / Documentation / Books / AQL / Functions / Geo . md <nl> ppp b / Documentation / Books / AQL / Functions / Geo . md <nl> contain the distance value in an attribute of that name . <nl> - * * latitude * * ( number ) : the latitude portion of the search coordinate <nl> - * * longitude * * ( number ) : the longitude portion of the search coordinate <nl> - * * limit * * ( number , * optional * ) : cap the result to at most this number of <nl> - documents . <nl> + documents . The default is 100 . If more documents than * limit * are found , <nl> + it is undefined which ones will be returned . <nl> - * * distanceName * * ( string , * optional * ) : include the distance to the search <nl> coordinate in each document in the result ( in meters ) , using the attribute <nl> name * distanceName * <nl> mmm a / Documentation / Books / Manual / ReleaseNotes / UpgradingChanges34 . md <nl> ppp b / Documentation / Books / Manual / ReleaseNotes / UpgradingChanges34 . md <nl> APIs : <nl> AQL user functions on the top level of the response . <nl> Each AQL user function description now also contains the ' isDeterministic ' attribute . <nl> <nl> - - ` GET / _admin / status ` now returns the attribute ` operationMode ` instead of ` mode ` . <nl> - The previously existing attribute ` writeOpsEnabled ` is no longer returned and was <nl> - replaced with an attribute ` readOnly ` with the inverted meaning . <nl> + - ` GET / _admin / status ` now returns the attribute ` operationMode ` in addition to <nl> + ` mode ` . The attribute ` writeOpsEnabled ` is now also represented by the new an <nl> + attribute ` readOnly ` , which is has an inverted value compared to the original <nl> + attribute . In future releases the old attributes will be deprecated in favor <nl> + of the new ones . <nl> <nl> - if authentication is turned on , requests to databases by users with insufficient <nl> access rights will be answered with HTTP 401 ( forbidden ) instead of HTTP 404 ( not found ) . <nl> AQL <nl> ( ` ERROR_QUERY_FUNCTION_NAME_UNKNOWN ` ) and 1541 ( ` ERROR_QUERY_FUNCTION_ARGUMENT_TYPE_MISMATCH ` ) <nl> instead of error 1582 ( ` ERROR_QUERY_FUNCTION_NOT_FOUND ` ) in some situations . <nl> <nl> - - the ` NEAR ` AQL function now does not default to a limit of 100 documents <nl> - any more , but will return all documents if no limit is specified . <nl> - <nl> - the existing " fulltext - index - optimizer " optimizer rule has been removed <nl> because its duty is now handled by the new " replace - function - with - index " rule . <nl> <nl> new file mode 100644 <nl> index 00000000000 . . 2aef90c393f <nl> mmm / dev / null <nl> ppp b / UnitTests / HttpInterface / api - miscellaneous - spec . rb <nl> <nl> + # coding : utf - 8 <nl> + <nl> + require ' rspec ' <nl> + require ' arangodb . rb ' <nl> + <nl> + describe ArangoDB do <nl> + prefix = " api - miscellaneous " <nl> + <nl> + context " admin status " do <nl> + it " checks attributes " do <nl> + cmd = " / _admin / status " <nl> + doc = ArangoDB . log_get ( " # { prefix } - status - attributes " , cmd ) <nl> + doc [ " server " ] . should eq ( " arango " ) <nl> + doc . should have_key ( " mode " ) # to be removed <nl> + doc . should have_key ( " operationMode " ) <nl> + doc [ " mode " ] . should eq ( doc [ " operationMode " ] ) <nl> + doc . should have_key ( " version " ) <nl> + doc . should have_key ( " pid " ) <nl> + doc . should have_key ( " license " ) <nl> + doc . should have_key ( " host " ) <nl> + doc . should have_key ( " hostname " ) <nl> + <nl> + <nl> + info = doc [ " serverInfo " ] <nl> + info . should have_key ( " maintenance " ) <nl> + info . should have_key ( " role " ) <nl> + info . should have_key ( " writeOpsEnabled " ) # to be removed <nl> + info . should have_key ( " readOnly " ) <nl> + info [ " writeOpsEnabled " ] . should eq ( ! info [ " readOnly " ] ) <nl> + end <nl> + end <nl> + end <nl> mmm a / arangod / Aql / OptimizerRulesReplaceFunctions . cpp <nl> ppp b / arangod / Aql / OptimizerRulesReplaceFunctions . cpp <nl> using namespace arangodb : : aql ; <nl> using EN = arangodb : : aql : : ExecutionNode ; <nl> <nl> namespace { <nl> - <nl> + <nl> bool isValueTypeCollection ( AstNode const * node ) { <nl> return node - > type = = NODE_TYPE_COLLECTION | | node - > isStringValue ( ) ; <nl> } <nl> AstNode * replaceNearOrWithin ( AstNode * funAstNode , ExecutionNode * calcNode , Execu <nl> auto * query = ast - > query ( ) ; <nl> NearOrWithinParams params ( funAstNode , isNear ) ; <nl> <nl> + if ( isNear & & ( ! params . limit | | params . limit - > isNullValue ( ) ) ) { <nl> + params . limit = ast - > createNodeValueInt ( 100 ) ; <nl> + } <nl> + <nl> / / RETURN ( <nl> / / FOR d IN col <nl> / / SORT DISTANCE ( d . lat , d . long , param . lat , param . lon ) / / NEAR <nl> AstNode * replaceNearOrWithin ( AstNode * funAstNode , ExecutionNode * calcNode , Execu <nl> <nl> / / / / wrap plan part into subquery <nl> return createSubqueryWithLimit ( plan , calcNode , eEnumerate , eCalcMerge , calcMergeOutVariable , params . limit ) ; <nl> - } <nl> + } / / merge <nl> <nl> / / / / wrap plan part into subquery <nl> return createSubqueryWithLimit ( plan , calcNode , <nl> eEnumerate / * first * / , eSortOrFilter / * last * / , <nl> enumerateOutVariable , params . limit ) ; <nl> } <nl> - <nl> + <nl> / / / @ brief replace WITHIN_RECTANGLE <nl> AstNode * replaceWithinRectangle ( AstNode * funAstNode , ExecutionNode * calcNode , ExecutionPlan * plan ) { <nl> auto * ast = plan - > getAst ( ) ; <nl> - <nl> + <nl> TRI_ASSERT ( funAstNode - > type = = AstNodeType : : NODE_TYPE_FCALL ) ; <nl> AstNode * fargs = funAstNode - > getMember ( 0 ) ; <nl> TRI_ASSERT ( fargs - > type = = AstNodeType : : NODE_TYPE_ARRAY ) ; <nl> - <nl> + <nl> if ( fargs - > numMembers ( ) < 5 ) { <nl> THROW_ARANGO_EXCEPTION_PARAMS ( TRI_ERROR_QUERY_FUNCTION_ARGUMENT_NUMBER_MISMATCH , " WITHIN_RECTANGLE " , 5 , 5 ) ; <nl> } <nl> AstNode * replaceWithinRectangle ( AstNode * funAstNode , ExecutionNode * calcNode , Ex <nl> if ( ! : : isValueTypeCollection ( coll ) ) { <nl> THROW_ARANGO_EXCEPTION ( TRI_ERROR_ARANGO_ILLEGAL_NAME ) ; <nl> } <nl> - <nl> + <nl> / / check for suitable indexes <nl> std : : string cname = coll - > getString ( ) ; <nl> std : : shared_ptr < arangodb : : Index > index ; <nl> AstNode * replaceWithinRectangle ( AstNode * funAstNode , ExecutionNode * calcNode , Ex <nl> THROW_ARANGO_EXCEPTION_PARAMS ( TRI_ERROR_QUERY_GEO_INDEX_MISSING , <nl> cname . c_str ( ) ) ; <nl> } <nl> - <nl> + <nl> if ( coll - > type ! = NODE_TYPE_COLLECTION ) { / / TODO does this work ? <nl> aql : : addCollectionToQuery ( ast - > query ( ) , cname , false ) ; <nl> coll = ast - > createNodeCollection ( coll - > getStringValue ( ) , <nl> AccessMode : : Type : : READ ) ; <nl> } <nl> - <nl> + <nl> / / FOR part <nl> Variable * collVar = ast - > variables ( ) - > createTemporaryVariable ( ) ; <nl> AstNode * forNode = ast - > createNodeFor ( collVar , coll ) ; <nl> AstNode * replaceWithinRectangle ( AstNode * funAstNode , ExecutionNode * calcNode , Ex <nl> <nl> / / create an on - the - fly subquery for a full collection access <nl> AstNode * rootNode = ast - > createNodeSubquery ( ) ; <nl> - <nl> + <nl> / / add nodes to subquery <nl> rootNode - > addMember ( forNode ) ; <nl> rootNode - > addMember ( filterNode ) ; <nl> mmm a / arangod / RestHandler / RestStatusHandler . cpp <nl> ppp b / arangod / RestHandler / RestStatusHandler . cpp <nl> RestStatus RestStatusHandler : : execute ( ) { <nl> result . add ( " version " , VPackValue ( ARANGODB_VERSION ) ) ; <nl> <nl> result . add ( " pid " , VPackValue ( Thread : : currentProcessId ( ) ) ) ; <nl> - <nl> + <nl> # ifdef USE_ENTERPRISE <nl> result . add ( " license " , VPackValue ( " enterprise " ) ) ; <nl> # else <nl> RestStatus RestStatusHandler : : execute ( ) { <nl> if ( application_features : : ApplicationServer : : server ! = nullptr ) { <nl> auto server = application_features : : ApplicationServer : : server <nl> - > getFeature < ServerFeature > ( " Server " ) ; <nl> + result . add ( " mode " , VPackValue ( server - > operationModeString ( ) ) ) ; / / to be deprecated - 3 . 3 compat <nl> result . add ( " operationMode " , VPackValue ( server - > operationModeString ( ) ) ) ; <nl> } <nl> <nl> RestStatus RestStatusHandler : : execute ( ) { <nl> <nl> result . add ( " maintenance " , VPackValue ( serverState - > isMaintenance ( ) ) ) ; <nl> result . add ( " role " , VPackValue ( ServerState : : roleToString ( serverState - > getRole ( ) ) ) ) ; <nl> + result . add ( " writeOpsEnabled " , VPackValue ( ! serverState - > readOnly ( ) ) ) ; / / to be deprecated - 3 . 3 compat <nl> result . add ( " readOnly " , VPackValue ( serverState - > readOnly ( ) ) ) ; <nl> <nl> if ( ! serverState - > isSingleServer ( ) ) { <nl> mmm a / js / server / tests / aql / aql - queries - geo . js <nl> ppp b / js / server / tests / aql / aql - queries - geo . js <nl> function ahuacatlLegacyGeoTestSuite ( ) { <nl> actual = runQuery ( query ) ; <nl> assertEqual ( expected , actual ) ; <nl> <nl> - expected = [ { " distance " : " 14891044 . 54146 " , " latitude " : 40 , " longitude " : - 40 } , <nl> - { " distance " : " 14853029 . 30724 " , " latitude " : 40 , " longitude " : - 39 } , <nl> - { " distance " : " 14815001 . 47646 " , " latitude " : 40 , " longitude " : - 38 } ] ; <nl> + / / until changed null will result in the default value of 100 <nl> + / / expected = [ { " distance " : " 14891044 . 54146 " , " latitude " : 40 , " longitude " : - 40 } , <nl> + / / { " distance " : " 14853029 . 30724 " , " latitude " : 40 , " longitude " : - 39 } , <nl> + / / { " distance " : " 14815001 . 47646 " , " latitude " : 40 , " longitude " : - 38 } ] ; <nl> query = " FOR x IN NEAR ( " + locations . name ( ) + " , - 70 , 70 , null , \ " distance \ " ) " + <nl> " SORT x . distance DESC LIMIT 3 RETURN x " ; <nl> actual = runQuery ( query ) ; <nl> function legacyGeoTestSuite ( ) { <nl> " SORT d DESC LIMIT 3 RETURN MERGE ( x , { distance : d } ) " ) ; <nl> assertEqual ( expected , actual ) ; <nl> <nl> - expected = [ { " distance " : " 14891044 . 54146 " , " latitude " : 40 , " longitude " : - 40 } , <nl> - { " distance " : " 14853029 . 30724 " , " latitude " : 40 , " longitude " : - 39 } , <nl> - { " distance " : " 14815001 . 47646 " , " latitude " : 40 , " longitude " : - 38 } ] ; <nl> + / / until changed null will result in the default value of 100 <nl> + / / expected = [ { " distance " : " 14891044 . 54146 " , " latitude " : 40 , " longitude " : - 40 } , <nl> + / / { " distance " : " 14853029 . 30724 " , " latitude " : 40 , " longitude " : - 39 } , <nl> + / / { " distance " : " 14815001 . 47646 " , " latitude " : 40 , " longitude " : - 38 } ] ; <nl> actual = runQuery ( " FOR x IN NEAR ( " + locations . name ( ) + " , - 70 , 70 , null ) " + <nl> " LET d = DISTANCE ( - 70 , 70 , x . latitude , x . longitude ) " + <nl> " SORT d DESC LIMIT 3 RETURN MERGE ( x , { distance : d } ) " ) ; <nl>
|
compatibilty 3 . 3 < - > 3 . 4 ( )
|
arangodb/arangodb
|
4c0f8817648f90f75733f048fe9977b2e8972a0f
|
2018-07-25T07:05:34Z
|
mmm a / project / VS2010Express / XBMC . vcxproj <nl> ppp b / project / VS2010Express / XBMC . vcxproj <nl> <nl> < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release ( DirectX ) | Win32 ' " > true < / ExcludedFromBuild > <nl> < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release ( OpenGL ) | Win32 ' " > true < / ExcludedFromBuild > <nl> < / ClCompile > <nl> + < ClCompile Include = " . . \ . . \ xbmc \ test \ TestTextureCache . cpp " > <nl> + < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug ( DirectX ) | Win32 ' " > true < / ExcludedFromBuild > <nl> + < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug ( OpenGL ) | Win32 ' " > true < / ExcludedFromBuild > <nl> + < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release ( DirectX ) | Win32 ' " > true < / ExcludedFromBuild > <nl> + < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Release ( OpenGL ) | Win32 ' " > true < / ExcludedFromBuild > <nl> + < / ClCompile > <nl> < ClCompile Include = " . . \ . . \ xbmc \ test \ TestUtils . cpp " > <nl> < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug ( DirectX ) | Win32 ' " > true < / ExcludedFromBuild > <nl> < ExcludedFromBuild Condition = " ' $ ( Configuration ) | $ ( Platform ) ' = = ' Debug ( OpenGL ) | Win32 ' " > true < / ExcludedFromBuild > <nl> mmm a / project / VS2010Express / XBMC . vcxproj . filters <nl> ppp b / project / VS2010Express / XBMC . vcxproj . filters <nl> <nl> < ClCompile Include = " . . \ . . \ xbmc \ test \ TestFileItem . cpp " > <nl> < Filter > test < / Filter > <nl> < / ClCompile > <nl> + < ClCompile Include = " . . \ . . \ xbmc \ test \ TestTextureCache . cpp " > <nl> + < Filter > test < / Filter > <nl> + < / ClCompile > <nl> < ClCompile Include = " . . \ . . \ xbmc \ interfaces \ json - rpc \ PVROperations . cpp " > <nl> < Filter > interfaces \ json - rpc < / Filter > <nl> < / ClCompile > <nl> mmm a / xbmc / test / Makefile <nl> ppp b / xbmc / test / Makefile <nl> <nl> SRCS = \ <nl> TestBasicEnvironment . cpp \ <nl> TestFileItem . cpp \ <nl> + TestTextureCache . cpp \ <nl> TestUtils . cpp \ <nl> xbmc - test . cpp <nl> <nl> new file mode 100644 <nl> index 000000000000 . . 083595a9200a <nl> mmm / dev / null <nl> ppp b / xbmc / test / TestTextureCache . cpp <nl> <nl> + / * <nl> + * Copyright ( C ) 2012 Team XBMC <nl> + * http : / / www . xbmc . org <nl> + * <nl> + * This Program is free software ; you can redistribute it and / or modify <nl> + * it under the terms of the GNU General Public License as published by <nl> + * the Free Software Foundation ; either version 2 , or ( at your option ) <nl> + * any later version . <nl> + * <nl> + * This Program is distributed in the hope that it will be useful , <nl> + * but WITHOUT ANY WARRANTY ; without even the implied warranty of <nl> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the <nl> + * GNU General Public License for more details . <nl> + * <nl> + * You should have received a copy of the GNU General Public License <nl> + * along with XBMC ; see the file COPYING . If not , see <nl> + * < http : / / www . gnu . org / licenses / > . <nl> + * <nl> + * / <nl> + <nl> + # include " URL . h " <nl> + # include " TextureCache . h " <nl> + <nl> + # include " gtest / gtest . h " <nl> + <nl> + TEST ( TestTextureCache , GetWrappedImageURL ) <nl> + { <nl> + typedef struct <nl> + { <nl> + const char * in ; <nl> + const char * type ; <nl> + const char * options ; <nl> + const char * out ; <nl> + } testfiles ; <nl> + <nl> + const testfiles test_files [ ] = { { " / path / to / image / file . jpg " , " " , " " , " image : / / % 2fpath % 2fto % 2fimage % 2ffile . jpg / " } , <nl> + { " / path / to / image / file . jpg " , " " , " size = thumb " , " image : / / % 2fpath % 2fto % 2fimage % 2ffile . jpg / transform ? size = thumb " } , <nl> + { " / path / to / video / file . mkv " , " video " , " " , " image : / / video @ % 2fpath % 2fto % 2fvideo % 2ffile . mkv / " } , <nl> + { " / path / to / music / file . mp3 " , " music " , " " , " image : / / music @ % 2fpath % 2fto % 2fmusic % 2ffile . mp3 / " } , <nl> + { " image : / / % 2fpath % 2fto % 2fimage % 2ffile . jpg / " , " " , " " , " image : / / % 2fpath % 2fto % 2fimage % 2ffile . jpg / " } , <nl> + { " image : / / % 2fpath % 2fto % 2fimage % 2ffile . jpg / transform ? size = thumb " , " " , " size = thumb " , " image : / / % 2fpath % 2fto % 2fimage % 2ffile . jpg / transform ? size = thumb " } } ; <nl> + <nl> + for ( unsigned int i = 0 ; i < sizeof ( test_files ) / sizeof ( testfiles ) ; i + + ) <nl> + { <nl> + std : : string expected = test_files [ i ] . out ; <nl> + std : : string out = CTextureCache : : GetWrappedImageURL ( test_files [ i ] . in , test_files [ i ] . type , test_files [ i ] . options ) ; <nl> + EXPECT_EQ ( out , expected ) ; <nl> + } <nl> + } <nl>
|
adds unit test for CTextureCache : : GetWrappedImageURL
|
xbmc/xbmc
|
a5d80392b7f7d40999683aa44b165170791283b3
|
2012-10-27T08:08:07Z
|
mmm a / src / webui / www / private / scripts / dynamicTable . js <nl> ppp b / src / webui / www / private / scripts / dynamicTable . js <nl> window . qBittorrent . DynamicTable = ( function ( ) { <nl> return false ; <nl> break ; <nl> default : <nl> - const tracker = trackerList . get ( trackerHashInt ) <nl> + const tracker = trackerList . get ( trackerHashInt ) ; <nl> if ( tracker & & ! tracker . torrents . includes ( row [ ' full_data ' ] . rowId ) ) <nl> - return false <nl> + return false ; <nl> break ; <nl> } <nl> <nl> window . qBittorrent . DynamicTable = ( function ( ) { <nl> tr . removeClass ( ' articleTableFeed ' ) ; <nl> tr . addClass ( ' articleTableArticle ' ) ; <nl> } <nl> - <nl> + <nl> const tds = tr . getElements ( ' td ' ) ; <nl> for ( let i = 0 ; i < this . columns . length ; + + i ) { <nl> if ( data . hasOwnProperty ( this . columns [ i ] . dataProperties [ 0 ] ) ) <nl> window . qBittorrent . DynamicTable = ( function ( ) { <nl> row [ ' data ' ] = { } ; <nl> } <nl> } ) ; <nl> - <nl> + <nl> <nl> return exports ( ) ; <nl> } ) ( ) ; <nl> mmm a / src / webui / www / private / scripts / mocha - init . js <nl> ppp b / src / webui / www / private / scripts / mocha - init . js <nl> const initializeWindows = function ( ) { <nl> hashes = torrentsTable . getFilteredTorrentsHashes ( ' all ' , CATEGORIES_ALL , TAGS_ALL , TRACKERS_TRACKERLESS ) ; <nl> break ; <nl> default : <nl> - hashes = trackerList . get ( trackerHashInt ) . torrents <nl> + hashes = trackerList . get ( trackerHashInt ) . torrents ; <nl> break ; <nl> } <nl> <nl> const initializeWindows = function ( ) { <nl> hashes = torrentsTable . getFilteredTorrentsHashes ( ' all ' , CATEGORIES_ALL , TAGS_ALL , TRACKERS_TRACKERLESS ) ; <nl> break ; <nl> default : <nl> - hashes = trackerList . get ( trackerHashInt ) . torrents <nl> + hashes = trackerList . get ( trackerHashInt ) . torrents ; <nl> break ; <nl> } <nl> <nl> mmm a / src / webui / www / private / views / rss . html <nl> ppp b / src / webui / www / private / views / rss . html <nl> <nl> overflow : hidden ; <nl> height : 30px ; <nl> } <nl> - <nl> + <nl> # rssContentView table { <nl> width : 100 % ; <nl> } <nl> - <nl> + <nl> < / style > <nl> <nl> < div id = " rssView " > <nl> <nl> $ ( ' rssDetailsView ' ) . style . height = ' calc ( 100vh - ' + nonPageHeight + ' px ) ' ; <nl> <nl> let nonTableHeight = nonPageHeight + $ ( ' rssFeedFixedHeaderDiv ' ) . getBoundingClientRect ( ) . height ; <nl> - <nl> + <nl> $ ( ' rssFeedTableDiv ' ) . style . height = ' calc ( 100vh - ' + nonTableHeight + ' px ) ' ; <nl> $ ( ' rssArticleTableDiv ' ) . style . height = ' calc ( 100vh - ' + nonTableHeight + ' px ) ' ; <nl> <nl> <nl> . filter ( ( e ) = > e ! = = 0 ) <nl> . map ( ( sRow ) = > rssFeedTable . rows [ sRow ] . full_data . dataPath ) ; <nl> / / filter children <nl> - let reducedDatapaths = selectedDatapaths . filter ( ( path ) = > <nl> + let reducedDatapaths = selectedDatapaths . filter ( ( path ) = > <nl> selectedDatapaths . filter ( ( innerPath ) = > path . slice ( 0 , innerPath . length ) = = = innerPath ) . length = = = 1 <nl> ) ; <nl> removeItem ( reducedDatapaths ) ; <nl> <nl> recFlatten ( current [ child ] , child , depth + 1 , currentFullName ) ; <nl> } <nl> } <nl> - } <nl> + } ; <nl> recFlatten ( response ) ; <nl> <nl> / / check if rows matche flattend response <nl> <nl> let selectedDatapaths = rssFeedTable . selectedRows <nl> . map ( ( sRow ) = > rssFeedTable . rows [ sRow ] . full_data . dataPath ) ; <nl> / / filter children <nl> - let reducedDatapaths = selectedDatapaths . filter ( ( path ) = > <nl> + let reducedDatapaths = selectedDatapaths . filter ( ( path ) = > <nl> selectedDatapaths . filter ( ( innerPath ) = > path . slice ( 0 , innerPath . length ) = = = innerPath ) . length = = = 1 <nl> ) ; <nl> reducedDatapaths . each ( ( path ) = > markItemAsRead ( path ) ) ; <nl> mmm a / src / webui / www / private / views / rssDownloader . html <nl> ppp b / src / webui / www / private / views / rssDownloader . html <nl> <nl> # lastMatchDiv { <nl> float : right ; <nl> } <nl> - <nl> + <nl> # ruleSettings { <nl> padding : 4px 10px 4px 10px <nl> } <nl> <nl> } ) . send ( ) ; <nl> $ ( ' savetoDifferentDir ' ) . addEvent ( ' click ' , ( ) = > { <nl> $ ( ' saveToText ' ) . disabled = ! $ ( ' savetoDifferentDir ' ) . checked ; <nl> - } ) <nl> + } ) ; <nl> updateRulesList ( ) ; <nl> } ; <nl> <nl> <nl> ' ● QBT_TR ( ? to match any single character ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> ' ● QBT_TR ( * to match zero or more of any characters ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> ' ● QBT_TR ( Whitespaces count as AND operators ( all words , any order ) ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> - ' ● QBT_TR ( | is used as OR operator ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n \ n ' + <nl> + ' ● QBT_TR ( | is used as OR operator ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n \ n ' + <nl> ' QBT_TR ( If word order is important use * instead of whitespace . ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n \ n ' ; <nl> } <nl> let secondPart = ' QBT_TR ( An expression with an empty % 1 clause ( e . g . % 2 ) ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] ' <nl> <nl> <nl> let episodeFilterTitle = ' QBT_TR ( Matches articles based on episode filter . ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n \ n ' + <nl> ' QBT_TR ( Example : ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] ' + <nl> - ' 1x2 ; 8 - 15 ; 5 ; 30 - ; ' + <nl> - ' QBT_TR ( will match 2 , 5 , 8 through 15 , 30 and onward episodes of season one ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n \ n ' + <nl> - ' QBT_TR ( Episode filter rules : ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n \ n ' + <nl> - ' ● QBT_TR ( Season number is a mandatory non - zero value ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> - ' ● QBT_TR ( Episode number is a mandatory positive value ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> - ' ● QBT_TR ( Filter must end with semicolon ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> - ' ● QBT_TR ( Three range types for episodes are supported : ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> - ' ● QBT_TR ( Single number : < b > 1x25 ; < / b > matches episode 25 of season one ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> - ' ● QBT_TR ( Normal range : < b > 1x25 - 40 ; < / b > matches episodes 25 through 40 of season one ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> + ' 1x2 ; 8 - 15 ; 5 ; 30 - ; ' + <nl> + ' QBT_TR ( will match 2 , 5 , 8 through 15 , 30 and onward episodes of season one ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n \ n ' + <nl> + ' QBT_TR ( Episode filter rules : ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n \ n ' + <nl> + ' ● QBT_TR ( Season number is a mandatory non - zero value ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> + ' ● QBT_TR ( Episode number is a mandatory positive value ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> + ' ● QBT_TR ( Filter must end with semicolon ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> + ' ● QBT_TR ( Three range types for episodes are supported : ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> + ' ● QBT_TR ( Single number : < b > 1x25 ; < / b > matches episode 25 of season one ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> + ' ● QBT_TR ( Normal range : < b > 1x25 - 40 ; < / b > matches episodes 25 through 40 of season one ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] \ n ' + <nl> ' ● QBT_TR ( Infinite range : < b > 1x25 - ; < / b > matches episodes 25 and upward of season one , and all episodes of later seasons ) QBT_TR [ CONTEXT = AutomatedRssDownloader ] ' ; <nl> <nl> episodeFilterTitle = episodeFilterTitle . replace ( / < b > / g , ' ' ) . replace ( / < \ / b > / g , ' ' ) ; <nl>
|
Add missing semicolons
|
qbittorrent/qBittorrent
|
ccdc3b201b5d7ce587070c300dc2be9c4f2ebdcd
|
2020-09-17T04:11:13Z
|
mmm a / tensorflow / compiler / mlir / lite / tests / end2end / fake_quant_per_channel . pbtxt <nl> ppp b / tensorflow / compiler / mlir / lite / tests / end2end / fake_quant_per_channel . pbtxt <nl> node { <nl> # CHECK : shape : [ 186 ] , <nl> # CHECK : type : INT32 , <nl> # CHECK : buffer : 3 , <nl> - # CHECK : name : " tfl . pseudo_qconst " , <nl> + # CHECK : name : " BoxPredictor_4 / ClassPredictor / BiasAdd , BoxPredictor_4 / ClassPredictor / Conv2D , BoxPredictor_4 / ClassPredictor / biases " , <nl> # CHECK : quantization : { <nl> # CHECK : scale : [ 0 . 027216 , 0 . 00038 , 0 . 000413 , 0 . 000426 , 0 . 001607 , <nl> # CHECK : zero_point : [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> node { <nl> # CHECK : shape : [ 186 , 1 , 1 , 256 ] , <nl> # CHECK : type : INT8 , <nl> # CHECK : buffer : 4 , <nl> - # CHECK : name : " tfl . pseudo_qconst1 " , <nl> + # CHECK : name : " BoxPredictor_4 / ClassPredictor / Conv2D , BoxPredictor_4 / ClassPredictor / weights_quant / FakeQuantWithMinMaxVarsPerChannel " , <nl> # CHECK : quantization : { <nl> # CHECK : scale : [ 0 . 12581 , 0 . 001755 , 0 . 001908 , 0 . 001967 , 0 . 007431 , <nl> # CHECK : zero_point : [ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , <nl> node { <nl> # CHECK : shape : [ 1 , 1 , 1 , 186 ] , <nl> # CHECK : type : INT8 , <nl> # CHECK : buffer : 5 , <nl> - # CHECK : name : " tfl . conv_2d " , <nl> + # CHECK : name : " BoxPredictor_4 / ClassPredictor / BiasAdd , BoxPredictor_4 / ClassPredictor / Conv2D , BoxPredictor_4 / ClassPredictor / biases1 " , <nl> # CHECK : quantization : { <nl> # CHECK : scale : [ 0 . 093635 ] , <nl> # CHECK : zero_point : [ 22 ] <nl> mmm a / tensorflow / compiler / mlir / op_or_arg_name_mapper . cc <nl> ppp b / tensorflow / compiler / mlir / op_or_arg_name_mapper . cc <nl> limitations under the License . <nl> <nl> # include " llvm / ADT / APInt . h " <nl> # include " llvm / ADT / SmallString . h " <nl> + # include " llvm / ADT / StringExtras . h " <nl> # include " llvm / ADT / StringRef . h " <nl> # include " mlir / IR / Location . h " / / TF : local_config_mlir <nl> # include " mlir / IR / Operation . h " / / TF : local_config_mlir <nl> bool OpOrArgNameMapper : : IsUnique ( llvm : : StringRef name ) { <nl> <nl> namespace { <nl> / / Derives name from location . <nl> - llvm : : StringRef GetNameFromLoc ( mlir : : Location loc ) { <nl> + std : : string GetNameFromLoc ( mlir : : Location loc ) { <nl> if ( auto name_loc = loc . dyn_cast < mlir : : NameLoc > ( ) ) <nl> - return name_loc . getName ( ) . strref ( ) ; <nl> + return name_loc . getName ( ) . str ( ) ; <nl> <nl> if ( auto call_loc = loc . dyn_cast < mlir : : CallSiteLoc > ( ) ) { <nl> / / Return name if CallSiteLoc ' s callee has a NameLoc ( as should be the case <nl> / / if imported with DebugInfo ) , else use the fallback naming scheme below . <nl> if ( auto name_loc = call_loc . getCallee ( ) . dyn_cast < mlir : : NameLoc > ( ) ) <nl> - return name_loc . getName ( ) . strref ( ) ; <nl> + return name_loc . getName ( ) . str ( ) ; <nl> } <nl> <nl> - return llvm : : StringRef ( ) ; <nl> + if ( auto fused_loc = loc . dyn_cast < mlir : : FusedLoc > ( ) ) { <nl> + llvm : : ArrayRef < mlir : : Location > locations = fused_loc . getLocations ( ) ; <nl> + std : : vector < std : : string > names ; <nl> + bool names_is_nonempty = false ; <nl> + for ( const auto & loc : locations ) { <nl> + const std : : string loc_name = GetNameFromLoc ( loc ) ; <nl> + names . push_back ( loc_name ) ; <nl> + if ( ! loc_name . empty ( ) ) { <nl> + names_is_nonempty = true ; <nl> + } <nl> + } <nl> + if ( names_is_nonempty ) { <nl> + return llvm : : join ( names . begin ( ) , names . end ( ) , " , " ) ; <nl> + } <nl> + } <nl> + <nl> + return " " ; <nl> } <nl> } / / anonymous namespace <nl> <nl>
|
Add custom FusedLoc naming in OpOrArgNameMapper .
|
tensorflow/tensorflow
|
43d77b42e7d00e0b8da3509141c5e9c8b6b3ae5d
|
2019-11-09T04:13:59Z
|
mmm a / test / cpp / api / fft . cpp <nl> ppp b / test / cpp / api / fft . cpp <nl> <nl> # include < gtest / gtest . h > <nl> <nl> # include < torch / torch . h > <nl> + # include < test / cpp / api / support . h > <nl> + <nl> + <nl> + / / Tests that the fft function can be called as usual <nl> + TEST ( FFTTest , unclobbered_fft ) { <nl> + auto t = torch : : randn ( { 64 , 2 } , torch : : dtype ( torch : : kDouble ) ) ; <nl> + torch : : fft ( t , 1 ) ; <nl> + } <nl> + <nl> + / / Clobbers torch : : fft the function with torch : : fft the namespace <nl> # include < torch / fft . h > <nl> <nl> - # include < test / cpp / api / support . h > <nl> <nl> / / NOTE : Visual Studio and ROCm builds don ' t understand complex literals <nl> / / as of August 2020 <nl> mmm a / torch / csrc / api / include / torch / all . h <nl> ppp b / torch / csrc / api / include / torch / all . h <nl> <nl> # include < torch / cuda . h > <nl> # include < torch / data . h > <nl> # include < torch / enum . h > <nl> - # include < torch / fft . h > <nl> # include < torch / jit . h > <nl> # include < torch / linalg . h > <nl> # include < torch / nn . h > <nl>
|
Fixes fft function calls for C + + API ( )
|
pytorch/pytorch
|
f4695203c2c38864753873802a0835cfb7bc3dde
|
2020-08-28T19:41:30Z
|
mmm a / DEFAULT_OPTIONS_HISTORY . md <nl> ppp b / DEFAULT_OPTIONS_HISTORY . md <nl> <nl> * options . target_file_size_base changes from 2MB to 64MB <nl> * options . max_bytes_for_level_base changes from 10MB to 256MB <nl> * options . soft_pending_compaction_bytes_limit changes from 0 ( disabled ) to 64GB <nl> - * options . hard_pending_compaction_bytes_limit changes from 0 ( disabled ) to 256GB <nl> \ No newline at end of file <nl> + * options . hard_pending_compaction_bytes_limit changes from 0 ( disabled ) to 256GB <nl> + * table_cache_numshardbits changes from 4 to 6 <nl> + * max_file_opening_threads changes from 1 to 16 <nl> \ No newline at end of file <nl> mmm a / table / table_test . cc <nl> ppp b / table / table_test . cc <nl> void PrefetchRange ( TableConstructor * c , Options * opt , <nl> const std : : vector < std : : string > & keys_not_in_cache , <nl> const Status expected_status = Status : : OK ( ) ) { <nl> / / reset the cache and reopen the table <nl> - table_options - > block_cache = NewLRUCache ( 16 * 1024 * 1024 ) ; <nl> + table_options - > block_cache = NewLRUCache ( 16 * 1024 * 1024 , 4 ) ; <nl> opt - > table_factory . reset ( NewBlockBasedTableFactory ( * table_options ) ) ; <nl> const ImmutableCFOptions ioptions2 ( * opt ) ; <nl> ASSERT_OK ( c - > Reopen ( ioptions2 ) ) ; <nl> TEST_F ( BlockBasedTableTest , PrefetchTest ) { <nl> BlockBasedTableOptions table_options ; <nl> table_options . block_size = 1024 ; <nl> / / big enough so we don ' t ever lose cached values . <nl> - table_options . block_cache = NewLRUCache ( 16 * 1024 * 1024 ) ; <nl> + table_options . block_cache = NewLRUCache ( 16 * 1024 * 1024 , 4 ) ; <nl> opt . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ; <nl> <nl> TableConstructor c ( BytewiseComparator ( ) ) ; <nl> TEST_F ( TableTest , HashIndexTest ) { <nl> table_options . index_type = BlockBasedTableOptions : : kHashSearch ; <nl> table_options . hash_index_allow_collision = true ; <nl> table_options . block_size = 1700 ; <nl> - table_options . block_cache = NewLRUCache ( 1024 ) ; <nl> + table_options . block_cache = NewLRUCache ( 1024 , 4 ) ; <nl> options . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ; <nl> <nl> std : : unique_ptr < InternalKeyComparator > comparator ( <nl> TEST_F ( BlockBasedTableTest , BlockCacheDisabledTest ) { <nl> options . create_if_missing = true ; <nl> options . statistics = CreateDBStatistics ( ) ; <nl> BlockBasedTableOptions table_options ; <nl> - table_options . block_cache = NewLRUCache ( 1024 ) ; <nl> + table_options . block_cache = NewLRUCache ( 1024 , 4 ) ; <nl> table_options . filter_policy . reset ( NewBloomFilterPolicy ( 10 ) ) ; <nl> options . table_factory . reset ( new BlockBasedTableFactory ( table_options ) ) ; <nl> std : : vector < std : : string > keys ; <nl> TEST_F ( BlockBasedTableTest , FilterBlockInBlockCache ) { <nl> <nl> / / Enable the cache for index / filter blocks <nl> BlockBasedTableOptions table_options ; <nl> - table_options . block_cache = NewLRUCache ( 1024 ) ; <nl> + table_options . block_cache = NewLRUCache ( 1024 , 4 ) ; <nl> table_options . cache_index_and_filter_blocks = true ; <nl> options . table_factory . reset ( new BlockBasedTableFactory ( table_options ) ) ; <nl> std : : vector < std : : string > keys ; <nl> TEST_F ( BlockBasedTableTest , FilterBlockInBlockCache ) { <nl> / / - - PART 2 : Open with very small block cache <nl> / / In this test , no block will ever get hit since the block cache is <nl> / / too small to fit even one entry . <nl> - table_options . block_cache = NewLRUCache ( 1 ) ; <nl> + table_options . block_cache = NewLRUCache ( 1 , 4 ) ; <nl> options . statistics = CreateDBStatistics ( ) ; <nl> options . table_factory . reset ( new BlockBasedTableFactory ( table_options ) ) ; <nl> const ImmutableCFOptions ioptions2 ( options ) ; <nl> TEST_F ( BlockBasedTableTest , FilterBlockInBlockCache ) { <nl> c . ResetTableReader ( ) ; <nl> <nl> / / - - PART 3 : Open table with bloom filter enabled but not in SST file <nl> - table_options . block_cache = NewLRUCache ( 4096 ) ; <nl> + table_options . block_cache = NewLRUCache ( 4096 , 4 ) ; <nl> table_options . cache_index_and_filter_blocks = false ; <nl> options . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ; <nl> <nl> TEST_F ( BlockBasedTableTest , BlockCacheLeak ) { <nl> BlockBasedTableOptions table_options ; <nl> table_options . block_size = 1024 ; <nl> / / big enough so we don ' t ever lose cached values . <nl> - table_options . block_cache = NewLRUCache ( 16 * 1024 * 1024 ) ; <nl> + table_options . block_cache = NewLRUCache ( 16 * 1024 * 1024 , 4 ) ; <nl> opt . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ; <nl> <nl> TableConstructor c ( BytewiseComparator ( ) ) ; <nl> TEST_F ( BlockBasedTableTest , BlockCacheLeak ) { <nl> c . ResetTableReader ( ) ; <nl> <nl> / / rerun with different block cache <nl> - table_options . block_cache = NewLRUCache ( 16 * 1024 * 1024 ) ; <nl> + table_options . block_cache = NewLRUCache ( 16 * 1024 * 1024 , 4 ) ; <nl> opt . table_factory . reset ( NewBlockBasedTableFactory ( table_options ) ) ; <nl> const ImmutableCFOptions ioptions2 ( opt ) ; <nl> ASSERT_OK ( c . Reopen ( ioptions2 ) ) ; <nl> mmm a / util / cache . cc <nl> ppp b / util / cache . cc <nl> void LRUCache : : Erase ( const Slice & key , uint32_t hash ) { <nl> } <nl> } <nl> <nl> - static int kNumShardBits = 4 ; / / default values , can be overridden <nl> + static int kNumShardBits = 6 ; / / default values , can be overridden <nl> <nl> class ShardedLRUCache : public Cache { <nl> private : <nl> mmm a / util / options . cc <nl> ppp b / util / options . cc <nl> DBOptions : : DBOptions ( ) <nl> info_log_level ( DEBUG_LEVEL ) , <nl> # endif / / NDEBUG <nl> max_open_files ( 5000 ) , <nl> - max_file_opening_threads ( 1 ) , <nl> + max_file_opening_threads ( 16 ) , <nl> max_total_wal_size ( 0 ) , <nl> statistics ( nullptr ) , <nl> disableDataSync ( false ) , <nl> DBOptions : : DBOptions ( ) <nl> keep_log_file_num ( 1000 ) , <nl> recycle_log_file_num ( 0 ) , <nl> max_manifest_file_size ( std : : numeric_limits < uint64_t > : : max ( ) ) , <nl> - table_cache_numshardbits ( 4 ) , <nl> + table_cache_numshardbits ( 6 ) , <nl> WAL_ttl_seconds ( 0 ) , <nl> WAL_size_limit_MB ( 0 ) , <nl> manifest_preallocation_size ( 4 * 1024 * 1024 ) , <nl> Options * Options : : OldDefaults ( int rocksdb_major_version , <nl> <nl> DBOptions * DBOptions : : OldDefaults ( int rocksdb_major_version , <nl> int rocksdb_minor_version ) { <nl> + max_file_opening_threads = 1 ; <nl> + table_cache_numshardbits = 4 ; <nl> return this ; <nl> } <nl> <nl> mmm a / util / options_test . cc <nl> ppp b / util / options_test . cc <nl> TEST_F ( OptionsParserTest , DifferentDefault ) { <nl> Options old_default_opts46 ; <nl> old_default_opts46 . OldDefaults ( ) ; <nl> ASSERT_EQ ( 10 * 1048576 , old_default_opts46 . max_bytes_for_level_base ) ; <nl> + ASSERT_EQ ( 4 , old_default_opts46 . table_cache_numshardbits ) ; <nl> <nl> ColumnFamilyOptions old_default_cf_opts ; <nl> old_default_cf_opts . OldDefaults ( ) ; <nl>
|
Change default number of cache shard bit to be 6 and max_file_opening_threads to be 16 .
|
facebook/rocksdb
|
1518b733ebea6df41d8330dbd23150ed736bdb33
|
2016-04-07T20:55:10Z
|
new file mode 100644 <nl> index 00000000000 . . 3a2550bd490 <nl> Binary files / dev / null and b / data / cat . jpg differ <nl> mmm a / include / caffe / vision_layers . hpp <nl> ppp b / include / caffe / vision_layers . hpp <nl> class DataLayer : public Layer < Dtype > { <nl> Blob < Dtype > data_mean_ ; <nl> } ; <nl> <nl> + / / This function is used to create a pthread that prefetches the data . <nl> + template < typename Dtype > <nl> + void * InputLayerPrefetch ( void * layer_pointer ) ; <nl> + <nl> template < typename Dtype > <nl> class InputLayer : public Layer < Dtype > { <nl> + / / The function used to perform prefetching . <nl> + friend void * InputLayerPrefetch < Dtype > ( void * layer_pointer ) ; <nl> + <nl> public : <nl> explicit InputLayer ( const LayerParameter & param ) <nl> : Layer < Dtype > ( param ) { } <nl> class InputLayer : public Layer < Dtype > { <nl> virtual Dtype Backward_gpu ( const vector < Blob < Dtype > * > & top , <nl> const bool propagate_down , vector < Blob < Dtype > * > * bottom ) ; <nl> <nl> + vector < std : : pair < std : : string , int > > lines_ ; <nl> + int lines_id_ ; <nl> int datum_channels_ ; <nl> int datum_height_ ; <nl> int datum_width_ ; <nl> int datum_size_ ; <nl> - bool biasterm_ ; <nl> - bool has_data_mean_ ; <nl> + pthread_t thread_ ; <nl> + shared_ptr < Blob < Dtype > > prefetch_data_ ; <nl> + shared_ptr < Blob < Dtype > > prefetch_label_ ; <nl> + Blob < Dtype > data_mean_ ; <nl> } ; <nl> <nl> <nl> mmm a / src / caffe / layers / input_layer . cpp <nl> ppp b / src / caffe / layers / input_layer . cpp <nl> <nl> - / / Copyright 2014 Sergio Guadarrama <nl> + / / Copyright 2013 Yangqing Jia <nl> <nl> # include < stdint . h > <nl> # include < leveldb / db . h > <nl> <nl> <nl> # include < string > <nl> # include < vector > <nl> + # include < iostream > <nl> + # include < fstream > <nl> <nl> # include " caffe / layer . hpp " <nl> # include " caffe / util / io . hpp " <nl> # include " caffe / vision_layers . hpp " <nl> - # include " caffe / filler . hpp " <nl> <nl> using std : : string ; <nl> + using std : : pair ; <nl> <nl> namespace caffe { <nl> <nl> void * InputLayerPrefetch ( void * layer_pointer ) { <nl> < < " set at the same time . " ; <nl> } <nl> / / datum scales <nl> - const int channels = layer - > bottom_channels_ ; <nl> - const int height = layer - > bottom_height_ ; <nl> - const int width = layer - > bottom_width_ ; <nl> - const int size = layer - > bottom_size_ ; <nl> + const int channels = layer - > datum_channels_ ; <nl> + const int height = layer - > datum_height_ ; <nl> + const int width = layer - > datum_width_ ; <nl> + const int size = layer - > datum_size_ ; <nl> + const int lines_size = layer - > lines_ . size ( ) ; <nl> const Dtype * mean = layer - > data_mean_ . cpu_data ( ) ; <nl> for ( int itemid = 0 ; itemid < batchsize ; + + itemid ) { <nl> / / get a blob <nl> - CHECK ( layer - > iter_ ) ; <nl> - CHECK ( layer - > iter_ - > Valid ( ) ) ; <nl> - datum . ParseFromString ( layer - > iter_ - > value ( ) . ToString ( ) ) ; <nl> + CHECK_GT ( lines_size , layer - > lines_id_ ) ; <nl> + if ( ! ReadImageToDatum ( layer - > lines_ [ layer - > lines_id_ ] . first , <nl> + layer - > lines_ [ layer - > lines_id_ ] . second , & datum ) ) { <nl> + continue ; <nl> + } ; <nl> const string & data = datum . data ( ) ; <nl> if ( cropsize ) { <nl> CHECK ( data . size ( ) ) < < " Image cropping only support uint8 data " ; <nl> void * InputLayerPrefetch ( void * layer_pointer ) { <nl> } <nl> } <nl> } else { <nl> - / / we will prefer to use data ( ) first , and then try float_data ( ) <nl> + / / Just copy the whole data <nl> if ( data . size ( ) ) { <nl> for ( int j = 0 ; j < size ; + + j ) { <nl> top_data [ itemid * size + j ] = <nl> void * InputLayerPrefetch ( void * layer_pointer ) { <nl> <nl> top_label [ itemid ] = datum . label ( ) ; <nl> / / go to the next iter <nl> - layer - > iter_ - > Next ( ) ; <nl> - if ( ! layer - > iter_ - > Valid ( ) ) { <nl> + layer - > lines_id_ + + ; <nl> + if ( layer - > lines_id_ > = lines_size ) { <nl> / / We have reached the end . Restart from the first . <nl> DLOG ( INFO ) < < " Restarting data prefetching from start . " ; <nl> - layer - > iter_ - > SeekToFirst ( ) ; <nl> + layer - > lines_id_ = 0 ; <nl> } <nl> } <nl> <nl> InputLayer < Dtype > : : ~ InputLayer < Dtype > ( ) { <nl> template < typename Dtype > <nl> void InputLayer < Dtype > : : SetUp ( const vector < Blob < Dtype > * > & bottom , <nl> vector < Blob < Dtype > * > * top ) { <nl> - CHECK_EQ ( bottom . size ( ) , 1 ) < < " Input Layer takes a single blob as input . " ; <nl> - CHECK_EQ ( top - > size ( ) , 1 ) < < " Input Layer takes a single blob as output . " ; <nl> + CHECK_EQ ( bottom . size ( ) , 0 ) < < " Input Layer takes no input blobs . " ; <nl> + CHECK_EQ ( top - > size ( ) , 2 ) < < " Input Layer takes two blobs as output . " ; <nl> + / / Read the file with filenames and labels <nl> + LOG ( INFO ) < < " Opening file " < < this - > layer_param_ . source ( ) ; <nl> + std : : ifstream infile ( this - > layer_param_ . source ( ) . c_str ( ) ) ; <nl> + string filename ; <nl> + int label ; <nl> + while ( infile > > filename > > label ) { <nl> + lines_ . push_back ( std : : make_pair ( filename , label ) ) ; <nl> + } <nl> + <nl> + if ( this - > layer_param_ . shuffle_data ( ) ) { <nl> + / / randomly shuffle data <nl> + LOG ( INFO ) < < " Shuffling data " ; <nl> + std : : random_shuffle ( lines_ . begin ( ) , lines_ . end ( ) ) ; <nl> + } <nl> + LOG ( INFO ) < < " A total of " < < lines_ . size ( ) < < " images . " ; <nl> + <nl> + lines_id_ = 0 ; <nl> + / / Check if we would need to randomly skip a few data points <nl> + if ( this - > layer_param_ . rand_skip ( ) ) { <nl> + unsigned int skip = rand ( ) % this - > layer_param_ . rand_skip ( ) ; <nl> + LOG ( INFO ) < < " Skipping first " < < skip < < " data points . " ; <nl> + CHECK_GT ( lines_ . size ( ) , skip ) < < " Not enought points to skip " ; <nl> + lines_id_ = skip ; <nl> + } <nl> + / / Read a data point , and use it to initialize the top blob . <nl> + Datum datum ; <nl> + CHECK ( ReadImageToDatum ( lines_ [ lines_id_ ] . first , lines_ [ lines_id_ ] . second , <nl> + & datum ) ) ; <nl> + / / image <nl> int cropsize = this - > layer_param_ . cropsize ( ) ; <nl> if ( cropsize > 0 ) { <nl> ( * top ) [ 0 ] - > Reshape ( <nl> - this - > layer_param_ . batchsize ( ) , bottom . channels ( ) , cropsize , cropsize ) ; <nl> + this - > layer_param_ . batchsize ( ) , datum . channels ( ) , cropsize , cropsize ) ; <nl> + prefetch_data_ . reset ( new Blob < Dtype > ( <nl> + this - > layer_param_ . batchsize ( ) , datum . channels ( ) , cropsize , cropsize ) ) ; <nl> } else { <nl> ( * top ) [ 0 ] - > Reshape ( <nl> - this - > layer_param_ . batchsize ( ) , bottom . channels ( ) , bottom . height ( ) , <nl> - bottom . width ( ) ) ; <nl> + this - > layer_param_ . batchsize ( ) , datum . channels ( ) , datum . height ( ) , <nl> + datum . width ( ) ) ; <nl> + prefetch_data_ . reset ( new Blob < Dtype > ( <nl> + this - > layer_param_ . batchsize ( ) , datum . channels ( ) , datum . height ( ) , <nl> + datum . width ( ) ) ) ; <nl> } <nl> LOG ( INFO ) < < " output data size : " < < ( * top ) [ 0 ] - > num ( ) < < " , " <nl> < < ( * top ) [ 0 ] - > channels ( ) < < " , " < < ( * top ) [ 0 ] - > height ( ) < < " , " <nl> < < ( * top ) [ 0 ] - > width ( ) ; <nl> - bottom_channels_ = bottom . channels ( ) ; <nl> - bottom_height_ = bottom . height ( ) ; <nl> - bottom_width_ = bottom . width ( ) ; <nl> - bottom_size_ = bottom . channels ( ) * bottom . height ( ) * bottom . width ( ) ; <nl> - CHECK_GT ( bottom_height_ , cropsize ) ; <nl> - CHECK_GT ( boottom_width_ , cropsize ) ; <nl> + / / label <nl> + ( * top ) [ 1 ] - > Reshape ( this - > layer_param_ . batchsize ( ) , 1 , 1 , 1 ) ; <nl> + prefetch_label_ . reset ( <nl> + new Blob < Dtype > ( this - > layer_param_ . batchsize ( ) , 1 , 1 , 1 ) ) ; <nl> + / / datum size <nl> + datum_channels_ = datum . channels ( ) ; <nl> + datum_height_ = datum . height ( ) ; <nl> + datum_width_ = datum . width ( ) ; <nl> + datum_size_ = datum . channels ( ) * datum . height ( ) * datum . width ( ) ; <nl> + CHECK_GT ( datum_height_ , cropsize ) ; <nl> + CHECK_GT ( datum_width_ , cropsize ) ; <nl> / / check if we want to have mean <nl> if ( this - > layer_param_ . has_meanfile ( ) ) { <nl> BlobProto blob_proto ; <nl> void InputLayer < Dtype > : : SetUp ( const vector < Blob < Dtype > * > & bottom , <nl> ReadProtoFromBinaryFile ( this - > layer_param_ . meanfile ( ) . c_str ( ) , & blob_proto ) ; <nl> data_mean_ . FromProto ( blob_proto ) ; <nl> CHECK_EQ ( data_mean_ . num ( ) , 1 ) ; <nl> - CHECK_EQ ( data_mean_ . channels ( ) , bottom_channels_ ) ; <nl> - CHECK_EQ ( data_mean_ . height ( ) , bottom_height_ ) ; <nl> - CHECK_EQ ( data_mean_ . width ( ) , boottom_width_ ) ; <nl> + CHECK_EQ ( data_mean_ . channels ( ) , datum_channels_ ) ; <nl> + CHECK_EQ ( data_mean_ . height ( ) , datum_height_ ) ; <nl> + CHECK_EQ ( data_mean_ . width ( ) , datum_width_ ) ; <nl> } else { <nl> - / / Intialize the data_mean with zeros <nl> - data_mean_ . Reshape ( 1 , bottom_channels_ , bottom_height_ , boottom_width_ ) ; <nl> - / / Or if there is a bias_filler use it to initialize the data_mean <nl> - if ( this - > layer_param_ . has_bias_filler ( ) ) { <nl> - shared_ptr < Filler < Dtype > > bias_filler ( <nl> - GetFiller < Dtype > ( this - > layer_param_ . bias_filler ( ) ) ) ; <nl> - bias_filler - > Fill ( & this - > data_mean_ ) ; <nl> - } <nl> + / / Simply initialize an all - empty mean . <nl> + data_mean_ . Reshape ( 1 , datum_channels_ , datum_height_ , datum_width_ ) ; <nl> } <nl> / / Now , start the prefetch thread . Before calling prefetch , we make two <nl> / / cpu_data calls so that the prefetch thread does not accidentally make <nl> void InputLayer < Dtype > : : SetUp ( const vector < Blob < Dtype > * > & bottom , <nl> prefetch_label_ - > mutable_cpu_data ( ) ; <nl> data_mean_ . cpu_data ( ) ; <nl> DLOG ( INFO ) < < " Initializing prefetch " ; <nl> - CHECK ( ! pthread_create ( & thread_ , NULL , DataLayerPrefetch < Dtype > , <nl> + CHECK ( ! pthread_create ( & thread_ , NULL , InputLayerPrefetch < Dtype > , <nl> reinterpret_cast < void * > ( this ) ) ) < < " Pthread execution failed . " ; <nl> DLOG ( INFO ) < < " Prefetch initialized . " ; <nl> } <nl> void InputLayer < Dtype > : : Forward_cpu ( const vector < Blob < Dtype > * > & bottom , <nl> memcpy ( ( * top ) [ 1 ] - > mutable_cpu_data ( ) , prefetch_label_ - > cpu_data ( ) , <nl> sizeof ( Dtype ) * prefetch_label_ - > count ( ) ) ; <nl> / / Start a new prefetch thread <nl> - CHECK ( ! pthread_create ( & thread_ , NULL , DataLayerPrefetch < Dtype > , <nl> + CHECK ( ! pthread_create ( & thread_ , NULL , InputLayerPrefetch < Dtype > , <nl> reinterpret_cast < void * > ( this ) ) ) < < " Pthread execution failed . " ; <nl> } <nl> <nl> void InputLayer < Dtype > : : Forward_gpu ( const vector < Blob < Dtype > * > & bottom , <nl> prefetch_label_ - > cpu_data ( ) , sizeof ( Dtype ) * prefetch_label_ - > count ( ) , <nl> cudaMemcpyHostToDevice ) ) ; <nl> / / Start a new prefetch thread <nl> - CHECK ( ! pthread_create ( & thread_ , NULL , DataLayerPrefetch < Dtype > , <nl> + CHECK ( ! pthread_create ( & thread_ , NULL , InputLayerPrefetch < Dtype > , <nl> reinterpret_cast < void * > ( this ) ) ) < < " Pthread execution failed . " ; <nl> } <nl> <nl> mmm a / src / caffe / proto / caffe . proto <nl> ppp b / src / caffe / proto / caffe . proto <nl> message LayerParameter { <nl> / / point would be set as rand_skip * rand ( 0 , 1 ) . Note that rand_skip should not <nl> / / be larger than the number of keys in the leveldb . <nl> optional uint32 rand_skip = 53 [ default = 0 ] ; <nl> + <nl> + optional bool shuffle_data = 61 [ default = true ] ; <nl> } <nl> <nl> message LayerConnection { <nl>
|
Fixed input_layer to pass tests , added cat image to data to perform the tests
|
BVLC/caffe
|
e8e3a1b27b5a2362387ec7efeff4d823caea437a
|
2014-02-17T18:32:36Z
|
mmm a / aten / src / ATen / native / cpu / UnaryOpsKernel . cpp <nl> ppp b / aten / src / ATen / native / cpu / UnaryOpsKernel . cpp <nl> void normal_fill ( Tensor & self , const scalar_t mean , const scalar_t std , Generato <nl> } <nl> } <nl> <nl> + std : : vector < int64_t > computeStrideForComplex ( IntArrayRef oldstride ) { <nl> + auto res = oldstride . vec ( ) ; <nl> + for ( size_t i = 0 ; i < res . size ( ) ; i + + ) { <nl> + res [ i ] = res [ i ] * 2 ; <nl> + } <nl> + res . emplace_back ( 1 ) ; <nl> + return res ; <nl> + } <nl> + <nl> + / / expects as input a complex tensor and returns back a float tensor <nl> + / / containing the complex values in the last two dimensions <nl> + Tensor view_complex_as_float ( const Tensor & self ) { <nl> + TORCH_INTERNAL_ASSERT ( self . is_complex ( ) ) ; <nl> + auto new_sizes = self . sizes ( ) . vec ( ) ; <nl> + / / last dimension will always have two elements containing the real and imag vals <nl> + new_sizes . emplace_back ( 2 ) ; <nl> + auto new_strides = computeStrideForComplex ( self . strides ( ) ) ; <nl> + if ( self . scalar_type ( ) = = at : : kComplexFloat ) { <nl> + float * data = reinterpret_cast < float * > ( self . data_ptr < std : : complex < float > > ( ) ) ; <nl> + return at : : from_blob ( data , new_sizes , new_strides , dtype ( at : : kFloat ) ) ; <nl> + } else { <nl> + double * data = reinterpret_cast < double * > ( self . data_ptr < std : : complex < double > > ( ) ) ; <nl> + return at : : from_blob ( data , new_sizes , new_strides , dtype ( at : : kDouble ) ) ; <nl> + } <nl> + } <nl> + <nl> void normal_kernel ( Tensor & self , double mean , double std , Generator * gen ) { <nl> + if ( self . is_complex ( ) ) { <nl> + / / note : float_tensor lives only as long as the self tensor lives <nl> + auto float_tensor = at : : native : : view_complex_as_float ( self ) ; <nl> + / / variance for normal distribution of the real and imaginary values <nl> + / / is half of the input variance <nl> + return normal_kernel ( float_tensor , mean , std / ( std : : sqrt ( 2 ) ) , gen ) ; <nl> + } <nl> auto size = self . numel ( ) ; <nl> if ( self . scalar_type ( ) = = ScalarType : : Float & & size > = 16 & & self . is_contiguous ( ) ) { <nl> # ifdef __AVX2__ <nl> mmm a / test / test_torch . py <nl> ppp b / test / test_torch . py <nl> def seed ( generator ) : <nl> self . assertTrue ( ( res1 > = 0 ) . all ( ) . item ( ) ) <nl> <nl> def test_randn ( self ) : <nl> - torch . manual_seed ( 123456 ) <nl> - res1 = torch . randn ( SIZE , SIZE ) <nl> - res2 = torch . Tensor ( ) <nl> - torch . manual_seed ( 123456 ) <nl> - torch . randn ( SIZE , SIZE , out = res2 ) <nl> - self . assertEqual ( res1 , res2 ) <nl> + def common_routine ( dtype ) : <nl> + torch . manual_seed ( 123456 ) <nl> + res1 = torch . randn ( SIZE , SIZE , dtype = dtype ) <nl> + res2 = torch . tensor ( [ ] , dtype = dtype ) <nl> + torch . manual_seed ( 123456 ) <nl> + torch . randn ( SIZE , SIZE , out = res2 ) <nl> + self . assertEqual ( res1 , res2 ) <nl> + <nl> + common_routine ( dtype = torch . float32 ) <nl> + common_routine ( dtype = torch . float64 ) <nl> + common_routine ( dtype = torch . complex64 ) <nl> + common_routine ( dtype = torch . complex128 ) <nl> <nl> def test_slice ( self ) : <nl> empty = torch . empty ( 0 , 4 ) <nl>
|
randn and normal_ for complex tensors ( )
|
pytorch/pytorch
|
fbc9c61c81a176ce5e571a41f79ca19a16aaf146
|
2020-03-03T20:46:01Z
|
mmm a / include / v8 . h <nl> ppp b / include / v8 . h <nl> class V8EXPORT Context { <nl> * Returns a persistent handle to the newly allocated context . This <nl> * persistent handle has to be disposed when the context is no <nl> * longer used so the context can be garbage collected . <nl> + * <nl> + * \ param extensions An optional extension configuration containing <nl> + * the extensions to be installed in the newly created context . <nl> + * <nl> + * \ param global_template An optional object template from which the <nl> + * global object for the newly created context will be created . <nl> + * <nl> + * \ param global_object An optional global object to be reused for <nl> + * the newly created context . This global object must have been <nl> + * created by a previous call to Context : : New with the same global <nl> + * template . The state of the global object will be completely reset <nl> + * and only object identify will remain . <nl> * / <nl> static Persistent < Context > New ( <nl> ExtensionConfiguration * extensions = NULL , <nl>
|
Add more documentation to Context : : New in the API header file .
|
v8/v8
|
218944fe6a95a97e66a60a2eb2c2c8f2a8f44876
|
2011-01-03T10:17:08Z
|
mmm a / src / arch / arch . hpp <nl> ppp b / src / arch / arch . hpp <nl> typedef io_config_t : : tcp_conn_t tcp_conn_t ; <nl> <nl> typedef io_config_t : : thread_message_t thread_message_t ; <nl> <nl> + # ifndef NDEBUG <nl> + inline void assert_good_thread_id ( int thread ) { <nl> + rassert ( thread > = 0 ) ; <nl> + rassert ( thread < thread_pool_t : : thread_pool - > n_threads ) ; <nl> + } <nl> + # else <nl> + # define assert_good_thread_id ( thread ) do { } while ( 0 ) <nl> + # endif <nl> + <nl> + <nl> inline int get_thread_id ( ) { <nl> return io_config_t : : get_thread_id ( ) ; <nl> } <nl> inline int get_num_threads ( ) { <nl> / / thread that we are already on , then it returns ' true ' ; otherwise , it will cause the other <nl> / / thread ' s event loop to call msg - > on_thread_switch ( ) . <nl> inline bool continue_on_thread ( int thread , thread_message_t * msg ) { <nl> + assert_good_thread_id ( thread ) ; <nl> return io_config_t : : continue_on_thread ( thread , msg ) ; <nl> } <nl> <nl> mmm a / src / arch / linux / coroutines . cc <nl> ppp b / src / arch / linux / coroutines . cc <nl> coro_t : : coro_t ( const boost : : function < void ( ) > & deed , int thread ) : <nl> notified_ ( false ) , <nl> waiting_ ( true ) <nl> { <nl> + assert_good_thread_id ( thread ) ; <nl> <nl> pm_active_coroutines + + ; <nl> <nl> void coro_t : : notify ( ) { <nl> } <nl> <nl> void coro_t : : move_to_thread ( int thread ) { / * class method * / <nl> + assert_good_thread_id ( thread ) ; <nl> if ( thread = = self ( ) - > current_thread_ ) { <nl> / / If we ' re trying to switch to the thread we ' re currently on , do nothing . <nl> return ; <nl> mmm a / src / utils . hpp <nl> ppp b / src / utils . hpp <nl> <nl> # include " utils2 . hpp " <nl> # include < string > <nl> <nl> + <nl> / / Precise time ( time + nanoseconds ) for logging , etc . <nl> struct precise_time_t : public tm { <nl> uint32_t ns ; / / nanoseconds since the start of the second <nl> struct on_thread_t : public home_thread_mixin_t { <nl> } ; <nl> <nl> struct thread_saver_t { <nl> - thread_saver_t ( ) : thread_id ( get_thread_id ( ) ) { } <nl> - thread_saver_t ( int thread_id ) : thread_id ( thread_id ) { } <nl> + thread_saver_t ( ) : thread_id ( get_thread_id ( ) ) { <nl> + assert_good_thread_id ( thread_id ) ; <nl> + } <nl> + thread_saver_t ( int _thread_id ) : thread_id ( _thread_id ) { <nl> + assert_good_thread_id ( thread_id ) ; <nl> + } <nl> ~ thread_saver_t ( ) { <nl> coro_t : : move_to_thread ( thread_id ) ; <nl> } <nl> mmm a / src / utils . tcc <nl> ppp b / src / utils . tcc <nl> struct thread_doer_t : <nl> state_go_home <nl> } state ; <nl> <nl> - thread_doer_t ( const callable_t & callable , int thread ) <nl> - : callable ( callable ) , thread ( thread ) , state ( state_go_to_core ) { } <nl> + thread_doer_t ( const callable_t & _callable , int _thread ) <nl> + : callable ( _callable ) , thread ( _thread ) , state ( state_go_to_core ) { <nl> + assert_good_thread_id ( thread ) ; <nl> + } <nl> <nl> void run ( ) { <nl> state = state_go_to_core ; <nl> struct thread_doer_t : <nl> <nl> template < class callable_t > <nl> void do_on_thread ( int thread , const callable_t & callable ) { <nl> + assert_good_thread_id ( thread ) ; <nl> thread_doer_t < callable_t > * fsm = new thread_doer_t < callable_t > ( callable , thread ) ; <nl> fsm - > run ( ) ; <nl> } <nl> struct later_doer_t : <nl> { <nl> callable_t callable ; <nl> <nl> - later_doer_t ( const callable_t & callable ) <nl> - : callable ( callable ) { <nl> + later_doer_t ( const callable_t & _callable ) <nl> + : callable ( _callable ) { <nl> call_later_on_this_thread ( this ) ; <nl> } <nl> <nl>
|
Added assert_good_thread_id because it seemed to be a problem , and now we get segfaults when we try to bring up a slave listening on a used port . So slave shutdown is somehow broken . Nevertheless if we bring it up on a different port we have replication generally working except that the slave is not seeing backfilling messages .
|
rethinkdb/rethinkdb
|
502e06ed6491ab47be668f40ee66545cc2eeaec3
|
2011-03-24T23:28:54Z
|
mmm a / include / grpc + + / server_builder . h <nl> ppp b / include / grpc + + / server_builder . h <nl> class ServerBuilder { <nl> <nl> struct SyncServerSettings { <nl> SyncServerSettings ( ) <nl> - : num_cqs ( 1 ) , min_pollers ( 1 ) , max_pollers ( 2 ) , cq_timeout_msec ( 10000 ) { } <nl> + : num_cqs ( GPR_MAX ( 1 , gpr_cpu_num_cores ( ) ) ) , <nl> + min_pollers ( 1 ) , <nl> + max_pollers ( 2 ) , <nl> + cq_timeout_msec ( 10000 ) { } <nl> <nl> / / / Number of server completion queues to create to listen to incoming RPCs . <nl> int num_cqs ; <nl> mmm a / src / core / lib / support / mpscq . cc <nl> ppp b / src / core / lib / support / mpscq . cc <nl> void gpr_mpscq_destroy ( gpr_mpscq * q ) { <nl> GPR_ASSERT ( q - > tail = = & q - > stub ) ; <nl> } <nl> <nl> - void gpr_mpscq_push ( gpr_mpscq * q , gpr_mpscq_node * n ) { <nl> + bool gpr_mpscq_push ( gpr_mpscq * q , gpr_mpscq_node * n ) { <nl> gpr_atm_no_barrier_store ( & n - > next , ( gpr_atm ) NULL ) ; <nl> gpr_mpscq_node * prev = <nl> ( gpr_mpscq_node * ) gpr_atm_full_xchg ( & q - > head , ( gpr_atm ) n ) ; <nl> gpr_atm_rel_store ( & prev - > next , ( gpr_atm ) n ) ; <nl> + return prev = = & q - > stub ; <nl> } <nl> <nl> gpr_mpscq_node * gpr_mpscq_pop ( gpr_mpscq * q ) { <nl> gpr_mpscq_node * gpr_mpscq_pop_and_check_end ( gpr_mpscq * q , bool * empty ) { <nl> * empty = false ; <nl> return NULL ; <nl> } <nl> + <nl> + void gpr_locked_mpscq_init ( gpr_locked_mpscq * q ) { <nl> + gpr_mpscq_init ( & q - > queue ) ; <nl> + gpr_mu_init ( & q - > mu ) ; <nl> + } <nl> + <nl> + void gpr_locked_mpscq_destroy ( gpr_locked_mpscq * q ) { <nl> + gpr_mpscq_destroy ( & q - > queue ) ; <nl> + gpr_mu_destroy ( & q - > mu ) ; <nl> + } <nl> + <nl> + bool gpr_locked_mpscq_push ( gpr_locked_mpscq * q , gpr_mpscq_node * n ) { <nl> + return gpr_mpscq_push ( & q - > queue , n ) ; <nl> + } <nl> + <nl> + gpr_mpscq_node * gpr_locked_mpscq_try_pop ( gpr_locked_mpscq * q ) { <nl> + if ( gpr_mu_trylock ( & q - > mu ) ) { <nl> + gpr_mpscq_node * n = gpr_mpscq_pop ( & q - > queue ) ; <nl> + gpr_mu_unlock ( & q - > mu ) ; <nl> + return n ; <nl> + } <nl> + return NULL ; <nl> + } <nl> + <nl> + gpr_mpscq_node * gpr_locked_mpscq_pop ( gpr_locked_mpscq * q ) { <nl> + gpr_mu_lock ( & q - > mu ) ; <nl> + bool empty = false ; <nl> + gpr_mpscq_node * n ; <nl> + do { <nl> + n = gpr_mpscq_pop_and_check_end ( & q - > queue , & empty ) ; <nl> + } while ( n = = NULL & & ! empty ) ; <nl> + gpr_mu_unlock ( & q - > mu ) ; <nl> + return n ; <nl> + } <nl> mmm a / src / core / lib / support / mpscq . h <nl> ppp b / src / core / lib / support / mpscq . h <nl> <nl> # define GRPC_CORE_LIB_SUPPORT_MPSCQ_H <nl> <nl> # include < grpc / support / atm . h > <nl> + # include < grpc / support / sync . h > <nl> # include < stdbool . h > <nl> # include < stddef . h > <nl> <nl> typedef struct gpr_mpscq { <nl> void gpr_mpscq_init ( gpr_mpscq * q ) ; <nl> void gpr_mpscq_destroy ( gpr_mpscq * q ) ; <nl> / / Push a node <nl> - void gpr_mpscq_push ( gpr_mpscq * q , gpr_mpscq_node * n ) ; <nl> + / / Thread safe - can be called from multiple threads concurrently <nl> + / / Returns true if this was possibly the first node ( may return true <nl> + / / sporadically , will not return false sporadically ) <nl> + bool gpr_mpscq_push ( gpr_mpscq * q , gpr_mpscq_node * n ) ; <nl> / / Pop a node ( returns NULL if no node is ready - which doesn ' t indicate that <nl> / / the queue is empty ! ! ) <nl> + / / Thread compatible - can only be called from one thread at a time <nl> gpr_mpscq_node * gpr_mpscq_pop ( gpr_mpscq * q ) ; <nl> / / Pop a node ; sets * empty to true if the queue is empty , or false if it is not <nl> gpr_mpscq_node * gpr_mpscq_pop_and_check_end ( gpr_mpscq * q , bool * empty ) ; <nl> <nl> + / / An mpscq with a lock : it ' s safe to pop from multiple threads , but doing <nl> + / / only one thread will succeed concurrently <nl> + typedef struct gpr_locked_mpscq { <nl> + gpr_mpscq queue ; <nl> + gpr_mu mu ; <nl> + } gpr_locked_mpscq ; <nl> + <nl> + void gpr_locked_mpscq_init ( gpr_locked_mpscq * q ) ; <nl> + void gpr_locked_mpscq_destroy ( gpr_locked_mpscq * q ) ; <nl> + / / Push a node <nl> + / / Thread safe - can be called from multiple threads concurrently <nl> + / / Returns true if this was possibly the first node ( may return true <nl> + / / sporadically , will not return false sporadically ) <nl> + bool gpr_locked_mpscq_push ( gpr_locked_mpscq * q , gpr_mpscq_node * n ) ; <nl> + <nl> + / / Pop a node ( returns NULL if no node is ready - which doesn ' t indicate that <nl> + / / the queue is empty ! ! ) <nl> + / / Thread safe - can be called from multiple threads concurrently <nl> + gpr_mpscq_node * gpr_locked_mpscq_try_pop ( gpr_locked_mpscq * q ) ; <nl> + <nl> + / / Pop a node . Returns NULL only if the queue was empty at some point after <nl> + / / calling this function <nl> + gpr_mpscq_node * gpr_locked_mpscq_pop ( gpr_locked_mpscq * q ) ; <nl> # ifdef __cplusplus <nl> } <nl> # endif <nl> mmm a / src / core / lib / surface / completion_queue . cc <nl> ppp b / src / core / lib / surface / completion_queue . cc <nl> int grpc_completion_queue_thread_local_cache_flush ( grpc_completion_queue * cq , <nl> ( grpc_completion_queue * ) gpr_tls_get ( & g_cached_cq ) = = cq ) { <nl> * tag = storage - > tag ; <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> - storage - > done ( & exec_ctx , storage - > done_arg , storage ) ; <nl> * ok = ( storage - > next & ( uintptr_t ) ( 1 ) ) = = 1 ; <nl> + storage - > done ( & exec_ctx , storage - > done_arg , storage ) ; <nl> ret = 1 ; <nl> cq_next_data * cqd = ( cq_next_data * ) DATA_FROM_CQ ( cq ) ; <nl> if ( gpr_atm_full_fetch_add ( & cqd - > pending_events , - 1 ) = = 1 ) { <nl> mmm a / src / core / lib / surface / server . cc <nl> ppp b / src / core / lib / surface / server . cc <nl> <nl> # include " src / core / lib / iomgr / executor . h " <nl> # include " src / core / lib / iomgr / iomgr . h " <nl> # include " src / core / lib / slice / slice_internal . h " <nl> - # include " src / core / lib / support / stack_lockfree . h " <nl> + # include " src / core / lib / support / mpscq . h " <nl> + # include " src / core / lib / support / spinlock . h " <nl> # include " src / core / lib / support / string . h " <nl> # include " src / core / lib / surface / api_trace . h " <nl> # include " src / core / lib / surface / call . h " <nl> grpc_tracer_flag grpc_server_channel_trace = <nl> GRPC_TRACER_INITIALIZER ( false , " server_channel " ) ; <nl> <nl> typedef struct requested_call { <nl> + gpr_mpscq_node request_link ; / * must be first * / <nl> requested_call_type type ; <nl> size_t cq_idx ; <nl> void * tag ; <nl> typedef struct request_matcher request_matcher ; <nl> struct call_data { <nl> grpc_call * call ; <nl> <nl> - / * * protects state * / <nl> - gpr_mu mu_state ; <nl> - / * * the current state of a call - see call_state * / <nl> - call_state state ; <nl> + gpr_atm state ; <nl> <nl> bool path_set ; <nl> bool host_set ; <nl> struct request_matcher { <nl> grpc_server * server ; <nl> call_data * pending_head ; <nl> call_data * pending_tail ; <nl> - gpr_stack_lockfree * * requests_per_cq ; <nl> + gpr_locked_mpscq * requests_per_cq ; <nl> } ; <nl> <nl> struct registered_method { <nl> struct grpc_server { <nl> registered_method * registered_methods ; <nl> / * * one request matcher for unregistered methods * / <nl> request_matcher unregistered_request_matcher ; <nl> - / * * free list of available requested_calls_per_cq indices * / <nl> - gpr_stack_lockfree * * request_freelist_per_cq ; <nl> - / * * requested call backing data * / <nl> - requested_call * * requested_calls_per_cq ; <nl> - int max_requested_calls_per_cq ; <nl> <nl> gpr_atm shutdown_flag ; <nl> uint8_t shutdown_published ; <nl> static void channel_broadcaster_shutdown ( grpc_exec_ctx * exec_ctx , <nl> * request_matcher <nl> * / <nl> <nl> - static void request_matcher_init ( request_matcher * rm , size_t entries , <nl> - grpc_server * server ) { <nl> + static void request_matcher_init ( request_matcher * rm , grpc_server * server ) { <nl> memset ( rm , 0 , sizeof ( * rm ) ) ; <nl> rm - > server = server ; <nl> - rm - > requests_per_cq = ( gpr_stack_lockfree * * ) gpr_malloc ( <nl> + rm - > requests_per_cq = ( gpr_locked_mpscq * ) gpr_malloc ( <nl> sizeof ( * rm - > requests_per_cq ) * server - > cq_count ) ; <nl> for ( size_t i = 0 ; i < server - > cq_count ; i + + ) { <nl> - rm - > requests_per_cq [ i ] = gpr_stack_lockfree_create ( entries ) ; <nl> + gpr_locked_mpscq_init ( & rm - > requests_per_cq [ i ] ) ; <nl> } <nl> } <nl> <nl> static void request_matcher_destroy ( request_matcher * rm ) { <nl> for ( size_t i = 0 ; i < rm - > server - > cq_count ; i + + ) { <nl> - GPR_ASSERT ( gpr_stack_lockfree_pop ( rm - > requests_per_cq [ i ] ) = = - 1 ) ; <nl> - gpr_stack_lockfree_destroy ( rm - > requests_per_cq [ i ] ) ; <nl> + GPR_ASSERT ( gpr_locked_mpscq_pop ( & rm - > requests_per_cq [ i ] ) = = NULL ) ; <nl> + gpr_locked_mpscq_destroy ( & rm - > requests_per_cq [ i ] ) ; <nl> } <nl> gpr_free ( rm - > requests_per_cq ) ; <nl> } <nl> static void request_matcher_zombify_all_pending_calls ( grpc_exec_ctx * exec_ctx , <nl> while ( rm - > pending_head ) { <nl> call_data * calld = rm - > pending_head ; <nl> rm - > pending_head = calld - > pending_next ; <nl> - gpr_mu_lock ( & calld - > mu_state ) ; <nl> - calld - > state = ZOMBIED ; <nl> - gpr_mu_unlock ( & calld - > mu_state ) ; <nl> + gpr_atm_no_barrier_store ( & calld - > state , ZOMBIED ) ; <nl> GRPC_CLOSURE_INIT ( <nl> & calld - > kill_zombie_closure , kill_zombie , <nl> grpc_call_stack_element ( grpc_call_get_call_stack ( calld - > call ) , 0 ) , <nl> static void request_matcher_kill_requests ( grpc_exec_ctx * exec_ctx , <nl> grpc_server * server , <nl> request_matcher * rm , <nl> grpc_error * error ) { <nl> - int request_id ; <nl> + requested_call * rc ; <nl> for ( size_t i = 0 ; i < server - > cq_count ; i + + ) { <nl> - while ( ( request_id = gpr_stack_lockfree_pop ( rm - > requests_per_cq [ i ] ) ) ! = <nl> - - 1 ) { <nl> - fail_call ( exec_ctx , server , i , <nl> - & server - > requested_calls_per_cq [ i ] [ request_id ] , <nl> - GRPC_ERROR_REF ( error ) ) ; <nl> + / * Here we know : <nl> + 1 . no requests are being added ( since the server is shut down ) <nl> + 2 . no other threads are pulling ( since the shut down process is single <nl> + threaded ) <nl> + So , we can ignore the queue lock and just pop , with the guarantee that a <nl> + NULL returned here truly means that the queue is empty * / <nl> + while ( ( rc = ( requested_call * ) gpr_mpscq_pop ( <nl> + & rm - > requests_per_cq [ i ] . queue ) ) ! = NULL ) { <nl> + fail_call ( exec_ctx , server , i , rc , GRPC_ERROR_REF ( error ) ) ; <nl> } <nl> } <nl> GRPC_ERROR_UNREF ( error ) ; <nl> static void server_delete ( grpc_exec_ctx * exec_ctx , grpc_server * server ) { <nl> } <nl> for ( i = 0 ; i < server - > cq_count ; i + + ) { <nl> GRPC_CQ_INTERNAL_UNREF ( exec_ctx , server - > cqs [ i ] , " server " ) ; <nl> - if ( server - > started ) { <nl> - gpr_stack_lockfree_destroy ( server - > request_freelist_per_cq [ i ] ) ; <nl> - gpr_free ( server - > requested_calls_per_cq [ i ] ) ; <nl> - } <nl> } <nl> - gpr_free ( server - > request_freelist_per_cq ) ; <nl> - gpr_free ( server - > requested_calls_per_cq ) ; <nl> gpr_free ( server - > cqs ) ; <nl> gpr_free ( server - > pollsets ) ; <nl> gpr_free ( server - > shutdown_tags ) ; <nl> static void destroy_channel ( grpc_exec_ctx * exec_ctx , channel_data * chand , <nl> <nl> static void done_request_event ( grpc_exec_ctx * exec_ctx , void * req , <nl> grpc_cq_completion * c ) { <nl> - requested_call * rc = ( requested_call * ) req ; <nl> - grpc_server * server = rc - > server ; <nl> - <nl> - if ( rc > = server - > requested_calls_per_cq [ rc - > cq_idx ] & & <nl> - rc < server - > requested_calls_per_cq [ rc - > cq_idx ] + <nl> - server - > max_requested_calls_per_cq ) { <nl> - GPR_ASSERT ( rc - server - > requested_calls_per_cq [ rc - > cq_idx ] < = INT_MAX ) ; <nl> - gpr_stack_lockfree_push ( <nl> - server - > request_freelist_per_cq [ rc - > cq_idx ] , <nl> - ( int ) ( rc - server - > requested_calls_per_cq [ rc - > cq_idx ] ) ) ; <nl> - } else { <nl> - gpr_free ( req ) ; <nl> - } <nl> - <nl> - server_unref ( exec_ctx , server ) ; <nl> + gpr_free ( req ) ; <nl> } <nl> <nl> static void publish_call ( grpc_exec_ctx * exec_ctx , grpc_server * server , <nl> static void publish_call ( grpc_exec_ctx * exec_ctx , grpc_server * server , <nl> GPR_UNREACHABLE_CODE ( return ) ; <nl> } <nl> <nl> - grpc_call_element * elem = <nl> - grpc_call_stack_element ( grpc_call_get_call_stack ( call ) , 0 ) ; <nl> - channel_data * chand = ( channel_data * ) elem - > channel_data ; <nl> - server_ref ( chand - > server ) ; <nl> grpc_cq_end_op ( exec_ctx , calld - > cq_new , rc - > tag , GRPC_ERROR_NONE , <nl> done_request_event , rc , & rc - > completion ) ; <nl> } <nl> static void publish_new_rpc ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_server * server = rm - > server ; <nl> <nl> if ( error ! = GRPC_ERROR_NONE | | gpr_atm_acq_load ( & server - > shutdown_flag ) ) { <nl> - gpr_mu_lock ( & calld - > mu_state ) ; <nl> - calld - > state = ZOMBIED ; <nl> - gpr_mu_unlock ( & calld - > mu_state ) ; <nl> + gpr_atm_no_barrier_store ( & calld - > state , ZOMBIED ) ; <nl> GRPC_CLOSURE_INIT ( <nl> & calld - > kill_zombie_closure , kill_zombie , <nl> grpc_call_stack_element ( grpc_call_get_call_stack ( calld - > call ) , 0 ) , <nl> static void publish_new_rpc ( grpc_exec_ctx * exec_ctx , void * arg , <nl> <nl> for ( size_t i = 0 ; i < server - > cq_count ; i + + ) { <nl> size_t cq_idx = ( chand - > cq_idx + i ) % server - > cq_count ; <nl> - int request_id = gpr_stack_lockfree_pop ( rm - > requests_per_cq [ cq_idx ] ) ; <nl> - if ( request_id = = - 1 ) { <nl> + requested_call * rc = <nl> + ( requested_call * ) gpr_locked_mpscq_try_pop ( & rm - > requests_per_cq [ cq_idx ] ) ; <nl> + if ( rc = = NULL ) { <nl> continue ; <nl> } else { <nl> GRPC_STATS_INC_SERVER_CQS_CHECKED ( exec_ctx , i ) ; <nl> - gpr_mu_lock ( & calld - > mu_state ) ; <nl> - calld - > state = ACTIVATED ; <nl> - gpr_mu_unlock ( & calld - > mu_state ) ; <nl> - publish_call ( exec_ctx , server , calld , cq_idx , <nl> - & server - > requested_calls_per_cq [ cq_idx ] [ request_id ] ) ; <nl> + gpr_atm_no_barrier_store ( & calld - > state , ACTIVATED ) ; <nl> + publish_call ( exec_ctx , server , calld , cq_idx , rc ) ; <nl> return ; / * early out * / <nl> } <nl> } <nl> static void publish_new_rpc ( grpc_exec_ctx * exec_ctx , void * arg , <nl> / * no cq to take the request found : queue it on the slow list * / <nl> GRPC_STATS_INC_SERVER_SLOWPATH_REQUESTS_QUEUED ( exec_ctx ) ; <nl> gpr_mu_lock ( & server - > mu_call ) ; <nl> - gpr_mu_lock ( & calld - > mu_state ) ; <nl> - calld - > state = PENDING ; <nl> - gpr_mu_unlock ( & calld - > mu_state ) ; <nl> + <nl> + / / We need to ensure that all the queues are empty . We do this under <nl> + / / the server mu_call lock to ensure that if something is added to <nl> + / / an empty request queue , it will block until the call is actually <nl> + / / added to the pending list . <nl> + for ( size_t i = 0 ; i < server - > cq_count ; i + + ) { <nl> + size_t cq_idx = ( chand - > cq_idx + i ) % server - > cq_count ; <nl> + requested_call * rc = <nl> + ( requested_call * ) gpr_locked_mpscq_pop ( & rm - > requests_per_cq [ cq_idx ] ) ; <nl> + if ( rc = = NULL ) { <nl> + continue ; <nl> + } else { <nl> + gpr_mu_unlock ( & server - > mu_call ) ; <nl> + GRPC_STATS_INC_SERVER_CQS_CHECKED ( exec_ctx , i + server - > cq_count ) ; <nl> + gpr_atm_no_barrier_store ( & calld - > state , ACTIVATED ) ; <nl> + publish_call ( exec_ctx , server , calld , cq_idx , rc ) ; <nl> + return ; / * early out * / <nl> + } <nl> + } <nl> + <nl> + gpr_atm_no_barrier_store ( & calld - > state , PENDING ) ; <nl> if ( rm - > pending_head = = NULL ) { <nl> rm - > pending_tail = rm - > pending_head = calld ; <nl> } else { <nl> static void finish_start_new_rpc ( <nl> call_data * calld = ( call_data * ) elem - > call_data ; <nl> <nl> if ( gpr_atm_acq_load ( & server - > shutdown_flag ) ) { <nl> - gpr_mu_lock ( & calld - > mu_state ) ; <nl> - calld - > state = ZOMBIED ; <nl> - gpr_mu_unlock ( & calld - > mu_state ) ; <nl> + gpr_atm_no_barrier_store ( & calld - > state , ZOMBIED ) ; <nl> GRPC_CLOSURE_INIT ( & calld - > kill_zombie_closure , kill_zombie , elem , <nl> grpc_schedule_on_exec_ctx ) ; <nl> GRPC_CLOSURE_SCHED ( exec_ctx , & calld - > kill_zombie_closure , GRPC_ERROR_NONE ) ; <nl> static void got_initial_metadata ( grpc_exec_ctx * exec_ctx , void * ptr , <nl> if ( error = = GRPC_ERROR_NONE ) { <nl> start_new_rpc ( exec_ctx , elem ) ; <nl> } else { <nl> - gpr_mu_lock ( & calld - > mu_state ) ; <nl> - if ( calld - > state = = NOT_STARTED ) { <nl> - calld - > state = ZOMBIED ; <nl> - gpr_mu_unlock ( & calld - > mu_state ) ; <nl> + if ( gpr_atm_full_cas ( & calld - > state , NOT_STARTED , ZOMBIED ) ) { <nl> GRPC_CLOSURE_INIT ( & calld - > kill_zombie_closure , kill_zombie , elem , <nl> grpc_schedule_on_exec_ctx ) ; <nl> GRPC_CLOSURE_SCHED ( exec_ctx , & calld - > kill_zombie_closure , <nl> GRPC_ERROR_NONE ) ; <nl> - } else if ( calld - > state = = PENDING ) { <nl> - calld - > state = ZOMBIED ; <nl> - gpr_mu_unlock ( & calld - > mu_state ) ; <nl> + } else if ( gpr_atm_full_cas ( & calld - > state , PENDING , ZOMBIED ) ) { <nl> / * zombied call will be destroyed when it ' s removed from the pending <nl> queue . . . later * / <nl> - } else { <nl> - gpr_mu_unlock ( & calld - > mu_state ) ; <nl> } <nl> } <nl> } <nl> static grpc_error * init_call_elem ( grpc_exec_ctx * exec_ctx , <nl> memset ( calld , 0 , sizeof ( call_data ) ) ; <nl> calld - > deadline = GRPC_MILLIS_INF_FUTURE ; <nl> calld - > call = grpc_call_from_top_element ( elem ) ; <nl> - gpr_mu_init ( & calld - > mu_state ) ; <nl> <nl> GRPC_CLOSURE_INIT ( & calld - > server_on_recv_initial_metadata , <nl> server_on_recv_initial_metadata , elem , <nl> static void destroy_call_elem ( grpc_exec_ctx * exec_ctx , grpc_call_element * elem , <nl> grpc_metadata_array_destroy ( & calld - > initial_metadata ) ; <nl> grpc_byte_buffer_destroy ( calld - > payload ) ; <nl> <nl> - gpr_mu_destroy ( & calld - > mu_state ) ; <nl> - <nl> server_unref ( exec_ctx , chand - > server ) ; <nl> } <nl> <nl> grpc_server * grpc_server_create ( const grpc_channel_args * args , void * reserved ) { <nl> server - > root_channel_data . next = server - > root_channel_data . prev = <nl> & server - > root_channel_data ; <nl> <nl> - / * TODO ( ctiller ) : expose a channel_arg for this * / <nl> - server - > max_requested_calls_per_cq = 32768 ; <nl> server - > channel_args = grpc_channel_args_copy ( args ) ; <nl> <nl> return server ; <nl> void grpc_server_start ( grpc_server * server ) { <nl> server - > pollset_count = 0 ; <nl> server - > pollsets = <nl> ( grpc_pollset * * ) gpr_malloc ( sizeof ( grpc_pollset * ) * server - > cq_count ) ; <nl> - server - > request_freelist_per_cq = ( gpr_stack_lockfree * * ) gpr_malloc ( <nl> - sizeof ( * server - > request_freelist_per_cq ) * server - > cq_count ) ; <nl> - server - > requested_calls_per_cq = ( requested_call * * ) gpr_malloc ( <nl> - sizeof ( * server - > requested_calls_per_cq ) * server - > cq_count ) ; <nl> for ( i = 0 ; i < server - > cq_count ; i + + ) { <nl> if ( grpc_cq_can_listen ( server - > cqs [ i ] ) ) { <nl> server - > pollsets [ server - > pollset_count + + ] = <nl> grpc_cq_pollset ( server - > cqs [ i ] ) ; <nl> } <nl> - server - > request_freelist_per_cq [ i ] = <nl> - gpr_stack_lockfree_create ( ( size_t ) server - > max_requested_calls_per_cq ) ; <nl> - for ( int j = 0 ; j < server - > max_requested_calls_per_cq ; j + + ) { <nl> - gpr_stack_lockfree_push ( server - > request_freelist_per_cq [ i ] , j ) ; <nl> - } <nl> - server - > requested_calls_per_cq [ i ] = <nl> - ( requested_call * ) gpr_malloc ( ( size_t ) server - > max_requested_calls_per_cq * <nl> - sizeof ( * server - > requested_calls_per_cq [ i ] ) ) ; <nl> } <nl> - request_matcher_init ( & server - > unregistered_request_matcher , <nl> - ( size_t ) server - > max_requested_calls_per_cq , server ) ; <nl> + request_matcher_init ( & server - > unregistered_request_matcher , server ) ; <nl> for ( registered_method * rm = server - > registered_methods ; rm ; rm = rm - > next ) { <nl> - request_matcher_init ( & rm - > matcher , <nl> - ( size_t ) server - > max_requested_calls_per_cq , server ) ; <nl> + request_matcher_init ( & rm - > matcher , server ) ; <nl> } <nl> <nl> server_ref ( server ) ; <nl> static grpc_call_error queue_call_request ( grpc_exec_ctx * exec_ctx , <nl> requested_call * rc ) { <nl> call_data * calld = NULL ; <nl> request_matcher * rm = NULL ; <nl> - int request_id ; <nl> if ( gpr_atm_acq_load ( & server - > shutdown_flag ) ) { <nl> fail_call ( exec_ctx , server , cq_idx , rc , <nl> GRPC_ERROR_CREATE_FROM_STATIC_STRING ( " Server Shutdown " ) ) ; <nl> return GRPC_CALL_OK ; <nl> } <nl> - request_id = gpr_stack_lockfree_pop ( server - > request_freelist_per_cq [ cq_idx ] ) ; <nl> - if ( request_id = = - 1 ) { <nl> - / * out of request ids : just fail this one * / <nl> - fail_call ( exec_ctx , server , cq_idx , rc , <nl> - grpc_error_set_int ( <nl> - GRPC_ERROR_CREATE_FROM_STATIC_STRING ( " Out of request ids " ) , <nl> - GRPC_ERROR_INT_LIMIT , server - > max_requested_calls_per_cq ) ) ; <nl> - return GRPC_CALL_OK ; <nl> - } <nl> switch ( rc - > type ) { <nl> case BATCH_CALL : <nl> rm = & server - > unregistered_request_matcher ; <nl> static grpc_call_error queue_call_request ( grpc_exec_ctx * exec_ctx , <nl> rm = & rc - > data . registered . method - > matcher ; <nl> break ; <nl> } <nl> - server - > requested_calls_per_cq [ cq_idx ] [ request_id ] = * rc ; <nl> - gpr_free ( rc ) ; <nl> - if ( gpr_stack_lockfree_push ( rm - > requests_per_cq [ cq_idx ] , request_id ) ) { <nl> + if ( gpr_locked_mpscq_push ( & rm - > requests_per_cq [ cq_idx ] , & rc - > request_link ) ) { <nl> / * this was the first queued request : we need to lock and start <nl> matching calls * / <nl> gpr_mu_lock ( & server - > mu_call ) ; <nl> while ( ( calld = rm - > pending_head ) ! = NULL ) { <nl> - request_id = gpr_stack_lockfree_pop ( rm - > requests_per_cq [ cq_idx ] ) ; <nl> - if ( request_id = = - 1 ) break ; <nl> + rc = ( requested_call * ) gpr_locked_mpscq_pop ( & rm - > requests_per_cq [ cq_idx ] ) ; <nl> + if ( rc = = NULL ) break ; <nl> rm - > pending_head = calld - > pending_next ; <nl> gpr_mu_unlock ( & server - > mu_call ) ; <nl> - gpr_mu_lock ( & calld - > mu_state ) ; <nl> - if ( calld - > state = = ZOMBIED ) { <nl> - gpr_mu_unlock ( & calld - > mu_state ) ; <nl> + if ( ! gpr_atm_full_cas ( & calld - > state , PENDING , ACTIVATED ) ) { <nl> + / / Zombied Call <nl> GRPC_CLOSURE_INIT ( <nl> & calld - > kill_zombie_closure , kill_zombie , <nl> grpc_call_stack_element ( grpc_call_get_call_stack ( calld - > call ) , 0 ) , <nl> static grpc_call_error queue_call_request ( grpc_exec_ctx * exec_ctx , <nl> GRPC_CLOSURE_SCHED ( exec_ctx , & calld - > kill_zombie_closure , <nl> GRPC_ERROR_NONE ) ; <nl> } else { <nl> - GPR_ASSERT ( calld - > state = = PENDING ) ; <nl> - calld - > state = ACTIVATED ; <nl> - gpr_mu_unlock ( & calld - > mu_state ) ; <nl> - publish_call ( exec_ctx , server , calld , cq_idx , <nl> - & server - > requested_calls_per_cq [ cq_idx ] [ request_id ] ) ; <nl> + publish_call ( exec_ctx , server , calld , cq_idx , rc ) ; <nl> } <nl> gpr_mu_lock ( & server - > mu_call ) ; <nl> } <nl> static void fail_call ( grpc_exec_ctx * exec_ctx , grpc_server * server , <nl> rc - > initial_metadata - > count = 0 ; <nl> GPR_ASSERT ( error ! = GRPC_ERROR_NONE ) ; <nl> <nl> - server_ref ( server ) ; <nl> grpc_cq_end_op ( exec_ctx , server - > cqs [ cq_idx ] , rc - > tag , error , <nl> done_request_event , rc , & rc - > completion ) ; <nl> } <nl>
|
Merge pull request from kpayson64 / attempt_2
|
grpc/grpc
|
c03867ff224a98dab5a93b3ba70b95c46f05a440
|
2017-11-07T21:32:41Z
|
mmm a / stdlib / public / core / Optional . swift <nl> ppp b / stdlib / public / core / Optional . swift <nl> public func = = < T : Equatable > ( lhs : T ? , rhs : T ? ) - > Bool { <nl> / / / Returns a Boolean value indicating whether two optional instances are not <nl> / / / equal . <nl> / / / <nl> - / / / Use this not - equal - to operator ( ` = = ` ) to compare any two optional instances <nl> + / / / Use this not - equal - to operator ( ` ! = ` ) to compare any two optional instances <nl> / / / of a type that conforms to the ` Equatable ` protocol . The comparison <nl> / / / returns ` true ` if only one of the arguments is ` nil ` or if the two <nl> / / / arguments wrap values that are not equal . The comparison returns ` false ` <nl>
|
[ stdlib ] Fix incorrect operator name
|
apple/swift
|
7ca1c4b2fe4e6726c1930528ac4642f4cf64fa08
|
2016-11-11T18:51:24Z
|
mmm a / tensorflow / lite / kernels / internal / common . h <nl> ppp b / tensorflow / lite / kernels / internal / common . h <nl> inline void gen_lut ( const std : : function < double ( double ) > & func , double min , <nl> } <nl> <nl> / / int16 func table lookup , e . g . , lookup exp ( ) and 1 / ( 1 + x ) used in softmax <nl> - static int16_t generic_int16_table_lookup ( int16_t value , const int16_t * lut ) { <nl> + inline int16_t generic_int16_table_lookup ( int16_t value , const int16_t * lut ) { <nl> / / 512 base value , lut [ 513 ] only for calculate slope <nl> uint16_t index = static_cast < uint16_t > ( 256 + ( value > > 7 ) ) ; <nl> assert ( index < 512 & & " LUT index out of range . " ) ; <nl>
|
Mark lookup method as inline rather than static
|
tensorflow/tensorflow
|
656aa0758b5629dfe5a61a4c4babe98b14bfa61d
|
2020-04-17T22:35:07Z
|
new file mode 100644 <nl> index 000000000000 . . 87f852bbf164 <nl> mmm / dev / null <nl> ppp b / buildscripts / resmokeconfig / suites / initial_sync_fuzzer . yml <nl> <nl> + test_kind : js_test <nl> + <nl> + selector : <nl> + roots : <nl> + - jstestfuzz / out / * . js <nl> + <nl> + executor : <nl> + archive : <nl> + tests : true <nl> + config : <nl> + shell_options : <nl> + nodb : ' ' <nl> + readMode : commands <nl> + global_vars : <nl> + TestData : <nl> + logComponentVerbosity : <nl> + replication : <nl> + initialSync : 4 <nl> + setParameters : <nl> + numInitialSyncAttempts : 10000000 <nl> mmm a / etc / evergreen . yml <nl> ppp b / etc / evergreen . yml <nl> tasks : <nl> jepsen_test_name : read - concern - majority <nl> jepsen_write_concern : - - write - concern w1 <nl> <nl> + # # initial sync generational fuzzer # # <nl> + - < < : * jstestfuzz_template <nl> + name : initial_sync_fuzzer_gen <nl> + commands : <nl> + - func : " generate fuzzer tasks " <nl> + vars : <nl> + < < : * jstestfuzz_config_vars <nl> + num_files : 10 <nl> + num_tasks : 5 <nl> + npm_command : initsync - fuzzer <nl> + resmoke_args : - - suites = initial_sync_fuzzer <nl> + name : initial_sync_fuzzer <nl> + <nl> # # Standalone generational fuzzer for aggregation pipelines # # <nl> - < < : * jstestfuzz_template <nl> name : aggregation_multiversion_fuzzer_gen <nl> buildvariants : <nl> - name : disk_wiredtiger <nl> - name : failpoints <nl> - name : free_monitoring <nl> + - name : initial_sync_fuzzer_gen <nl> - name : integration_tests_standalone <nl> distros : <nl> - windows - 64 - vs2017 - compile <nl> buildvariants : <nl> - name : gle_auth_basics_passthrough <nl> - name : gle_auth_basics_passthrough_write_cmd <nl> - name : gle_auth_write_cmd <nl> + - name : initial_sync_fuzzer_gen <nl> - name : jsCore <nl> - name : jsCore_compatibility <nl> - name : jsCore_decimal <nl> buildvariants : <nl> - name : gle_auth_basics_passthrough_write_cmd <nl> - name : gle_auth_write_cmd <nl> - name : idl_tests <nl> + - name : initial_sync_fuzzer_gen <nl> - name : integration_tests_replset <nl> distros : <nl> - rhel62 - large <nl> buildvariants : <nl> - name : gle_auth_basics_passthrough <nl> - name : gle_auth_basics_passthrough_write_cmd <nl> - name : gle_auth_write_cmd <nl> + - name : initial_sync_fuzzer_gen <nl> - name : integration_tests_replset <nl> distros : <nl> - rhel62 - large <nl> buildvariants : <nl> - name : gle_auth_basics_passthrough <nl> - name : gle_auth_basics_passthrough_write_cmd <nl> - name : gle_auth_write_cmd <nl> + - name : initial_sync_fuzzer_gen <nl> - name : integration_tests_replset <nl> - name : integration_tests_sharded <nl> - name : integration_tests_standalone <nl> buildvariants : <nl> - name : gle_auth_basics_passthrough <nl> - name : gle_auth_basics_passthrough_write_cmd <nl> - name : gle_auth_write_cmd <nl> + - name : initial_sync_fuzzer_gen <nl> - name : integration_tests_replset <nl> - name : integration_tests_sharded <nl> - name : jsCore <nl> buildvariants : <nl> - name : gle_auth_basics_passthrough <nl> - name : gle_auth_basics_passthrough_write_cmd <nl> - name : gle_auth_write_cmd <nl> + - name : initial_sync_fuzzer_gen <nl> - name : integration_tests_replset <nl> - name : integration_tests_sharded <nl> - name : integration_tests_standalone <nl> mmm a / jstests / replsets / libs / initial_sync_test . js <nl> ppp b / jstests / replsets / libs / initial_sync_test . js <nl> function InitialSyncTest ( name = " InitialSyncTest " , replSet , timeout ) { <nl> secondary , <nl> { <nl> startClean : true , <nl> - setParameter : <nl> - { ' failpoint . initialSyncFuzzerSynchronizationPoint1 ' : tojson ( { mode : ' alwaysOn ' } ) } <nl> + setParameter : { <nl> + ' failpoint . initialSyncFuzzerSynchronizationPoint1 ' : tojson ( { mode : ' alwaysOn ' } ) , <nl> + ' logComponentVerbosity ' : tojsononeline ( TestData . logComponentVerbosity ) , <nl> + } <nl> } , <nl> true ) ; <nl> } <nl>
|
SERVER - 39899 Enable the initial sync fuzzer in Evergreen
|
mongodb/mongo
|
6b8b02e8d72c055c6f686a781e53cde9384461b3
|
2019-03-27T20:01:38Z
|
mmm a / src / builtins / builtins - array . cc <nl> ppp b / src / builtins / builtins - array . cc <nl> void Builtins : : Generate_ArrayIsArray ( CodeStubAssembler * assembler ) { <nl> Label call_runtime ( assembler ) , return_true ( assembler ) , <nl> return_false ( assembler ) ; <nl> <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( object ) , & return_false ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( object ) , & return_false ) ; <nl> Node * instance_type = assembler - > LoadInstanceType ( object ) ; <nl> <nl> assembler - > GotoIf ( assembler - > Word32Equal ( <nl> void Builtins : : Generate_ArrayIncludes ( CodeStubAssembler * assembler ) { <nl> { <nl> / / Handle case where JSArray length is not an Smi in the runtime <nl> Node * len = assembler - > LoadObjectField ( array , JSArray : : kLengthOffset ) ; <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( len ) , & call_runtime ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( len ) , & call_runtime ) ; <nl> <nl> len_var . Bind ( assembler - > SmiToWord ( len ) ) ; <nl> assembler - > Branch ( assembler - > WordEqual ( len_var . value ( ) , intptr_zero ) , <nl> void Builtins : : Generate_ArrayIncludes ( CodeStubAssembler * assembler ) { <nl> init_k_zero ( assembler ) , init_k_n ( assembler ) ; <nl> Node * tagged_n = assembler - > ToInteger ( context , start_from ) ; <nl> <nl> - assembler - > Branch ( assembler - > WordIsSmi ( tagged_n ) , & init_k_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( tagged_n ) , & init_k_smi , <nl> & init_k_heap_num ) ; <nl> <nl> assembler - > Bind ( & init_k_smi ) ; <nl> void Builtins : : Generate_ArrayIncludes ( CodeStubAssembler * assembler ) { <nl> undef_loop ( assembler , & index_var ) , not_smi ( assembler ) , <nl> not_heap_num ( assembler ) ; <nl> <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( search_element ) , & not_smi ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( search_element ) , & not_smi ) ; <nl> search_num . Bind ( assembler - > SmiToFloat64 ( search_element ) ) ; <nl> assembler - > Goto ( & heap_num_loop ) ; <nl> <nl> void Builtins : : Generate_ArrayIncludes ( CodeStubAssembler * assembler ) { <nl> Node * element_k = assembler - > LoadFixedArrayElement ( <nl> elements , index_var . value ( ) , 0 , <nl> CodeStubAssembler : : INTPTR_PARAMETERS ) ; <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( element_k ) , & not_smi ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( element_k ) , & not_smi ) ; <nl> assembler - > Branch ( <nl> assembler - > Float64Equal ( search_num . value ( ) , <nl> assembler - > SmiToFloat64 ( element_k ) ) , <nl> void Builtins : : Generate_ArrayIncludes ( CodeStubAssembler * assembler ) { <nl> Node * element_k = assembler - > LoadFixedArrayElement ( <nl> elements , index_var . value ( ) , 0 , <nl> CodeStubAssembler : : INTPTR_PARAMETERS ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( element_k ) , & continue_loop ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( element_k ) , & continue_loop ) ; <nl> assembler - > GotoIf ( assembler - > WordNotEqual ( assembler - > LoadMap ( element_k ) , <nl> heap_number_map ) , <nl> & continue_loop ) ; <nl> void Builtins : : Generate_ArrayIncludes ( CodeStubAssembler * assembler ) { <nl> & return_false ) ; <nl> Node * element_k = assembler - > LoadFixedArrayElement ( <nl> elements , index_var . value ( ) , 0 , CodeStubAssembler : : INTPTR_PARAMETERS ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( element_k ) , & continue_loop ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( element_k ) , & continue_loop ) ; <nl> assembler - > GotoUnless ( assembler - > IsStringInstanceType ( <nl> assembler - > LoadInstanceType ( element_k ) ) , <nl> & continue_loop ) ; <nl> void Builtins : : Generate_ArrayIncludes ( CodeStubAssembler * assembler ) { <nl> <nl> Node * element_k = assembler - > LoadFixedArrayElement ( <nl> elements , index_var . value ( ) , 0 , CodeStubAssembler : : INTPTR_PARAMETERS ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( element_k ) , & continue_loop ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( element_k ) , & continue_loop ) ; <nl> <nl> Node * map_k = assembler - > LoadMap ( element_k ) ; <nl> assembler - > BranchIfSimd128Equal ( search_element , map , element_k , map_k , <nl> void Builtins : : Generate_ArrayIncludes ( CodeStubAssembler * assembler ) { <nl> hole_loop ( assembler , & index_var ) , search_notnan ( assembler ) ; <nl> Variable search_num ( assembler , MachineRepresentation : : kFloat64 ) ; <nl> <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( search_element ) , & search_notnan ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( search_element ) , <nl> + & search_notnan ) ; <nl> search_num . Bind ( assembler - > SmiToFloat64 ( search_element ) ) ; <nl> assembler - > Goto ( & not_nan_loop ) ; <nl> <nl> void Builtins : : Generate_ArrayIncludes ( CodeStubAssembler * assembler ) { <nl> hole_loop ( assembler , & index_var ) , search_notnan ( assembler ) ; <nl> Variable search_num ( assembler , MachineRepresentation : : kFloat64 ) ; <nl> <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( search_element ) , & search_notnan ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( search_element ) , <nl> + & search_notnan ) ; <nl> search_num . Bind ( assembler - > SmiToFloat64 ( search_element ) ) ; <nl> assembler - > Goto ( & not_nan_loop ) ; <nl> <nl> void Builtins : : Generate_ArrayIndexOf ( CodeStubAssembler * assembler ) { <nl> { <nl> / / Handle case where JSArray length is not an Smi in the runtime <nl> Node * len = assembler - > LoadObjectField ( array , JSArray : : kLengthOffset ) ; <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( len ) , & call_runtime ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( len ) , & call_runtime ) ; <nl> <nl> len_var . Bind ( assembler - > SmiToWord ( len ) ) ; <nl> assembler - > Branch ( assembler - > WordEqual ( len_var . value ( ) , intptr_zero ) , <nl> void Builtins : : Generate_ArrayIndexOf ( CodeStubAssembler * assembler ) { <nl> init_k_zero ( assembler ) , init_k_n ( assembler ) ; <nl> Node * tagged_n = assembler - > ToInteger ( context , start_from ) ; <nl> <nl> - assembler - > Branch ( assembler - > WordIsSmi ( tagged_n ) , & init_k_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( tagged_n ) , & init_k_smi , <nl> & init_k_heap_num ) ; <nl> <nl> assembler - > Bind ( & init_k_smi ) ; <nl> void Builtins : : Generate_ArrayIndexOf ( CodeStubAssembler * assembler ) { <nl> undef_loop ( assembler , & index_var ) , not_smi ( assembler ) , <nl> not_heap_num ( assembler ) ; <nl> <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( search_element ) , & not_smi ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( search_element ) , & not_smi ) ; <nl> search_num . Bind ( assembler - > SmiToFloat64 ( search_element ) ) ; <nl> assembler - > Goto ( & heap_num_loop ) ; <nl> <nl> void Builtins : : Generate_ArrayIndexOf ( CodeStubAssembler * assembler ) { <nl> Node * element_k = assembler - > LoadFixedArrayElement ( <nl> elements , index_var . value ( ) , 0 , <nl> CodeStubAssembler : : INTPTR_PARAMETERS ) ; <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( element_k ) , & not_smi ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( element_k ) , & not_smi ) ; <nl> assembler - > Branch ( <nl> assembler - > Float64Equal ( search_num . value ( ) , <nl> assembler - > SmiToFloat64 ( element_k ) ) , <nl> void Builtins : : Generate_ArrayIndexOf ( CodeStubAssembler * assembler ) { <nl> & return_not_found ) ; <nl> Node * element_k = assembler - > LoadFixedArrayElement ( <nl> elements , index_var . value ( ) , 0 , CodeStubAssembler : : INTPTR_PARAMETERS ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( element_k ) , & continue_loop ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( element_k ) , & continue_loop ) ; <nl> assembler - > GotoUnless ( assembler - > IsStringInstanceType ( <nl> assembler - > LoadInstanceType ( element_k ) ) , <nl> & continue_loop ) ; <nl> void Builtins : : Generate_ArrayIndexOf ( CodeStubAssembler * assembler ) { <nl> <nl> Node * element_k = assembler - > LoadFixedArrayElement ( <nl> elements , index_var . value ( ) , 0 , CodeStubAssembler : : INTPTR_PARAMETERS ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( element_k ) , & continue_loop ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( element_k ) , & continue_loop ) ; <nl> <nl> Node * map_k = assembler - > LoadMap ( element_k ) ; <nl> assembler - > BranchIfSimd128Equal ( search_element , map , element_k , map_k , <nl> void Builtins : : Generate_ArrayIndexOf ( CodeStubAssembler * assembler ) { <nl> Label not_nan_loop ( assembler , & index_var ) , search_notnan ( assembler ) ; <nl> Variable search_num ( assembler , MachineRepresentation : : kFloat64 ) ; <nl> <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( search_element ) , & search_notnan ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( search_element ) , <nl> + & search_notnan ) ; <nl> search_num . Bind ( assembler - > SmiToFloat64 ( search_element ) ) ; <nl> assembler - > Goto ( & not_nan_loop ) ; <nl> <nl> void Builtins : : Generate_ArrayIndexOf ( CodeStubAssembler * assembler ) { <nl> Label not_nan_loop ( assembler , & index_var ) , search_notnan ( assembler ) ; <nl> Variable search_num ( assembler , MachineRepresentation : : kFloat64 ) ; <nl> <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( search_element ) , & search_notnan ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( search_element ) , <nl> + & search_notnan ) ; <nl> search_num . Bind ( assembler - > SmiToFloat64 ( search_element ) ) ; <nl> assembler - > Goto ( & not_nan_loop ) ; <nl> <nl> mmm a / src / builtins / builtins - conversion . cc <nl> ppp b / src / builtins / builtins - conversion . cc <nl> void Generate_NonPrimitiveToPrimitive ( CodeStubAssembler * assembler , <nl> / / Verify that the { result } is actually a primitive . <nl> Label if_resultisprimitive ( assembler ) , <nl> if_resultisnotprimitive ( assembler , Label : : kDeferred ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( result ) , & if_resultisprimitive ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( result ) , & if_resultisprimitive ) ; <nl> Node * result_instance_type = assembler - > LoadInstanceType ( result ) ; <nl> STATIC_ASSERT ( FIRST_PRIMITIVE_TYPE = = FIRST_TYPE ) ; <nl> assembler - > Branch ( assembler - > Int32LessThanOrEqual ( <nl> void Builtins : : Generate_ToString ( CodeStubAssembler * assembler ) { <nl> Label is_number ( assembler ) ; <nl> Label runtime ( assembler ) ; <nl> <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( input ) , & is_number ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( input ) , & is_number ) ; <nl> <nl> Node * input_map = assembler - > LoadMap ( input ) ; <nl> Node * input_instance_type = assembler - > LoadMapInstanceType ( input_map ) ; <nl> void Generate_OrdinaryToPrimitive ( CodeStubAssembler * assembler , <nl> / / Check if the { method } is callable . <nl> Label if_methodiscallable ( assembler ) , <nl> if_methodisnotcallable ( assembler , Label : : kDeferred ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( method ) , & if_methodisnotcallable ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( method ) , & if_methodisnotcallable ) ; <nl> Node * method_map = assembler - > LoadMap ( method ) ; <nl> Node * method_bit_field = assembler - > LoadMapBitField ( method_map ) ; <nl> assembler - > Branch ( <nl> void Generate_OrdinaryToPrimitive ( CodeStubAssembler * assembler , <nl> var_result . Bind ( result ) ; <nl> <nl> / / Return the { result } if it is a primitive . <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( result ) , & return_result ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( result ) , & return_result ) ; <nl> Node * result_instance_type = assembler - > LoadInstanceType ( result ) ; <nl> STATIC_ASSERT ( FIRST_PRIMITIVE_TYPE = = FIRST_TYPE ) ; <nl> assembler - > GotoIf ( assembler - > Int32LessThanOrEqual ( <nl> void Builtins : : Generate_ToLength ( CodeStubAssembler * assembler ) { <nl> assembler - > GotoIf ( assembler - > WordIsPositiveSmi ( len ) , & return_len ) ; <nl> <nl> / / Check if { len } is a ( negative ) Smi . <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( len ) , & return_zero ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( len ) , & return_zero ) ; <nl> <nl> / / Check if { len } is a HeapNumber . <nl> Label if_lenisheapnumber ( assembler ) , <nl> void Builtins : : Generate_ToObject ( CodeStubAssembler * assembler ) { <nl> Variable constructor_function_index_var ( assembler , <nl> MachineType : : PointerRepresentation ( ) ) ; <nl> <nl> - assembler - > Branch ( assembler - > WordIsSmi ( object ) , & if_number , & if_notsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( object ) , & if_number , & if_notsmi ) ; <nl> <nl> assembler - > Bind ( & if_notsmi ) ; <nl> Node * map = assembler - > LoadMap ( object ) ; <nl> mmm a / src / builtins / builtins - date . cc <nl> ppp b / src / builtins / builtins - date . cc <nl> void Builtins : : Generate_DatePrototype_GetField ( CodeStubAssembler * assembler , <nl> <nl> Label receiver_not_date ( assembler , Label : : kDeferred ) ; <nl> <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( receiver ) , & receiver_not_date ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( receiver ) , & receiver_not_date ) ; <nl> Node * receiver_instance_type = assembler - > LoadInstanceType ( receiver ) ; <nl> assembler - > GotoIf ( <nl> assembler - > Word32NotEqual ( receiver_instance_type , <nl> mmm a / src / builtins / builtins - generator . cc <nl> ppp b / src / builtins / builtins - generator . cc <nl> void Generate_GeneratorPrototypeResume ( <nl> <nl> / / Check if the { receiver } is actually a JSGeneratorObject . <nl> Label if_receiverisincompatible ( assembler , Label : : kDeferred ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( receiver ) , & if_receiverisincompatible ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( receiver ) , <nl> + & if_receiverisincompatible ) ; <nl> Node * receiver_instance_type = assembler - > LoadInstanceType ( receiver ) ; <nl> assembler - > GotoUnless ( assembler - > Word32Equal ( <nl> receiver_instance_type , <nl> mmm a / src / builtins / builtins - global . cc <nl> ppp b / src / builtins / builtins - global . cc <nl> void Builtins : : Generate_GlobalIsFinite ( CodeStubAssembler * assembler ) { <nl> Node * num = var_num . value ( ) ; <nl> <nl> / / Check if { num } is a Smi or a HeapObject . <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( num ) , & return_true ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( num ) , & return_true ) ; <nl> <nl> / / Check if { num } is a HeapNumber . <nl> Label if_numisheapnumber ( assembler ) , <nl> void Builtins : : Generate_GlobalIsNaN ( CodeStubAssembler * assembler ) { <nl> Node * num = var_num . value ( ) ; <nl> <nl> / / Check if { num } is a Smi or a HeapObject . <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( num ) , & return_false ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( num ) , & return_false ) ; <nl> <nl> / / Check if { num } is a HeapNumber . <nl> Label if_numisheapnumber ( assembler ) , <nl> mmm a / src / builtins / builtins - math . cc <nl> ppp b / src / builtins / builtins - math . cc <nl> void Generate_MathRoundingOperation ( <nl> <nl> / / Check if { x } is a Smi or a HeapObject . <nl> Label if_xissmi ( assembler ) , if_xisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( x ) , & if_xissmi , & if_xisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( x ) , & if_xissmi , & if_xisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_xissmi ) ; <nl> { <nl> void Builtins : : Generate_MathClz32 ( CodeStubAssembler * assembler ) { <nl> <nl> / / Check if { x } is a Smi or a HeapObject . <nl> Label if_xissmi ( assembler ) , if_xisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( x ) , & if_xissmi , & if_xisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( x ) , & if_xissmi , & if_xisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_xissmi ) ; <nl> { <nl> mmm a / src / builtins / builtins - number . cc <nl> ppp b / src / builtins / builtins - number . cc <nl> void Builtins : : Generate_NumberIsFinite ( CodeStubAssembler * assembler ) { <nl> Label return_true ( assembler ) , return_false ( assembler ) ; <nl> <nl> / / Check if { number } is a Smi . <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( number ) , & return_true ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( number ) , & return_true ) ; <nl> <nl> / / Check if { number } is a HeapNumber . <nl> assembler - > GotoUnless ( <nl> void Builtins : : Generate_NumberIsInteger ( CodeStubAssembler * assembler ) { <nl> Label return_true ( assembler ) , return_false ( assembler ) ; <nl> <nl> / / Check if { number } is a Smi . <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( number ) , & return_true ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( number ) , & return_true ) ; <nl> <nl> / / Check if { number } is a HeapNumber . <nl> assembler - > GotoUnless ( <nl> void Builtins : : Generate_NumberIsNaN ( CodeStubAssembler * assembler ) { <nl> Label return_true ( assembler ) , return_false ( assembler ) ; <nl> <nl> / / Check if { number } is a Smi . <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( number ) , & return_false ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( number ) , & return_false ) ; <nl> <nl> / / Check if { number } is a HeapNumber . <nl> assembler - > GotoUnless ( <nl> void Builtins : : Generate_NumberIsSafeInteger ( CodeStubAssembler * assembler ) { <nl> Label return_true ( assembler ) , return_false ( assembler ) ; <nl> <nl> / / Check if { number } is a Smi . <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( number ) , & return_true ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( number ) , & return_true ) ; <nl> <nl> / / Check if { number } is a HeapNumber . <nl> assembler - > GotoUnless ( <nl> void Builtins : : Generate_NumberParseFloat ( CodeStubAssembler * assembler ) { <nl> <nl> / / Check if the { input } is a HeapObject or a Smi . <nl> Label if_inputissmi ( assembler ) , if_inputisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( input ) , & if_inputissmi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( input ) , & if_inputissmi , <nl> & if_inputisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_inputissmi ) ; <nl> void Builtins : : Generate_Add ( CodeStubAssembler * assembler ) { <nl> <nl> / / Check if the { lhs } is a Smi or a HeapObject . <nl> Label if_lhsissmi ( assembler ) , if_lhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( lhs ) , & if_lhsissmi , <nl> + & if_lhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_lhsissmi ) ; <nl> { <nl> / / Check if the { rhs } is also a Smi . <nl> Label if_rhsissmi ( assembler ) , if_rhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & if_rhsissmi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & if_rhsissmi , <nl> & if_rhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_rhsissmi ) ; <nl> void Builtins : : Generate_Add ( CodeStubAssembler * assembler ) { <nl> { <nl> / / Check if { rhs } is a Smi . <nl> Label if_rhsissmi ( assembler ) , if_rhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & if_rhsissmi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & if_rhsissmi , <nl> & if_rhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_rhsissmi ) ; <nl> void Builtins : : Generate_Subtract ( CodeStubAssembler * assembler ) { <nl> <nl> / / Check if the { lhs } is a Smi or a HeapObject . <nl> Label if_lhsissmi ( assembler ) , if_lhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( lhs ) , & if_lhsissmi , <nl> + & if_lhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_lhsissmi ) ; <nl> { <nl> / / Check if the { rhs } is also a Smi . <nl> Label if_rhsissmi ( assembler ) , if_rhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & if_rhsissmi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & if_rhsissmi , <nl> & if_rhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_rhsissmi ) ; <nl> void Builtins : : Generate_Subtract ( CodeStubAssembler * assembler ) { <nl> { <nl> / / Check if the { rhs } is a Smi . <nl> Label if_rhsissmi ( assembler ) , if_rhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & if_rhsissmi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & if_rhsissmi , <nl> & if_rhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_rhsissmi ) ; <nl> void Builtins : : Generate_Multiply ( CodeStubAssembler * assembler ) { <nl> Node * rhs = var_rhs . value ( ) ; <nl> <nl> Label lhs_is_smi ( assembler ) , lhs_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( lhs ) , & lhs_is_smi , & lhs_is_not_smi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( lhs ) , & lhs_is_smi , <nl> + & lhs_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & lhs_is_smi ) ; <nl> { <nl> Label rhs_is_smi ( assembler ) , rhs_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & rhs_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & rhs_is_smi , <nl> & rhs_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & rhs_is_smi ) ; <nl> void Builtins : : Generate_Multiply ( CodeStubAssembler * assembler ) { <nl> { <nl> / / Check if { rhs } is a Smi . <nl> Label rhs_is_smi ( assembler ) , rhs_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & rhs_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & rhs_is_smi , <nl> & rhs_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & rhs_is_smi ) ; <nl> void Builtins : : Generate_Divide ( CodeStubAssembler * assembler ) { <nl> Node * divisor = var_divisor . value ( ) ; <nl> <nl> Label dividend_is_smi ( assembler ) , dividend_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( dividend ) , & dividend_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( dividend ) , & dividend_is_smi , <nl> & dividend_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & dividend_is_smi ) ; <nl> { <nl> Label divisor_is_smi ( assembler ) , divisor_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( divisor ) , & divisor_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( divisor ) , & divisor_is_smi , <nl> & divisor_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & divisor_is_smi ) ; <nl> void Builtins : : Generate_Divide ( CodeStubAssembler * assembler ) { <nl> { <nl> / / Check if { divisor } is a Smi . <nl> Label divisor_is_smi ( assembler ) , divisor_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( divisor ) , & divisor_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( divisor ) , & divisor_is_smi , <nl> & divisor_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & divisor_is_smi ) ; <nl> void Builtins : : Generate_Modulus ( CodeStubAssembler * assembler ) { <nl> Node * divisor = var_divisor . value ( ) ; <nl> <nl> Label dividend_is_smi ( assembler ) , dividend_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( dividend ) , & dividend_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( dividend ) , & dividend_is_smi , <nl> & dividend_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & dividend_is_smi ) ; <nl> { <nl> Label dividend_is_not_zero ( assembler ) ; <nl> Label divisor_is_smi ( assembler ) , divisor_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( divisor ) , & divisor_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( divisor ) , & divisor_is_smi , <nl> & divisor_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & divisor_is_smi ) ; <nl> void Builtins : : Generate_Modulus ( CodeStubAssembler * assembler ) { <nl> { <nl> / / Check if { divisor } is a Smi . <nl> Label divisor_is_smi ( assembler ) , divisor_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( divisor ) , & divisor_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( divisor ) , & divisor_is_smi , <nl> & divisor_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & divisor_is_smi ) ; <nl> mmm a / src / builtins / builtins - object . cc <nl> ppp b / src / builtins / builtins - object . cc <nl> void Builtins : : Generate_ObjectHasOwnProperty ( CodeStubAssembler * assembler ) { <nl> <nl> / / Smi receivers do not have own properties . <nl> Label if_objectisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( object ) , & return_false , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( object ) , & return_false , <nl> & if_objectisnotsmi ) ; <nl> assembler - > Bind ( & if_objectisnotsmi ) ; <nl> <nl> void IsString ( CodeStubAssembler * assembler , compiler : : Node * object , <nl> typedef CodeStubAssembler : : Label Label ; <nl> <nl> Label if_notsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( object ) , if_notstring , & if_notsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( object ) , if_notstring , & if_notsmi ) ; <nl> <nl> assembler - > Bind ( & if_notsmi ) ; <nl> { <nl> void Builtins : : Generate_ObjectProtoToString ( CodeStubAssembler * assembler ) { <nl> assembler - > GotoIf ( assembler - > Word32Equal ( receiver , assembler - > NullConstant ( ) ) , <nl> & return_null ) ; <nl> <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( receiver ) , & return_number ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( receiver ) , & return_number ) ; <nl> <nl> Node * receiver_instance_type = assembler - > LoadInstanceType ( receiver ) ; <nl> ReturnIfPrimitive ( assembler , receiver_instance_type , & return_string , <nl> void Builtins : : Generate_ObjectProtoToString ( CodeStubAssembler * assembler ) { <nl> assembler - > Bind ( & return_jsvalue ) ; <nl> { <nl> Node * value = assembler - > LoadJSValueValue ( receiver ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( value ) , & return_number ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( value ) , & return_number ) ; <nl> <nl> ReturnIfPrimitive ( assembler , assembler - > LoadInstanceType ( value ) , <nl> & return_string , & return_boolean , & return_number ) ; <nl> mmm a / src / builtins / builtins - regexp . cc <nl> ppp b / src / builtins / builtins - regexp . cc <nl> void Builtins : : Generate_RegExpPrototypeExec ( CodeStubAssembler * a ) { <nl> var_lastindex . Bind ( lastindex ) ; <nl> <nl> Label if_isoob ( a , Label : : kDeferred ) ; <nl> - a - > GotoUnless ( a - > WordIsSmi ( lastindex ) , & if_isoob ) ; <nl> + a - > GotoUnless ( a - > TaggedIsSmi ( lastindex ) , & if_isoob ) ; <nl> a - > GotoUnless ( a - > SmiLessThanOrEqual ( lastindex , string_length ) , & if_isoob ) ; <nl> a - > Goto ( & run_exec ) ; <nl> <nl> compiler : : Node * ThrowIfNotJSReceiver ( CodeStubAssembler * a , Isolate * isolate , <nl> Label out ( a ) , throw_exception ( a , Label : : kDeferred ) ; <nl> Variable var_value_map ( a , MachineRepresentation : : kTagged ) ; <nl> <nl> - a - > GotoIf ( a - > WordIsSmi ( value ) , & throw_exception ) ; <nl> + a - > GotoIf ( a - > TaggedIsSmi ( value ) , & throw_exception ) ; <nl> <nl> / / Load the instance type of the { value } . <nl> var_value_map . Bind ( a - > LoadMap ( value ) ) ; <nl> void Generate_FlagGetter ( CodeStubAssembler * a , JSRegExp : : Flag flag , <nl> Label if_isunmodifiedjsregexp ( a ) , <nl> if_isnotunmodifiedjsregexp ( a , Label : : kDeferred ) ; <nl> <nl> - a - > GotoIf ( a - > WordIsSmi ( receiver ) , & if_isnotunmodifiedjsregexp ) ; <nl> + a - > GotoIf ( a - > TaggedIsSmi ( receiver ) , & if_isnotunmodifiedjsregexp ) ; <nl> <nl> Node * const receiver_map = a - > LoadMap ( receiver ) ; <nl> Node * const instance_type = a - > LoadMapInstanceType ( receiver_map ) ; <nl> mmm a / src / builtins / builtins - sharedarraybuffer . cc <nl> ppp b / src / builtins / builtins - sharedarraybuffer . cc <nl> void ValidateSharedTypedArray ( CodeStubAssembler * a , compiler : : Node * tagged , <nl> not_float_or_clamped ( a ) , invalid ( a ) ; <nl> <nl> / / Fail if it is not a heap object . <nl> - a - > Branch ( a - > WordIsSmi ( tagged ) , & is_smi , & not_smi ) ; <nl> + a - > Branch ( a - > TaggedIsSmi ( tagged ) , & is_smi , & not_smi ) ; <nl> a - > Bind ( & is_smi ) ; <nl> a - > Goto ( & invalid ) ; <nl> <nl> compiler : : Node * ConvertTaggedAtomicIndexToWord32 ( CodeStubAssembler * a , <nl> CodeStubAssembler : : Label done ( a , & var_result ) ; <nl> <nl> CodeStubAssembler : : Label if_numberissmi ( a ) , if_numberisnotsmi ( a ) ; <nl> - a - > Branch ( a - > WordIsSmi ( number_index ) , & if_numberissmi , & if_numberisnotsmi ) ; <nl> + a - > Branch ( a - > TaggedIsSmi ( number_index ) , & if_numberissmi , & if_numberisnotsmi ) ; <nl> <nl> a - > Bind ( & if_numberissmi ) ; <nl> { <nl> mmm a / src / builtins / builtins - string . cc <nl> ppp b / src / builtins / builtins - string . cc <nl> void Builtins : : Generate_StringPrototypeCharAt ( CodeStubAssembler * assembler ) { <nl> Label return_emptystring ( assembler , Label : : kDeferred ) ; <nl> position = assembler - > ToInteger ( context , position , <nl> CodeStubAssembler : : kTruncateMinusZero ) ; <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( position ) , & return_emptystring ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( position ) , <nl> + & return_emptystring ) ; <nl> <nl> / / Determine the actual length of the { receiver } String . <nl> Node * receiver_length = <nl> void Builtins : : Generate_StringPrototypeCharCodeAt ( <nl> Label return_nan ( assembler , Label : : kDeferred ) ; <nl> position = assembler - > ToInteger ( context , position , <nl> CodeStubAssembler : : kTruncateMinusZero ) ; <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( position ) , & return_nan ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( position ) , & return_nan ) ; <nl> <nl> / / Determine the actual length of the { receiver } String . <nl> Node * receiver_length = <nl> void Builtins : : Generate_StringPrototypeSubstr ( CodeStubAssembler * a ) { <nl> a - > ToInteger ( context , start , CodeStubAssembler : : kTruncateMinusZero ) ; <nl> <nl> Label if_issmi ( a ) , if_isheapnumber ( a , Label : : kDeferred ) ; <nl> - a - > Branch ( a - > WordIsSmi ( start_int ) , & if_issmi , & if_isheapnumber ) ; <nl> + a - > Branch ( a - > TaggedIsSmi ( start_int ) , & if_issmi , & if_isheapnumber ) ; <nl> <nl> a - > Bind ( & if_issmi ) ; <nl> { <nl> void Builtins : : Generate_StringPrototypeSubstr ( CodeStubAssembler * a ) { <nl> a - > ToInteger ( context , length , CodeStubAssembler : : kTruncateMinusZero ) ) ; <nl> } <nl> <nl> - a - > Branch ( a - > WordIsSmi ( var_length . value ( ) ) , & if_issmi , & if_isheapnumber ) ; <nl> + a - > Branch ( a - > TaggedIsSmi ( var_length . value ( ) ) , & if_issmi , & if_isheapnumber ) ; <nl> <nl> / / Set { length } to min ( max ( { length } , 0 ) , { string_length } - { start } <nl> a - > Bind ( & if_issmi ) ; <nl> compiler : : Node * ToSmiBetweenZeroAnd ( CodeStubAssembler * a , <nl> a - > ToInteger ( context , value , CodeStubAssembler : : kTruncateMinusZero ) ; <nl> <nl> Label if_issmi ( a ) , if_isnotsmi ( a , Label : : kDeferred ) ; <nl> - a - > Branch ( a - > WordIsSmi ( value_int ) , & if_issmi , & if_isnotsmi ) ; <nl> + a - > Branch ( a - > TaggedIsSmi ( value_int ) , & if_issmi , & if_isnotsmi ) ; <nl> <nl> a - > Bind ( & if_issmi ) ; <nl> { <nl> void Builtins : : Generate_StringIteratorPrototypeNext ( <nl> Node * iterator = assembler - > Parameter ( 0 ) ; <nl> Node * context = assembler - > Parameter ( 3 ) ; <nl> <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( iterator ) , & throw_bad_receiver ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( iterator ) , & throw_bad_receiver ) ; <nl> assembler - > GotoUnless ( <nl> assembler - > WordEqual ( assembler - > LoadInstanceType ( iterator ) , <nl> assembler - > Int32Constant ( JS_STRING_ITERATOR_TYPE ) ) , <nl> mmm a / src / builtins / builtins - typedarray . cc <nl> ppp b / src / builtins / builtins - typedarray . cc <nl> void Generate_TypedArrayProtoypeGetter ( CodeStubAssembler * assembler , <nl> <nl> / / Check if the { receiver } is actually a JSTypedArray . <nl> Label if_receiverisincompatible ( assembler , Label : : kDeferred ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( receiver ) , & if_receiverisincompatible ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( receiver ) , <nl> + & if_receiverisincompatible ) ; <nl> Node * receiver_instance_type = assembler - > LoadInstanceType ( receiver ) ; <nl> assembler - > GotoUnless ( <nl> assembler - > Word32Equal ( receiver_instance_type , <nl> mmm a / src / code - stub - assembler . cc <nl> ppp b / src / code - stub - assembler . cc <nl> Node * CodeStubAssembler : : SmiToFloat64 ( Node * value ) { <nl> return ChangeInt32ToFloat64 ( SmiToWord32 ( value ) ) ; <nl> } <nl> <nl> - Node * CodeStubAssembler : : SmiAdd ( Node * a , Node * b ) { return IntPtrAdd ( a , b ) ; } <nl> + Node * CodeStubAssembler : : SmiAdd ( Node * a , Node * b ) { <nl> + return BitcastWordToTaggedSigned ( <nl> + IntPtrAdd ( BitcastTaggedToWord ( a ) , BitcastTaggedToWord ( b ) ) ) ; <nl> + } <nl> <nl> Node * CodeStubAssembler : : SmiAddWithOverflow ( Node * a , Node * b ) { <nl> - return IntPtrAddWithOverflow ( a , b ) ; <nl> + return IntPtrAddWithOverflow ( BitcastTaggedToWord ( a ) , BitcastTaggedToWord ( b ) ) ; <nl> } <nl> <nl> - Node * CodeStubAssembler : : SmiSub ( Node * a , Node * b ) { return IntPtrSub ( a , b ) ; } <nl> + Node * CodeStubAssembler : : SmiSub ( Node * a , Node * b ) { <nl> + return BitcastWordToTaggedSigned ( <nl> + IntPtrSub ( BitcastTaggedToWord ( a ) , BitcastTaggedToWord ( b ) ) ) ; <nl> + } <nl> <nl> Node * CodeStubAssembler : : SmiSubWithOverflow ( Node * a , Node * b ) { <nl> - return IntPtrSubWithOverflow ( a , b ) ; <nl> + return IntPtrSubWithOverflow ( BitcastTaggedToWord ( a ) , BitcastTaggedToWord ( b ) ) ; <nl> } <nl> <nl> - Node * CodeStubAssembler : : SmiEqual ( Node * a , Node * b ) { return WordEqual ( a , b ) ; } <nl> + Node * CodeStubAssembler : : SmiEqual ( Node * a , Node * b ) { <nl> + return WordEqual ( BitcastTaggedToWord ( a ) , BitcastTaggedToWord ( b ) ) ; <nl> + } <nl> <nl> Node * CodeStubAssembler : : SmiAbove ( Node * a , Node * b ) { <nl> - return UintPtrGreaterThan ( a , b ) ; <nl> + return UintPtrGreaterThan ( BitcastTaggedToWord ( a ) , BitcastTaggedToWord ( b ) ) ; <nl> } <nl> <nl> Node * CodeStubAssembler : : SmiAboveOrEqual ( Node * a , Node * b ) { <nl> - return UintPtrGreaterThanOrEqual ( a , b ) ; <nl> + return UintPtrGreaterThanOrEqual ( BitcastTaggedToWord ( a ) , <nl> + BitcastTaggedToWord ( b ) ) ; <nl> } <nl> <nl> Node * CodeStubAssembler : : SmiBelow ( Node * a , Node * b ) { <nl> - return UintPtrLessThan ( a , b ) ; <nl> + return UintPtrLessThan ( BitcastTaggedToWord ( a ) , BitcastTaggedToWord ( b ) ) ; <nl> } <nl> <nl> Node * CodeStubAssembler : : SmiLessThan ( Node * a , Node * b ) { <nl> - return IntPtrLessThan ( a , b ) ; <nl> + return IntPtrLessThan ( BitcastTaggedToWord ( a ) , BitcastTaggedToWord ( b ) ) ; <nl> } <nl> <nl> Node * CodeStubAssembler : : SmiLessThanOrEqual ( Node * a , Node * b ) { <nl> - return IntPtrLessThanOrEqual ( a , b ) ; <nl> + return IntPtrLessThanOrEqual ( BitcastTaggedToWord ( a ) , BitcastTaggedToWord ( b ) ) ; <nl> } <nl> <nl> Node * CodeStubAssembler : : SmiMax ( Node * a , Node * b ) { <nl> Node * CodeStubAssembler : : SmiMul ( Node * a , Node * b ) { <nl> return var_result . value ( ) ; <nl> } <nl> <nl> - Node * CodeStubAssembler : : WordIsSmi ( Node * a ) { <nl> - return WordEqual ( WordAnd ( a , IntPtrConstant ( kSmiTagMask ) ) , IntPtrConstant ( 0 ) ) ; <nl> + Node * CodeStubAssembler : : TaggedIsSmi ( Node * a ) { <nl> + return WordEqual ( WordAnd ( BitcastTaggedToWord ( a ) , IntPtrConstant ( kSmiTagMask ) ) , <nl> + IntPtrConstant ( 0 ) ) ; <nl> } <nl> <nl> Node * CodeStubAssembler : : WordIsPositiveSmi ( Node * a ) { <nl> void CodeStubAssembler : : BranchIfPrototypesHaveNoElements ( <nl> void CodeStubAssembler : : BranchIfFastJSArray ( Node * object , Node * context , <nl> Label * if_true , Label * if_false ) { <nl> / / Bailout if receiver is a Smi . <nl> - GotoIf ( WordIsSmi ( object ) , if_false ) ; <nl> + GotoIf ( TaggedIsSmi ( object ) , if_false ) ; <nl> <nl> Node * map = LoadMap ( object ) ; <nl> <nl> void CodeStubAssembler : : BranchIfToBooleanIsTrue ( Node * value , Label * if_true , <nl> GotoIf ( WordEqual ( value , BooleanConstant ( false ) ) , if_false ) ; <nl> <nl> / / Check if { value } is a Smi or a HeapObject . <nl> - Branch ( WordIsSmi ( value ) , & if_valueissmi , & if_valueisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( value ) , & if_valueissmi , & if_valueisnotsmi ) ; <nl> <nl> Bind ( & if_valueissmi ) ; <nl> { <nl> Node * CodeStubAssembler : : LoadMapConstructor ( Node * map ) { <nl> Goto ( & loop ) ; <nl> Bind ( & loop ) ; <nl> { <nl> - GotoIf ( WordIsSmi ( result . value ( ) ) , & done ) ; <nl> + GotoIf ( TaggedIsSmi ( result . value ( ) ) , & done ) ; <nl> Node * is_map_type = <nl> Word32Equal ( LoadInstanceType ( result . value ( ) ) , Int32Constant ( MAP_TYPE ) ) ; <nl> GotoUnless ( is_map_type , & done ) ; <nl> CodeStubAssembler : : AllocateUninitializedJSArrayWithElements ( <nl> Node * array = AllocateUninitializedJSArray ( kind , array_map , length , <nl> allocation_site , size ) ; <nl> <nl> - Node * elements = InnerAllocate ( array , elements_offset ) ; <nl> + / / The bitcast here is safe because InnerAllocate doesn ' t actually allocate . <nl> + Node * elements = InnerAllocate ( BitcastTaggedToWord ( array ) , elements_offset ) ; <nl> StoreObjectField ( array , JSObject : : kElementsOffset , elements ) ; <nl> <nl> return { array , elements } ; <nl> Node * CodeStubAssembler : : AllocateJSArray ( ElementsKind kind , Node * array_map , <nl> TagParameter ( capacity , capacity_mode ) ) ; <nl> <nl> / / Fill in the elements with holes . <nl> - FillFixedArrayWithValue ( kind , elements , IntPtrConstant ( 0 ) , capacity , <nl> - Heap : : kTheHoleValueRootIndex , capacity_mode ) ; <nl> + FillFixedArrayWithValue ( <nl> + kind , elements , capacity_mode = = SMI_PARAMETERS ? SmiConstant ( Smi : : kZero ) <nl> + : IntPtrConstant ( 0 ) , <nl> + capacity , Heap : : kTheHoleValueRootIndex , capacity_mode ) ; <nl> <nl> return array ; <nl> } <nl> void CodeStubAssembler : : CopyFixedArrayElements ( <nl> StoreNoWriteBarrier ( MachineRepresentation : : kFloat64 , to_array , to_offset , <nl> value ) ; <nl> } else { <nl> - StoreNoWriteBarrier ( MachineType : : PointerRepresentation ( ) , to_array , <nl> - to_offset , value ) ; <nl> + StoreNoWriteBarrier ( MachineRepresentation : : kTagged , to_array , to_offset , <nl> + value ) ; <nl> } <nl> Goto ( & next_iter ) ; <nl> <nl> Node * CodeStubAssembler : : LoadElementAndPrepareForStore ( Node * array , <nl> return value ; <nl> <nl> } else { <nl> - Node * value = Load ( MachineType : : Pointer ( ) , array , offset ) ; <nl> + Node * value = Load ( MachineType : : AnyTagged ( ) , array , offset ) ; <nl> if ( if_hole ) { <nl> GotoIf ( WordEqual ( value , TheHoleConstant ( ) ) , if_hole ) ; <nl> } <nl> void CodeStubAssembler : : InitializeAllocationMemento ( <nl> if ( FLAG_allocation_site_pretenuring ) { <nl> Node * count = LoadObjectField ( allocation_site , <nl> AllocationSite : : kPretenureCreateCountOffset ) ; <nl> - Node * incremented_count = IntPtrAdd ( count , SmiConstant ( Smi : : FromInt ( 1 ) ) ) ; <nl> + Node * incremented_count = SmiAdd ( count , SmiConstant ( Smi : : FromInt ( 1 ) ) ) ; <nl> StoreObjectFieldNoWriteBarrier ( allocation_site , <nl> AllocationSite : : kPretenureCreateCountOffset , <nl> incremented_count ) ; <nl> Node * CodeStubAssembler : : TruncateTaggedToFloat64 ( Node * context , Node * value ) { <nl> <nl> / / Check if the { value } is a Smi or a HeapObject . <nl> Label if_valueissmi ( this ) , if_valueisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( value ) , & if_valueissmi , & if_valueisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( value ) , & if_valueissmi , & if_valueisnotsmi ) ; <nl> <nl> Bind ( & if_valueissmi ) ; <nl> { <nl> Node * CodeStubAssembler : : TruncateTaggedToWord32 ( Node * context , Node * value ) { <nl> <nl> / / Check if the { value } is a Smi or a HeapObject . <nl> Label if_valueissmi ( this ) , if_valueisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( value ) , & if_valueissmi , & if_valueisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( value ) , & if_valueissmi , & if_valueisnotsmi ) ; <nl> <nl> Bind ( & if_valueissmi ) ; <nl> { <nl> Node * CodeStubAssembler : : ToThisString ( Node * context , Node * value , <nl> / / Check if the { value } is a Smi or a HeapObject . <nl> Label if_valueissmi ( this , Label : : kDeferred ) , if_valueisnotsmi ( this ) , <nl> if_valueisstring ( this ) ; <nl> - Branch ( WordIsSmi ( value ) , & if_valueissmi , & if_valueisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( value ) , & if_valueissmi , & if_valueisnotsmi ) ; <nl> Bind ( & if_valueisnotsmi ) ; <nl> { <nl> / / Load the instance type of the { value } . <nl> Node * CodeStubAssembler : : ToThisValue ( Node * context , Node * value , <nl> value = var_value . value ( ) ; <nl> <nl> / / Check if the { value } is a Smi or a HeapObject . <nl> - GotoIf ( WordIsSmi ( value ) , ( primitive_type = = PrimitiveType : : kNumber ) <nl> - ? & done_loop <nl> - : & done_throw ) ; <nl> + GotoIf ( TaggedIsSmi ( value ) , ( primitive_type = = PrimitiveType : : kNumber ) <nl> + ? & done_loop <nl> + : & done_throw ) ; <nl> <nl> / / Load the mape of the { value } . <nl> Node * value_map = LoadMap ( value ) ; <nl> Node * CodeStubAssembler : : ThrowIfNotInstanceType ( Node * context , Node * value , <nl> Label out ( this ) , throw_exception ( this , Label : : kDeferred ) ; <nl> Variable var_value_map ( this , MachineRepresentation : : kTagged ) ; <nl> <nl> - GotoIf ( WordIsSmi ( value ) , & throw_exception ) ; <nl> + GotoIf ( TaggedIsSmi ( value ) , & throw_exception ) ; <nl> <nl> / / Load the instance type of the { value } . <nl> var_value_map . Bind ( LoadMap ( value ) ) ; <nl> Node * CodeStubAssembler : : SubString ( Node * context , Node * string , Node * from , <nl> / / Make sure first argument is a string . <nl> <nl> / / Bailout if receiver is a Smi . <nl> - GotoIf ( WordIsSmi ( string ) , & runtime ) ; <nl> + GotoIf ( TaggedIsSmi ( string ) , & runtime ) ; <nl> <nl> / / Load the instance type of the { string } . <nl> Node * const instance_type = LoadInstanceType ( string ) ; <nl> Node * CodeStubAssembler : : NumberToString ( compiler : : Node * context , <nl> Node * one = IntPtrConstant ( 1 ) ; <nl> mask = IntPtrSub ( mask , one ) ; <nl> <nl> - GotoIf ( WordIsSmi ( argument ) , & smi ) ; <nl> + GotoIf ( TaggedIsSmi ( argument ) , & smi ) ; <nl> <nl> / / Argument isn ' t smi , check to see if it ' s a heap - number . <nl> Node * map = LoadMap ( argument ) ; <nl> Node * CodeStubAssembler : : NumberToString ( compiler : : Node * context , <nl> / / Cache entry ' s key must be a heap number <nl> Node * number_key = <nl> LoadFixedArrayElement ( number_string_cache , index , 0 , INTPTR_PARAMETERS ) ; <nl> - GotoIf ( WordIsSmi ( number_key ) , & runtime ) ; <nl> + GotoIf ( TaggedIsSmi ( number_key ) , & runtime ) ; <nl> map = LoadMap ( number_key ) ; <nl> GotoUnless ( WordEqual ( map , HeapNumberMapConstant ( ) ) , & runtime ) ; <nl> <nl> Node * CodeStubAssembler : : ToName ( Node * context , Node * value ) { <nl> Variable var_result ( this , MachineRepresentation : : kTagged ) ; <nl> <nl> Label is_number ( this ) ; <nl> - GotoIf ( WordIsSmi ( value ) , & is_number ) ; <nl> + GotoIf ( TaggedIsSmi ( value ) , & is_number ) ; <nl> <nl> Label not_name ( this ) ; <nl> Node * value_instance_type = LoadInstanceType ( value ) ; <nl> Node * CodeStubAssembler : : ToName ( Node * context , Node * value ) { <nl> <nl> Node * CodeStubAssembler : : NonNumberToNumber ( Node * context , Node * input ) { <nl> / / Assert input is a HeapObject ( not smi or heap number ) <nl> - Assert ( Word32BinaryNot ( WordIsSmi ( input ) ) ) ; <nl> + Assert ( Word32BinaryNot ( TaggedIsSmi ( input ) ) ) ; <nl> Assert ( Word32NotEqual ( LoadMap ( input ) , HeapNumberMapConstant ( ) ) ) ; <nl> <nl> / / We might need to loop once here due to ToPrimitive conversions . <nl> Node * CodeStubAssembler : : NonNumberToNumber ( Node * context , Node * input ) { <nl> <nl> / / Check if the { result } is already a Number . <nl> Label if_resultisnumber ( this ) , if_resultisnotnumber ( this ) ; <nl> - GotoIf ( WordIsSmi ( result ) , & if_resultisnumber ) ; <nl> + GotoIf ( TaggedIsSmi ( result ) , & if_resultisnumber ) ; <nl> Node * result_map = LoadMap ( result ) ; <nl> Branch ( WordEqual ( result_map , HeapNumberMapConstant ( ) ) , & if_resultisnumber , <nl> & if_resultisnotnumber ) ; <nl> Node * CodeStubAssembler : : ToNumber ( Node * context , Node * input ) { <nl> Label end ( this ) ; <nl> <nl> Label not_smi ( this , Label : : kDeferred ) ; <nl> - GotoUnless ( WordIsSmi ( input ) , & not_smi ) ; <nl> + GotoUnless ( TaggedIsSmi ( input ) , & not_smi ) ; <nl> var_result . Bind ( input ) ; <nl> Goto ( & end ) ; <nl> <nl> Node * CodeStubAssembler : : ToInteger ( Node * context , Node * input , <nl> Node * arg = var_arg . value ( ) ; <nl> <nl> / / Check if { arg } is a Smi . <nl> - GotoIf ( WordIsSmi ( arg ) , & out ) ; <nl> + GotoIf ( TaggedIsSmi ( arg ) , & out ) ; <nl> <nl> / / Check if { arg } is a HeapNumber . <nl> Label if_argisheapnumber ( this ) , <nl> void CodeStubAssembler : : NumberDictionaryLookup ( Node * dictionary , <nl> Label next_probe ( this ) ; <nl> { <nl> Label if_currentissmi ( this ) , if_currentisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( current ) , & if_currentissmi , & if_currentisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( current ) , & if_currentissmi , & if_currentisnotsmi ) ; <nl> Bind ( & if_currentissmi ) ; <nl> { <nl> Node * current_value = SmiUntag ( current ) ; <nl> void CodeStubAssembler : : TryPrototypeChainLookup ( <nl> Label * if_bailout ) { <nl> / / Ensure receiver is JSReceiver , otherwise bailout . <nl> Label if_objectisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( receiver ) , if_bailout , & if_objectisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( receiver ) , if_bailout , & if_objectisnotsmi ) ; <nl> Bind ( & if_objectisnotsmi ) ; <nl> <nl> Node * map = LoadMap ( receiver ) ; <nl> Node * CodeStubAssembler : : OrdinaryHasInstance ( Node * context , Node * callable , <nl> return_runtime ( this , Label : : kDeferred ) , return_result ( this ) ; <nl> <nl> / / Goto runtime if { object } is a Smi . <nl> - GotoIf ( WordIsSmi ( object ) , & return_runtime ) ; <nl> + GotoIf ( TaggedIsSmi ( object ) , & return_runtime ) ; <nl> <nl> / / Load map of { object } . <nl> Node * object_map = LoadMap ( object ) ; <nl> Node * CodeStubAssembler : : OrdinaryHasInstance ( Node * context , Node * callable , <nl> } <nl> <nl> / / Goto runtime if { callable } is a Smi . <nl> - GotoIf ( WordIsSmi ( callable ) , & return_runtime ) ; <nl> + GotoIf ( TaggedIsSmi ( callable ) , & return_runtime ) ; <nl> <nl> / / Load map of { callable } . <nl> Node * callable_map = LoadMap ( callable ) ; <nl> compiler : : Node * CodeStubAssembler : : ElementOffsetFromIndex ( Node * index_node , <nl> element_size_shift - = kSmiShiftBits ; <nl> constant_index = ToIntPtrConstant ( index_node , index ) ; <nl> index = index > > kSmiShiftBits ; <nl> + index_node = BitcastTaggedToWord ( index_node ) ; <nl> } else if ( mode = = INTEGER_PARAMETERS ) { <nl> int32_t temp = 0 ; <nl> constant_index = ToInt32Constant ( index_node , temp ) ; <nl> compiler : : Node * CodeStubAssembler : : LoadReceiverMap ( compiler : : Node * receiver ) { <nl> Label load_smi_map ( this / * , Label : : kDeferred * / ) , load_receiver_map ( this ) , <nl> if_result ( this ) ; <nl> <nl> - Branch ( WordIsSmi ( receiver ) , & load_smi_map , & load_receiver_map ) ; <nl> + Branch ( TaggedIsSmi ( receiver ) , & load_smi_map , & load_receiver_map ) ; <nl> Bind ( & load_smi_map ) ; <nl> { <nl> var_receiver_map . Bind ( LoadRoot ( Heap : : kHeapNumberMapRootIndex ) ) ; <nl> void CodeStubAssembler : : TryProbeStubCache ( <nl> IncrementCounter ( counters - > megamorphic_stub_cache_probes ( ) , 1 ) ; <nl> <nl> / / Check that the { receiver } isn ' t a smi . <nl> - GotoIf ( WordIsSmi ( receiver ) , & miss ) ; <nl> + GotoIf ( TaggedIsSmi ( receiver ) , & miss ) ; <nl> <nl> Node * receiver_map = LoadMap ( receiver ) ; <nl> <nl> void CodeStubAssembler : : TryProbeStubCache ( <nl> Node * CodeStubAssembler : : TryToIntptr ( Node * key , Label * miss ) { <nl> Variable var_intptr_key ( this , MachineType : : PointerRepresentation ( ) ) ; <nl> Label done ( this , & var_intptr_key ) , key_is_smi ( this ) ; <nl> - GotoIf ( WordIsSmi ( key ) , & key_is_smi ) ; <nl> + GotoIf ( TaggedIsSmi ( key ) , & key_is_smi ) ; <nl> / / Try to convert a heap number to a Smi . <nl> GotoUnless ( WordEqual ( LoadMap ( key ) , HeapNumberMapConstant ( ) ) , miss ) ; <nl> { <nl> void CodeStubAssembler : : HandleLoadICHandlerCase ( <nl> ElementSupport support_elements ) { <nl> Comment ( " have_handler " ) ; <nl> Label call_handler ( this ) ; <nl> - GotoUnless ( WordIsSmi ( handler ) , & call_handler ) ; <nl> + GotoUnless ( TaggedIsSmi ( handler ) , & call_handler ) ; <nl> <nl> / / | handler | is a Smi , encoding what to do . See handler - configuration . h <nl> / / for the encoding format . <nl> void CodeStubAssembler : : KeyedLoadICGeneric ( const LoadICParameters * p ) { <nl> if_property_dictionary ( this ) , if_found_on_receiver ( this ) ; <nl> <nl> Node * receiver = p - > receiver ; <nl> - GotoIf ( WordIsSmi ( receiver ) , & slow ) ; <nl> + GotoIf ( TaggedIsSmi ( receiver ) , & slow ) ; <nl> Node * receiver_map = LoadMap ( receiver ) ; <nl> Node * instance_type = LoadMapInstanceType ( receiver_map ) ; <nl> / / Receivers requiring non - standard element accesses ( interceptors , access <nl> Node * CodeStubAssembler : : PrepareValueForWrite ( Node * value , <nl> if ( representation . IsDouble ( ) ) { <nl> Variable var_value ( this , MachineRepresentation : : kFloat64 ) ; <nl> Label if_smi ( this ) , if_heap_object ( this ) , done ( this ) ; <nl> - Branch ( WordIsSmi ( value ) , & if_smi , & if_heap_object ) ; <nl> + Branch ( TaggedIsSmi ( value ) , & if_smi , & if_heap_object ) ; <nl> Bind ( & if_smi ) ; <nl> { <nl> var_value . Bind ( SmiToFloat64 ( value ) ) ; <nl> Node * CodeStubAssembler : : PrepareValueForWrite ( Node * value , <nl> } else if ( representation . IsHeapObject ( ) ) { <nl> / / Field type is checked by the handler , here we only check if the value <nl> / / is a heap object . <nl> - GotoIf ( WordIsSmi ( value ) , bailout ) ; <nl> + GotoIf ( TaggedIsSmi ( value ) , bailout ) ; <nl> } else if ( representation . IsSmi ( ) ) { <nl> - GotoUnless ( WordIsSmi ( value ) , bailout ) ; <nl> + GotoUnless ( TaggedIsSmi ( value ) , bailout ) ; <nl> } else { <nl> DCHECK ( representation . IsTagged ( ) ) ; <nl> } <nl> Node * CodeStubAssembler : : EmitKeyedSloppyArguments ( Node * receiver , Node * key , <nl> <nl> bool is_load = value = = nullptr ; <nl> <nl> - GotoUnless ( WordIsSmi ( key ) , bailout ) ; <nl> + GotoUnless ( TaggedIsSmi ( key ) , bailout ) ; <nl> key = SmiUntag ( key ) ; <nl> GotoIf ( IntPtrLessThan ( key , IntPtrConstant ( 0 ) ) , bailout ) ; <nl> <nl> Node * CodeStubAssembler : : EmitKeyedSloppyArguments ( Node * receiver , Node * key , <nl> <nl> Bind ( & if_mapped ) ; <nl> { <nl> - Assert ( WordIsSmi ( mapped_index ) ) ; <nl> + Assert ( TaggedIsSmi ( mapped_index ) ) ; <nl> mapped_index = SmiUntag ( mapped_index ) ; <nl> Node * the_context = LoadFixedArrayElement ( elements , IntPtrConstant ( 0 ) , 0 , <nl> INTPTR_PARAMETERS ) ; <nl> void CodeStubAssembler : : EmitElementStore ( Node * object , Node * key , Node * value , <nl> / / a smi before manipulating the backing store . Otherwise the backing store <nl> / / may be left in an invalid state . <nl> if ( IsFastSmiElementsKind ( elements_kind ) ) { <nl> - GotoUnless ( WordIsSmi ( value ) , bailout ) ; <nl> + GotoUnless ( TaggedIsSmi ( value ) , bailout ) ; <nl> } else if ( IsFastDoubleElementsKind ( elements_kind ) ) { <nl> value = PrepareValueForWrite ( value , Representation : : Double ( ) , bailout ) ; <nl> } <nl> compiler : : Node * CodeStubAssembler : : RelationalComparison ( <nl> <nl> / / Check if the { lhs } is a Smi or a HeapObject . <nl> Label if_lhsissmi ( this ) , if_lhsisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> <nl> Bind ( & if_lhsissmi ) ; <nl> { <nl> / / Check if { rhs } is a Smi or a HeapObject . <nl> Label if_rhsissmi ( this ) , if_rhsisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> <nl> Bind ( & if_rhsissmi ) ; <nl> { <nl> compiler : : Node * CodeStubAssembler : : RelationalComparison ( <nl> <nl> / / Check if { rhs } is a Smi or a HeapObject . <nl> Label if_rhsissmi ( this ) , if_rhsisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> <nl> Bind ( & if_rhsissmi ) ; <nl> { <nl> void GenerateEqual_Same ( CodeStubAssembler * assembler , compiler : : Node * value , <nl> <nl> / / Check if { value } is a Smi or a HeapObject . <nl> Label if_valueissmi ( assembler ) , if_valueisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( value ) , & if_valueissmi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( value ) , & if_valueissmi , <nl> & if_valueisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_valueisnotsmi ) ; <nl> compiler : : Node * CodeStubAssembler : : Equal ( ResultMode mode , compiler : : Node * lhs , <nl> { <nl> / / Check if { lhs } is a Smi or a HeapObject . <nl> Label if_lhsissmi ( this ) , if_lhsisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> <nl> Bind ( & if_lhsissmi ) ; <nl> { <nl> / / Check if { rhs } is a Smi or a HeapObject . <nl> Label if_rhsissmi ( this ) , if_rhsisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> <nl> Bind ( & if_rhsissmi ) ; <nl> / / We have already checked for { lhs } and { rhs } being the same value , so <nl> compiler : : Node * CodeStubAssembler : : Equal ( ResultMode mode , compiler : : Node * lhs , <nl> { <nl> / / Check if { rhs } is a Smi or a HeapObject . <nl> Label if_rhsissmi ( this ) , if_rhsisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> <nl> Bind ( & if_rhsissmi ) ; <nl> { <nl> compiler : : Node * CodeStubAssembler : : StrictEqual ( ResultMode mode , <nl> <nl> / / Check if { lhs } is a Smi or a HeapObject . <nl> Label if_lhsissmi ( this ) , if_lhsisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> <nl> Bind ( & if_lhsisnotsmi ) ; <nl> { <nl> compiler : : Node * CodeStubAssembler : : StrictEqual ( ResultMode mode , <nl> { <nl> / / Check if { rhs } is a Smi or a HeapObject . <nl> Label if_rhsissmi ( this ) , if_rhsisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> <nl> Bind ( & if_rhsissmi ) ; <nl> { <nl> compiler : : Node * CodeStubAssembler : : StrictEqual ( ResultMode mode , <nl> { <nl> / / Check if { rhs } is a Smi or a HeapObject . <nl> Label if_rhsissmi ( this ) , if_rhsisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> <nl> Bind ( & if_rhsissmi ) ; <nl> Goto ( & if_notequal ) ; <nl> compiler : : Node * CodeStubAssembler : : StrictEqual ( ResultMode mode , <nl> <nl> / / Check if { rhs } is a Smi or a HeapObject . <nl> Label if_rhsissmi ( this ) , if_rhsisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> <nl> Bind ( & if_rhsissmi ) ; <nl> Goto ( & if_notequal ) ; <nl> compiler : : Node * CodeStubAssembler : : Typeof ( compiler : : Node * value , <nl> return_function ( this ) , return_undefined ( this ) , return_object ( this ) , <nl> return_string ( this ) , return_result ( this ) ; <nl> <nl> - GotoIf ( WordIsSmi ( value ) , & return_number ) ; <nl> + GotoIf ( TaggedIsSmi ( value ) , & return_number ) ; <nl> <nl> Node * map = LoadMap ( value ) ; <nl> <nl> compiler : : Node * CodeStubAssembler : : InstanceOf ( compiler : : Node * object , <nl> & return_runtime ) ; <nl> <nl> / / Check if { callable } is a valid receiver . <nl> - GotoIf ( WordIsSmi ( callable ) , & return_runtime ) ; <nl> + GotoIf ( TaggedIsSmi ( callable ) , & return_runtime ) ; <nl> GotoIf ( Word32Equal ( Word32And ( LoadMapBitField ( LoadMap ( callable ) ) , <nl> Int32Constant ( 1 < < Map : : kIsCallable ) ) , <nl> Int32Constant ( 0 ) ) , <nl> mmm a / src / code - stub - assembler . h <nl> ppp b / src / code - stub - assembler . h <nl> class CodeStubAssembler : public compiler : : CodeAssembler { <nl> void Assert ( compiler : : Node * condition ) ; <nl> <nl> / / Check a value for smi - ness <nl> - compiler : : Node * WordIsSmi ( compiler : : Node * a ) ; <nl> + compiler : : Node * TaggedIsSmi ( compiler : : Node * a ) ; <nl> / / Check that the value is a non - negative smi . <nl> compiler : : Node * WordIsPositiveSmi ( compiler : : Node * a ) ; <nl> <nl> mmm a / src / code - stubs . cc <nl> ppp b / src / code - stubs . cc <nl> compiler : : Node * AddWithFeedbackStub : : Generate ( <nl> <nl> / / Check if the { lhs } is a Smi or a HeapObject . <nl> Label if_lhsissmi ( assembler ) , if_lhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_lhsissmi ) ; <nl> { <nl> / / Check if the { rhs } is also a Smi . <nl> Label if_rhsissmi ( assembler ) , if_rhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & if_rhsissmi , <nl> + & if_rhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_rhsissmi ) ; <nl> { <nl> compiler : : Node * AddWithFeedbackStub : : Generate ( <nl> <nl> / / Check if the { rhs } is Smi . <nl> Label if_rhsissmi ( assembler ) , if_rhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & if_rhsissmi , <nl> + & if_rhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_rhsissmi ) ; <nl> { <nl> compiler : : Node * AddWithFeedbackStub : : Generate ( <nl> assembler - > Bind ( & check_string ) ; <nl> { <nl> / / Check if the { rhs } is a smi , and exit the string check early if it is . <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( rhs ) , & call_add_stub ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( rhs ) , & call_add_stub ) ; <nl> <nl> Node * lhs_instance_type = assembler - > LoadMapInstanceType ( lhs_map ) ; <nl> <nl> compiler : : Node * SubtractWithFeedbackStub : : Generate ( <nl> <nl> / / Check if the { lhs } is a Smi or a HeapObject . <nl> Label if_lhsissmi ( assembler ) , if_lhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( lhs ) , & if_lhsissmi , & if_lhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_lhsissmi ) ; <nl> { <nl> / / Check if the { rhs } is also a Smi . <nl> Label if_rhsissmi ( assembler ) , if_rhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & if_rhsissmi , <nl> + & if_rhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_rhsissmi ) ; <nl> { <nl> compiler : : Node * SubtractWithFeedbackStub : : Generate ( <nl> <nl> / / Check if the { rhs } is a Smi . <nl> Label if_rhsissmi ( assembler ) , if_rhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & if_rhsissmi , <nl> + & if_rhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_rhsissmi ) ; <nl> { <nl> compiler : : Node * SubtractWithFeedbackStub : : Generate ( <nl> assembler - > GotoUnless ( lhs_is_oddball , & call_with_any_feedback ) ; <nl> <nl> Label if_rhsissmi ( assembler ) , if_rhsisnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & if_rhsissmi , & if_rhsisnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & if_rhsissmi , <nl> + & if_rhsisnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_rhsissmi ) ; <nl> { <nl> compiler : : Node * MultiplyWithFeedbackStub : : Generate ( <nl> Node * number_map = assembler - > HeapNumberMapConstant ( ) ; <nl> <nl> Label lhs_is_smi ( assembler ) , lhs_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( lhs ) , & lhs_is_smi , & lhs_is_not_smi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( lhs ) , & lhs_is_smi , & lhs_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & lhs_is_smi ) ; <nl> { <nl> Label rhs_is_smi ( assembler ) , rhs_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & rhs_is_smi , & rhs_is_not_smi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & rhs_is_smi , <nl> + & rhs_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & rhs_is_smi ) ; <nl> { <nl> compiler : : Node * MultiplyWithFeedbackStub : : Generate ( <nl> / / in case of overflow . <nl> var_result . Bind ( assembler - > SmiMul ( lhs , rhs ) ) ; <nl> var_type_feedback . Bind ( assembler - > Select ( <nl> - assembler - > WordIsSmi ( var_result . value ( ) ) , <nl> + assembler - > TaggedIsSmi ( var_result . value ( ) ) , <nl> assembler - > Int32Constant ( BinaryOperationFeedback : : kSignedSmall ) , <nl> assembler - > Int32Constant ( BinaryOperationFeedback : : kNumber ) , <nl> MachineRepresentation : : kWord32 ) ) ; <nl> compiler : : Node * MultiplyWithFeedbackStub : : Generate ( <nl> <nl> / / Check if { rhs } is a Smi . <nl> Label rhs_is_smi ( assembler ) , rhs_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( rhs ) , & rhs_is_smi , & rhs_is_not_smi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( rhs ) , & rhs_is_smi , <nl> + & rhs_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & rhs_is_smi ) ; <nl> { <nl> compiler : : Node * DivideWithFeedbackStub : : Generate ( <nl> Node * number_map = assembler - > HeapNumberMapConstant ( ) ; <nl> <nl> Label dividend_is_smi ( assembler ) , dividend_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( dividend ) , & dividend_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( dividend ) , & dividend_is_smi , <nl> & dividend_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & dividend_is_smi ) ; <nl> { <nl> Label divisor_is_smi ( assembler ) , divisor_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( divisor ) , & divisor_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( divisor ) , & divisor_is_smi , <nl> & divisor_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & divisor_is_smi ) ; <nl> compiler : : Node * DivideWithFeedbackStub : : Generate ( <nl> <nl> / / Check if { divisor } is a Smi . <nl> Label divisor_is_smi ( assembler ) , divisor_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( divisor ) , & divisor_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( divisor ) , & divisor_is_smi , <nl> & divisor_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & divisor_is_smi ) ; <nl> compiler : : Node * ModulusWithFeedbackStub : : Generate ( <nl> Node * number_map = assembler - > HeapNumberMapConstant ( ) ; <nl> <nl> Label dividend_is_smi ( assembler ) , dividend_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( dividend ) , & dividend_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( dividend ) , & dividend_is_smi , <nl> & dividend_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & dividend_is_smi ) ; <nl> { <nl> Label divisor_is_smi ( assembler ) , divisor_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( divisor ) , & divisor_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( divisor ) , & divisor_is_smi , <nl> & divisor_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & divisor_is_smi ) ; <nl> { <nl> var_result . Bind ( assembler - > SmiMod ( dividend , divisor ) ) ; <nl> var_type_feedback . Bind ( assembler - > Select ( <nl> - assembler - > WordIsSmi ( var_result . value ( ) ) , <nl> + assembler - > TaggedIsSmi ( var_result . value ( ) ) , <nl> assembler - > Int32Constant ( BinaryOperationFeedback : : kSignedSmall ) , <nl> assembler - > Int32Constant ( BinaryOperationFeedback : : kNumber ) ) ) ; <nl> assembler - > Goto ( & end ) ; <nl> compiler : : Node * ModulusWithFeedbackStub : : Generate ( <nl> <nl> / / Check if { divisor } is a Smi . <nl> Label divisor_is_smi ( assembler ) , divisor_is_not_smi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( divisor ) , & divisor_is_smi , <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( divisor ) , & divisor_is_smi , <nl> & divisor_is_not_smi ) ; <nl> <nl> assembler - > Bind ( & divisor_is_smi ) ; <nl> compiler : : Node * IncStub : : Generate ( CodeStubAssembler * assembler , <nl> value = value_var . value ( ) ; <nl> <nl> Label if_issmi ( assembler ) , if_isnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( value ) , & if_issmi , & if_isnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( value ) , & if_issmi , & if_isnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_issmi ) ; <nl> { <nl> compiler : : Node * DecStub : : Generate ( CodeStubAssembler * assembler , <nl> value = value_var . value ( ) ; <nl> <nl> Label if_issmi ( assembler ) , if_isnotsmi ( assembler ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( value ) , & if_issmi , & if_isnotsmi ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( value ) , & if_issmi , & if_isnotsmi ) ; <nl> <nl> assembler - > Bind ( & if_issmi ) ; <nl> { <nl> void StoreGlobalStub : : GenerateAssembly ( CodeStubAssembler * assembler ) const { <nl> Node * weak_cell = assembler - > HeapConstant ( isolate ( ) - > factory ( ) - > NewWeakCell ( <nl> StoreGlobalStub : : property_cell_placeholder ( isolate ( ) ) ) ) ; <nl> Node * cell = assembler - > LoadWeakCellValue ( weak_cell ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( cell ) , & miss ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( cell ) , & miss ) ; <nl> <nl> / / Load the payload of the global parameter cell . A hole indicates that the <nl> / / cell has been invalidated and that the store must be handled by the <nl> void StoreGlobalStub : : GenerateAssembly ( CodeStubAssembler * assembler ) const { <nl> if ( cell_type = = PropertyCellType : : kConstantType ) { <nl> switch ( constant_type ( ) ) { <nl> case PropertyCellConstantType : : kSmi : <nl> - assembler - > GotoUnless ( assembler - > WordIsSmi ( value ) , & miss ) ; <nl> + assembler - > GotoUnless ( assembler - > TaggedIsSmi ( value ) , & miss ) ; <nl> value_is_smi = true ; <nl> break ; <nl> case PropertyCellConstantType : : kStableMap : { <nl> void StoreGlobalStub : : GenerateAssembly ( CodeStubAssembler * assembler ) const { <nl> / / are the maps that were originally in the cell or not . If optimized <nl> / / code will deopt when a cell has a unstable map and if it has a <nl> / / dependency on a stable map , it will deopt if the map destabilizes . <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( value ) , & miss ) ; <nl> - assembler - > GotoIf ( assembler - > WordIsSmi ( cell_contents ) , & miss ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( value ) , & miss ) ; <nl> + assembler - > GotoIf ( assembler - > TaggedIsSmi ( cell_contents ) , & miss ) ; <nl> Node * expected_map = assembler - > LoadMap ( cell_contents ) ; <nl> Node * map = assembler - > LoadMap ( value ) ; <nl> assembler - > GotoIf ( assembler - > WordNotEqual ( expected_map , map ) , & miss ) ; <nl> void SingleArgumentConstructorCommon ( CodeStubAssembler * assembler , <nl> Label call_runtime ( assembler , Label : : kDeferred ) ; <nl> <nl> Node * size = assembler - > Parameter ( Descriptor : : kArraySizeSmiParameter ) ; <nl> - assembler - > Branch ( assembler - > WordIsSmi ( size ) , & smi_size , & call_runtime ) ; <nl> + assembler - > Branch ( assembler - > TaggedIsSmi ( size ) , & smi_size , & call_runtime ) ; <nl> <nl> assembler - > Bind ( & smi_size ) ; <nl> <nl> mmm a / src / interpreter / interpreter - assembler . cc <nl> ppp b / src / interpreter / interpreter - assembler . cc <nl> Node * InterpreterAssembler : : CallJSWithFeedback ( Node * function , Node * context , <nl> { <nl> / / The compare above could have been a SMI / SMI comparison . Guard against <nl> / / this convincing us that we have a monomorphic JSFunction . <nl> - Node * is_smi = WordIsSmi ( function ) ; <nl> + Node * is_smi = TaggedIsSmi ( function ) ; <nl> GotoIf ( is_smi , & extra_checks ) ; <nl> <nl> / / Increment the call count . <nl> Node * InterpreterAssembler : : CallJSWithFeedback ( Node * function , Node * context , <nl> HeapConstant ( TypeFeedbackVector : : UninitializedSentinel ( isolate ( ) ) ) ) ; <nl> GotoUnless ( is_uninitialized , & mark_megamorphic ) ; <nl> <nl> - Node * is_smi = WordIsSmi ( function ) ; <nl> + Node * is_smi = TaggedIsSmi ( function ) ; <nl> GotoIf ( is_smi , & mark_megamorphic ) ; <nl> <nl> / / Check if function is an object of JSFunction type <nl> Node * InterpreterAssembler : : CallConstruct ( Node * constructor , Node * context , <nl> GotoIf ( is_feedback_unavailable , & call_construct ) ; <nl> <nl> / / Check that the constructor is not a smi . <nl> - Node * is_smi = WordIsSmi ( constructor ) ; <nl> + Node * is_smi = TaggedIsSmi ( constructor ) ; <nl> GotoIf ( is_smi , & call_construct ) ; <nl> <nl> / / Check that constructor is a JSFunction . <nl> Node * InterpreterAssembler : : CallConstruct ( Node * constructor , Node * context , <nl> / / If the weak cell is cleared , we have a new chance to become <nl> / / monomorphic . <nl> Comment ( " check if weak cell is cleared " ) ; <nl> - Node * is_smi = WordIsSmi ( feedback_value ) ; <nl> + Node * is_smi = TaggedIsSmi ( feedback_value ) ; <nl> BranchIf ( is_smi , & initialize , & mark_megamorphic ) ; <nl> } <nl> <nl> Node * InterpreterAssembler : : TruncateTaggedToWord32WithFeedback ( <nl> <nl> / / Check if the { value } is a Smi or a HeapObject . <nl> Label if_valueissmi ( this ) , if_valueisnotsmi ( this ) ; <nl> - Branch ( WordIsSmi ( value ) , & if_valueissmi , & if_valueisnotsmi ) ; <nl> + Branch ( TaggedIsSmi ( value ) , & if_valueissmi , & if_valueisnotsmi ) ; <nl> <nl> Bind ( & if_valueissmi ) ; <nl> { <nl> mmm a / src / interpreter / interpreter - intrinsics . cc <nl> ppp b / src / interpreter / interpreter - intrinsics . cc <nl> Node * IntrinsicsHelper : : IsInstanceType ( Node * input , int type ) { <nl> InterpreterAssembler : : Label if_not_smi ( assembler_ ) , return_true ( assembler_ ) , <nl> return_false ( assembler_ ) , end ( assembler_ ) ; <nl> Node * arg = __ LoadRegister ( input ) ; <nl> - __ GotoIf ( __ WordIsSmi ( arg ) , & return_false ) ; <nl> + __ GotoIf ( __ TaggedIsSmi ( arg ) , & return_false ) ; <nl> <nl> Node * condition = CompareInstanceType ( arg , type , kInstanceTypeEqual ) ; <nl> __ Branch ( condition , & return_true , & return_false ) ; <nl> Node * IntrinsicsHelper : : IsJSReceiver ( Node * input , Node * arg_count , <nl> end ( assembler_ ) ; <nl> <nl> Node * arg = __ LoadRegister ( input ) ; <nl> - __ GotoIf ( __ WordIsSmi ( arg ) , & return_false ) ; <nl> + __ GotoIf ( __ TaggedIsSmi ( arg ) , & return_false ) ; <nl> <nl> STATIC_ASSERT ( LAST_TYPE = = LAST_JS_RECEIVER_TYPE ) ; <nl> Node * condition = CompareInstanceType ( arg , FIRST_JS_RECEIVER_TYPE , <nl> Node * IntrinsicsHelper : : IsSmi ( Node * input , Node * arg_count , Node * context ) { <nl> <nl> Node * arg = __ LoadRegister ( input ) ; <nl> <nl> - __ Branch ( __ WordIsSmi ( arg ) , & if_smi , & if_not_smi ) ; <nl> + __ Branch ( __ TaggedIsSmi ( arg ) , & if_smi , & if_not_smi ) ; <nl> __ Bind ( & if_smi ) ; <nl> { <nl> return_value . Bind ( __ BooleanConstant ( true ) ) ; <nl> Node * IntrinsicsHelper : : ValueOf ( Node * args_reg , Node * arg_count , <nl> return_value . Bind ( object ) ; <nl> <nl> / / If the object is a smi return the object . <nl> - __ GotoIf ( __ WordIsSmi ( object ) , & done ) ; <nl> + __ GotoIf ( __ TaggedIsSmi ( object ) , & done ) ; <nl> <nl> / / If the object is not a value type , return the object . <nl> Node * condition = <nl> Node * IntrinsicsHelper : : ClassOf ( Node * args_reg , Node * arg_count , <nl> Node * object = __ LoadRegister ( args_reg ) ; <nl> <nl> / / If the object is not a JSReceiver , we return null . <nl> - __ GotoIf ( __ WordIsSmi ( object ) , & null ) ; <nl> + __ GotoIf ( __ TaggedIsSmi ( object ) , & null ) ; <nl> STATIC_ASSERT ( LAST_JS_RECEIVER_TYPE = = LAST_TYPE ) ; <nl> Node * is_js_receiver = CompareInstanceType ( object , FIRST_JS_RECEIVER_TYPE , <nl> kInstanceTypeGreaterThanOrEqual ) ; <nl> mmm a / src / interpreter / interpreter . cc <nl> ppp b / src / interpreter / interpreter . cc <nl> void Interpreter : : DoCompareOpWithFeedback ( Token : : Value compare_op , <nl> Variable var_type_feedback ( assembler , MachineRepresentation : : kWord32 ) ; <nl> Label lhs_is_smi ( assembler ) , lhs_is_not_smi ( assembler ) , <nl> gather_rhs_type ( assembler ) , do_compare ( assembler ) ; <nl> - __ Branch ( __ WordIsSmi ( lhs ) , & lhs_is_smi , & lhs_is_not_smi ) ; <nl> + __ Branch ( __ TaggedIsSmi ( lhs ) , & lhs_is_smi , & lhs_is_not_smi ) ; <nl> <nl> __ Bind ( & lhs_is_smi ) ; <nl> var_type_feedback . Bind ( <nl> void Interpreter : : DoCompareOpWithFeedback ( Token : : Value compare_op , <nl> __ Bind ( & gather_rhs_type ) ; <nl> { <nl> Label rhs_is_smi ( assembler ) ; <nl> - __ GotoIf ( __ WordIsSmi ( rhs ) , & rhs_is_smi ) ; <nl> + __ GotoIf ( __ TaggedIsSmi ( rhs ) , & rhs_is_smi ) ; <nl> <nl> Node * rhs_map = __ LoadMap ( rhs ) ; <nl> Node * rhs_type = <nl> void Interpreter : : DoBitwiseBinaryOp ( Token : : Value bitwise_op , <nl> } <nl> <nl> Node * result_type = <nl> - __ Select ( __ WordIsSmi ( result ) , <nl> + __ Select ( __ TaggedIsSmi ( result ) , <nl> __ Int32Constant ( BinaryOperationFeedback : : kSignedSmall ) , <nl> __ Int32Constant ( BinaryOperationFeedback : : kNumber ) ) ; <nl> <nl> if ( FLAG_debug_code ) { <nl> Label ok ( assembler ) ; <nl> - __ GotoIf ( __ WordIsSmi ( result ) , & ok ) ; <nl> + __ GotoIf ( __ TaggedIsSmi ( result ) , & ok ) ; <nl> Node * result_map = __ LoadMap ( result ) ; <nl> __ AbortIfWordNotEqual ( result_map , __ HeapNumberMapConstant ( ) , <nl> kExpectedHeapNumber ) ; <nl> void Interpreter : : DoAddSmi ( InterpreterAssembler * assembler ) { <nl> <nl> / / { right } is known to be a Smi . <nl> / / Check if the { left } is a Smi take the fast path . <nl> - __ BranchIf ( __ WordIsSmi ( left ) , & fastpath , & slowpath ) ; <nl> + __ BranchIf ( __ TaggedIsSmi ( left ) , & fastpath , & slowpath ) ; <nl> __ Bind ( & fastpath ) ; <nl> { <nl> / / Try fast Smi addition first . <nl> void Interpreter : : DoSubSmi ( InterpreterAssembler * assembler ) { <nl> <nl> / / { right } is known to be a Smi . <nl> / / Check if the { left } is a Smi take the fast path . <nl> - __ BranchIf ( __ WordIsSmi ( left ) , & fastpath , & slowpath ) ; <nl> + __ BranchIf ( __ TaggedIsSmi ( left ) , & fastpath , & slowpath ) ; <nl> __ Bind ( & fastpath ) ; <nl> { <nl> / / Try fast Smi subtraction first . <nl> void Interpreter : : DoBitwiseOrSmi ( InterpreterAssembler * assembler ) { <nl> Node * value = __ Word32Or ( lhs_value , rhs_value ) ; <nl> Node * result = __ ChangeInt32ToTagged ( value ) ; <nl> Node * result_type = <nl> - __ Select ( __ WordIsSmi ( result ) , <nl> + __ Select ( __ TaggedIsSmi ( result ) , <nl> __ Int32Constant ( BinaryOperationFeedback : : kSignedSmall ) , <nl> __ Int32Constant ( BinaryOperationFeedback : : kNumber ) ) ; <nl> __ UpdateFeedback ( __ Word32Or ( result_type , var_lhs_type_feedback . value ( ) ) , <nl> void Interpreter : : DoBitwiseAndSmi ( InterpreterAssembler * assembler ) { <nl> Node * value = __ Word32And ( lhs_value , rhs_value ) ; <nl> Node * result = __ ChangeInt32ToTagged ( value ) ; <nl> Node * result_type = <nl> - __ Select ( __ WordIsSmi ( result ) , <nl> + __ Select ( __ TaggedIsSmi ( result ) , <nl> __ Int32Constant ( BinaryOperationFeedback : : kSignedSmall ) , <nl> __ Int32Constant ( BinaryOperationFeedback : : kNumber ) ) ; <nl> __ UpdateFeedback ( __ Word32Or ( result_type , var_lhs_type_feedback . value ( ) ) , <nl> void Interpreter : : DoShiftLeftSmi ( InterpreterAssembler * assembler ) { <nl> Node * value = __ Word32Shl ( lhs_value , shift_count ) ; <nl> Node * result = __ ChangeInt32ToTagged ( value ) ; <nl> Node * result_type = <nl> - __ Select ( __ WordIsSmi ( result ) , <nl> + __ Select ( __ TaggedIsSmi ( result ) , <nl> __ Int32Constant ( BinaryOperationFeedback : : kSignedSmall ) , <nl> __ Int32Constant ( BinaryOperationFeedback : : kNumber ) ) ; <nl> __ UpdateFeedback ( __ Word32Or ( result_type , var_lhs_type_feedback . value ( ) ) , <nl> void Interpreter : : DoShiftRightSmi ( InterpreterAssembler * assembler ) { <nl> Node * value = __ Word32Sar ( lhs_value , shift_count ) ; <nl> Node * result = __ ChangeInt32ToTagged ( value ) ; <nl> Node * result_type = <nl> - __ Select ( __ WordIsSmi ( result ) , <nl> + __ Select ( __ TaggedIsSmi ( result ) , <nl> __ Int32Constant ( BinaryOperationFeedback : : kSignedSmall ) , <nl> __ Int32Constant ( BinaryOperationFeedback : : kNumber ) ) ; <nl> __ UpdateFeedback ( __ Word32Or ( result_type , var_lhs_type_feedback . value ( ) ) , <nl>
|
[ stubs ] Renames WordIsSmi to TaggedIsSmi , introducing an appropriate bitcast of the parameter .
|
v8/v8
|
87cc641e8c24b62ddb61306efe54b9bcb1be9cf3
|
2016-10-12T10:01:01Z
|
mmm a / src / mongo / db / catalog / collection_options . cpp <nl> ppp b / src / mongo / db / catalog / collection_options . cpp <nl> namespace mongo { <nl> Status CollectionOptions : : parse ( const BSONObj & options ) { <nl> reset ( ) ; <nl> <nl> + / / During parsing , ignore some validation errors in order to accept options objects that <nl> + / / were valid in previous versions of the server . SERVER - 13737 . <nl> BSONObjIterator i ( options ) ; <nl> while ( i . more ( ) ) { <nl> BSONElement e = i . next ( ) ; <nl> namespace mongo { <nl> capped = e . trueValue ( ) ; <nl> } <nl> else if ( fieldName = = " size " ) { <nl> - if ( ! e . isNumber ( ) ) <nl> - return Status ( ErrorCodes : : BadValue , " size has to be a number " ) ; <nl> + if ( ! e . isNumber ( ) ) { <nl> + / / Ignoring for backwards compatibility . <nl> + continue ; <nl> + } <nl> cappedSize = e . numberLong ( ) ; <nl> if ( cappedSize < 0 ) <nl> return Status ( ErrorCodes : : BadValue , " size has to be > = 0 " ) ; <nl> namespace mongo { <nl> cappedSize & = 0xffffffffffffff00LL ; <nl> } <nl> else if ( fieldName = = " max " ) { <nl> - if ( ! e . isNumber ( ) ) <nl> - return Status ( ErrorCodes : : BadValue , " max has to be a number " ) ; <nl> + if ( ! options [ " capped " ] . trueValue ( ) | | ! e . isNumber ( ) ) { <nl> + / / Ignoring for backwards compatibility . <nl> + continue ; <nl> + } <nl> cappedMaxDocs = e . numberLong ( ) ; <nl> if ( ! validMaxCappedDocs ( & cappedMaxDocs ) ) <nl> return Status ( ErrorCodes : : BadValue , <nl> mmm a / src / mongo / db / catalog / collection_options_test . cpp <nl> ppp b / src / mongo / db / catalog / collection_options_test . cpp <nl> namespace mongo { <nl> checkRoundTrip ( options ) ; <nl> } <nl> <nl> + TEST ( CollectionOptions , ErrorBadSize ) { <nl> + ASSERT_NOT_OK ( CollectionOptions ( ) . parse ( fromjson ( " { capped : true , size : - 1 } " ) ) ) ; <nl> + ASSERT_NOT_OK ( CollectionOptions ( ) . parse ( fromjson ( " { capped : false , size : - 1 } " ) ) ) ; <nl> + } <nl> + <nl> + TEST ( CollectionOptions , ErrorBadMax ) { <nl> + ASSERT_NOT_OK ( CollectionOptions ( ) . parse ( BSON ( " capped " < < true < < " max " <nl> + < < ( 1LL < < 31 ) ) ) ) ; <nl> + } <nl> + <nl> + TEST ( CollectionOptions , IgnoreSizeWrongType ) { <nl> + CollectionOptions options ; <nl> + ASSERT_OK ( options . parse ( fromjson ( " { size : undefined , capped : undefined } " ) ) ) ; <nl> + ASSERT_EQUALS ( options . capped , false ) ; <nl> + ASSERT_EQUALS ( options . cappedSize , 0 ) ; <nl> + } <nl> + <nl> + TEST ( CollectionOptions , IgnoreMaxWrongType ) { <nl> + CollectionOptions options ; <nl> + ASSERT_OK ( options . parse ( fromjson ( " { capped : true , size : 1024 , max : ' ' } " ) ) ) ; <nl> + ASSERT_EQUALS ( options . capped , true ) ; <nl> + ASSERT_EQUALS ( options . cappedSize , 1024 ) ; <nl> + ASSERT_EQUALS ( options . cappedMaxDocs , 0 ) ; <nl> + } <nl> + <nl> + TEST ( CollectionOptions , IgnoreUnregisteredFields ) { <nl> + ASSERT_OK ( CollectionOptions ( ) . parse ( BSON ( " create " < < " c " ) ) ) ; <nl> + ASSERT_OK ( CollectionOptions ( ) . parse ( BSON ( " foo " < < " bar " ) ) ) ; <nl> + } <nl> + <nl> } <nl>
|
SERVER - 13737 CollectionOptions parser skip size / max if non - numeric
|
mongodb/mongo
|
0a0ba030626243e3482830f485a3ecd79da1b7c8
|
2014-05-21T23:47:49Z
|
mmm a / arangod / VocBase / SingleServerTraverser . cpp <nl> ppp b / arangod / VocBase / SingleServerTraverser . cpp <nl> static int FetchDocumentById ( arangodb : : Transaction * trx , <nl> return res ; <nl> } <nl> <nl> - SingleServerEdgeCursor : : SingleServerEdgeCursor ( size_t nrCursors ) <nl> - : _cursors ( ) , _currentCursor ( 0 ) , _currentSubCursor ( 0 ) , _cachePos ( 0 ) { <nl> + SingleServerEdgeCursor : : SingleServerEdgeCursor ( <nl> + size_t nrCursors , std : : vector < size_t > const * mapping ) <nl> + : _cursors ( ) , <nl> + _currentCursor ( 0 ) , <nl> + _currentSubCursor ( 0 ) , <nl> + _cachePos ( 0 ) , <nl> + _internalCursorMapping ( mapping ) { <nl> _cursors . reserve ( nrCursors ) ; <nl> _cache . reserve ( 1000 ) ; <nl> } ; <nl> bool SingleServerEdgeCursor : : next ( std : : vector < VPackSlice > & result , <nl> _cachePos + + ; <nl> if ( _cachePos < _cache . size ( ) ) { <nl> result . emplace_back ( _cache [ _cachePos ] - > vpack ( ) ) ; <nl> - cursorId = _currentCursor ; <nl> + if ( _internalCursorMapping ! = nullptr ) { <nl> + TRI_ASSERT ( _currentCursor < _internalCursorMapping - > size ( ) ) ; <nl> + cursorId = _internalCursorMapping - > at ( _currentCursor ) ; <nl> + } else { <nl> + cursorId = _currentCursor ; <nl> + } <nl> return true ; <nl> } <nl> / / We need to refill the cache . <nl> bool SingleServerEdgeCursor : : next ( std : : vector < VPackSlice > & result , <nl> } while ( _cache . empty ( ) ) ; <nl> TRI_ASSERT ( _cachePos < _cache . size ( ) ) ; <nl> result . emplace_back ( _cache [ _cachePos ] - > vpack ( ) ) ; <nl> - cursorId = _currentCursor ; <nl> + if ( _internalCursorMapping ! = nullptr ) { <nl> + TRI_ASSERT ( _currentCursor < _internalCursorMapping - > size ( ) ) ; <nl> + cursorId = _internalCursorMapping - > at ( _currentCursor ) ; <nl> + } else { <nl> + cursorId = _currentCursor ; <nl> + } <nl> return true ; <nl> } <nl> <nl> bool SingleServerEdgeCursor : : readAll ( std : : unordered_set < VPackSlice > & result , <nl> if ( _currentCursor > = _cursors . size ( ) ) { <nl> return false ; <nl> } <nl> - cursorId = _currentCursor ; <nl> + if ( _internalCursorMapping ! = nullptr ) { <nl> + TRI_ASSERT ( _currentCursor < _internalCursorMapping - > size ( ) ) ; <nl> + cursorId = _internalCursorMapping - > at ( _currentCursor ) ; <nl> + } else { <nl> + cursorId = _currentCursor ; <nl> + } <nl> auto & cursorSet = _cursors [ _currentCursor ] ; <nl> for ( auto & cursor : cursorSet ) { <nl> while ( cursor - > hasMore ( ) ) { <nl> mmm a / arangod / VocBase / SingleServerTraverser . h <nl> ppp b / arangod / VocBase / SingleServerTraverser . h <nl> class SingleServerEdgeCursor : public EdgeCursor { <nl> size_t _currentSubCursor ; <nl> std : : vector < TRI_doc_mptr_t * > _cache ; <nl> size_t _cachePos ; <nl> + std : : vector < size_t > const * _internalCursorMapping ; <nl> <nl> public : <nl> - explicit SingleServerEdgeCursor ( size_t ) ; <nl> + explicit SingleServerEdgeCursor ( size_t , <nl> + std : : vector < size_t > const * mapping = nullptr ) ; <nl> <nl> ~ SingleServerEdgeCursor ( ) { <nl> for ( auto & it : _cursors ) { <nl>
|
Added a mapping for Traverser cursor ids .
|
arangodb/arangodb
|
053e7fcc6bc5bc3f5c78cb9b923964dc519bf895
|
2016-10-11T09:03:36Z
|
mmm a / xbmc / video / VideoDatabase . cpp <nl> ppp b / xbmc / video / VideoDatabase . cpp <nl> string CVideoDatabase : : GetArtForItem ( int mediaId , const string & mediaType , const <nl> return GetSingleValue ( " art " , " url " , PrepareSQL ( " media_id = % i AND media_type = ' % s ' AND type = ' % s ' " , mediaId , mediaType . c_str ( ) , artType . c_str ( ) ) ) ; <nl> } <nl> <nl> + bool CVideoDatabase : : GetTvShowSeasonArt ( int showId , map < int , string > & seasonArt ) <nl> + { <nl> + try <nl> + { <nl> + if ( NULL = = m_pDB . get ( ) ) return false ; <nl> + if ( NULL = = m_pDS2 . get ( ) ) return false ; / / using dataset 2 as we ' re likely called in loops on dataset 1 <nl> + <nl> + / / get all seasons for this show <nl> + CStdString sql = PrepareSQL ( " select idSeason , season from seasons where idShow = % i " , showId ) ; <nl> + m_pDS2 - > query ( sql . c_str ( ) ) ; <nl> + <nl> + vector < pair < int , int > > seasons ; <nl> + while ( ! m_pDS2 - > eof ( ) ) <nl> + { <nl> + seasons . push_back ( make_pair ( m_pDS2 - > fv ( 0 ) . get_asInt ( ) , m_pDS2 - > fv ( 1 ) . get_asInt ( ) ) ) ; <nl> + m_pDS2 - > next ( ) ; <nl> + } <nl> + m_pDS2 - > close ( ) ; <nl> + <nl> + for ( vector < pair < int , int > > : : const_iterator i = seasons . begin ( ) ; i ! = seasons . end ( ) ; + + i ) <nl> + seasonArt . insert ( make_pair ( i - > second , GetArtForItem ( i - > first , " season " , " thumb " ) ) ) ; <nl> + } <nl> + catch ( . . . ) <nl> + { <nl> + CLog : : Log ( LOGERROR , " % s ( % d ) failed " , __FUNCTION__ , showId ) ; <nl> + } <nl> + return false ; <nl> + } <nl> + <nl> / / / \ brief GetStackTimes ( ) obtains any saved video times for the stacked file <nl> / / / \ retval Returns true if the stack times exist , false otherwise . <nl> bool CVideoDatabase : : GetStackTimes ( const CStdString & filePath , vector < int > & times ) <nl> mmm a / xbmc / video / VideoDatabase . h <nl> ppp b / xbmc / video / VideoDatabase . h <nl> class CVideoDatabase : public CDatabase <nl> void SetArtForItem ( int mediaId , const std : : string & mediaType , const std : : map < std : : string , std : : string > & art ) ; <nl> bool GetArtForItem ( int mediaId , const std : : string & mediaType , std : : map < std : : string , std : : string > & art ) ; <nl> std : : string GetArtForItem ( int mediaId , const std : : string & mediaType , const std : : string & artType ) ; <nl> + bool GetTvShowSeasonArt ( int mediaId , std : : map < int , std : : string > & seasonArt ) ; <nl> <nl> protected : <nl> int GetMovieId ( const CStdString & strFilenameAndPath ) ; <nl>
|
add GetTvShowSeasonArt helper to VideoDatabase
|
xbmc/xbmc
|
7e424534b558076a057fb315e4b357bfe98684f7
|
2012-05-08T06:14:05Z
|
mmm a / torch / csrc / jit / graph_executor . cpp <nl> ppp b / torch / csrc / jit / graph_executor . cpp <nl> bool needsGradient ( const std : : shared_ptr < const Graph > & graph ) { <nl> } <nl> <nl> void runNondiffOptimization ( std : : shared_ptr < Graph > & graph ) { <nl> + / / Run custom passes that different backends can register . <nl> + for ( const auto & pass : getCustomPreFusionPasses ( ) ) { <nl> + pass ( graph ) ; <nl> + } <nl> + <nl> / / decomposition pass , decompose certain ops that will be used in the <nl> / / following passes ( like batchmm and jit fusion ) <nl> if ( ! getProfilingMode ( ) ) { <nl> void runNondiffOptimization ( std : : shared_ptr < Graph > & graph ) { <nl> <nl> FuseGraph ( graph ) ; <nl> <nl> - / / Run custom passes that different backends can register . <nl> - / / This is done last to give internal optimization passes priority . <nl> - for ( const auto & pass : getCustomPasses ( ) ) { <nl> + / / Run custom post - fusion passes <nl> + for ( const auto & pass : getCustomPostFusionPasses ( ) ) { <nl> pass ( graph ) ; <nl> } <nl> } <nl> mmm a / torch / csrc / jit / pass_manager . cpp <nl> ppp b / torch / csrc / jit / pass_manager . cpp <nl> <nl> namespace torch { <nl> namespace jit { <nl> <nl> - std : : vector < Pass > & getCustomPasses ( ) { <nl> + std : : vector < Pass > & getCustomPostFusionPasses ( ) { <nl> static std : : vector < Pass > passes ; <nl> return passes ; <nl> } <nl> <nl> - RegisterPass : : RegisterPass ( Pass p ) { <nl> - getCustomPasses ( ) . emplace_back ( std : : move ( p ) ) ; <nl> + std : : vector < Pass > & getCustomPreFusionPasses ( ) { <nl> + static std : : vector < Pass > passes ; <nl> + return passes ; <nl> + } <nl> + <nl> + RegisterPostFusionPass : : RegisterPostFusionPass ( Pass p ) { <nl> + getCustomPostFusionPasses ( ) . emplace_back ( std : : move ( p ) ) ; <nl> + } <nl> + <nl> + RegisterPreFusionPass : : RegisterPreFusionPass ( Pass p ) { <nl> + getCustomPreFusionPasses ( ) . emplace_back ( std : : move ( p ) ) ; <nl> } <nl> <nl> } / / namespace jit <nl> mmm a / torch / csrc / jit / pass_manager . h <nl> ppp b / torch / csrc / jit / pass_manager . h <nl> <nl> <nl> # include < torch / csrc / jit / ir . h > <nl> <nl> - / * ` getCustomPasses ( ) ` returns a vector of passes that will be executed after <nl> - * differentiation but before any fusion . This is the de - facto location <nl> + / * ` getCustomPreFusionPasses ( ) ` returns a vector of passes that will be executed <nl> + * after differentiation but before any fusion . This is the de - facto location <nl> * for compiler backends to insert passes . <nl> * <nl> + * ` getCustomPostFusionPasses ( ) ` returns a vector of passes that will be <nl> + * executed after differentiation and after fusion ( if any ) . This is the <nl> + * location for fusion cleanup passes if they are needed . <nl> + * <nl> * Static registration of a pass can be done by creating a global <nl> - * ` RegisterPass r ( Pass ) ` variable in a compilation unit . <nl> + * ` Register { Pre , Post } FusionPass r ( Pass ) ` variable in a compilation unit . <nl> * <nl> - * pass_manager . h uses a Meyer ' s singleton <nl> - * to store a vector of ` Pass ` es , which modify the IR graph in place . <nl> + * pass_manager . h uses a Meyer ' s singleton to store a vector of ` Pass ` es , which <nl> + * modify the IR graph in place . <nl> * / <nl> <nl> namespace torch { <nl> namespace jit { <nl> / / A pass modifies a Graph in place . <nl> using Pass = std : : function < void ( std : : shared_ptr < Graph > & ) > ; <nl> <nl> - TORCH_API std : : vector < Pass > & getCustomPasses ( ) ; <nl> + TORCH_API std : : vector < Pass > & getCustomPostFusionPasses ( ) ; <nl> + TORCH_API std : : vector < Pass > & getCustomPreFusionPasses ( ) ; <nl> + <nl> + struct TORCH_API RegisterPostFusionPass { <nl> + RegisterPostFusionPass ( Pass p ) ; <nl> + } ; <nl> + <nl> + using RegisterPass = RegisterPostFusionPass ; <nl> <nl> - struct TORCH_API RegisterPass { <nl> - RegisterPass ( Pass p ) ; <nl> + struct TORCH_API RegisterPreFusionPass { <nl> + RegisterPreFusionPass ( Pass p ) ; <nl> } ; <nl> <nl> } / / namespace jit <nl>
|
Allow to register custom passes both before and after fusion . ( )
|
pytorch/pytorch
|
e1a895858f166a99dfd8a32b096dff4b270149ba
|
2020-02-15T00:28:52Z
|
mmm a / googlemock / docs / cook_book . md <nl> ppp b / googlemock / docs / cook_book . md <nl> generated method : <nl> ` noexcept ` method . <nl> * * * ` Calltype ( . . . ) ` * * - Sets the call type for the method ( e . g . to <nl> ` STDMETHODCALLTYPE ` ) , useful in Windows . <nl> + * * * ` ref ( . . . ) ` * * - Marks the method with the reference qualification <nl> + specified . Required if overriding a method that has reference <nl> + qualifications . Eg ` ref ( & ) ` or ` ref ( & & ) ` . <nl> <nl> # # # Dealing with unprotected commas <nl> <nl> mmm a / googlemock / include / gmock / gmock - function - mocker . h <nl> ppp b / googlemock / include / gmock / gmock - function - mocker . h <nl> namespace internal { <nl> template < typename T > <nl> using identity_t = T ; <nl> <nl> - template < typename MockType > <nl> - const MockType * AdjustConstness_const ( const MockType * mock ) { <nl> - return mock ; <nl> - } <nl> - <nl> - template < typename MockType > <nl> - MockType * AdjustConstness_ ( const MockType * mock ) { <nl> - return const_cast < MockType * > ( mock ) ; <nl> - } <nl> + template < typename Pattern > <nl> + struct ThisRefAdjuster { <nl> + template < typename T > <nl> + using AdjustT = typename std : : conditional < <nl> + std : : is_const < typename std : : remove_reference < Pattern > : : type > : : value , <nl> + typename std : : conditional < std : : is_lvalue_reference < Pattern > : : value , <nl> + const T & , const T & & > : : type , <nl> + typename std : : conditional < std : : is_lvalue_reference < Pattern > : : value , T & , <nl> + T & & > : : type > : : type ; <nl> + <nl> + template < typename MockType > <nl> + static AdjustT < MockType > Adjust ( const MockType & mock ) { <nl> + return static_cast < AdjustT < MockType > > ( const_cast < MockType & > ( mock ) ) ; <nl> + } <nl> + } ; <nl> <nl> } / / namespace internal <nl> <nl> using internal : : FunctionMocker ; <nl> # define GMOCK_INTERNAL_MOCK_METHOD_ARG_3 ( _Ret , _MethodName , _Args ) \ <nl> GMOCK_INTERNAL_MOCK_METHOD_ARG_4 ( _Ret , _MethodName , _Args , ( ) ) <nl> <nl> - # define GMOCK_INTERNAL_MOCK_METHOD_ARG_4 ( _Ret , _MethodName , _Args , _Spec ) \ <nl> - GMOCK_INTERNAL_ASSERT_PARENTHESIS ( _Args ) ; \ <nl> - GMOCK_INTERNAL_ASSERT_PARENTHESIS ( _Spec ) ; \ <nl> - GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE ( \ <nl> - GMOCK_PP_NARG0 _Args , GMOCK_INTERNAL_SIGNATURE ( _Ret , _Args ) ) ; \ <nl> - GMOCK_INTERNAL_ASSERT_VALID_SPEC ( _Spec ) \ <nl> - GMOCK_INTERNAL_MOCK_METHOD_IMPL ( \ <nl> - GMOCK_PP_NARG0 _Args , _MethodName , GMOCK_INTERNAL_HAS_CONST ( _Spec ) , \ <nl> - GMOCK_INTERNAL_HAS_OVERRIDE ( _Spec ) , GMOCK_INTERNAL_HAS_FINAL ( _Spec ) , \ <nl> - GMOCK_INTERNAL_GET_NOEXCEPT_SPEC ( _Spec ) , \ <nl> - GMOCK_INTERNAL_GET_CALLTYPE ( _Spec ) , \ <nl> + # define GMOCK_INTERNAL_MOCK_METHOD_ARG_4 ( _Ret , _MethodName , _Args , _Spec ) \ <nl> + GMOCK_INTERNAL_ASSERT_PARENTHESIS ( _Args ) ; \ <nl> + GMOCK_INTERNAL_ASSERT_PARENTHESIS ( _Spec ) ; \ <nl> + GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE ( \ <nl> + GMOCK_PP_NARG0 _Args , GMOCK_INTERNAL_SIGNATURE ( _Ret , _Args ) ) ; \ <nl> + GMOCK_INTERNAL_ASSERT_VALID_SPEC ( _Spec ) \ <nl> + GMOCK_INTERNAL_MOCK_METHOD_IMPL ( \ <nl> + GMOCK_PP_NARG0 _Args , _MethodName , GMOCK_INTERNAL_HAS_CONST ( _Spec ) , \ <nl> + GMOCK_INTERNAL_HAS_OVERRIDE ( _Spec ) , GMOCK_INTERNAL_HAS_FINAL ( _Spec ) , \ <nl> + GMOCK_INTERNAL_GET_NOEXCEPT_SPEC ( _Spec ) , \ <nl> + GMOCK_INTERNAL_GET_CALLTYPE ( _Spec ) , GMOCK_INTERNAL_GET_REF_SPEC ( _Spec ) , \ <nl> ( GMOCK_INTERNAL_SIGNATURE ( _Ret , _Args ) ) ) <nl> <nl> # define GMOCK_INTERNAL_MOCK_METHOD_ARG_5 ( . . . ) \ <nl> using internal : : FunctionMocker ; <nl> <nl> # define GMOCK_INTERNAL_MOCK_METHOD_IMPL ( _N , _MethodName , _Constness , \ <nl> _Override , _Final , _NoexceptSpec , \ <nl> - _CallType , _Signature ) \ <nl> + _CallType , _RefSpec , _Signature ) \ <nl> typename : : testing : : internal : : Function < GMOCK_PP_REMOVE_PARENS ( \ <nl> _Signature ) > : : Result \ <nl> GMOCK_INTERNAL_EXPAND ( _CallType ) \ <nl> _MethodName ( GMOCK_PP_REPEAT ( GMOCK_INTERNAL_PARAMETER , _Signature , _N ) ) \ <nl> - GMOCK_PP_IF ( _Constness , const , ) _NoexceptSpec \ <nl> + GMOCK_PP_IF ( _Constness , const , ) _RefSpec _NoexceptSpec \ <nl> GMOCK_PP_IF ( _Override , override , ) GMOCK_PP_IF ( _Final , final , ) { \ <nl> GMOCK_MOCKER_ ( _N , _Constness , _MethodName ) \ <nl> . SetOwnerAndName ( this , # _MethodName ) ; \ <nl> using internal : : FunctionMocker ; <nl> } \ <nl> : : testing : : MockSpec < GMOCK_PP_REMOVE_PARENS ( _Signature ) > gmock_ # # _MethodName ( \ <nl> GMOCK_PP_REPEAT ( GMOCK_INTERNAL_MATCHER_PARAMETER , _Signature , _N ) ) \ <nl> - GMOCK_PP_IF ( _Constness , const , ) { \ <nl> + GMOCK_PP_IF ( _Constness , const , ) _RefSpec { \ <nl> GMOCK_MOCKER_ ( _N , _Constness , _MethodName ) . RegisterOwner ( this ) ; \ <nl> return GMOCK_MOCKER_ ( _N , _Constness , _MethodName ) \ <nl> . With ( GMOCK_PP_REPEAT ( GMOCK_INTERNAL_MATCHER_ARGUMENT , , _N ) ) ; \ <nl> using internal : : FunctionMocker ; <nl> : : testing : : MockSpec < GMOCK_PP_REMOVE_PARENS ( _Signature ) > gmock_ # # _MethodName ( \ <nl> const : : testing : : internal : : WithoutMatchers & , \ <nl> GMOCK_PP_IF ( _Constness , const , ) : : testing : : internal : : Function < \ <nl> - GMOCK_PP_REMOVE_PARENS ( _Signature ) > * ) const _NoexceptSpec { \ <nl> - return GMOCK_PP_CAT ( : : testing : : internal : : AdjustConstness_ , \ <nl> - GMOCK_PP_IF ( _Constness , const , ) ) ( this ) \ <nl> - - > gmock_ # # _MethodName ( GMOCK_PP_REPEAT ( \ <nl> + GMOCK_PP_REMOVE_PARENS ( _Signature ) > * ) const _RefSpec _NoexceptSpec { \ <nl> + return : : testing : : internal : : ThisRefAdjuster < GMOCK_PP_IF ( \ <nl> + _Constness , const , ) int _RefSpec > : : Adjust ( * this ) \ <nl> + . gmock_ # # _MethodName ( GMOCK_PP_REPEAT ( \ <nl> GMOCK_INTERNAL_A_MATCHER_ARGUMENT , _Signature , _N ) ) ; \ <nl> } \ <nl> mutable : : testing : : FunctionMocker < GMOCK_PP_REMOVE_PARENS ( _Signature ) > \ <nl> using internal : : FunctionMocker ; <nl> GMOCK_PP_HAS_COMMA ( GMOCK_INTERNAL_DETECT_NOEXCEPT ( _i , _ , _elem ) ) , \ <nl> _elem , ) <nl> <nl> + # define GMOCK_INTERNAL_GET_REF_SPEC ( _Tuple ) \ <nl> + GMOCK_PP_FOR_EACH ( GMOCK_INTERNAL_REF_SPEC_IF_REF , ~ , _Tuple ) <nl> + <nl> + # define GMOCK_INTERNAL_REF_SPEC_IF_REF ( _i , _ , _elem ) \ <nl> + GMOCK_PP_IF ( GMOCK_PP_HAS_COMMA ( GMOCK_INTERNAL_DETECT_REF ( _i , _ , _elem ) ) , \ <nl> + GMOCK_PP_CAT ( GMOCK_INTERNAL_UNPACK_ , _elem ) , ) <nl> + <nl> # define GMOCK_INTERNAL_GET_CALLTYPE ( _Tuple ) \ <nl> GMOCK_PP_FOR_EACH ( GMOCK_INTERNAL_GET_CALLTYPE_IMPL , ~ , _Tuple ) <nl> <nl> using internal : : FunctionMocker ; <nl> GMOCK_PP_HAS_COMMA ( GMOCK_INTERNAL_DETECT_OVERRIDE ( _i , _ , _elem ) ) + \ <nl> GMOCK_PP_HAS_COMMA ( GMOCK_INTERNAL_DETECT_FINAL ( _i , _ , _elem ) ) + \ <nl> GMOCK_PP_HAS_COMMA ( GMOCK_INTERNAL_DETECT_NOEXCEPT ( _i , _ , _elem ) ) + \ <nl> + GMOCK_PP_HAS_COMMA ( GMOCK_INTERNAL_DETECT_REF ( _i , _ , _elem ) ) + \ <nl> GMOCK_INTERNAL_IS_CALLTYPE ( _elem ) ) = = 1 , \ <nl> GMOCK_PP_STRINGIZE ( \ <nl> _elem ) " cannot be recognized as a valid specification modifier . " ) ; <nl> using internal : : FunctionMocker ; <nl> <nl> # define GMOCK_INTERNAL_DETECT_NOEXCEPT_I_noexcept , <nl> <nl> + # define GMOCK_INTERNAL_DETECT_REF ( _i , _ , _elem ) \ <nl> + GMOCK_PP_CAT ( GMOCK_INTERNAL_DETECT_REF_I_ , _elem ) <nl> + <nl> + # define GMOCK_INTERNAL_DETECT_REF_I_ref , <nl> + <nl> + # define GMOCK_INTERNAL_UNPACK_ref ( x ) x <nl> + <nl> # define GMOCK_INTERNAL_GET_CALLTYPE_IMPL ( _i , _ , _elem ) \ <nl> GMOCK_PP_IF ( GMOCK_INTERNAL_IS_CALLTYPE ( _elem ) , \ <nl> GMOCK_INTERNAL_GET_VALUE_CALLTYPE , GMOCK_PP_EMPTY ) \ <nl> using internal : : FunctionMocker ; <nl> GMOCK_INTERNAL_ASSERT_VALID_SIGNATURE ( \ <nl> args_num , : : testing : : internal : : identity_t < __VA_ARGS__ > ) ; \ <nl> GMOCK_INTERNAL_MOCK_METHOD_IMPL ( \ <nl> - args_num , Method , GMOCK_PP_NARG0 ( constness ) , 0 , 0 , , ct , \ <nl> + args_num , Method , GMOCK_PP_NARG0 ( constness ) , 0 , 0 , , ct , , \ <nl> ( : : testing : : internal : : identity_t < __VA_ARGS__ > ) ) <nl> <nl> # define GMOCK_MOCKER_ ( arity , constness , Method ) \ <nl> mmm a / googlemock / test / gmock - function - mocker_test . cc <nl> ppp b / googlemock / test / gmock - function - mocker_test . cc <nl> class FooInterface { <nl> using fn_ptr = int ( * ) ( bool ) ; <nl> virtual fn_ptr ReturnsFunctionPointer2 ( int ) = 0 ; <nl> <nl> + virtual int RefQualifiedConstRef ( ) const & = 0 ; <nl> + virtual int RefQualifiedConstRefRef ( ) const & & = 0 ; <nl> + virtual int RefQualifiedRef ( ) & = 0 ; <nl> + virtual int RefQualifiedRefRef ( ) & & = 0 ; <nl> + <nl> + virtual int RefQualifiedOverloaded ( ) const & = 0 ; <nl> + virtual int RefQualifiedOverloaded ( ) const & & = 0 ; <nl> + virtual int RefQualifiedOverloaded ( ) & = 0 ; <nl> + virtual int RefQualifiedOverloaded ( ) & & = 0 ; <nl> + <nl> # if GTEST_OS_WINDOWS <nl> STDMETHOD_ ( int , CTNullary ) ( ) = 0 ; <nl> STDMETHOD_ ( bool , CTUnary ) ( int x ) = 0 ; <nl> class MockFoo : public FooInterface { <nl> ( Calltype ( STDMETHODCALLTYPE ) ) ) ; <nl> # endif / / GTEST_OS_WINDOWS <nl> <nl> + / / Test reference qualified functions . <nl> + MOCK_METHOD ( int , RefQualifiedConstRef , ( ) , ( const , ref ( & ) , override ) ) ; <nl> + MOCK_METHOD ( int , RefQualifiedConstRefRef , ( ) , ( const , ref ( & & ) , override ) ) ; <nl> + MOCK_METHOD ( int , RefQualifiedRef , ( ) , ( ref ( & ) , override ) ) ; <nl> + MOCK_METHOD ( int , RefQualifiedRefRef , ( ) , ( ref ( & & ) , override ) ) ; <nl> + <nl> + MOCK_METHOD ( int , RefQualifiedOverloaded , ( ) , ( const , ref ( & ) , override ) ) ; <nl> + MOCK_METHOD ( int , RefQualifiedOverloaded , ( ) , ( const , ref ( & & ) , override ) ) ; <nl> + MOCK_METHOD ( int , RefQualifiedOverloaded , ( ) , ( ref ( & ) , override ) ) ; <nl> + MOCK_METHOD ( int , RefQualifiedOverloaded , ( ) , ( ref ( & & ) , override ) ) ; <nl> + <nl> private : <nl> GTEST_DISALLOW_COPY_AND_ASSIGN_ ( MockFoo ) ; <nl> } ; <nl> class LegacyMockFoo : public FooInterface { <nl> std : : map < int , std : : string > ( ) ) ; <nl> # endif / / GTEST_OS_WINDOWS <nl> <nl> + / / We can ' t mock these with the old macros , but we need to define them to make <nl> + / / it concrete . <nl> + int RefQualifiedConstRef ( ) const & override { return 0 ; } <nl> + int RefQualifiedConstRefRef ( ) const & & override { return 0 ; } <nl> + int RefQualifiedRef ( ) & override { return 0 ; } <nl> + int RefQualifiedRefRef ( ) & & override { return 0 ; } <nl> + int RefQualifiedOverloaded ( ) const & override { return 0 ; } <nl> + int RefQualifiedOverloaded ( ) const & & override { return 0 ; } <nl> + int RefQualifiedOverloaded ( ) & override { return 0 ; } <nl> + int RefQualifiedOverloaded ( ) & & override { return 0 ; } <nl> + <nl> private : <nl> GTEST_DISALLOW_COPY_AND_ASSIGN_ ( LegacyMockFoo ) ; <nl> } ; <nl> TYPED_TEST ( FunctionMockerTest , MocksReturnTypeWithCommaAndCallType ) { <nl> <nl> # endif / / GTEST_OS_WINDOWS <nl> <nl> + TEST ( FunctionMockerTest , RefQualified ) { <nl> + MockFoo mock_foo ; <nl> + <nl> + EXPECT_CALL ( mock_foo , RefQualifiedConstRef ) . WillOnce ( Return ( 1 ) ) ; <nl> + EXPECT_CALL ( std : : move ( mock_foo ) , / / NOLINT <nl> + RefQualifiedConstRefRef ) <nl> + . WillOnce ( Return ( 2 ) ) ; <nl> + EXPECT_CALL ( mock_foo , RefQualifiedRef ) . WillOnce ( Return ( 3 ) ) ; <nl> + EXPECT_CALL ( std : : move ( mock_foo ) , / / NOLINT <nl> + RefQualifiedRefRef ) <nl> + . WillOnce ( Return ( 4 ) ) ; <nl> + <nl> + EXPECT_CALL ( static_cast < const MockFoo & > ( mock_foo ) , RefQualifiedOverloaded ( ) ) <nl> + . WillOnce ( Return ( 5 ) ) ; <nl> + EXPECT_CALL ( static_cast < const MockFoo & & > ( mock_foo ) , RefQualifiedOverloaded ( ) ) <nl> + . WillOnce ( Return ( 6 ) ) ; <nl> + EXPECT_CALL ( static_cast < MockFoo & > ( mock_foo ) , RefQualifiedOverloaded ( ) ) <nl> + . WillOnce ( Return ( 7 ) ) ; <nl> + EXPECT_CALL ( static_cast < MockFoo & & > ( mock_foo ) , RefQualifiedOverloaded ( ) ) <nl> + . WillOnce ( Return ( 8 ) ) ; <nl> + <nl> + EXPECT_EQ ( mock_foo . RefQualifiedConstRef ( ) , 1 ) ; <nl> + EXPECT_EQ ( std : : move ( mock_foo ) . RefQualifiedConstRefRef ( ) , 2 ) ; / / NOLINT <nl> + EXPECT_EQ ( mock_foo . RefQualifiedRef ( ) , 3 ) ; <nl> + EXPECT_EQ ( std : : move ( mock_foo ) . RefQualifiedRefRef ( ) , 4 ) ; / / NOLINT <nl> + <nl> + EXPECT_EQ ( std : : cref ( mock_foo ) . get ( ) . RefQualifiedOverloaded ( ) , 5 ) ; <nl> + EXPECT_EQ ( std : : move ( std : : cref ( mock_foo ) . get ( ) ) / / NOLINT <nl> + . RefQualifiedOverloaded ( ) , <nl> + 6 ) ; <nl> + EXPECT_EQ ( mock_foo . RefQualifiedOverloaded ( ) , 7 ) ; <nl> + EXPECT_EQ ( std : : move ( mock_foo ) . RefQualifiedOverloaded ( ) , 8 ) ; / / NOLINT <nl> + } <nl> + <nl> class MockB { <nl> public : <nl> MockB ( ) { } <nl>
|
Googletest export
|
google/googletest
|
d89b36302116233b8c6377e6e891083f41ee51c5
|
2020-11-06T18:23:55Z
|
mmm a / tensorflow / core / kernels / BUILD <nl> ppp b / tensorflow / core / kernels / BUILD <nl> tf_kernel_libraries ( <nl> " count_up_to_op " , <nl> " dense_update_ops " , <nl> " scatter_op " , <nl> + " scatter_nd_op " , <nl> " variable_ops " , <nl> ] , <nl> deps = [ <nl> " : assign_op " , <nl> " : bounds_check " , <nl> + " : fill_functor " , <nl> " : scatter_functor " , <nl> " / / tensorflow / core : framework " , <nl> " / / tensorflow / core : lib " , <nl> tf_cc_test ( <nl> size = " small " , <nl> srcs = [ " scatter_op_test . cc " ] , <nl> deps = [ <nl> + " : fill_functor " , <nl> " : ops_testutil " , <nl> " : ops_util " , <nl> " : scatter_op " , <nl> mmm a / tensorflow / python / ops / array_grad . py <nl> ppp b / tensorflow / python / ops / array_grad . py <nl> def _GatherGrad ( op , grad ) : <nl> <nl> <nl> @ ops . RegisterGradient ( " GatherNd " ) <nl> - def _GatherNdGrad ( unused_op , unused_grad ) : <nl> - raise NotImplementedError ( " Gradient for gather_nd is not implemented . " ) <nl> + def _GatherNdGrad ( op , grad ) : <nl> + ref = op . inputs [ 0 ] <nl> + ref_shape = array_ops . shape ( ref ) <nl> + indices = op . inputs [ 1 ] <nl> + ref_grad = array_ops . scatter_nd ( indices , grad , ref_shape ) <nl> + return [ ref_grad , None ] <nl> <nl> <nl> @ ops . RegisterGradient ( " CheckNumerics " ) <nl> def _ExtractImagePatchesGrad ( op , grad ) : <nl> grad_out = array_ops . transpose ( grad_out , ( 2 , 0 , 1 , 3 ) ) <nl> <nl> return [ grad_out ] <nl> + <nl> + <nl> + @ ops . RegisterGradient ( " ScatterNd " ) <nl> + def _ScatterNdGrad ( op , grad ) : <nl> + indices = op . inputs [ 0 ] <nl> + updates_grad = array_ops . gather_nd ( grad , indices ) <nl> + return [ None , updates_grad , None ] <nl> mmm a / tensorflow / python / ops / array_ops . py <nl> ppp b / tensorflow / python / ops / array_ops . py <nl> <nl> @ @ gather <nl> @ @ gather_nd <nl> @ @ unique_with_counts <nl> + @ @ scatter_nd <nl> @ @ dynamic_partition <nl> @ @ dynamic_stitch <nl> @ @ boolean_mask <nl> def setdiff1d ( x , y , index_dtype = dtypes . int32 , name = None ) : <nl> # pylint : enable = protected - access <nl> <nl> <nl> - def setdiff1d ( x , y , index_dtype = dtypes . int32 , name = None ) : <nl> - " " " Returns the difference between the ` x ` and ` y ` treated as sets . <nl> - <nl> - Args : <nl> - x : Set of values not assumed to be unique . <nl> - y : Set of values not assumed to be unique . <nl> - index_dtype : Output index type ( ` tf . int32 ` , ` tf . int64 ` ) default : ` tf . int32 ` <nl> - name : A name for the operation ( optional ) . <nl> - <nl> - <nl> - Returns : <nl> - A ` Tensor ` the same type as ` x ` and ` y ` <nl> - A ` Tensor ` that is of type ` index_dtype ` representing indices from . <nl> - " " " <nl> - <nl> - return gen_array_ops . list_diff ( x , y , index_dtype , name ) <nl> - <nl> - <nl> def shape ( input , name = None , out_type = dtypes . int32 ) : <nl> # pylint : disable = redefined - builtin <nl> " " " Returns the shape of a tensor . <nl> def where ( condition , x = None , y = None , name = None ) : <nl> raise ValueError ( " x and y must both be non - None or both be None . " ) <nl> <nl> <nl> - def where ( condition , x = None , y = None , name = None ) : <nl> - " " " Return the elements , either from ` x ` or ` y ` , depending on the ` condition ` . <nl> - <nl> - If both ` x ` and ` y ` are None , then this operation returns the coordinates of <nl> - true elements of ` condition ` . The coordinates are returned in a 2 - D tensor <nl> - where the first dimension ( rows ) represents the number of true elements , and <nl> - the second dimension ( columns ) represents the coordinates of the true <nl> - elements . Keep in mind , the shape of the output tensor can vary depending on <nl> - how many true values there are in input . Indices are output in row - major <nl> - order . <nl> - <nl> - If both non - None , ` x ` and ` y ` must have the same shape . <nl> - The ` condition ` tensor must be a scalar if ` x ` and ` y ` are scalar . <nl> - If ` x ` and ` y ` are vectors or higher rank , then ` condition ` must be either a <nl> - vector with size matching the first dimension of ` x ` , or must have the same <nl> - shape as ` x ` . <nl> - <nl> - The ` condition ` tensor acts as a mask that chooses , based on the value at each <nl> - element , whether the corresponding element / row in the output should be taken <nl> - from ` x ` ( if true ) or ` y ` ( if false ) . <nl> - <nl> - If ` condition ` is a vector and ` x ` and ` y ` are higher rank matrices , then it <nl> - chooses which row ( outer dimension ) to copy from ` x ` and ` y ` . If ` condition ` <nl> - has the same shape as ` x ` and ` y ` , then it chooses which element to copy from <nl> - ` x ` and ` y ` . <nl> - <nl> - Args : <nl> - condition : A ` Tensor ` of type ` bool ` <nl> - x : A Tensor which may have the same shape as ` condition ` . If ` condition ` is <nl> - rank 1 , ` x ` may have higher rank , but its first dimension must match the <nl> - size of ` condition ` . <nl> - y : A ` tensor ` with the same shape and type as ` x ` . <nl> - name : A name of the operation ( optional ) <nl> - <nl> - Returns : <nl> - A ` Tensor ` with the same type and shape as ` x ` , ` y ` if they are non - None . <nl> - A ` Tensor ` with shape ` ( num_true , dim_size ( condition ) ) ` . <nl> - <nl> - Raises : <nl> - ValueError : When exactly one of ` x ` or ` y ` is non - None . <nl> - " " " <nl> - if x is None and y is None : <nl> - return gen_array_ops . where ( input = condition , name = name ) <nl> - elif x is not None and y is not None : <nl> - return gen_math_ops . select ( condition = condition , t = x , e = y , name = name ) <nl> - else : <nl> - raise ValueError ( " x and y must both be non - None or both be None . " ) <nl> - <nl> - <nl> @ ops . RegisterShape ( " QuantizedReshape " ) <nl> def _DelegateQuantizedReshapeShape ( op ) : <nl> return common_shapes . call_cpp_shape_fn ( <nl> mmm a / tensorflow / python / ops / image_ops_test . py <nl> ppp b / tensorflow / python / ops / image_ops_test . py <nl> def testSynthetic ( self ) : <nl> jpeg0 , image0 , image1 , image2 = sess . run ( [ jpeg0 , image0 , image1 , image2 ] ) <nl> <nl> # The decoded - encoded image should be similar to the input <nl> - self . assertLess ( self . averageError ( image0 , image1 ) , 0 . 7 ) <nl> + self . assertLess ( self . averageError ( image0 , image1 ) , 0 . 6 ) <nl> <nl> # We should be very close to a fixpoint <nl> - self . assertLess ( self . averageError ( image1 , image2 ) , 0 . 6 ) <nl> + self . assertLess ( self . averageError ( image1 , image2 ) , 0 . 02 ) <nl> <nl> # Smooth ramps compress well ( input size is 153600 ) <nl> self . assertGreaterEqual ( len ( jpeg0 ) , 5000 ) <nl> mmm a / tensorflow / python / ops / state_grad . py <nl> ppp b / tensorflow / python / ops / state_grad . py <nl> <nl> from __future__ import print_function <nl> <nl> from tensorflow . python . framework import ops <nl> - from tensorflow . python . ops import state_ops <nl> + <nl> <nl> # TODO ( b / 31222613 ) : These ops may be differentiable , and there may be <nl> # latent bugs here . <nl> <nl> <nl> <nl> ops . NotDifferentiable ( " ScatterDiv " ) <nl> + <nl> + <nl> + ops . NotDifferentiable ( " ScatterNdUpdate " ) <nl> + <nl> + ops . NotDifferentiable ( " ScatterNdAdd " ) <nl> + <nl> + ops . NotDifferentiable ( " ScatterNdSub " ) <nl> + <nl> + ops . NotDifferentiable ( " ScatterNdMul " ) <nl> + <nl> + ops . NotDifferentiable ( " ScatterNdDiv " ) <nl> mmm a / tensorflow / python / ops / variables . py <nl> ppp b / tensorflow / python / ops / variables . py <nl> <nl> from tensorflow . python . framework import tensor_shape <nl> from tensorflow . python . ops import array_ops <nl> from tensorflow . python . ops import control_flow_ops <nl> - from tensorflow . python . ops import gen_state_ops <nl> from tensorflow . python . ops import math_ops <nl> from tensorflow . python . ops import state_ops <nl> from tensorflow . python . util . deprecation import deprecated <nl> def assert_expected_shape ( ) : <nl> if init_from_fn : <nl> expected_shape_list = full_shape_to_list ( expected_shape ) <nl> set_shape = validate_shape and expected_shape . is_fully_defined ( ) <nl> - self . _variable = gen_state_ops . _variable ( <nl> - shape = expected_shape_list , <nl> - dtype = dtype . base_dtype , <nl> - name = name , <nl> - container = " " , <nl> - shared_name = " " ) <nl> - if set_shape : <nl> - self . _variable . set_shape ( expected_shape_list ) <nl> + self . _variable = state_ops . variable_op ( <nl> + expected_shape_list , dtype . base_dtype , set_shape = set_shape , <nl> + name = name ) <nl> with ops . colocate_with ( self . _variable . op ) : <nl> with ops . name_scope ( " Initializer " ) : <nl> # Colocate the tensors created by the initial_value ( ) function <nl> def assert_expected_shape ( ) : <nl> and self . _initial_value . get_shape ( ) . is_fully_defined ( ) ) <nl> # In this case , the variable op can ' t be created until after the <nl> # initial_value has been converted to a Tensor with a known type . <nl> - self . _variable = gen_state_ops . _variable ( <nl> - shape = full_shape_to_list ( self . _initial_value . get_shape ( ) ) , <nl> - dtype = self . _initial_value . dtype . base_dtype , <nl> - name = name , <nl> - container = " " , <nl> - shared_name = " " ) <nl> - if set_shape : <nl> - self . _variable . set_shape ( <nl> - full_shape_to_list ( self . _initial_value . get_shape ( ) ) ) <nl> + self . _variable = state_ops . variable_op ( <nl> + full_shape_to_list ( self . _initial_value . get_shape ( ) ) , <nl> + self . _initial_value . dtype . base_dtype , <nl> + set_shape = set_shape , <nl> + name = name ) <nl> + <nl> # Manually overrides the variable ' s shape with the initial value ' s . <nl> if validate_shape : <nl> initial_value_shape = self . _initial_value . get_shape ( ) <nl> mmm a / tensorflow / python / platform / tf_logging . py <nl> ppp b / tensorflow / python / platform / tf_logging . py <nl> <nl> # Even now , we may be in an interactive shell with ` python - i ` . <nl> _interactive = _sys . flags . interactive <nl> <nl> - # Determine whether we are in an interactive environment <nl> - try : <nl> - # This is only defined in interactive shells <nl> - if sys . ps1 : _interactive = True <nl> - except AttributeError : <nl> - # Even now , we may be in an interactive shell with ` python - i ` . <nl> - _interactive = sys . flags . interactive <nl> - <nl> # Scope the tensorflow logger to not conflict with users ' loggers <nl> _logger = _logging . getLogger ( ' tensorflow ' ) <nl> <nl>
|
Fixed bad merge
|
tensorflow/tensorflow
|
723b76d45168ee3b63cb0f7bcd869caf88064c08
|
2016-11-16T04:01:47Z
|
mmm a / src / core / ext / transport / chttp2 / client / secure / secure_channel_create . c <nl> ppp b / src / core / ext / transport / chttp2 / client / secure / secure_channel_create . c <nl> static grpc_subchannel_args * get_secure_naming_subchannel_args ( <nl> if ( target_uri - > path [ 0 ] ! = ' \ 0 ' ) { / / " path " may be empty <nl> const grpc_slice key = grpc_slice_from_static_string ( <nl> target_uri - > path [ 0 ] = = ' / ' ? target_uri - > path + 1 : target_uri - > path ) ; <nl> - const char * value = grpc_slice_hash_table_get ( targets_info , key ) ; <nl> + const char * value = <nl> + ( const char * ) grpc_slice_hash_table_get ( targets_info , key ) ; <nl> if ( value ! = NULL ) target_name_to_check = gpr_strdup ( value ) ; <nl> grpc_slice_unref_internal ( exec_ctx , key ) ; <nl> } <nl> static grpc_subchannel_args * get_secure_naming_subchannel_args ( <nl> if ( new_args_from_connector ! = NULL ) { <nl> grpc_channel_args_destroy ( exec_ctx , new_args_from_connector ) ; <nl> } <nl> - grpc_subchannel_args * final_sc_args = ( grpc_subchannel_args * ) gpr_malloc ( sizeof ( * final_sc_args ) ) ; <nl> + grpc_subchannel_args * final_sc_args = <nl> + ( grpc_subchannel_args * ) gpr_malloc ( sizeof ( * final_sc_args ) ) ; <nl> memcpy ( final_sc_args , args , sizeof ( * args ) ) ; <nl> final_sc_args - > args = new_args ; <nl> return final_sc_args ; <nl> static grpc_channel * client_channel_factory_create_channel ( <nl> } <nl> / / Add channel arg containing the server URI . <nl> grpc_arg arg = grpc_channel_arg_string_create ( <nl> - GRPC_ARG_SERVER_URI , <nl> + ( char * ) GRPC_ARG_SERVER_URI , <nl> grpc_resolver_factory_add_default_prefix_if_needed ( exec_ctx , target ) ) ; <nl> const char * to_remove [ ] = { GRPC_ARG_SERVER_URI } ; <nl> grpc_channel_args * new_args = <nl> mmm a / src / core / ext / transport / cronet / transport / cronet_transport . c <nl> ppp b / src / core / ext / transport / cronet / transport / cronet_transport . c <nl> static void maybe_flush_read ( stream_obj * s ) { <nl> CRONET_LOG ( GPR_DEBUG , " % p : Flush read " , s ) ; <nl> s - > state . flush_read = true ; <nl> null_and_maybe_free_read_buffer ( s ) ; <nl> - s - > state . rs . read_buffer = ( char * ) gpr_malloc ( GRPC_FLUSH_READ_SIZE ) ; <nl> + s - > state . rs . read_buffer = ( char * ) gpr_malloc ( GRPC_FLUSH_READ_SIZE ) ; <nl> if ( ! s - > state . pending_read_from_cronet ) { <nl> CRONET_LOG ( GPR_DEBUG , " bidirectional_stream_read ( % p ) " , s - > cbs ) ; <nl> bidirectional_stream_read ( s - > cbs , s - > state . rs . read_buffer , <nl> static void add_to_storage ( struct stream_obj * s , <nl> struct op_storage * storage = & s - > storage ; <nl> / * add new op at the beginning of the linked list . The memory is freed <nl> in remove_from_storage * / <nl> - struct op_and_state * new_op = ( struct op_and_state * ) gpr_malloc ( sizeof ( struct op_and_state ) ) ; <nl> + struct op_and_state * new_op = <nl> + ( struct op_and_state * ) gpr_malloc ( sizeof ( struct op_and_state ) ) ; <nl> memcpy ( & new_op - > op , op , sizeof ( grpc_transport_stream_op_batch ) ) ; <nl> memset ( & new_op - > state , 0 , sizeof ( new_op - > state ) ) ; <nl> new_op - > s = s ; <nl> static void create_grpc_frame ( grpc_exec_ctx * exec_ctx , <nl> size_t length = GRPC_SLICE_LENGTH ( slice ) ; <nl> * p_write_buffer_size = length + GRPC_HEADER_SIZE_IN_BYTES ; <nl> / * This is freed in the on_write_completed callback * / <nl> - char * write_buffer = ( char * ) gpr_malloc ( length + GRPC_HEADER_SIZE_IN_BYTES ) ; <nl> + char * write_buffer = ( char * ) gpr_malloc ( length + GRPC_HEADER_SIZE_IN_BYTES ) ; <nl> * pp_write_buffer = write_buffer ; <nl> uint8_t * p = ( uint8_t * ) write_buffer ; <nl> / * Append 5 byte header * / <nl> static enum e_op_result execute_stream_op ( grpc_exec_ctx * exec_ctx , <nl> stream_state - > rs . length_field ) ; <nl> if ( stream_state - > rs . length_field > 0 ) { <nl> stream_state - > rs . read_buffer = <nl> - gpr_malloc ( ( size_t ) stream_state - > rs . length_field ) ; <nl> + ( char * ) gpr_malloc ( ( size_t ) stream_state - > rs . length_field ) ; <nl> GPR_ASSERT ( stream_state - > rs . read_buffer ) ; <nl> stream_state - > rs . remaining_bytes = stream_state - > rs . length_field ; <nl> stream_state - > rs . received_bytes = 0 ; <nl> static const grpc_transport_vtable grpc_cronet_vtable = { <nl> grpc_transport * grpc_create_cronet_transport ( void * engine , const char * target , <nl> const grpc_channel_args * args , <nl> void * reserved ) { <nl> - grpc_cronet_transport * ct = ( grpc_cronet_transport * ) gpr_malloc ( sizeof ( grpc_cronet_transport ) ) ; <nl> + grpc_cronet_transport * ct = <nl> + ( grpc_cronet_transport * ) gpr_malloc ( sizeof ( grpc_cronet_transport ) ) ; <nl> if ( ! ct ) { <nl> goto error ; <nl> } <nl> ct - > base . vtable = & grpc_cronet_vtable ; <nl> - ct - > engine = engine ; <nl> - ct - > host = ( char * ) gpr_malloc ( strlen ( target ) + 1 ) ; <nl> + ct - > engine = ( stream_engine * ) engine ; <nl> + ct - > host = ( char * ) gpr_malloc ( strlen ( target ) + 1 ) ; <nl> if ( ! ct - > host ) { <nl> goto error ; <nl> } <nl> mmm a / src / core / lib / http / httpcli_security_connector . c <nl> ppp b / src / core / lib / http / httpcli_security_connector . c <nl> static grpc_security_status httpcli_ssl_channel_security_connector_create ( <nl> return GRPC_SECURITY_ERROR ; <nl> } <nl> <nl> - c = ( grpc_httpcli_ssl_channel_security_connector * ) gpr_zalloc ( sizeof ( grpc_httpcli_ssl_channel_security_connector ) ) ; <nl> + c = ( grpc_httpcli_ssl_channel_security_connector * ) gpr_zalloc ( <nl> + sizeof ( grpc_httpcli_ssl_channel_security_connector ) ) ; <nl> <nl> gpr_ref_init ( & c - > base . base . refcount , 1 ) ; <nl> c - > base . base . vtable = & httpcli_ssl_vtable ; <nl> typedef struct { <nl> <nl> static void on_handshake_done ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> - grpc_handshaker_args * args = ( grpc_handshaker_args * ) arg ; <nl> + grpc_handshaker_args * args = ( grpc_handshaker_args * ) arg ; <nl> on_done_closure * c = ( on_done_closure * ) args - > user_data ; <nl> if ( error ! = GRPC_ERROR_NONE ) { <nl> const char * msg = grpc_error_string ( error ) ; <nl> static void ssl_handshake ( grpc_exec_ctx * exec_ctx , void * arg , <nl> gpr_timespec deadline , <nl> void ( * on_done ) ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_endpoint * endpoint ) ) { <nl> - on_done_closure * c = ( on_done_closure * ) gpr_malloc ( sizeof ( * c ) ) ; <nl> + on_done_closure * c = ( on_done_closure * ) gpr_malloc ( sizeof ( * c ) ) ; <nl> const char * pem_root_certs = grpc_get_default_ssl_roots ( ) ; <nl> if ( pem_root_certs = = NULL ) { <nl> gpr_log ( GPR_ERROR , " Could not get default pem root certs . " ) ; <nl> mmm a / src / core / lib / security / context / security_context . c <nl> ppp b / src / core / lib / security / context / security_context . c <nl> void grpc_auth_context_release ( grpc_auth_context * context ) { <nl> / * mmm grpc_client_security_context mmm * / <nl> <nl> grpc_client_security_context * grpc_client_security_context_create ( void ) { <nl> - return ( grpc_client_security_context * ) gpr_zalloc ( sizeof ( grpc_client_security_context ) ) ; <nl> + return ( grpc_client_security_context * ) gpr_zalloc ( <nl> + sizeof ( grpc_client_security_context ) ) ; <nl> } <nl> <nl> void grpc_client_security_context_destroy ( void * ctx ) { <nl> void grpc_client_security_context_destroy ( void * ctx ) { <nl> / * mmm grpc_server_security_context mmm * / <nl> <nl> grpc_server_security_context * grpc_server_security_context_create ( void ) { <nl> - return ( grpc_client_security_context * ) gpr_zalloc ( sizeof ( grpc_server_security_context ) ) ; <nl> + return ( grpc_server_security_context * ) gpr_zalloc ( <nl> + sizeof ( grpc_server_security_context ) ) ; <nl> } <nl> <nl> void grpc_server_security_context_destroy ( void * ctx ) { <nl> void grpc_server_security_context_destroy ( void * ctx ) { <nl> static grpc_auth_property_iterator empty_iterator = { NULL , 0 , NULL } ; <nl> <nl> grpc_auth_context * grpc_auth_context_create ( grpc_auth_context * chained ) { <nl> - grpc_auth_context * ctx = ( grpc_auth_context * ) gpr_zalloc ( sizeof ( grpc_auth_context ) ) ; <nl> + grpc_auth_context * ctx = <nl> + ( grpc_auth_context * ) gpr_zalloc ( sizeof ( grpc_auth_context ) ) ; <nl> gpr_ref_init ( & ctx - > refcount , 1 ) ; <nl> if ( chained ! = NULL ) { <nl> ctx - > chained = GRPC_AUTH_CONTEXT_REF ( chained , " chained " ) ; <nl> static void ensure_auth_context_capacity ( grpc_auth_context * ctx ) { <nl> if ( ctx - > properties . count = = ctx - > properties . capacity ) { <nl> ctx - > properties . capacity = <nl> GPR_MAX ( ctx - > properties . capacity + 8 , ctx - > properties . capacity * 2 ) ; <nl> - ctx - > properties . array = ( grpc_auth_property * ) <nl> - gpr_realloc ( ctx - > properties . array , <nl> - ctx - > properties . capacity * sizeof ( grpc_auth_property ) ) ; <nl> + ctx - > properties . array = ( grpc_auth_property * ) gpr_realloc ( <nl> + ctx - > properties . array , <nl> + ctx - > properties . capacity * sizeof ( grpc_auth_property ) ) ; <nl> } <nl> } <nl> <nl> void grpc_auth_context_add_property ( grpc_auth_context * ctx , const char * name , <nl> ensure_auth_context_capacity ( ctx ) ; <nl> prop = & ctx - > properties . array [ ctx - > properties . count + + ] ; <nl> prop - > name = gpr_strdup ( name ) ; <nl> - prop - > value = ( char * ) gpr_malloc ( value_length + 1 ) ; <nl> + prop - > value = ( char * ) gpr_malloc ( value_length + 1 ) ; <nl> memcpy ( prop - > value , value , value_length ) ; <nl> prop - > value [ value_length ] = ' \ 0 ' ; <nl> prop - > value_length = value_length ; <nl> void grpc_auth_property_reset ( grpc_auth_property * property ) { <nl> } <nl> <nl> static void auth_context_pointer_arg_destroy ( grpc_exec_ctx * exec_ctx , void * p ) { <nl> - GRPC_AUTH_CONTEXT_UNREF ( ( grpc_auth_context * ) p , " auth_context_pointer_arg " ) ; <nl> + GRPC_AUTH_CONTEXT_UNREF ( ( grpc_auth_context * ) p , " auth_context_pointer_arg " ) ; <nl> } <nl> <nl> static void * auth_context_pointer_arg_copy ( void * p ) { <nl> - return GRPC_AUTH_CONTEXT_REF ( ( grpc_auth_context * ) p , " auth_context_pointer_arg " ) ; <nl> + return GRPC_AUTH_CONTEXT_REF ( ( grpc_auth_context * ) p , <nl> + " auth_context_pointer_arg " ) ; <nl> } <nl> <nl> static int auth_context_pointer_cmp ( void * a , void * b ) { return GPR_ICMP ( a , b ) ; } <nl> static const grpc_arg_pointer_vtable auth_context_pointer_vtable = { <nl> auth_context_pointer_cmp } ; <nl> <nl> grpc_arg grpc_auth_context_to_arg ( grpc_auth_context * p ) { <nl> - return grpc_channel_arg_pointer_create ( GRPC_AUTH_CONTEXT_ARG , p , <nl> - ( char * ) & auth_context_pointer_vtable ) ; <nl> + return grpc_channel_arg_pointer_create ( ( char * ) GRPC_AUTH_CONTEXT_ARG , p , <nl> + & auth_context_pointer_vtable ) ; <nl> } <nl> <nl> grpc_auth_context * grpc_auth_context_from_arg ( const grpc_arg * arg ) { <nl> grpc_auth_context * grpc_auth_context_from_arg ( const grpc_arg * arg ) { <nl> GRPC_AUTH_CONTEXT_ARG ) ; <nl> return NULL ; <nl> } <nl> - return ( grpc_auth_context * ) arg - > value . pointer . p ; <nl> + return ( grpc_auth_context * ) arg - > value . pointer . p ; <nl> } <nl> <nl> grpc_auth_context * grpc_find_auth_context_in_args ( <nl> mmm a / src / core / lib / security / credentials / composite / composite_credentials . c <nl> ppp b / src / core / lib / security / credentials / composite / composite_credentials . c <nl> static bool composite_call_get_request_metadata ( <nl> grpc_error * * error ) { <nl> grpc_composite_call_credentials * c = ( grpc_composite_call_credentials * ) creds ; <nl> grpc_composite_call_credentials_metadata_context * ctx ; <nl> - ctx = ( grpc_composite_call_credentials_metadata_context * ) gpr_zalloc ( sizeof ( grpc_composite_call_credentials_metadata_context ) ) ; <nl> + ctx = ( grpc_composite_call_credentials_metadata_context * ) gpr_zalloc ( <nl> + sizeof ( grpc_composite_call_credentials_metadata_context ) ) ; <nl> ctx - > composite_creds = c ; <nl> ctx - > pollent = pollent ; <nl> ctx - > auth_md_context = auth_md_context ; <nl> grpc_call_credentials * grpc_composite_call_credentials_create ( <nl> GPR_ASSERT ( reserved = = NULL ) ; <nl> GPR_ASSERT ( creds1 ! = NULL ) ; <nl> GPR_ASSERT ( creds2 ! = NULL ) ; <nl> - c = ( grpc_composite_call_credentials * ) gpr_zalloc ( sizeof ( grpc_composite_call_credentials ) ) ; <nl> + c = ( grpc_composite_call_credentials * ) gpr_zalloc ( <nl> + sizeof ( grpc_composite_call_credentials ) ) ; <nl> c - > base . type = GRPC_CALL_CREDENTIALS_TYPE_COMPOSITE ; <nl> c - > base . vtable = & composite_call_credentials_vtable ; <nl> gpr_ref_init ( & c - > base . refcount , 1 ) ; <nl> grpc_call_credentials * grpc_composite_call_credentials_create ( <nl> creds2_array = get_creds_array ( & creds2 ) ; <nl> c - > inner . num_creds = creds1_array . num_creds + creds2_array . num_creds ; <nl> creds_array_byte_size = c - > inner . num_creds * sizeof ( grpc_call_credentials * ) ; <nl> - c - > inner . creds_array = ( grpc_call_credentials * * ) gpr_zalloc ( creds_array_byte_size ) ; <nl> + c - > inner . creds_array = <nl> + ( grpc_call_credentials * * ) gpr_zalloc ( creds_array_byte_size ) ; <nl> for ( i = 0 ; i < creds1_array . num_creds ; i + + ) { <nl> grpc_call_credentials * cur_creds = creds1_array . creds_array [ i ] ; <nl> c - > inner . creds_array [ i ] = grpc_call_credentials_ref ( cur_creds ) ; <nl> static grpc_channel_credentials_vtable composite_channel_credentials_vtable = { <nl> grpc_channel_credentials * grpc_composite_channel_credentials_create ( <nl> grpc_channel_credentials * channel_creds , grpc_call_credentials * call_creds , <nl> void * reserved ) { <nl> - grpc_composite_channel_credentials * c = ( grpc_composite_channel_credentials * ) gpr_zalloc ( sizeof ( * c ) ) ; <nl> + grpc_composite_channel_credentials * c = <nl> + ( grpc_composite_channel_credentials * ) gpr_zalloc ( sizeof ( * c ) ) ; <nl> GPR_ASSERT ( channel_creds ! = NULL & & call_creds ! = NULL & & reserved = = NULL ) ; <nl> GRPC_API_TRACE ( <nl> " grpc_composite_channel_credentials_create ( channel_creds = % p , " <nl> mmm a / src / core / lib / security / credentials / credentials . c <nl> ppp b / src / core / lib / security / credentials / credentials . c <nl> <nl> grpc_credentials_metadata_request * grpc_credentials_metadata_request_create ( <nl> grpc_call_credentials * creds ) { <nl> grpc_credentials_metadata_request * r = <nl> - gpr_zalloc ( sizeof ( grpc_credentials_metadata_request ) ) ; <nl> + ( grpc_credentials_metadata_request * ) gpr_zalloc ( <nl> + sizeof ( grpc_credentials_metadata_request ) ) ; <nl> r - > creds = grpc_call_credentials_ref ( creds ) ; <nl> return r ; <nl> } <nl> grpc_channel_credentials_duplicate_without_call_credentials ( <nl> } <nl> <nl> static void credentials_pointer_arg_destroy ( grpc_exec_ctx * exec_ctx , void * p ) { <nl> - grpc_channel_credentials_unref ( exec_ctx , p ) ; <nl> + grpc_channel_credentials_unref ( exec_ctx , ( grpc_channel_credentials * ) p ) ; <nl> } <nl> <nl> static void * credentials_pointer_arg_copy ( void * p ) { <nl> - return grpc_channel_credentials_ref ( p ) ; <nl> + return grpc_channel_credentials_ref ( ( grpc_channel_credentials * ) p ) ; <nl> } <nl> <nl> static int credentials_pointer_cmp ( void * a , void * b ) { return GPR_ICMP ( a , b ) ; } <nl> static const grpc_arg_pointer_vtable credentials_pointer_vtable = { <nl> <nl> grpc_arg grpc_channel_credentials_to_arg ( <nl> grpc_channel_credentials * credentials ) { <nl> - return grpc_channel_arg_pointer_create ( <nl> - GRPC_ARG_CHANNEL_CREDENTIALS , credentials , & credentials_pointer_vtable ) ; <nl> + return grpc_channel_arg_pointer_create ( ( char * ) GRPC_ARG_CHANNEL_CREDENTIALS , <nl> + credentials , <nl> + & credentials_pointer_vtable ) ; <nl> } <nl> <nl> grpc_channel_credentials * grpc_channel_credentials_from_arg ( <nl> grpc_channel_credentials * grpc_channel_credentials_from_arg ( <nl> GRPC_ARG_CHANNEL_CREDENTIALS ) ; <nl> return NULL ; <nl> } <nl> - return arg - > value . pointer . p ; <nl> + return ( grpc_channel_credentials * ) arg - > value . pointer . p ; <nl> } <nl> <nl> grpc_channel_credentials * grpc_channel_credentials_find_in_args ( <nl> void grpc_server_credentials_set_auth_metadata_processor ( <nl> <nl> static void server_credentials_pointer_arg_destroy ( grpc_exec_ctx * exec_ctx , <nl> void * p ) { <nl> - grpc_server_credentials_unref ( exec_ctx , p ) ; <nl> + grpc_server_credentials_unref ( exec_ctx , ( grpc_server_credentials * ) p ) ; <nl> } <nl> <nl> static void * server_credentials_pointer_arg_copy ( void * p ) { <nl> - return grpc_server_credentials_ref ( p ) ; <nl> + return grpc_server_credentials_ref ( ( grpc_server_credentials * ) p ) ; <nl> } <nl> <nl> static int server_credentials_pointer_cmp ( void * a , void * b ) { <nl> static const grpc_arg_pointer_vtable cred_ptr_vtable = { <nl> server_credentials_pointer_cmp } ; <nl> <nl> grpc_arg grpc_server_credentials_to_arg ( grpc_server_credentials * p ) { <nl> - return grpc_channel_arg_pointer_create ( GRPC_SERVER_CREDENTIALS_ARG , p , <nl> + return grpc_channel_arg_pointer_create ( ( char * ) GRPC_SERVER_CREDENTIALS_ARG , p , <nl> & cred_ptr_vtable ) ; <nl> } <nl> <nl> grpc_server_credentials * grpc_server_credentials_from_arg ( const grpc_arg * arg ) { <nl> GRPC_SERVER_CREDENTIALS_ARG ) ; <nl> return NULL ; <nl> } <nl> - return arg - > value . pointer . p ; <nl> + return ( grpc_server_credentials * ) arg - > value . pointer . p ; <nl> } <nl> <nl> grpc_server_credentials * grpc_find_server_credentials_in_args ( <nl> mmm a / src / core / lib / security / credentials / credentials_metadata . c <nl> ppp b / src / core / lib / security / credentials / credentials_metadata . c <nl> static void mdelem_list_ensure_capacity ( grpc_credentials_mdelem_array * list , <nl> while ( new_size < target_size ) { <nl> new_size * = 2 ; <nl> } <nl> - list - > md = ( grpc_mdelem * ) gpr_realloc ( list - > md , sizeof ( grpc_mdelem ) * new_size ) ; <nl> + list - > md = <nl> + ( grpc_mdelem * ) gpr_realloc ( list - > md , sizeof ( grpc_mdelem ) * new_size ) ; <nl> } <nl> <nl> void grpc_credentials_mdelem_array_add ( grpc_credentials_mdelem_array * list , <nl> mmm a / src / core / lib / security / credentials / fake / fake_credentials . c <nl> ppp b / src / core / lib / security / credentials / fake / fake_credentials . c <nl> static grpc_server_credentials_vtable <nl> <nl> grpc_channel_credentials * grpc_fake_transport_security_credentials_create ( <nl> void ) { <nl> - grpc_channel_credentials * c = ( grpc_channel_credentials * ) gpr_zalloc ( sizeof ( grpc_channel_credentials ) ) ; <nl> + grpc_channel_credentials * c = <nl> + ( grpc_channel_credentials * ) gpr_zalloc ( sizeof ( grpc_channel_credentials ) ) ; <nl> c - > type = GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY ; <nl> c - > vtable = & fake_transport_security_credentials_vtable ; <nl> gpr_ref_init ( & c - > refcount , 1 ) ; <nl> grpc_channel_credentials * grpc_fake_transport_security_credentials_create ( <nl> <nl> grpc_server_credentials * grpc_fake_transport_security_server_credentials_create ( <nl> void ) { <nl> - grpc_server_credentials * c = ( grpc_server_credentials * ) gpr_malloc ( sizeof ( grpc_server_credentials ) ) ; <nl> + grpc_server_credentials * c = <nl> + ( grpc_server_credentials * ) gpr_malloc ( sizeof ( grpc_server_credentials ) ) ; <nl> memset ( c , 0 , sizeof ( grpc_server_credentials ) ) ; <nl> c - > type = GRPC_CHANNEL_CREDENTIALS_TYPE_FAKE_TRANSPORT_SECURITY ; <nl> gpr_ref_init ( & c - > refcount , 1 ) ; <nl> grpc_server_credentials * grpc_fake_transport_security_server_credentials_create ( <nl> } <nl> <nl> grpc_arg grpc_fake_transport_expected_targets_arg ( char * expected_targets ) { <nl> - return grpc_channel_arg_string_create ( GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS , <nl> - expected_targets ) ; <nl> + return grpc_channel_arg_string_create ( <nl> + ( char * ) GRPC_ARG_FAKE_SECURITY_EXPECTED_TARGETS , expected_targets ) ; <nl> } <nl> <nl> const char * grpc_fake_transport_get_expected_targets ( <nl> grpc_call_credentials * grpc_md_only_test_credentials_create ( <nl> grpc_exec_ctx * exec_ctx , const char * md_key , const char * md_value , <nl> bool is_async ) { <nl> grpc_md_only_test_credentials * c = <nl> - gpr_zalloc ( sizeof ( grpc_md_only_test_credentials ) ) ; <nl> + ( grpc_md_only_test_credentials * ) gpr_zalloc ( <nl> + sizeof ( grpc_md_only_test_credentials ) ) ; <nl> c - > base . type = GRPC_CALL_CREDENTIALS_TYPE_OAUTH2 ; <nl> c - > base . vtable = & md_only_test_vtable ; <nl> gpr_ref_init ( & c - > base . refcount , 1 ) ; <nl> mmm a / src / core / lib / security / credentials / google_default / google_default_credentials . c <nl> ppp b / src / core / lib / security / credentials / google_default / google_default_credentials . c <nl> static void on_compute_engine_detection_http_response ( grpc_exec_ctx * exec_ctx , <nl> } <nl> <nl> static void destroy_pollset ( grpc_exec_ctx * exec_ctx , void * p , grpc_error * e ) { <nl> - grpc_pollset_destroy ( exec_ctx , p ) ; <nl> + grpc_pollset_destroy ( exec_ctx , ( grpc_pollset * ) p ) ; <nl> } <nl> <nl> static int is_stack_running_on_compute_engine ( grpc_exec_ctx * exec_ctx ) { <nl> static int is_stack_running_on_compute_engine ( grpc_exec_ctx * exec_ctx ) { <nl> on compute engine . * / <nl> gpr_timespec max_detection_delay = gpr_time_from_seconds ( 1 , GPR_TIMESPAN ) ; <nl> <nl> - grpc_pollset * pollset = ( grpc_pollset * ) gpr_zalloc ( grpc_pollset_size ( ) ) ; <nl> + grpc_pollset * pollset = ( grpc_pollset * ) gpr_zalloc ( grpc_pollset_size ( ) ) ; <nl> grpc_pollset_init ( pollset , & g_polling_mu ) ; <nl> detector . pollent = grpc_polling_entity_create_from_pollset ( pollset ) ; <nl> detector . is_done = 0 ; <nl> static int is_stack_running_on_compute_engine ( grpc_exec_ctx * exec_ctx ) { <nl> <nl> memset ( & detector . response , 0 , sizeof ( detector . response ) ) ; <nl> memset ( & request , 0 , sizeof ( grpc_httpcli_request ) ) ; <nl> - request . host = GRPC_COMPUTE_ENGINE_DETECTION_HOST ; <nl> - request . http . path = " / " ; <nl> + request . host = ( char * ) GRPC_COMPUTE_ENGINE_DETECTION_HOST ; <nl> + request . http . path = ( char * ) " / " ; <nl> <nl> grpc_httpcli_context_init ( & context ) ; <nl> <nl> mmm a / src / core / lib / security / credentials / iam / iam_credentials . c <nl> ppp b / src / core / lib / security / credentials / iam / iam_credentials . c <nl> grpc_call_credentials * grpc_google_iam_credentials_create ( <nl> GPR_ASSERT ( reserved = = NULL ) ; <nl> GPR_ASSERT ( token ! = NULL ) ; <nl> GPR_ASSERT ( authority_selector ! = NULL ) ; <nl> - grpc_google_iam_credentials * c = ( grpc_google_iam_credentials * ) gpr_zalloc ( sizeof ( * c ) ) ; <nl> + grpc_google_iam_credentials * c = <nl> + ( grpc_google_iam_credentials * ) gpr_zalloc ( sizeof ( * c ) ) ; <nl> c - > base . type = GRPC_CALL_CREDENTIALS_TYPE_IAM ; <nl> c - > base . vtable = & iam_vtable ; <nl> gpr_ref_init ( & c - > base . refcount , 1 ) ; <nl> mmm a / src / core / lib / security / credentials / jwt / json_token . c <nl> ppp b / src / core / lib / security / credentials / jwt / json_token . c <nl> grpc_auth_json_key grpc_auth_json_key_create_from_json ( const grpc_json * json ) { <nl> gpr_log ( GPR_ERROR , " Could not write into openssl BIO . " ) ; <nl> goto end ; <nl> } <nl> - result . private_key = PEM_read_bio_RSAPrivateKey ( bio , NULL , NULL , " " ) ; <nl> + result . private_key = PEM_read_bio_RSAPrivateKey ( bio , NULL , NULL , ( void * ) " " ) ; <nl> if ( result . private_key = = NULL ) { <nl> gpr_log ( GPR_ERROR , " Could not deserialize private key . " ) ; <nl> goto end ; <nl> static char * dot_concat_and_free_strings ( char * str1 , char * str2 ) { <nl> size_t str1_len = strlen ( str1 ) ; <nl> size_t str2_len = strlen ( str2 ) ; <nl> size_t result_len = str1_len + 1 / * dot * / + str2_len ; <nl> - char * result = ( char * ) gpr_malloc ( result_len + 1 / * NULL terminated * / ) ; <nl> + char * result = ( char * ) gpr_malloc ( result_len + 1 / * NULL terminated * / ) ; <nl> char * current = result ; <nl> memcpy ( current , str1 , str1_len ) ; <nl> current + = str1_len ; <nl> char * compute_and_encode_signature ( const grpc_auth_json_key * json_key , <nl> gpr_log ( GPR_ERROR , " DigestFinal ( get signature length ) failed . " ) ; <nl> goto end ; <nl> } <nl> - sig = ( unsigned char * ) gpr_malloc ( sig_len ) ; <nl> + sig = ( unsigned char * ) gpr_malloc ( sig_len ) ; <nl> if ( EVP_DigestSignFinal ( md_ctx , sig , & sig_len ) ! = 1 ) { <nl> gpr_log ( GPR_ERROR , " DigestFinal ( signature compute ) failed . " ) ; <nl> goto end ; <nl> mmm a / src / core / lib / security / credentials / jwt / jwt_credentials . c <nl> ppp b / src / core / lib / security / credentials / jwt / jwt_credentials . c <nl> grpc_service_account_jwt_access_credentials_create_from_auth_json_key ( <nl> gpr_log ( GPR_ERROR , " Invalid input for jwt credentials creation " ) ; <nl> return NULL ; <nl> } <nl> - c = ( grpc_service_account_jwt_access_credentials * ) gpr_zalloc ( sizeof ( grpc_service_account_jwt_access_credentials ) ) ; <nl> + c = ( grpc_service_account_jwt_access_credentials * ) gpr_zalloc ( <nl> + sizeof ( grpc_service_account_jwt_access_credentials ) ) ; <nl> c - > base . type = GRPC_CALL_CREDENTIALS_TYPE_JWT ; <nl> gpr_ref_init ( & c - > base . refcount , 1 ) ; <nl> c - > base . vtable = & jwt_vtable ; <nl> mmm a / src / core / lib / security / credentials / jwt / jwt_verifier . c <nl> ppp b / src / core / lib / security / credentials / jwt / jwt_verifier . c <nl> static void jose_header_destroy ( grpc_exec_ctx * exec_ctx , jose_header * h ) { <nl> static jose_header * jose_header_from_json ( grpc_exec_ctx * exec_ctx , <nl> grpc_json * json , grpc_slice buffer ) { <nl> grpc_json * cur ; <nl> - jose_header * h = ( jose_header * ) gpr_zalloc ( sizeof ( jose_header ) ) ; <nl> + jose_header * h = ( jose_header * ) gpr_zalloc ( sizeof ( jose_header ) ) ; <nl> h - > buffer = buffer ; <nl> for ( cur = json - > child ; cur ! = NULL ; cur = cur - > next ) { <nl> if ( strcmp ( cur - > key , " alg " ) = = 0 ) { <nl> gpr_timespec grpc_jwt_claims_not_before ( const grpc_jwt_claims * claims ) { <nl> grpc_jwt_claims * grpc_jwt_claims_from_json ( grpc_exec_ctx * exec_ctx , <nl> grpc_json * json , grpc_slice buffer ) { <nl> grpc_json * cur ; <nl> - grpc_jwt_claims * claims = ( grpc_jwt_claims * ) gpr_malloc ( sizeof ( grpc_jwt_claims ) ) ; <nl> + grpc_jwt_claims * claims = <nl> + ( grpc_jwt_claims * ) gpr_malloc ( sizeof ( grpc_jwt_claims ) ) ; <nl> memset ( claims , 0 , sizeof ( grpc_jwt_claims ) ) ; <nl> claims - > json = json ; <nl> claims - > buffer = buffer ; <nl> static verifier_cb_ctx * verifier_cb_ctx_create ( <nl> const char * signed_jwt , size_t signed_jwt_len , void * user_data , <nl> grpc_jwt_verification_done_cb cb ) { <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> - verifier_cb_ctx * ctx = ( verifier_cb_ctx * ) gpr_zalloc ( sizeof ( verifier_cb_ctx ) ) ; <nl> + verifier_cb_ctx * ctx = ( verifier_cb_ctx * ) gpr_zalloc ( sizeof ( verifier_cb_ctx ) ) ; <nl> ctx - > verifier = verifier ; <nl> ctx - > pollent = grpc_polling_entity_create_from_pollset ( pollset ) ; <nl> ctx - > header = header ; <nl> static void on_openid_config_retrieved ( grpc_exec_ctx * exec_ctx , void * user_data , <nl> grpc_json * json = json_from_http ( response ) ; <nl> grpc_httpcli_request req ; <nl> const char * jwks_uri ; <nl> + grpc_resource_quota * resource_quota = NULL ; <nl> <nl> / * TODO ( jboeuf ) : Cache the jwks_uri in order to avoid this hop next time . * / <nl> if ( json = = NULL ) goto error ; <nl> static void on_openid_config_retrieved ( grpc_exec_ctx * exec_ctx , void * user_data , <nl> jwks_uri + = 8 ; <nl> req . handshaker = & grpc_httpcli_ssl ; <nl> req . host = gpr_strdup ( jwks_uri ) ; <nl> - req . http . path = strchr ( jwks_uri , ' / ' ) ; <nl> + req . http . path = ( char * ) strchr ( jwks_uri , ' / ' ) ; <nl> if ( req . http . path = = NULL ) { <nl> - req . http . path = " " ; <nl> + req . http . path = ( char * ) " " ; <nl> } else { <nl> * ( req . host + ( req . http . path - jwks_uri ) ) = ' \ 0 ' ; <nl> } <nl> static void on_openid_config_retrieved ( grpc_exec_ctx * exec_ctx , void * user_data , <nl> / * TODO ( ctiller ) : Carry the resource_quota in ctx and share it with the host <nl> channel . This would allow us to cancel an authentication query when under <nl> extreme memory pressure . * / <nl> - grpc_resource_quota * resource_quota = <nl> - grpc_resource_quota_create ( " jwt_verifier " ) ; <nl> + resource_quota = grpc_resource_quota_create ( " jwt_verifier " ) ; <nl> grpc_httpcli_get ( <nl> exec_ctx , & ctx - > verifier - > http_ctx , & ctx - > pollent , resource_quota , & req , <nl> gpr_time_add ( gpr_now ( GPR_CLOCK_REALTIME ) , grpc_jwt_verifier_max_delay ) , <nl> const char * grpc_jwt_issuer_email_domain ( const char * issuer ) { <nl> if ( dot = = NULL | | dot = = email_domain ) return email_domain ; <nl> GPR_ASSERT ( dot > email_domain ) ; <nl> / * There may be a subdomain , we just want the domain . * / <nl> - dot = gpr_memrchr ( email_domain , ' . ' , ( size_t ) ( dot - email_domain ) ) ; <nl> + dot = ( const char * ) gpr_memrchr ( ( void * ) email_domain , ' . ' , ( size_t ) ( dot - email_domain ) ) ; <nl> if ( dot = = NULL ) return email_domain ; <nl> return dot + 1 ; <nl> } <nl> static void retrieve_key_and_verify ( grpc_exec_ctx * exec_ctx , <nl> char * path_prefix = NULL ; <nl> const char * iss ; <nl> grpc_httpcli_request req ; <nl> + grpc_resource_quota * resource_quota = NULL ; <nl> memset ( & req , 0 , sizeof ( grpc_httpcli_request ) ) ; <nl> req . handshaker = & grpc_httpcli_ssl ; <nl> http_response_index rsp_idx ; <nl> static void retrieve_key_and_verify ( grpc_exec_ctx * exec_ctx , <nl> / * TODO ( ctiller ) : Carry the resource_quota in ctx and share it with the host <nl> channel . This would allow us to cancel an authentication query when under <nl> extreme memory pressure . * / <nl> - grpc_resource_quota * resource_quota = <nl> - grpc_resource_quota_create ( " jwt_verifier " ) ; <nl> + resource_quota = grpc_resource_quota_create ( " jwt_verifier " ) ; <nl> grpc_httpcli_get ( <nl> exec_ctx , & ctx - > verifier - > http_ctx , & ctx - > pollent , resource_quota , & req , <nl> gpr_time_add ( gpr_now ( GPR_CLOCK_REALTIME ) , grpc_jwt_verifier_max_delay ) , <nl> void grpc_jwt_verifier_verify ( grpc_exec_ctx * exec_ctx , <nl> grpc_jwt_verifier * grpc_jwt_verifier_create ( <nl> const grpc_jwt_verifier_email_domain_key_url_mapping * mappings , <nl> size_t num_mappings ) { <nl> - grpc_jwt_verifier * v = ( grpc_jwt_verifier * ) gpr_zalloc ( sizeof ( grpc_jwt_verifier ) ) ; <nl> + grpc_jwt_verifier * v = <nl> + ( grpc_jwt_verifier * ) gpr_zalloc ( sizeof ( grpc_jwt_verifier ) ) ; <nl> grpc_httpcli_context_init ( & v - > http_ctx ) ; <nl> <nl> / * We know at least of one mapping . * / <nl> v - > allocated_mappings = 1 + num_mappings ; <nl> - v - > mappings = ( email_key_mapping * ) gpr_malloc ( v - > allocated_mappings * sizeof ( email_key_mapping ) ) ; <nl> + v - > mappings = ( email_key_mapping * ) gpr_malloc ( v - > allocated_mappings * <nl> + sizeof ( email_key_mapping ) ) ; <nl> verifier_put_mapping ( v , GRPC_GOOGLE_SERVICE_ACCOUNTS_EMAIL_DOMAIN , <nl> GRPC_GOOGLE_SERVICE_ACCOUNTS_KEY_URL_PREFIX ) ; <nl> / * User - Provided mappings . * / <nl> mmm a / src / core / lib / security / credentials / oauth2 / oauth2_credentials . c <nl> ppp b / src / core / lib / security / credentials / oauth2 / oauth2_credentials . c <nl> grpc_oauth2_token_fetcher_credentials_parse_server_response ( <nl> } <nl> <nl> if ( response - > body_length > 0 ) { <nl> - null_terminated_body = ( char * ) gpr_malloc ( response - > body_length + 1 ) ; <nl> + null_terminated_body = ( char * ) gpr_malloc ( response - > body_length + 1 ) ; <nl> null_terminated_body [ response - > body_length ] = ' \ 0 ' ; <nl> memcpy ( null_terminated_body , response - > body , response - > body_length ) ; <nl> } <nl> static void compute_engine_fetch_oauth2 ( <nl> grpc_exec_ctx * exec_ctx , grpc_credentials_metadata_request * metadata_req , <nl> grpc_httpcli_context * httpcli_context , grpc_polling_entity * pollent , <nl> grpc_iomgr_cb_func response_cb , gpr_timespec deadline ) { <nl> - grpc_http_header header = { " Metadata - Flavor " , " Google " } ; <nl> + grpc_http_header header = { ( char * ) " Metadata - Flavor " , ( char * ) " Google " } ; <nl> grpc_httpcli_request request ; <nl> memset ( & request , 0 , sizeof ( grpc_httpcli_request ) ) ; <nl> - request . host = GRPC_COMPUTE_ENGINE_METADATA_HOST ; <nl> - request . http . path = GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH ; <nl> + request . host = ( char * ) GRPC_COMPUTE_ENGINE_METADATA_HOST ; <nl> + request . http . path = ( char * ) GRPC_COMPUTE_ENGINE_METADATA_TOKEN_PATH ; <nl> request . http . hdr_count = 1 ; <nl> request . http . hdrs = & header ; <nl> / * TODO ( ctiller ) : Carry the resource_quota in ctx and share it with the host <nl> static void compute_engine_fetch_oauth2 ( <nl> grpc_call_credentials * grpc_google_compute_engine_credentials_create ( <nl> void * reserved ) { <nl> grpc_oauth2_token_fetcher_credentials * c = <nl> - gpr_malloc ( sizeof ( grpc_oauth2_token_fetcher_credentials ) ) ; <nl> + ( grpc_oauth2_token_fetcher_credentials * ) gpr_malloc ( <nl> + sizeof ( grpc_oauth2_token_fetcher_credentials ) ) ; <nl> GRPC_API_TRACE ( " grpc_compute_engine_credentials_create ( reserved = % p ) " , 1 , <nl> ( reserved ) ) ; <nl> GPR_ASSERT ( reserved = = NULL ) ; <nl> static void refresh_token_fetch_oauth2 ( <nl> grpc_iomgr_cb_func response_cb , gpr_timespec deadline ) { <nl> grpc_google_refresh_token_credentials * c = <nl> ( grpc_google_refresh_token_credentials * ) metadata_req - > creds ; <nl> - grpc_http_header header = { " Content - Type " , <nl> - " application / x - www - form - urlencoded " } ; <nl> + grpc_http_header header = { ( char * ) " Content - Type " , <nl> + ( char * ) " application / x - www - form - urlencoded " } ; <nl> grpc_httpcli_request request ; <nl> char * body = NULL ; <nl> gpr_asprintf ( & body , GRPC_REFRESH_TOKEN_POST_BODY_FORMAT_STRING , <nl> c - > refresh_token . client_id , c - > refresh_token . client_secret , <nl> c - > refresh_token . refresh_token ) ; <nl> memset ( & request , 0 , sizeof ( grpc_httpcli_request ) ) ; <nl> - request . host = GRPC_GOOGLE_OAUTH2_SERVICE_HOST ; <nl> - request . http . path = GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH ; <nl> + request . host = ( char * ) GRPC_GOOGLE_OAUTH2_SERVICE_HOST ; <nl> + request . http . path = ( char * ) GRPC_GOOGLE_OAUTH2_SERVICE_TOKEN_PATH ; <nl> request . http . hdr_count = 1 ; <nl> request . http . hdrs = & header ; <nl> request . handshaker = & grpc_httpcli_ssl ; <nl> grpc_refresh_token_credentials_create_from_auth_refresh_token ( <nl> gpr_log ( GPR_ERROR , " Invalid input for refresh token credentials creation " ) ; <nl> return NULL ; <nl> } <nl> - c = ( grpc_google_refresh_token_credentials * ) gpr_zalloc ( sizeof ( grpc_google_refresh_token_credentials ) ) ; <nl> + c = ( grpc_google_refresh_token_credentials * ) gpr_zalloc ( <nl> + sizeof ( grpc_google_refresh_token_credentials ) ) ; <nl> init_oauth2_token_fetcher ( & c - > base , refresh_token_fetch_oauth2 ) ; <nl> c - > base . base . vtable = & refresh_token_vtable ; <nl> c - > refresh_token = refresh_token ; <nl> static grpc_call_credentials_vtable access_token_vtable = { <nl> grpc_call_credentials * grpc_access_token_credentials_create ( <nl> const char * access_token , void * reserved ) { <nl> grpc_access_token_credentials * c = <nl> - gpr_zalloc ( sizeof ( grpc_access_token_credentials ) ) ; <nl> + ( grpc_access_token_credentials * ) gpr_zalloc ( <nl> + sizeof ( grpc_access_token_credentials ) ) ; <nl> GRPC_API_TRACE ( <nl> " grpc_access_token_credentials_create ( access_token = < redacted > , " <nl> " reserved = % p ) " , <nl> mmm a / src / core / lib / security / credentials / plugin / plugin_credentials . c <nl> ppp b / src / core / lib / security / credentials / plugin / plugin_credentials . c <nl> static grpc_call_credentials_vtable plugin_vtable = { <nl> <nl> grpc_call_credentials * grpc_metadata_credentials_create_from_plugin ( <nl> grpc_metadata_credentials_plugin plugin , void * reserved ) { <nl> - grpc_plugin_credentials * c = ( grpc_plugin_credentials * ) gpr_zalloc ( sizeof ( * c ) ) ; <nl> + grpc_plugin_credentials * c = <nl> + ( grpc_plugin_credentials * ) gpr_zalloc ( sizeof ( * c ) ) ; <nl> GRPC_API_TRACE ( " grpc_metadata_credentials_create_from_plugin ( reserved = % p ) " , 1 , <nl> ( reserved ) ) ; <nl> GPR_ASSERT ( reserved = = NULL ) ; <nl> mmm a / src / core / lib / security / credentials / ssl / ssl_credentials . c <nl> ppp b / src / core / lib / security / credentials / ssl / ssl_credentials . c <nl> static grpc_security_status ssl_create_security_connector ( <nl> return status ; <nl> } <nl> grpc_arg new_arg = <nl> - grpc_channel_arg_string_create ( GRPC_ARG_HTTP2_SCHEME , " https " ) ; <nl> + grpc_channel_arg_string_create ( ( char * ) GRPC_ARG_HTTP2_SCHEME , ( char * ) " https " ) ; <nl> * new_args = grpc_channel_args_copy_and_add ( args , & new_arg , 1 ) ; <nl> return status ; <nl> } <nl> static void ssl_build_config ( const char * pem_root_certs , <nl> grpc_channel_credentials * grpc_ssl_credentials_create ( <nl> const char * pem_root_certs , grpc_ssl_pem_key_cert_pair * pem_key_cert_pair , <nl> void * reserved ) { <nl> - grpc_ssl_credentials * c = ( grpc_ssl_credentials * ) gpr_zalloc ( sizeof ( grpc_ssl_credentials ) ) ; <nl> + grpc_ssl_credentials * c = <nl> + ( grpc_ssl_credentials * ) gpr_zalloc ( sizeof ( grpc_ssl_credentials ) ) ; <nl> GRPC_API_TRACE ( <nl> " grpc_ssl_credentials_create ( pem_root_certs = % s , " <nl> " pem_key_cert_pair = % p , " <nl> static void ssl_build_server_config ( <nl> } <nl> if ( num_key_cert_pairs > 0 ) { <nl> GPR_ASSERT ( pem_key_cert_pairs ! = NULL ) ; <nl> - config - > pem_key_cert_pairs = <nl> - gpr_zalloc ( num_key_cert_pairs * sizeof ( tsi_ssl_pem_key_cert_pair ) ) ; <nl> + config - > pem_key_cert_pairs = ( tsi_ssl_pem_key_cert_pair * ) gpr_zalloc ( <nl> + num_key_cert_pairs * sizeof ( tsi_ssl_pem_key_cert_pair ) ) ; <nl> } <nl> config - > num_key_cert_pairs = num_key_cert_pairs ; <nl> for ( i = 0 ; i < num_key_cert_pairs ; i + + ) { <nl> grpc_server_credentials * grpc_ssl_server_credentials_create_ex ( <nl> size_t num_key_cert_pairs , <nl> grpc_ssl_client_certificate_request_type client_certificate_request , <nl> void * reserved ) { <nl> - grpc_ssl_server_credentials * c = <nl> - gpr_zalloc ( sizeof ( grpc_ssl_server_credentials ) ) ; <nl> + grpc_ssl_server_credentials * c = ( grpc_ssl_server_credentials * ) gpr_zalloc ( <nl> + sizeof ( grpc_ssl_server_credentials ) ) ; <nl> GRPC_API_TRACE ( <nl> " grpc_ssl_server_credentials_create_ex ( " <nl> " pem_root_certs = % s , pem_key_cert_pairs = % p , num_key_cert_pairs = % lu , " <nl> mmm a / src / core / lib / security / transport / client_auth_filter . c <nl> ppp b / src / core / lib / security / transport / client_auth_filter . c <nl> static void add_error ( grpc_error * * combined , grpc_error * error ) { <nl> static void on_credentials_metadata ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * input_error ) { <nl> grpc_transport_stream_op_batch * batch = ( grpc_transport_stream_op_batch * ) arg ; <nl> - grpc_call_element * elem = batch - > handler_private . extra_arg ; <nl> - call_data * calld = elem - > call_data ; <nl> + grpc_call_element * elem = <nl> + ( grpc_call_element * ) batch - > handler_private . extra_arg ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> reset_auth_metadata_context ( & calld - > auth_md_context ) ; <nl> grpc_error * error = GRPC_ERROR_REF ( input_error ) ; <nl> if ( error = = GRPC_ERROR_NONE ) { <nl> static void cancel_get_request_metadata ( grpc_exec_ctx * exec_ctx , void * arg , <nl> static void send_security_metadata ( grpc_exec_ctx * exec_ctx , <nl> grpc_call_element * elem , <nl> grpc_transport_stream_op_batch * batch ) { <nl> - call_data * calld = elem - > call_data ; <nl> - channel_data * chand = elem - > channel_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> + channel_data * chand = ( channel_data * ) elem - > channel_data ; <nl> grpc_client_security_context * ctx = <nl> ( grpc_client_security_context * ) batch - > payload <nl> - > context [ GRPC_CONTEXT_SECURITY ] <nl> static void send_security_metadata ( grpc_exec_ctx * exec_ctx , <nl> static void on_host_checked ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> grpc_transport_stream_op_batch * batch = ( grpc_transport_stream_op_batch * ) arg ; <nl> - grpc_call_element * elem = batch - > handler_private . extra_arg ; <nl> - call_data * calld = elem - > call_data ; <nl> + grpc_call_element * elem = ( grpc_call_element * ) batch - > handler_private . extra_arg ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> if ( error = = GRPC_ERROR_NONE ) { <nl> send_security_metadata ( exec_ctx , elem , batch ) ; <nl> } else { <nl> static void auth_start_transport_stream_op_batch ( <nl> GPR_TIMER_BEGIN ( " auth_start_transport_stream_op_batch " , 0 ) ; <nl> <nl> / * grab pointers to our data from the call element * / <nl> - call_data * calld = elem - > call_data ; <nl> - channel_data * chand = elem - > channel_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> + channel_data * chand = ( channel_data * ) elem - > channel_data ; <nl> <nl> if ( ! batch - > cancel_stream ) { <nl> GPR_ASSERT ( batch - > payload - > context ! = NULL ) ; <nl> static void auth_start_transport_stream_op_batch ( <nl> grpc_client_security_context_destroy ; <nl> } <nl> grpc_client_security_context * sec_ctx = <nl> - batch - > payload - > context [ GRPC_CONTEXT_SECURITY ] . value ; <nl> + ( grpc_client_security_context * ) batch - > payload <nl> + - > context [ GRPC_CONTEXT_SECURITY ] <nl> + . value ; <nl> GRPC_AUTH_CONTEXT_UNREF ( sec_ctx - > auth_context , " client auth filter " ) ; <nl> sec_ctx - > auth_context = <nl> GRPC_AUTH_CONTEXT_REF ( chand - > auth_context , " client_auth_filter " ) ; <nl> static void auth_start_transport_stream_op_batch ( <nl> static grpc_error * init_call_elem ( grpc_exec_ctx * exec_ctx , <nl> grpc_call_element * elem , <nl> const grpc_call_element_args * args ) { <nl> - call_data * calld = elem - > call_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> calld - > owning_call = args - > call_stack ; <nl> calld - > call_combiner = args - > call_combiner ; <nl> return GRPC_ERROR_NONE ; <nl> static grpc_error * init_call_elem ( grpc_exec_ctx * exec_ctx , <nl> static void set_pollset_or_pollset_set ( grpc_exec_ctx * exec_ctx , <nl> grpc_call_element * elem , <nl> grpc_polling_entity * pollent ) { <nl> - call_data * calld = elem - > call_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> calld - > pollent = pollent ; <nl> } <nl> <nl> static void set_pollset_or_pollset_set ( grpc_exec_ctx * exec_ctx , <nl> static void destroy_call_elem ( grpc_exec_ctx * exec_ctx , grpc_call_element * elem , <nl> const grpc_call_final_info * final_info , <nl> grpc_closure * ignored ) { <nl> - call_data * calld = elem - > call_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> grpc_credentials_mdelem_array_destroy ( exec_ctx , & calld - > md_array ) ; <nl> grpc_call_credentials_unref ( exec_ctx , calld - > creds ) ; <nl> if ( calld - > have_host ) { <nl> static grpc_error * init_channel_elem ( grpc_exec_ctx * exec_ctx , <nl> } <nl> <nl> / * grab pointers to our data from the channel element * / <nl> - channel_data * chand = elem - > channel_data ; <nl> + channel_data * chand = ( channel_data * ) elem - > channel_data ; <nl> <nl> / * The first and the last filters tend to be implemented differently to <nl> handle the case that there ' s no ' next ' filter to call on the up or down <nl> static grpc_error * init_channel_elem ( grpc_exec_ctx * exec_ctx , <nl> static void destroy_channel_elem ( grpc_exec_ctx * exec_ctx , <nl> grpc_channel_element * elem ) { <nl> / * grab pointers to our data from the channel element * / <nl> - channel_data * chand = elem - > channel_data ; <nl> + channel_data * chand = ( channel_data * ) elem - > channel_data ; <nl> grpc_channel_security_connector * sc = chand - > security_connector ; <nl> if ( sc ! = NULL ) { <nl> GRPC_SECURITY_CONNECTOR_UNREF ( exec_ctx , & sc - > base , " client_auth_filter " ) ; <nl> mmm a / src / core / lib / security / transport / lb_targets_info . c <nl> ppp b / src / core / lib / security / transport / lb_targets_info . c <nl> <nl> * secure naming purposes . * / <nl> # define GRPC_ARG_LB_SECURE_NAMING_MAP " grpc . lb_secure_naming_map " <nl> <nl> - static void * targets_info_copy ( void * p ) { return grpc_slice_hash_table_ref ( p ) ; } <nl> + static void * targets_info_copy ( void * p ) { <nl> + return grpc_slice_hash_table_ref ( ( grpc_slice_hash_table * ) p ) ; <nl> + } <nl> static void targets_info_destroy ( grpc_exec_ctx * exec_ctx , void * p ) { <nl> - grpc_slice_hash_table_unref ( exec_ctx , p ) ; <nl> + grpc_slice_hash_table_unref ( exec_ctx , ( grpc_slice_hash_table * ) p ) ; <nl> } <nl> static int targets_info_cmp ( void * a , void * b ) { <nl> - return grpc_slice_hash_table_cmp ( a , b ) ; <nl> + return grpc_slice_hash_table_cmp ( ( const grpc_slice_hash_table * ) a , <nl> + ( const grpc_slice_hash_table * ) b ) ; <nl> } <nl> static const grpc_arg_pointer_vtable server_to_balancer_names_vtable = { <nl> targets_info_copy , targets_info_destroy , targets_info_cmp } ; <nl> <nl> grpc_arg grpc_lb_targets_info_create_channel_arg ( <nl> grpc_slice_hash_table * targets_info ) { <nl> - return grpc_channel_arg_pointer_create ( GRPC_ARG_LB_SECURE_NAMING_MAP , <nl> + return grpc_channel_arg_pointer_create ( ( char * ) GRPC_ARG_LB_SECURE_NAMING_MAP , <nl> targets_info , <nl> & server_to_balancer_names_vtable ) ; <nl> } <nl> grpc_slice_hash_table * grpc_lb_targets_info_find_in_args ( <nl> grpc_channel_args_find ( args , GRPC_ARG_LB_SECURE_NAMING_MAP ) ; <nl> if ( targets_info_arg ! = NULL ) { <nl> GPR_ASSERT ( targets_info_arg - > type = = GRPC_ARG_POINTER ) ; <nl> - return targets_info_arg - > value . pointer . p ; <nl> + return ( grpc_slice_hash_table * ) targets_info_arg - > value . pointer . p ; <nl> } <nl> return NULL ; <nl> } <nl> mmm a / src / core / lib / security / transport / security_connector . c <nl> ppp b / src / core / lib / security / transport / security_connector . c <nl> void grpc_security_connector_unref ( grpc_exec_ctx * exec_ctx , <nl> } <nl> <nl> static void connector_pointer_arg_destroy ( grpc_exec_ctx * exec_ctx , void * p ) { <nl> - GRPC_SECURITY_CONNECTOR_UNREF ( exec_ctx , p , " connector_pointer_arg_destroy " ) ; <nl> + GRPC_SECURITY_CONNECTOR_UNREF ( exec_ctx , ( grpc_security_connector * ) p , <nl> + " connector_pointer_arg_destroy " ) ; <nl> } <nl> <nl> static void * connector_pointer_arg_copy ( void * p ) { <nl> - return GRPC_SECURITY_CONNECTOR_REF ( p , " connector_pointer_arg_copy " ) ; <nl> + return GRPC_SECURITY_CONNECTOR_REF ( ( grpc_security_connector * ) p , <nl> + " connector_pointer_arg_copy " ) ; <nl> } <nl> <nl> static int connector_pointer_cmp ( void * a , void * b ) { return GPR_ICMP ( a , b ) ; } <nl> static const grpc_arg_pointer_vtable connector_pointer_vtable = { <nl> connector_pointer_cmp } ; <nl> <nl> grpc_arg grpc_security_connector_to_arg ( grpc_security_connector * sc ) { <nl> - return grpc_channel_arg_pointer_create ( GRPC_ARG_SECURITY_CONNECTOR , sc , <nl> - & connector_pointer_vtable ) ; <nl> + return grpc_channel_arg_pointer_create ( ( char * ) GRPC_ARG_SECURITY_CONNECTOR , <nl> + sc , & connector_pointer_vtable ) ; <nl> } <nl> <nl> grpc_security_connector * grpc_security_connector_from_arg ( const grpc_arg * arg ) { <nl> grpc_security_connector * grpc_security_connector_from_arg ( const grpc_arg * arg ) { <nl> GRPC_ARG_SECURITY_CONNECTOR ) ; <nl> return NULL ; <nl> } <nl> - return arg - > value . pointer . p ; <nl> + return ( grpc_security_connector * ) arg - > value . pointer . p ; <nl> } <nl> <nl> grpc_security_connector * grpc_security_connector_find_in_args ( <nl> static grpc_security_connector_vtable fake_server_vtable = { <nl> grpc_channel_security_connector * grpc_fake_channel_security_connector_create ( <nl> grpc_call_credentials * request_metadata_creds , const char * target , <nl> const grpc_channel_args * args ) { <nl> - grpc_fake_channel_security_connector * c = ( grpc_fake_channel_security_connector * ) gpr_zalloc ( sizeof ( * c ) ) ; <nl> + grpc_fake_channel_security_connector * c = <nl> + ( grpc_fake_channel_security_connector * ) gpr_zalloc ( sizeof ( * c ) ) ; <nl> gpr_ref_init ( & c - > base . base . refcount , 1 ) ; <nl> c - > base . base . url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME ; <nl> c - > base . base . vtable = & fake_channel_vtable ; <nl> grpc_channel_security_connector * grpc_fake_channel_security_connector_create ( <nl> grpc_server_security_connector * grpc_fake_server_security_connector_create ( <nl> void ) { <nl> grpc_server_security_connector * c = <nl> - gpr_zalloc ( sizeof ( grpc_server_security_connector ) ) ; <nl> + ( grpc_server_security_connector * ) gpr_zalloc ( <nl> + sizeof ( grpc_server_security_connector ) ) ; <nl> gpr_ref_init ( & c - > base . refcount , 1 ) ; <nl> c - > base . vtable = & fake_server_vtable ; <nl> c - > base . url_scheme = GRPC_FAKE_SECURITY_URL_SCHEME ; <nl> tsi_peer tsi_shallow_peer_from_ssl_auth_context ( <nl> while ( grpc_auth_property_iterator_next ( & it ) ! = NULL ) max_num_props + + ; <nl> <nl> if ( max_num_props > 0 ) { <nl> - peer . properties = ( tsi_peer_property * ) gpr_malloc ( max_num_props * sizeof ( tsi_peer_property ) ) ; <nl> + peer . properties = ( tsi_peer_property * ) gpr_malloc ( <nl> + max_num_props * sizeof ( tsi_peer_property ) ) ; <nl> it = grpc_auth_context_property_iterator ( auth_context ) ; <nl> while ( ( prop = grpc_auth_property_iterator_next ( & it ) ) ! = NULL ) { <nl> if ( strcmp ( prop - > name , GRPC_X509_SAN_PROPERTY_NAME ) = = 0 ) { <nl> grpc_security_status grpc_ssl_channel_security_connector_create ( <nl> const char * overridden_target_name , grpc_channel_security_connector * * sc ) { <nl> size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions ( ) ; <nl> const char * * alpn_protocol_strings = <nl> - gpr_malloc ( sizeof ( const char * ) * num_alpn_protocols ) ; <nl> + ( const char * * ) gpr_malloc ( sizeof ( const char * ) * num_alpn_protocols ) ; <nl> tsi_result result = TSI_OK ; <nl> grpc_ssl_channel_security_connector * c ; <nl> size_t i ; <nl> const char * pem_root_certs ; <nl> char * port ; <nl> - <nl> + bool has_key_cert_pair ; <nl> for ( i = 0 ; i < num_alpn_protocols ; i + + ) { <nl> alpn_protocol_strings [ i ] = grpc_chttp2_get_alpn_version_index ( i ) ; <nl> } <nl> grpc_security_status grpc_ssl_channel_security_connector_create ( <nl> pem_root_certs = config - > pem_root_certs ; <nl> } <nl> <nl> - c = ( grpc_ssl_channel_security_connector * ) gpr_zalloc ( sizeof ( grpc_ssl_channel_security_connector ) ) ; <nl> + c = ( grpc_ssl_channel_security_connector * ) gpr_zalloc ( <nl> + sizeof ( grpc_ssl_channel_security_connector ) ) ; <nl> <nl> gpr_ref_init ( & c - > base . base . refcount , 1 ) ; <nl> c - > base . base . vtable = & ssl_channel_vtable ; <nl> grpc_security_status grpc_ssl_channel_security_connector_create ( <nl> c - > overridden_target_name = gpr_strdup ( overridden_target_name ) ; <nl> } <nl> <nl> - bool has_key_cert_pair = config - > pem_key_cert_pair . private_key ! = NULL & & <nl> - config - > pem_key_cert_pair . cert_chain ! = NULL ; <nl> + has_key_cert_pair = config - > pem_key_cert_pair . private_key ! = NULL & & <nl> + config - > pem_key_cert_pair . cert_chain ! = NULL ; <nl> result = tsi_create_ssl_client_handshaker_factory ( <nl> has_key_cert_pair ? & config - > pem_key_cert_pair : NULL , pem_root_certs , <nl> ssl_cipher_suites ( ) , alpn_protocol_strings , ( uint16_t ) num_alpn_protocols , <nl> grpc_security_status grpc_ssl_server_security_connector_create ( <nl> grpc_server_security_connector * * sc ) { <nl> size_t num_alpn_protocols = grpc_chttp2_num_alpn_versions ( ) ; <nl> const char * * alpn_protocol_strings = <nl> - gpr_malloc ( sizeof ( const char * ) * num_alpn_protocols ) ; <nl> + ( const char * * ) gpr_malloc ( sizeof ( const char * ) * num_alpn_protocols ) ; <nl> tsi_result result = TSI_OK ; <nl> grpc_ssl_server_security_connector * c ; <nl> size_t i ; <nl> grpc_security_status grpc_ssl_server_security_connector_create ( <nl> gpr_log ( GPR_ERROR , " An SSL server needs a key and a cert . " ) ; <nl> goto error ; <nl> } <nl> - c = ( grpc_ssl_server_security_connector * ) gpr_zalloc ( sizeof ( grpc_ssl_server_security_connector ) ) ; <nl> + c = ( grpc_ssl_server_security_connector * ) gpr_zalloc ( <nl> + sizeof ( grpc_ssl_server_security_connector ) ) ; <nl> <nl> gpr_ref_init ( & c - > base . base . refcount , 1 ) ; <nl> c - > base . base . url_scheme = GRPC_SSL_URL_SCHEME ; <nl> mmm a / src / core / lib / security / transport / server_auth_filter . c <nl> ppp b / src / core / lib / security / transport / server_auth_filter . c <nl> static grpc_metadata_array metadata_batch_to_md_array ( <nl> grpc_slice value = GRPC_MDVALUE ( md ) ; <nl> if ( result . count = = result . capacity ) { <nl> result . capacity = GPR_MAX ( result . capacity + 8 , result . capacity * 2 ) ; <nl> - result . metadata = <nl> - gpr_realloc ( result . metadata , result . capacity * sizeof ( grpc_metadata ) ) ; <nl> + result . metadata = ( grpc_metadata * ) gpr_realloc ( <nl> + result . metadata , result . capacity * sizeof ( grpc_metadata ) ) ; <nl> } <nl> usr_md = & result . metadata [ result . count + + ] ; <nl> usr_md - > key = grpc_slice_ref_internal ( key ) ; <nl> static grpc_metadata_array metadata_batch_to_md_array ( <nl> static grpc_filtered_mdelem remove_consumed_md ( grpc_exec_ctx * exec_ctx , <nl> void * user_data , <nl> grpc_mdelem md ) { <nl> - grpc_call_element * elem = user_data ; <nl> - call_data * calld = elem - > call_data ; <nl> + grpc_call_element * elem = ( grpc_call_element * ) user_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> size_t i ; <nl> for ( i = 0 ; i < calld - > num_consumed_md ; i + + ) { <nl> const grpc_metadata * consumed_md = & calld - > consumed_md [ i ] ; <nl> static void on_md_processing_done_inner ( grpc_exec_ctx * exec_ctx , <nl> const grpc_metadata * response_md , <nl> size_t num_response_md , <nl> grpc_error * error ) { <nl> - call_data * calld = elem - > call_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> grpc_transport_stream_op_batch * batch = calld - > recv_initial_metadata_batch ; <nl> / * TODO ( jboeuf ) : Implement support for response_md . * / <nl> if ( response_md ! = NULL & & num_response_md > 0 ) { <nl> static void on_md_processing_done ( <nl> void * user_data , const grpc_metadata * consumed_md , size_t num_consumed_md , <nl> const grpc_metadata * response_md , size_t num_response_md , <nl> grpc_status_code status , const char * error_details ) { <nl> - grpc_call_element * elem = user_data ; <nl> - call_data * calld = elem - > call_data ; <nl> + grpc_call_element * elem = ( grpc_call_element * ) user_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT ; <nl> / / If the call was not cancelled while we were in flight , process the result . <nl> if ( gpr_atm_full_cas ( & calld - > state , ( gpr_atm ) STATE_INIT , <nl> static void on_md_processing_done ( <nl> <nl> static void cancel_call ( grpc_exec_ctx * exec_ctx , void * arg , grpc_error * error ) { <nl> grpc_call_element * elem = ( grpc_call_element * ) arg ; <nl> - call_data * calld = elem - > call_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> / / If the result was not already processed , invoke the callback now . <nl> if ( error ! = GRPC_ERROR_NONE & & <nl> gpr_atm_full_cas ( & calld - > state , ( gpr_atm ) STATE_INIT , <nl> static void cancel_call ( grpc_exec_ctx * exec_ctx , void * arg , grpc_error * error ) { <nl> static void recv_initial_metadata_ready ( grpc_exec_ctx * exec_ctx , void * arg , <nl> grpc_error * error ) { <nl> grpc_call_element * elem = ( grpc_call_element * ) arg ; <nl> - channel_data * chand = elem - > channel_data ; <nl> - call_data * calld = elem - > call_data ; <nl> + channel_data * chand = ( channel_data * ) elem - > channel_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> grpc_transport_stream_op_batch * batch = calld - > recv_initial_metadata_batch ; <nl> if ( error = = GRPC_ERROR_NONE ) { <nl> if ( chand - > creds ! = NULL & & chand - > creds - > processor . process ! = NULL ) { <nl> static void recv_initial_metadata_ready ( grpc_exec_ctx * exec_ctx , void * arg , <nl> static void auth_start_transport_stream_op_batch ( <nl> grpc_exec_ctx * exec_ctx , grpc_call_element * elem , <nl> grpc_transport_stream_op_batch * batch ) { <nl> - call_data * calld = elem - > call_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> if ( batch - > recv_initial_metadata ) { <nl> / / Inject our callback . <nl> calld - > recv_initial_metadata_batch = batch ; <nl> static void auth_start_transport_stream_op_batch ( <nl> static grpc_error * init_call_elem ( grpc_exec_ctx * exec_ctx , <nl> grpc_call_element * elem , <nl> const grpc_call_element_args * args ) { <nl> - call_data * calld = elem - > call_data ; <nl> - channel_data * chand = elem - > channel_data ; <nl> + call_data * calld = ( call_data * ) elem - > call_data ; <nl> + channel_data * chand = ( channel_data * ) elem - > channel_data ; <nl> calld - > call_combiner = args - > call_combiner ; <nl> calld - > owning_call = args - > call_stack ; <nl> GRPC_CLOSURE_INIT ( & calld - > recv_initial_metadata_ready , <nl> static grpc_error * init_channel_elem ( grpc_exec_ctx * exec_ctx , <nl> grpc_channel_element * elem , <nl> grpc_channel_element_args * args ) { <nl> GPR_ASSERT ( ! args - > is_last ) ; <nl> - channel_data * chand = elem - > channel_data ; <nl> + channel_data * chand = ( channel_data * ) elem - > channel_data ; <nl> grpc_auth_context * auth_context = <nl> grpc_find_auth_context_in_args ( args - > channel_args ) ; <nl> GPR_ASSERT ( auth_context ! = NULL ) ; <nl> static grpc_error * init_channel_elem ( grpc_exec_ctx * exec_ctx , <nl> / * Destructor for channel data * / <nl> static void destroy_channel_elem ( grpc_exec_ctx * exec_ctx , <nl> grpc_channel_element * elem ) { <nl> - channel_data * chand = elem - > channel_data ; <nl> + channel_data * chand = ( channel_data * ) elem - > channel_data ; <nl> GRPC_AUTH_CONTEXT_UNREF ( chand - > auth_context , " server_auth_filter " ) ; <nl> grpc_server_credentials_unref ( exec_ctx , chand - > creds ) ; <nl> } <nl> mmm a / src / core / tsi / fake_transport_security . c <nl> ppp b / src / core / tsi / fake_transport_security . c <nl> static const char * tsi_fake_handshake_message_to_string ( int msg ) { <nl> <nl> static tsi_result tsi_fake_handshake_message_from_string ( <nl> const char * msg_string , tsi_fake_handshake_message * msg ) { <nl> - tsi_fake_handshake_message i ; <nl> + int i ; <nl> for ( i = 0 ; i < TSI_FAKE_HANDSHAKE_MESSAGE_MAX ; i + + ) { <nl> if ( strncmp ( msg_string , tsi_fake_handshake_message_strings [ i ] , <nl> strlen ( tsi_fake_handshake_message_strings [ i ] ) ) = = 0 ) { <nl> - * msg = i ; <nl> + * msg = ( tsi_fake_handshake_message ) i ; <nl> return TSI_OK ; <nl> } <nl> } <nl> static void tsi_fake_frame_reset ( tsi_fake_frame * frame , int needs_draining ) { <nl> static void tsi_fake_frame_ensure_size ( tsi_fake_frame * frame ) { <nl> if ( frame - > data = = NULL ) { <nl> frame - > allocated_size = frame - > size ; <nl> - frame - > data = ( unsigned char * ) gpr_malloc ( frame - > allocated_size ) ; <nl> + frame - > data = ( unsigned char * ) gpr_malloc ( frame - > allocated_size ) ; <nl> } else if ( frame - > size > frame - > allocated_size ) { <nl> - unsigned char * new_data = ( unsigned char * ) gpr_realloc ( frame - > data , frame - > size ) ; <nl> + unsigned char * new_data = <nl> + ( unsigned char * ) gpr_realloc ( frame - > data , frame - > size ) ; <nl> frame - > data = new_data ; <nl> frame - > allocated_size = frame - > size ; <nl> } <nl> static tsi_result tsi_fake_frame_decode ( const unsigned char * incoming_bytes , <nl> if ( frame - > needs_draining ) return TSI_INTERNAL_ERROR ; <nl> if ( frame - > data = = NULL ) { <nl> frame - > allocated_size = TSI_FAKE_FRAME_INITIAL_ALLOCATED_SIZE ; <nl> - frame - > data = ( unsigned char * ) gpr_malloc ( frame - > allocated_size ) ; <nl> + frame - > data = ( unsigned char * ) gpr_malloc ( frame - > allocated_size ) ; <nl> } <nl> <nl> if ( frame - > offset < TSI_FAKE_FRAME_HEADER_SIZE ) { <nl> static tsi_result fake_handshaker_result_create ( <nl> handshaker_result = = NULL ) { <nl> return TSI_INVALID_ARGUMENT ; <nl> } <nl> - fake_handshaker_result * result = ( fake_handshaker_result * ) gpr_zalloc ( sizeof ( * result ) ) ; <nl> + fake_handshaker_result * result = <nl> + ( fake_handshaker_result * ) gpr_zalloc ( sizeof ( * result ) ) ; <nl> result - > base . vtable = & handshaker_result_vtable ; <nl> if ( unused_bytes_size > 0 ) { <nl> - result - > unused_bytes = ( unsigned char * ) gpr_malloc ( unused_bytes_size ) ; <nl> + result - > unused_bytes = ( unsigned char * ) gpr_malloc ( unused_bytes_size ) ; <nl> memcpy ( result - > unused_bytes , unused_bytes , unused_bytes_size ) ; <nl> } <nl> result - > unused_bytes_size = unused_bytes_size ; <nl> static tsi_result fake_handshaker_get_bytes_to_send_to_peer ( <nl> } <nl> if ( ! impl - > outgoing_frame . needs_draining ) { <nl> tsi_fake_handshake_message next_message_to_send = <nl> - impl - > next_message_to_send + 2 ; <nl> + ( tsi_fake_handshake_message ) ( impl - > next_message_to_send + 2 ) ; <nl> const char * msg_string = <nl> tsi_fake_handshake_message_to_string ( impl - > next_message_to_send ) ; <nl> result = tsi_fake_frame_set_data ( ( unsigned char * ) msg_string , <nl> static tsi_result fake_handshaker_process_bytes_from_peer ( <nl> tsi_handshaker * self , const unsigned char * bytes , size_t * bytes_size ) { <nl> tsi_result result = TSI_OK ; <nl> tsi_fake_handshaker * impl = ( tsi_fake_handshaker * ) self ; <nl> - tsi_fake_handshake_message expected_msg = impl - > next_message_to_send - 1 ; <nl> + tsi_fake_handshake_message expected_msg = <nl> + ( tsi_fake_handshake_message ) ( impl - > next_message_to_send - 1 ) ; <nl> tsi_fake_handshake_message received_msg ; <nl> <nl> if ( ! impl - > needs_incoming_message | | impl - > result = = TSI_OK ) { <nl> static tsi_result fake_handshaker_next ( <nl> if ( result = = TSI_INCOMPLETE_DATA ) { <nl> handshaker - > outgoing_bytes_buffer_size * = 2 ; <nl> handshaker - > outgoing_bytes_buffer = <nl> - gpr_realloc ( handshaker - > outgoing_bytes_buffer , <nl> - handshaker - > outgoing_bytes_buffer_size ) ; <nl> + ( unsigned char * ) gpr_realloc ( handshaker - > outgoing_bytes_buffer , <nl> + handshaker - > outgoing_bytes_buffer_size ) ; <nl> } <nl> } while ( result = = TSI_INCOMPLETE_DATA ) ; <nl> if ( result ! = TSI_OK ) return result ; <nl> static const tsi_handshaker_vtable handshaker_vtable = { <nl> } ; <nl> <nl> tsi_handshaker * tsi_create_fake_handshaker ( int is_client ) { <nl> - tsi_fake_handshaker * impl = ( tsi_fake_handshaker * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> + tsi_fake_handshaker * impl = ( tsi_fake_handshaker * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> impl - > base . vtable = & handshaker_vtable ; <nl> impl - > is_client = is_client ; <nl> impl - > result = TSI_HANDSHAKE_IN_PROGRESS ; <nl> impl - > outgoing_bytes_buffer_size = <nl> TSI_FAKE_HANDSHAKER_OUTGOING_BUFFER_INITIAL_SIZE ; <nl> - impl - > outgoing_bytes_buffer = ( unsigned char * ) gpr_malloc ( impl - > outgoing_bytes_buffer_size ) ; <nl> + impl - > outgoing_bytes_buffer = <nl> + ( unsigned char * ) gpr_malloc ( impl - > outgoing_bytes_buffer_size ) ; <nl> if ( is_client ) { <nl> impl - > needs_incoming_message = 0 ; <nl> impl - > next_message_to_send = TSI_FAKE_CLIENT_INIT ; <nl> tsi_handshaker * tsi_create_fake_handshaker ( int is_client ) { <nl> <nl> tsi_frame_protector * tsi_create_fake_frame_protector ( <nl> size_t * max_protected_frame_size ) { <nl> - tsi_fake_frame_protector * impl = ( tsi_fake_frame_protector * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> + tsi_fake_frame_protector * impl = <nl> + ( tsi_fake_frame_protector * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> impl - > max_frame_size = ( max_protected_frame_size = = NULL ) <nl> ? TSI_FAKE_DEFAULT_FRAME_SIZE <nl> : * max_protected_frame_size ; <nl> tsi_frame_protector * tsi_create_fake_frame_protector ( <nl> <nl> tsi_zero_copy_grpc_protector * tsi_create_fake_zero_copy_grpc_protector ( <nl> size_t * max_protected_frame_size ) { <nl> - tsi_fake_zero_copy_grpc_protector * impl = ( tsi_fake_zero_copy_grpc_protector * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> + tsi_fake_zero_copy_grpc_protector * impl = <nl> + ( tsi_fake_zero_copy_grpc_protector * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> grpc_slice_buffer_init ( & impl - > header_sb ) ; <nl> grpc_slice_buffer_init ( & impl - > protected_sb ) ; <nl> impl - > max_frame_size = ( max_protected_frame_size = = NULL ) <nl> mmm a / src / core / tsi / ssl_transport_security . c <nl> ppp b / src / core / tsi / ssl_transport_security . c <nl> static void init_openssl ( void ) { <nl> OpenSSL_add_all_algorithms ( ) ; <nl> num_locks = CRYPTO_num_locks ( ) ; <nl> GPR_ASSERT ( num_locks > 0 ) ; <nl> - openssl_mutexes = ( gpr_mu * ) gpr_malloc ( ( size_t ) num_locks * sizeof ( gpr_mu ) ) ; <nl> + openssl_mutexes = ( gpr_mu * ) gpr_malloc ( ( size_t ) num_locks * sizeof ( gpr_mu ) ) ; <nl> for ( i = 0 ; i < CRYPTO_num_locks ( ) ; i + + ) { <nl> gpr_mu_init ( & openssl_mutexes [ i ] ) ; <nl> } <nl> static tsi_result peer_from_x509 ( X509 * cert , int include_certificate_type , <nl> tsi_peer * peer ) { <nl> / * TODO ( jboeuf ) : Maybe add more properties . * / <nl> GENERAL_NAMES * subject_alt_names = <nl> - X509_get_ext_d2i ( cert , NID_subject_alt_name , 0 , 0 ) ; <nl> + ( GENERAL_NAMES * ) X509_get_ext_d2i ( cert , NID_subject_alt_name , 0 , 0 ) ; <nl> int subject_alt_name_count = ( subject_alt_names ! = NULL ) <nl> ? ( int ) sk_GENERAL_NAME_num ( subject_alt_names ) <nl> : 0 ; <nl> static tsi_result ssl_ctx_use_certificate_chain ( SSL_CTX * context , <nl> if ( pem = = NULL ) return TSI_OUT_OF_RESOURCES ; <nl> <nl> do { <nl> - certificate = PEM_read_bio_X509_AUX ( pem , NULL , NULL , " " ) ; <nl> + certificate = PEM_read_bio_X509_AUX ( pem , NULL , NULL , ( void * ) " " ) ; <nl> if ( certificate = = NULL ) { <nl> result = TSI_INVALID_ARGUMENT ; <nl> break ; <nl> static tsi_result ssl_ctx_use_certificate_chain ( SSL_CTX * context , <nl> break ; <nl> } <nl> while ( 1 ) { <nl> - X509 * certificate_authority = PEM_read_bio_X509 ( pem , NULL , NULL , " " ) ; <nl> + X509 * certificate_authority = <nl> + PEM_read_bio_X509 ( pem , NULL , NULL , ( void * ) " " ) ; <nl> if ( certificate_authority = = NULL ) { <nl> ERR_clear_error ( ) ; <nl> break ; / * Done reading . * / <nl> static tsi_result ssl_ctx_use_private_key ( SSL_CTX * context , const char * pem_key , <nl> pem = BIO_new_mem_buf ( ( void * ) pem_key , ( int ) pem_key_size ) ; <nl> if ( pem = = NULL ) return TSI_OUT_OF_RESOURCES ; <nl> do { <nl> - private_key = PEM_read_bio_PrivateKey ( pem , NULL , NULL , " " ) ; <nl> + private_key = PEM_read_bio_PrivateKey ( pem , NULL , NULL , ( void * ) " " ) ; <nl> if ( private_key = = NULL ) { <nl> result = TSI_INVALID_ARGUMENT ; <nl> break ; <nl> static tsi_result ssl_ctx_load_verification_certs ( SSL_CTX * context , <nl> } <nl> <nl> while ( 1 ) { <nl> - root = PEM_read_bio_X509_AUX ( pem , NULL , NULL , " " ) ; <nl> + root = PEM_read_bio_X509_AUX ( pem , NULL , NULL , ( void * ) " " ) ; <nl> if ( root = = NULL ) { <nl> ERR_clear_error ( ) ; <nl> break ; / * We ' re at the end of stream . * / <nl> static tsi_result extract_x509_subject_names_from_pem_cert ( const char * pem_cert , <nl> pem = BIO_new_mem_buf ( ( void * ) pem_cert , ( int ) strlen ( pem_cert ) ) ; <nl> if ( pem = = NULL ) return TSI_OUT_OF_RESOURCES ; <nl> <nl> - cert = PEM_read_bio_X509 ( pem , NULL , NULL , " " ) ; <nl> + cert = PEM_read_bio_X509 ( pem , NULL , NULL , ( void * ) " " ) ; <nl> if ( cert = = NULL ) { <nl> gpr_log ( GPR_ERROR , " Invalid certificate " ) ; <nl> result = TSI_INVALID_ARGUMENT ; <nl> static tsi_result build_alpn_protocol_name_list ( <nl> } <nl> * protocol_name_list_length + = length + 1 ; <nl> } <nl> - * protocol_name_list = ( unsigned char * ) gpr_malloc ( * protocol_name_list_length ) ; <nl> + * protocol_name_list = ( unsigned char * ) gpr_malloc ( * protocol_name_list_length ) ; <nl> if ( * protocol_name_list = = NULL ) return TSI_OUT_OF_RESOURCES ; <nl> current = * protocol_name_list ; <nl> for ( i = 0 ; i < num_alpn_protocols ; i + + ) { <nl> static tsi_result ssl_handshaker_extract_peer ( tsi_handshaker * self , <nl> } <nl> if ( alpn_selected ! = NULL ) { <nl> size_t i ; <nl> - tsi_peer_property * new_properties = <nl> - gpr_zalloc ( sizeof ( * new_properties ) * ( peer - > property_count + 1 ) ) ; <nl> + tsi_peer_property * new_properties = ( tsi_peer_property * ) gpr_zalloc ( <nl> + sizeof ( * new_properties ) * ( peer - > property_count + 1 ) ) ; <nl> for ( i = 0 ; i < peer - > property_count ; i + + ) { <nl> new_properties [ i ] = peer - > properties [ i ] ; <nl> } <nl> static tsi_result ssl_handshaker_create_frame_protector ( <nl> size_t actual_max_output_protected_frame_size = <nl> TSI_SSL_MAX_PROTECTED_FRAME_SIZE_UPPER_BOUND ; <nl> tsi_ssl_handshaker * impl = ( tsi_ssl_handshaker * ) self ; <nl> - tsi_ssl_frame_protector * protector_impl = ( tsi_ssl_frame_protector * ) gpr_zalloc ( sizeof ( * protector_impl ) ) ; <nl> + tsi_ssl_frame_protector * protector_impl = <nl> + ( tsi_ssl_frame_protector * ) gpr_zalloc ( sizeof ( * protector_impl ) ) ; <nl> <nl> if ( max_output_protected_frame_size ! = NULL ) { <nl> if ( * max_output_protected_frame_size > <nl> static tsi_result ssl_handshaker_create_frame_protector ( <nl> } <nl> protector_impl - > buffer_size = <nl> actual_max_output_protected_frame_size - TSI_SSL_MAX_PROTECTION_OVERHEAD ; <nl> - protector_impl - > buffer = ( unsigned char * ) gpr_malloc ( protector_impl - > buffer_size ) ; <nl> + protector_impl - > buffer = <nl> + ( unsigned char * ) gpr_malloc ( protector_impl - > buffer_size ) ; <nl> if ( protector_impl - > buffer = = NULL ) { <nl> gpr_log ( GPR_ERROR , <nl> " Could not allocated buffer for tsi_ssl_frame_protector . " ) ; <nl> static tsi_result create_tsi_ssl_handshaker ( SSL_CTX * ctx , int is_client , <nl> SSL_set_accept_state ( ssl ) ; <nl> } <nl> <nl> - impl = ( tsi_ssl_handshaker * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> + impl = ( tsi_ssl_handshaker * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> impl - > ssl = ssl ; <nl> impl - > into_ssl = into_ssl ; <nl> impl - > from_ssl = from_ssl ; <nl> tsi_result tsi_create_ssl_client_handshaker_factory ( <nl> return TSI_INVALID_ARGUMENT ; <nl> } <nl> <nl> - impl = ( tsi_ssl_client_handshaker_factory * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> + impl = ( tsi_ssl_client_handshaker_factory * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> tsi_ssl_handshaker_factory_init ( & impl - > base ) ; <nl> impl - > base . vtable = & client_handshaker_factory_vtable ; <nl> <nl> tsi_result tsi_create_ssl_server_handshaker_factory_ex ( <nl> return TSI_INVALID_ARGUMENT ; <nl> } <nl> <nl> - impl = ( tsi_ssl_server_handshaker_factory * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> + impl = ( tsi_ssl_server_handshaker_factory * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> tsi_ssl_handshaker_factory_init ( & impl - > base ) ; <nl> impl - > base . vtable = & server_handshaker_factory_vtable ; <nl> <nl> - impl - > ssl_contexts = ( SSL_CTX * * ) gpr_zalloc ( num_key_cert_pairs * sizeof ( SSL_CTX * ) ) ; <nl> + impl - > ssl_contexts = <nl> + ( SSL_CTX * * ) gpr_zalloc ( num_key_cert_pairs * sizeof ( SSL_CTX * ) ) ; <nl> impl - > ssl_context_x509_subject_names = <nl> - gpr_zalloc ( num_key_cert_pairs * sizeof ( tsi_peer ) ) ; <nl> + ( tsi_peer * ) gpr_zalloc ( num_key_cert_pairs * sizeof ( tsi_peer ) ) ; <nl> if ( impl - > ssl_contexts = = NULL | | <nl> impl - > ssl_context_x509_subject_names = = NULL ) { <nl> tsi_ssl_handshaker_factory_unref ( & impl - > base ) ; <nl> mmm a / src / core / tsi / transport_security . c <nl> ppp b / src / core / tsi / transport_security . c <nl> tsi_result tsi_construct_allocated_string_peer_property ( <nl> * property = tsi_init_peer_property ( ) ; <nl> if ( name ! = NULL ) property - > name = gpr_strdup ( name ) ; <nl> if ( value_length > 0 ) { <nl> - property - > value . data = ( char * ) gpr_zalloc ( value_length ) ; <nl> + property - > value . data = ( char * ) gpr_zalloc ( value_length ) ; <nl> property - > value . length = value_length ; <nl> } <nl> return TSI_OK ; <nl> tsi_result tsi_construct_string_peer_property ( const char * name , <nl> tsi_result tsi_construct_peer ( size_t property_count , tsi_peer * peer ) { <nl> memset ( peer , 0 , sizeof ( tsi_peer ) ) ; <nl> if ( property_count > 0 ) { <nl> - peer - > properties = ( tsi_peer_property * ) gpr_zalloc ( property_count * sizeof ( tsi_peer_property ) ) ; <nl> + peer - > properties = ( tsi_peer_property * ) gpr_zalloc ( <nl> + property_count * sizeof ( tsi_peer_property ) ) ; <nl> peer - > property_count = property_count ; <nl> } <nl> return TSI_OK ; <nl> mmm a / src / core / tsi / transport_security_adapter . c <nl> ppp b / src / core / tsi / transport_security_adapter . c <nl> static tsi_result tsi_adapter_create_handshaker_result ( <nl> if ( wrapped = = NULL | | ( unused_bytes_size > 0 & & unused_bytes = = NULL ) ) { <nl> return TSI_INVALID_ARGUMENT ; <nl> } <nl> - tsi_adapter_handshaker_result * impl = ( tsi_adapter_handshaker_result * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> + tsi_adapter_handshaker_result * impl = <nl> + ( tsi_adapter_handshaker_result * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> impl - > base . vtable = & result_vtable ; <nl> impl - > wrapped = wrapped ; <nl> impl - > unused_bytes_size = unused_bytes_size ; <nl> if ( unused_bytes_size > 0 ) { <nl> - impl - > unused_bytes = ( unsigned char * ) gpr_malloc ( unused_bytes_size ) ; <nl> + impl - > unused_bytes = ( unsigned char * ) gpr_malloc ( unused_bytes_size ) ; <nl> memcpy ( impl - > unused_bytes , unused_bytes , unused_bytes_size ) ; <nl> } else { <nl> impl - > unused_bytes = NULL ; <nl> static tsi_result adapter_next ( <nl> offset + = to_send_size ; <nl> if ( status = = TSI_INCOMPLETE_DATA ) { <nl> impl - > adapter_buffer_size * = 2 ; <nl> - impl - > adapter_buffer = <nl> - gpr_realloc ( impl - > adapter_buffer , impl - > adapter_buffer_size ) ; <nl> + impl - > adapter_buffer = ( unsigned char * ) gpr_realloc ( <nl> + impl - > adapter_buffer , impl - > adapter_buffer_size ) ; <nl> } <nl> } while ( status = = TSI_INCOMPLETE_DATA ) ; <nl> if ( status ! = TSI_OK ) return status ; <nl> static const tsi_handshaker_vtable handshaker_vtable = { <nl> <nl> tsi_handshaker * tsi_create_adapter_handshaker ( tsi_handshaker * wrapped ) { <nl> GPR_ASSERT ( wrapped ! = NULL ) ; <nl> - tsi_adapter_handshaker * impl = ( tsi_adapter_handshaker * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> + tsi_adapter_handshaker * impl = <nl> + ( tsi_adapter_handshaker * ) gpr_zalloc ( sizeof ( * impl ) ) ; <nl> impl - > base . vtable = & handshaker_vtable ; <nl> impl - > wrapped = wrapped ; <nl> impl - > adapter_buffer_size = TSI_ADAPTER_INITIAL_BUFFER_SIZE ; <nl> - impl - > adapter_buffer = ( unsigned char * ) gpr_malloc ( impl - > adapter_buffer_size ) ; <nl> + impl - > adapter_buffer = ( unsigned char * ) gpr_malloc ( impl - > adapter_buffer_size ) ; <nl> return & impl - > base ; <nl> } <nl> <nl>
|
More pointer conversions , deprecated string to char * , goto crossing initializations
|
grpc/grpc
|
acd46e571c3dd4721a21c934c4ccb983ed2f687c
|
2017-10-02T23:22:41Z
|
mmm a / dbms / include / DB / IO / ReadHelpers . h <nl> ppp b / dbms / include / DB / IO / ReadHelpers . h <nl> inline bool checkString ( const String & s , ReadBuffer & buf ) <nl> return checkString ( s . c_str ( ) , buf ) ; <nl> } <nl> <nl> + inline bool checkChar ( char c , ReadBuffer & buf ) <nl> + { <nl> + if ( buf . eof ( ) | | * buf . position ( ) ! = c ) <nl> + return false ; <nl> + + + buf . position ( ) ; <nl> + return true ; <nl> + } <nl> + <nl> inline void readBoolText ( bool & x , ReadBuffer & buf ) <nl> { <nl> char tmp = ' 0 ' ; <nl> bool exceptionPolicySelector ( ExcepFun & & excep_f , NoExcepFun & & no_excep_f , Args <nl> <nl> <nl> / / / грубо <nl> - template < typename T , typename ReturnType > <nl> + template < typename T , typename ReturnType , char point_symbol = ' . ' > <nl> ReturnType readFloatTextImpl ( T & x , ReadBuffer & buf ) <nl> { <nl> static constexpr bool throw_exception = std : : is_same < ReturnType , void > : : value ; <nl> ReturnType readFloatTextImpl ( T & x , ReadBuffer & buf ) <nl> case ' - ' : <nl> negative = true ; <nl> break ; <nl> - case ' . ' : <nl> + case point_symbol : <nl> after_point = true ; <nl> break ; <nl> case ' 0 ' : <nl>
|
Merge
|
ClickHouse/ClickHouse
|
1b1a1143a96f98d319bb47d1adf4f9a9852f4b2d
|
2015-12-03T11:02:02Z
|
mmm a / vnext / package . json <nl> ppp b / vnext / package . json <nl> <nl> " tslint - microsoft - contrib " : " ^ 5 . 0 . 1 " , <nl> " tslint - react " : " ^ 3 . 5 . 0 " , <nl> " typescript " : " 3 . 3 . 3 " , <nl> - " react - native " : " 0 . 58 . 6 - microsoft . 34 " <nl> + " react - native " : " 0 . 58 . 6 - microsoft . 36 " <nl> } , <nl> " peerDependencies " : { <nl> " react " : " 16 . 6 . 3 " , <nl> - " react - native " : " 0 . 58 . 6 - microsoft . 34 | | https : / / github . com / Microsoft / react - native / archive / v0 . 58 . 6 - microsoft . 34 . tar . gz " <nl> + " react - native " : " 0 . 58 . 6 - microsoft . 36 | | https : / / github . com / Microsoft / react - native / archive / v0 . 58 . 6 - microsoft . 36 . tar . gz " <nl> } <nl> } <nl> \ No newline at end of file <nl> mmm a / vnext / yarn . lock <nl> ppp b / vnext / yarn . lock <nl> react - native - local - cli @ ^ 1 . 0 . 0 - alpha . 5 : <nl> xcode " ^ 1 . 0 . 0 " <nl> xmldoc " ^ 0 . 4 . 0 " <nl> <nl> - " react - native @ https : / / github . com / Microsoft / react - native / archive / v0 . 58 . 6 - microsoft . 34 . tar . gz " : <nl> - version " 0 . 58 . 6 - microsoft . 34 " <nl> - resolved " https : / / github . com / Microsoft / react - native / archive / v0 . 58 . 6 - microsoft . 34 . tar . gz # 5d1676aa073f7264971bfd27f51d98fdfd55c33e " <nl> + " react - native @ https : / / github . com / Microsoft / react - native / archive / v0 . 58 . 6 - microsoft . 36 . tar . gz " : <nl> + version " 0 . 58 . 6 - microsoft . 36 " <nl> + resolved " https : / / github . com / Microsoft / react - native / archive / v0 . 58 . 6 - microsoft . 36 . tar . gz # 8bd436641c21ab9756ff1aea75377e3344870ca2 " <nl> dependencies : <nl> " @ babel / core " " ^ 7 . 4 . 0 " <nl> " @ babel / generator " " ^ 7 . 4 . 0 " <nl>
|
Update to react - native @ 0 . 58 . 6 - microsoft . 36 ( )
|
microsoft/react-native-windows
|
66323e5de3410b1ca8cf51484eb331bb4d052035
|
2019-05-08T16:49:05Z
|
mmm a / src / clustering / administration / main / command_line . cc <nl> ppp b / src / clustering / administration / main / command_line . cc <nl> <nl> # include < stdio . h > <nl> # include < stdlib . h > <nl> # include < unistd . h > <nl> + # include < libgen . h > <nl> # include < pwd . h > <nl> # include < grp . h > <nl> # include < sys / stat . h > <nl> void remove_pid_file ( ) { <nl> } <nl> } <nl> <nl> + int check_pid_file ( const std : : string & pid_filepath ) { <nl> + guarantee ( pid_filepath . size ( ) > 0 ) ; <nl> + <nl> + if ( access ( pid_filepath . c_str ( ) , F_OK ) = = 0 ) { <nl> + logERR ( " The pid - file specified already exists . This might mean that an instance is already running . " ) ; <nl> + return EXIT_FAILURE ; <nl> + } <nl> + <nl> + / / Make a copy of the filename since ` dirname ` may modify it <nl> + char pid_dir [ PATH_MAX + 1 ] ; <nl> + strncpy ( pid_dir , pid_filepath . c_str ( ) , PATH_MAX + 1 ) ; <nl> + if ( access ( dirname ( pid_dir ) , W_OK ) = = - 1 ) { <nl> + logERR ( " Cannot access the pid - file directory . " ) ; <nl> + return EXIT_FAILURE ; <nl> + } <nl> + <nl> + return EXIT_SUCCESS ; <nl> + } <nl> + <nl> int write_pid_file ( const std : : string & pid_filepath ) { <nl> guarantee ( pid_filepath . size ( ) > 0 ) ; <nl> <nl> int write_pid_file ( const std : : string & pid_filepath ) { <nl> / / pid - file only run if the checks here pass . Right now , this is guaranteed by the return on <nl> / / failure here . <nl> if ( ! pid_file . empty ( ) ) { <nl> - fprintf ( stderr , " ERROR : Attempting to write pid - file twice . \ n " ) ; <nl> + logERR ( " Attempting to write pid - file twice . " ) ; <nl> return EXIT_FAILURE ; <nl> } <nl> - if ( ! access ( pid_filepath . c_str ( ) , F_OK ) ) { <nl> - fprintf ( stderr , " ERROR : The pid - file specified already exists . This might mean that an instance is already running . \ n " ) ; <nl> + <nl> + if ( check_pid_file ( pid_filepath ) = = EXIT_FAILURE ) { <nl> return EXIT_FAILURE ; <nl> } <nl> + <nl> if ( ! numwrite ( pid_filepath . c_str ( ) , getpid ( ) ) ) { <nl> - fprintf ( stderr , " ERROR : Writing to the specified pid - file failed . \ n " ) ; <nl> + logERR ( " Writing to the specified pid - file failed . " ) ; <nl> return EXIT_FAILURE ; <nl> } <nl> pid_file = pid_filepath ; <nl> void set_user_group ( const std : : map < std : : string , options : : values_t > & opts ) { <nl> } <nl> } <nl> <nl> + int check_pid_file ( const std : : map < std : : string , options : : values_t > & opts ) { <nl> + boost : : optional < std : : string > pid_filepath = get_optional_option ( opts , " - - pid - file " ) ; <nl> + if ( ! pid_filepath | | pid_filepath - > empty ( ) ) { <nl> + return EXIT_SUCCESS ; <nl> + } <nl> + <nl> + return check_pid_file ( * pid_filepath ) ; <nl> + } <nl> + <nl> / / Maybe writes a pid file , using the - - pid - file option , if it ' s present . <nl> int write_pid_file ( const std : : map < std : : string , options : : values_t > & opts ) { <nl> boost : : optional < std : : string > pid_filepath = get_optional_option ( opts , " - - pid - file " ) ; <nl> serializer_filepath_t metadata_file ( const base_path_t & dirpath ) { <nl> } <nl> <nl> void initialize_logfile ( const std : : map < std : : string , options : : values_t > & opts , <nl> - const base_path_t & dirpath ) { <nl> + const base_path_t & dirpath ) { <nl> std : : string filename ; <nl> if ( exists_option ( opts , " - - log - file " ) ) { <nl> filename = get_single_option ( opts , " - - log - file " ) ; <nl> int main_rethinkdb_serve ( int argc , char * argv [ ] ) { <nl> base_path . make_absolute ( ) ; <nl> initialize_logfile ( opts , base_path ) ; <nl> <nl> + if ( check_pid_file ( opts ) ! = EXIT_SUCCESS ) { <nl> + return EXIT_FAILURE ; <nl> + } <nl> + <nl> if ( ! maybe_daemonize ( opts ) ) { <nl> / / This is the parent process of the daemon , just exit <nl> return EXIT_SUCCESS ; <nl> int main_rethinkdb_proxy ( int argc , char * argv [ ] ) { <nl> const std : : string web_path = get_web_path ( opts , argv ) ; <nl> const int num_workers = get_cpu_count ( ) ; <nl> <nl> + if ( check_pid_file ( opts ) ! = EXIT_SUCCESS ) { <nl> + return EXIT_FAILURE ; <nl> + } <nl> + <nl> if ( ! maybe_daemonize ( opts ) ) { <nl> / / This is the parent process of the daemon , just exit <nl> return EXIT_SUCCESS ; <nl> int main_rethinkdb_porcelain ( int argc , char * argv [ ] ) { <nl> base_path . make_absolute ( ) ; <nl> initialize_logfile ( opts , base_path ) ; <nl> <nl> + if ( check_pid_file ( opts ) ! = EXIT_SUCCESS ) { <nl> + return EXIT_FAILURE ; <nl> + } <nl> + <nl> if ( ! maybe_daemonize ( opts ) ) { <nl> / / This is the parent process of the daemon , just exit <nl> return EXIT_SUCCESS ; <nl>
|
adding an extra check for pid - file creation , and making the output more reliable , especially when daemonizing
|
rethinkdb/rethinkdb
|
6cafbbbf381962f3c524a387d0e3a8ef133f6fbc
|
2013-05-29T02:16:25Z
|
mmm a / PowerEditor / installer / nativeLang / english . xml <nl> ppp b / PowerEditor / installer / nativeLang / english . xml <nl> Find in all files except exe , obj & amp ; & amp ; log : <nl> < summary - nbsel2 value = " bytes ) in " / > <nl> < summary - nbrange value = " ranges " / > <nl> < multi - edge - radio - tip value = " Add your column marker by indicating its position with a decimal number . <nl> - You can define several column markers by using white space to seperate the different numbers . " / > <nl> + You can define several column markers by using white space to separate the different numbers . " / > <nl> < / MiscStrings > <nl> < / Native - Langue > <nl> < / NotepadPlus > <nl> mmm a / PowerEditor / src / TinyXml / tinyXmlA / tinyxmlerrorA . cpp <nl> ppp b / PowerEditor / src / TinyXml / tinyXmlA / tinyxmlerrorA . cpp <nl> distribution . <nl> <nl> # include " tinyxmlA . h " <nl> <nl> - / / The goal of the seperate error file is to make the first <nl> + / / The goal of the separate error file is to make the first <nl> / / step towards localization . tinyxml ( currently ) only supports <nl> / / latin - 1 , but at least the error messages could now be translated . <nl> / / <nl> mmm a / PowerEditor / src / TinyXml / tinyxmlerror . cpp <nl> ppp b / PowerEditor / src / TinyXml / tinyxmlerror . cpp <nl> distribution . <nl> <nl> # include " tinyxml . h " <nl> <nl> - / / The goal of the seperate error file is to make the first <nl> + / / The goal of the separate error file is to make the first <nl> / / step towards localization . tinyxml ( currently ) only supports <nl> / / latin - 1 , but at least the error messages could now be translated . <nl> / / <nl> mmm a / PowerEditor / src / WinControls / Preference / preferenceDlg . cpp <nl> ppp b / PowerEditor / src / WinControls / Preference / preferenceDlg . cpp <nl> void MarginsDlg : : initScintParam ( ) <nl> : : EnableWindow ( : : GetDlgItem ( _hSelf , IDC_COLUMNPOS_EDIT ) , isEnable & & isCheckedOrNot ( IDC_RADIO_MULTILNMODE ) ) ; <nl> <nl> NativeLangSpeaker * pNativeSpeaker = ( NppParameters : : getInstance ( ) ) . getNativeLangSpeaker ( ) ; <nl> - generic_string radioboxTip = pNativeSpeaker - > getLocalizedStrFromID ( " multi - edge - radio - tip " , TEXT ( " Add your column marker by indicating its position with a decimal number . \ nYou can define several column markers by using white space to seperate the different numbers . " ) ) ; <nl> + generic_string radioboxTip = pNativeSpeaker - > getLocalizedStrFromID ( " multi - edge - radio - tip " , TEXT ( " Add your column marker by indicating its position with a decimal number . \ nYou can define several column markers by using white space to separate the different numbers . " ) ) ; <nl> _multiEdgeTip = CreateToolTip ( IDC_RADIO_MULTILNMODE , _hSelf , _hInst , const_cast < PTSTR > ( radioboxTip . c_str ( ) ) ) ; <nl> <nl> oldFunclstToolbarProc = reinterpret_cast < WNDPROC > ( : : SetWindowLongPtr ( : : GetDlgItem ( _hSelf , IDC_COLUMNPOS_EDIT ) , GWLP_WNDPROC , reinterpret_cast < LONG_PTR > ( editNumSpaceProc ) ) ) ; <nl>
|
Fix typos
|
notepad-plus-plus/notepad-plus-plus
|
8a37faa7046169e4f8b675671e384ade1c9b57a6
|
2020-04-14T20:28:16Z
|
mmm a / include / swift / IDE / Utils . h <nl> ppp b / include / swift / IDE / Utils . h <nl> class DeclNameViewer { <nl> SmallVector < StringRef , 4 > Labels ; <nl> public : <nl> DeclNameViewer ( StringRef Text ) ; <nl> + DeclNameViewer ( ) : DeclNameViewer ( StringRef ( ) ) { } <nl> + operator bool ( ) const { return ! BaseName . empty ( ) ; } <nl> StringRef base ( ) const { return BaseName ; } <nl> llvm : : ArrayRef < StringRef > args ( ) const { return llvm : : makeArrayRef ( Labels ) ; } <nl> + unsigned argSize ( ) const { return Labels . size ( ) ; } <nl> unsigned partsCount ( ) const { return 1 + Labels . size ( ) ; } <nl> unsigned commonPartsCount ( DeclNameViewer & Other ) const ; <nl> } ; <nl> class SourceEditOutputConsumer : public SourceEditConsumer { <nl> void accept ( SourceManager & SM , RegionType RegionType , ArrayRef < Replacement > Replacements ) override ; <nl> } ; <nl> <nl> + enum class LabelRangeEndAt : int8_t { <nl> + BeforeElemStart , <nl> + LabelNameOnly , <nl> + } ; <nl> + <nl> / / Get the ranges of argument labels from an Arg , either tuple or paren . <nl> - std : : vector < CharSourceRange > getCallArgLabelRanges ( SourceManager & SM , Expr * Arg ) ; <nl> + std : : vector < CharSourceRange > <nl> + getCallArgLabelRanges ( SourceManager & SM , Expr * Arg , LabelRangeEndAt EndKind ) ; <nl> + <nl> } / / namespace ide <nl> } / / namespace swift <nl> <nl> mmm a / lib / IDE / APIDigesterData . cpp <nl> ppp b / lib / IDE / APIDigesterData . cpp <nl> struct swift : : ide : : api : : APIDiffItemStore : : Implementation { <nl> ArrayRef < APIDiffItem * > swift : : ide : : api : : APIDiffItemStore : : <nl> getDiffItems ( StringRef Key ) const { <nl> if ( Impl . PrintUsr ) <nl> - llvm : : outs ( ) < < Key ; <nl> + llvm : : outs ( ) < < Key < < " \ n " ; <nl> return Impl . Data [ Key ] ; <nl> } <nl> <nl> mmm a / lib / IDE / SwiftSourceDocInfo . cpp <nl> ppp b / lib / IDE / SwiftSourceDocInfo . cpp <nl> void swift : : ide : : getLocationInfo ( const ValueDecl * VD , <nl> } <nl> <nl> std : : vector < CharSourceRange > swift : : ide : : <nl> - getCallArgLabelRanges ( SourceManager & SM , Expr * Arg ) { <nl> + getCallArgLabelRanges ( SourceManager & SM , Expr * Arg , LabelRangeEndAt EndKind ) { <nl> std : : vector < CharSourceRange > Ranges ; <nl> if ( TupleExpr * TE = dyn_cast < TupleExpr > ( Arg ) ) { <nl> size_t ElemIndex = 0 ; <nl> getCallArgLabelRanges ( SourceManager & SM , Expr * Arg ) { <nl> auto NameIdentifier = TE - > getElementName ( ElemIndex ) ; <nl> if ( ! NameIdentifier . empty ( ) ) { <nl> LabelStart = TE - > getElementNameLoc ( ElemIndex ) ; <nl> + if ( EndKind = = LabelRangeEndAt : : LabelNameOnly ) <nl> + LabelEnd = LabelStart . getAdvancedLoc ( NameIdentifier . getLength ( ) ) ; <nl> } <nl> + <nl> Ranges . push_back ( CharSourceRange ( SM , LabelStart , LabelEnd ) ) ; <nl> + + ElemIndex ; <nl> } <nl> mmm a / lib / Migrator / SyntacticMigratorPass . cpp <nl> ppp b / lib / Migrator / SyntacticMigratorPass . cpp <nl> <nl> <nl> # include " swift / AST / USRGeneration . h " <nl> # include " swift / Frontend / Frontend . h " <nl> + # include " swift / IDE / Utils . h " <nl> # include " swift / Migrator / EditorAdapter . h " <nl> # include " swift / Migrator / FixitApplyDiagnosticConsumer . h " <nl> # include " swift / Migrator / Migrator . h " <nl> <nl> <nl> using namespace swift ; <nl> using namespace swift : : migrator ; <nl> + using namespace swift : : ide ; <nl> using namespace swift : : ide : : api ; <nl> <nl> struct SyntacticMigratorPass : : Implementation : public SourceEntityWalker { <nl> struct SyntacticMigratorPass : : Implementation : public SourceEntityWalker { <nl> return DiffStore . getDiffItems ( Buffer . str ( ) ) ; <nl> } <nl> <nl> + DeclNameViewer getFuncRename ( ValueDecl * VD , bool & IgnoreBase ) { <nl> + for ( auto * Item : getRelatedDiffItems ( VD ) ) { <nl> + if ( auto * CI = dyn_cast < CommonDiffItem > ( Item ) ) { <nl> + if ( CI - > isRename ( ) ) { <nl> + IgnoreBase = true ; <nl> + switch ( CI - > NodeKind ) { <nl> + case SDKNodeKind : : Function : <nl> + IgnoreBase = false ; <nl> + LLVM_FALLTHROUGH ; <nl> + case SDKNodeKind : : Constructor : <nl> + return DeclNameViewer ( CI - > getNewName ( ) ) ; <nl> + default : <nl> + return DeclNameViewer ( ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + return DeclNameViewer ( ) ; <nl> + } <nl> + <nl> bool isSimpleReplacement ( APIDiffItem * Item , std : : string & Text ) { <nl> if ( auto * MD = dyn_cast < TypeMemberDiffItem > ( Item ) ) { <nl> / / We need to pull the self if self index is set . <nl> struct SyntacticMigratorPass : : Implementation : public SourceEntityWalker { <nl> } <nl> return true ; <nl> } <nl> + <nl> + struct ReferenceCollector : public SourceEntityWalker { <nl> + ValueDecl * Target ; <nl> + CharSourceRange Result ; <nl> + ReferenceCollector ( ValueDecl * Target ) : Target ( Target ) { } <nl> + bool visitDeclReference ( ValueDecl * D , CharSourceRange Range , <nl> + TypeDecl * CtorTyRef , ExtensionDecl * ExtTyRef , <nl> + Type T , ReferenceMetaData Data ) override { <nl> + if ( D = = Target ) { <nl> + Result = Range ; <nl> + return false ; <nl> + } <nl> + return true ; <nl> + } <nl> + } ; <nl> + <nl> + void handleFuncRename ( ValueDecl * FD , Expr * FuncRefContainer , Expr * Arg ) { <nl> + bool IgnoreBase = false ; <nl> + if ( auto View = getFuncRename ( FD , IgnoreBase ) ) { <nl> + if ( ! IgnoreBase ) { <nl> + ReferenceCollector Walker ( FD ) ; <nl> + Walker . walk ( FuncRefContainer ) ; <nl> + Editor . replace ( Walker . Result , View . base ( ) ) ; <nl> + } <nl> + unsigned Idx = 0 ; <nl> + for ( auto LR : getCallArgLabelRanges ( SM , Arg , <nl> + LabelRangeEndAt : : LabelNameOnly ) ) { <nl> + if ( Idx < View . argSize ( ) ) { <nl> + auto Label = View . args ( ) [ Idx + + ] ; <nl> + <nl> + / / FIXME : We update only when args are consistently valid . <nl> + if ( Label ! = " _ " & & LR . getByteLength ( ) ) <nl> + Editor . replace ( LR , Label ) ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + <nl> + bool walkToExprPre ( Expr * E ) override { <nl> + if ( auto * CE = dyn_cast < CallExpr > ( E ) ) { <nl> + auto Fn = CE - > getFn ( ) ; <nl> + auto Args = CE - > getArg ( ) ; <nl> + switch ( Fn - > getKind ( ) ) { <nl> + case ExprKind : : DeclRef : { <nl> + if ( auto FD = Fn - > getReferencedDecl ( ) . getDecl ( ) ) <nl> + handleFuncRename ( FD , Fn , Args ) ; <nl> + break ; <nl> + } <nl> + case ExprKind : : DotSyntaxCall : { <nl> + auto DSC = cast < DotSyntaxCallExpr > ( Fn ) ; <nl> + if ( auto FD = DSC - > getFn ( ) - > getReferencedDecl ( ) . getDecl ( ) ) <nl> + handleFuncRename ( FD , DSC - > getFn ( ) , Args ) ; <nl> + break ; <nl> + } <nl> + case ExprKind : : ConstructorRefCall : { <nl> + auto CCE = cast < ConstructorRefCallExpr > ( Fn ) ; <nl> + if ( auto FD = CCE - > getFn ( ) - > getReferencedDecl ( ) . getDecl ( ) ) <nl> + handleFuncRename ( FD , CCE - > getFn ( ) , Args ) ; <nl> + break ; <nl> + } <nl> + default : <nl> + break ; <nl> + } <nl> + } <nl> + return true ; <nl> + } <nl> } ; <nl> <nl> SyntacticMigratorPass : : <nl> mmm a / test / migrator / API . json <nl> ppp b / test / migrator / API . json <nl> <nl> " RightUsr " : " " , <nl> " RightComment " : " theSimpleNewName " , <nl> " ModuleName " : " SomeModule " <nl> + } , <nl> + { <nl> + " DiffItemKind " : " CommonDiffItem " , <nl> + " NodeKind " : " Function " , <nl> + " NodeAnnotation " : " Rename " , <nl> + " ChildIndex " : " 0 " , <nl> + " LeftUsr " : " c : @ F @ barGlobalFuncOldName " , <nl> + " LeftComment " : " " , <nl> + " RightUsr " : " " , <nl> + " RightComment " : " barGlobalFuncNewName ( newlabel : ) " , <nl> + " ModuleName " : " bar " <nl> + } , <nl> + { <nl> + " DiffItemKind " : " CommonDiffItem " , <nl> + " NodeKind " : " Function " , <nl> + " NodeAnnotation " : " Rename " , <nl> + " ChildIndex " : " 0 " , <nl> + " LeftUsr " : " c : objc ( cs ) BarForwardDeclaredClass ( im ) barInstanceFunc1 : anotherValue : anotherValue1 : anotherValue2 : " , <nl> + " LeftComment " : " " , <nl> + " RightUsr " : " " , <nl> + " RightComment " : " barNewInstanceFunc1 ( newlabel1 : newlabel2 : newlabel3 : newlabel4 : ) " , <nl> + " ModuleName " : " bar " <nl> + } , <nl> + { <nl> + " DiffItemKind " : " CommonDiffItem " , <nl> + " NodeKind " : " Constructor " , <nl> + " NodeAnnotation " : " Rename " , <nl> + " ChildIndex " : " 0 " , <nl> + " LeftUsr " : " c : objc ( cs ) BarForwardDeclaredClass ( im ) initWithOldLabel0 : " , <nl> + " LeftComment " : " " , <nl> + " RightUsr " : " " , <nl> + " RightComment " : " init ( newlabel1 : ) " , <nl> + " ModuleName " : " bar " <nl> } <nl> ] <nl> deleted file mode 100644 <nl> index 4f77ec9b969c . . 000000000000 <nl> mmm a / test / migrator / dump_usr . swift <nl> ppp / dev / null <nl> <nl> - / / REQUIRES : objc_interop <nl> - / / RUN : rm - rf % t & & mkdir - p % t & & % swift - update - code - primary - file % s - F % S / mock - sdk - api - diff - data - file % S / API . json - o % t / member . swift . remap - dump - usr | % FileCheck % s - check - prefix = USR <nl> - <nl> - import Bar <nl> - <nl> - func foo ( _ b : BarForwardDeclaredClass ) - > Int32 { <nl> - return barGlobalVariable <nl> - } <nl> - <nl> - / / USR : c : objc ( cs ) BarForwardDeclaredClasss : s5Int32Vc : @ barGlobalVariable <nl> mmm a / test / migrator / mock - sdk / Bar . framework / Headers / Bar . h <nl> ppp b / test / migrator / mock - sdk / Bar . framework / Headers / Bar . h <nl> int barGlobalFunc ( int a ) ; <nl> <nl> int barGlobalVariable = 1 ; <nl> <nl> + int barGlobalFuncOldName ( int a ) ; <nl> + <nl> @ interface BarForwardDeclaredClass <nl> + - ( id ) initWithOldLabel0 : ( int ) frame ; <nl> - ( void ) barInstanceFunc0 ; <nl> + - ( void ) barInstanceFunc1 : ( int ) info anotherValue : ( int ) info1 anotherValue1 : ( int ) info2 anotherValue2 : ( int ) info3 ; <nl> @ end <nl> <nl> enum BarForwardDeclaredEnum { <nl> new file mode 100644 <nl> index 000000000000 . . ed3be459fbf8 <nl> mmm / dev / null <nl> ppp b / test / migrator / rename - init . swift <nl> <nl> + / / REQUIRES : objc_interop <nl> + / / RUN : rm - rf % t & & mkdir - p % t & & % swift - update - code - primary - file % s - F % S / mock - sdk - api - diff - data - file % S / API . json - emit - migrated - file - path % t / rename - init . swift . result - o % t / rename - init . swift . remap - disable - migrator - fixits <nl> + / / RUN : diff - u % S / rename - init . swift . expected % t / rename - init . swift . result <nl> + <nl> + import Bar <nl> + <nl> + func foo ( ) { <nl> + _ = BarForwardDeclaredClass ( oldLabel0 : 1 ) <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . be77bb6a4fcc <nl> mmm / dev / null <nl> ppp b / test / migrator / rename - init . swift . expected <nl> <nl> + / / REQUIRES : objc_interop <nl> + / / RUN : rm - rf % t & & mkdir - p % t & & % swift - update - code - primary - file % s - F % S / mock - sdk - api - diff - data - file % S / API . json - emit - migrated - file - path % t / rename - init . swift . result - o % t / rename - init . swift . remap - disable - migrator - fixits <nl> + / / RUN : diff - u % S / rename - init . swift . expected % t / rename - init . swift . result <nl> + <nl> + import Bar <nl> + <nl> + func foo ( ) { <nl> + _ = BarForwardDeclaredClass ( newlabel1 : 1 ) <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 5e2ec1b68241 <nl> mmm / dev / null <nl> ppp b / test / migrator / rename . swift <nl> <nl> + / / REQUIRES : objc_interop <nl> + / / RUN : rm - rf % t & & mkdir - p % t & & % swift - update - code - primary - file % s - F % S / mock - sdk - api - diff - data - file % S / API . json - emit - migrated - file - path % t / rename . swift . result - o % t / rename . swift . remap <nl> + / / RUN : diff - u % S / rename . swift . expected % t / rename . swift . result <nl> + <nl> + import Bar <nl> + <nl> + func foo ( _ b : BarForwardDeclaredClass ) { <nl> + b . barInstanceFunc1 ( _ : 0 , anotherValue : 1 , anotherValue1 : 2 , anotherValue2 : 3 ) <nl> + barGlobalFuncOldName ( 2 ) <nl> + b . barInstanceFunc1 ( _ : 0 , anotherValue : 1 , anotherValue1 : 2 , anotherValue2 : 3 ) <nl> + barGlobalFuncOldName ( 2 ) <nl> + b . barInstanceFunc1 ( _ : 0 , anotherValue : 1 , anotherValue1 : 2 , anotherValue2 : 3 ) <nl> + barGlobalFuncOldName ( 2 ) <nl> + b . barInstanceFunc1 ( _ : 0 , anotherValue : 1 , anotherValue1 : 2 , anotherValue2 : 3 ) <nl> + barGlobalFuncOldName ( 2 ) <nl> + b . barInstanceFunc1 ( _ : 0 , anotherValue : 1 , anotherValue1 : 2 , anotherValue2 : 3 ) <nl> + barGlobalFuncOldName ( 2 ) <nl> + } <nl> new file mode 100644 <nl> index 000000000000 . . 092f9fe8574b <nl> mmm / dev / null <nl> ppp b / test / migrator / rename . swift . expected <nl> <nl> + / / REQUIRES : objc_interop <nl> + / / RUN : rm - rf % t & & mkdir - p % t & & % swift - update - code - primary - file % s - F % S / mock - sdk - api - diff - data - file % S / API . json - emit - migrated - file - path % t / rename . swift . result - o % t / rename . swift . remap <nl> + / / RUN : diff - u % S / rename . swift . expected % t / rename . swift . result <nl> + <nl> + import Bar <nl> + <nl> + func foo ( _ b : BarForwardDeclaredClass ) { <nl> + b . barNewInstanceFunc1 ( _ : 0 , newlabel2 : 1 , newlabel3 : 2 , newlabel4 : 3 ) <nl> + barGlobalFuncNewName ( 2 ) <nl> + b . barNewInstanceFunc1 ( _ : 0 , newlabel2 : 1 , newlabel3 : 2 , newlabel4 : 3 ) <nl> + barGlobalFuncNewName ( 2 ) <nl> + b . barNewInstanceFunc1 ( _ : 0 , newlabel2 : 1 , newlabel3 : 2 , newlabel4 : 3 ) <nl> + barGlobalFuncNewName ( 2 ) <nl> + b . barNewInstanceFunc1 ( _ : 0 , newlabel2 : 1 , newlabel3 : 2 , newlabel4 : 3 ) <nl> + barGlobalFuncNewName ( 2 ) <nl> + b . barNewInstanceFunc1 ( _ : 0 , newlabel2 : 1 , newlabel3 : 2 , newlabel4 : 3 ) <nl> + barGlobalFuncNewName ( 2 ) <nl> + } <nl>
|
[ Migrator ] Support framework API function renames . rdar : / / 31766131 ( )
|
apple/swift
|
7163a40ffb78f5d5d0c5a91034a4ae4679e75a67
|
2017-04-25T22:50:40Z
|
mmm a / Telegram / SourceFiles / platform / mac / window_title_mac . h <nl> ppp b / Telegram / SourceFiles / platform / mac / window_title_mac . h <nl> namespace Platform { <nl> <nl> class MainWindow ; <nl> <nl> - class TitleWidget : public Window : : TitleWidget , private base : : Subscriber { <nl> + class TitleWidget : public Window : : TitleWidget { <nl> public : <nl> TitleWidget ( MainWindow * parent , int height ) ; <nl> <nl> mmm a / Telegram / SourceFiles / platform / win / window_title_win . cpp <nl> ppp b / Telegram / SourceFiles / platform / win / window_title_win . cpp <nl> TitleWidget : : TitleWidget ( QWidget * parent ) <nl> } <nl> <nl> void TitleWidget : : init ( ) { <nl> - connect ( window ( ) - > windowHandle ( ) , SIGNAL ( windowStateChanged ( Qt : : WindowState ) ) , this , SLOT ( onWindowStateChanged ( Qt : : WindowState ) ) ) ; <nl> + connect ( <nl> + window ( ) - > windowHandle ( ) , <nl> + & QWindow : : windowStateChanged , <nl> + this , <nl> + [ = ] ( Qt : : WindowState state ) { windowStateChanged ( state ) ; } ) ; <nl> _maximizedState = ( window ( ) - > windowState ( ) & Qt : : WindowMaximized ) ; <nl> _activeState = isActiveWindow ( ) ; <nl> updateButtonsState ( ) ; <nl> void TitleWidget : : resizeEvent ( QResizeEvent * e ) { <nl> _shadow - > setGeometry ( 0 , height ( ) - st : : lineWidth , width ( ) , st : : lineWidth ) ; <nl> } <nl> <nl> - void TitleWidget : : updateControlsVisibility ( ) { <nl> - updateControlsPosition ( ) ; <nl> - update ( ) ; <nl> - } <nl> - <nl> - void TitleWidget : : onWindowStateChanged ( Qt : : WindowState state ) { <nl> - if ( state = = Qt : : WindowMinimized ) return ; <nl> + void TitleWidget : : windowStateChanged ( Qt : : WindowState state ) { <nl> + if ( state = = Qt : : WindowMinimized ) { <nl> + return ; <nl> + } <nl> <nl> - auto maximized = ( state = = Qt : : WindowMaximized ) ; <nl> + const auto maximized = ( state = = Qt : : WindowMaximized ) ; <nl> if ( _maximizedState ! = maximized ) { <nl> _maximizedState = maximized ; <nl> updateButtonsState ( ) ; <nl> mmm a / Telegram / SourceFiles / platform / win / window_title_win . h <nl> ppp b / Telegram / SourceFiles / platform / win / window_title_win . h <nl> void DefaultPreviewWindowFramePaint ( QImage & preview , const style : : palette & palet <nl> <nl> namespace Platform { <nl> <nl> - class TitleWidget : public Window : : TitleWidget , private base : : Subscriber { <nl> - Q_OBJECT <nl> - <nl> + class TitleWidget : public Window : : TitleWidget { <nl> public : <nl> TitleWidget ( QWidget * parent ) ; <nl> <nl> void init ( ) override ; <nl> <nl> - Window : : HitTestResult hitTest ( const QPoint & p ) const override ; <nl> - <nl> - public slots : <nl> - void onWindowStateChanged ( Qt : : WindowState state = Qt : : WindowNoState ) ; <nl> - void updateControlsVisibility ( ) ; <nl> + [ [ nodiscard ] ] Window : : HitTestResult hitTest ( <nl> + const QPoint & p ) const override ; <nl> <nl> protected : <nl> void paintEvent ( QPaintEvent * e ) override ; <nl> void resizeEvent ( QResizeEvent * e ) override ; <nl> <nl> private : <nl> + void windowStateChanged ( Qt : : WindowState state = Qt : : WindowNoState ) ; <nl> void updateButtonsState ( ) ; <nl> void updateControlsPosition ( ) ; <nl> <nl> mmm a / Telegram / SourceFiles / window / notifications_manager . cpp <nl> ppp b / Telegram / SourceFiles / window / notifications_manager . cpp <nl> QString Manager : : addTargetAccountName ( <nl> const QString & title , <nl> not_null < Main : : Session * > session ) { <nl> return ( Core : : App ( ) . domain ( ) . accounts ( ) . size ( ) > 1 ) <nl> - ? ( title + accountNameSeparator ( ) + session - > user ( ) - > name ) <nl> + ? ( title <nl> + + accountNameSeparator ( ) <nl> + + ( session - > user ( ) - > username . isEmpty ( ) <nl> + ? session - > user ( ) - > name <nl> + : session - > user ( ) - > username ) ) <nl> : title ; <nl> } <nl> <nl>
|
Use username in notifications if available .
|
telegramdesktop/tdesktop
|
4a8d297df3c90d0f4178389e7fc4ad3c9475b47e
|
2020-06-23T17:53:43Z
|
mmm a / lib / IRGen / GenProto . cpp <nl> ppp b / lib / IRGen / GenProto . cpp <nl> namespace { <nl> ModuleDecl & M ; <nl> CanSILFunctionType FnType ; <nl> <nl> - / / / This is the canonical " mangling " signature of the function type , which <nl> - / / / is minimized in a way such that getAllDependentTypes ( ) excludes <nl> - / / / types with equality constraints to concrete types . <nl> CanGenericSignature Generics ; <nl> <nl> std : : vector < Source > Sources ; <nl> namespace { <nl> selfTy ) ; <nl> <nl> if ( auto paramTy = dyn_cast < GenericTypeParamType > ( selfTy ) ) { <nl> - / / Don ' t pass in witness tables for associated types of Self . <nl> - addImpossibleFulfillments ( paramTy ) ; <nl> - <nl> / / The Self type is abstract , so we must pass in a witness table . <nl> addSelfMetadataFulfillment ( paramTy ) ; <nl> <nl> namespace { <nl> llvm_unreachable ( " bad parameter convention " ) ; <nl> } <nl> <nl> - / / / We ' re binding an archetype for a protocol witness , and we ' re only <nl> - / / / passing in metadata for Self , so make sure we don ' t try passing in <nl> - / / / secondary archetypes too , since that would break the calling <nl> - / / / convention . <nl> - / / / <nl> - / / / This works when calling concrete witnesses because there the <nl> - / / / associated types are always known ; for default implementations , <nl> - / / / we will need to do some work still to implement default <nl> - / / / implementations for protocols with associated types . <nl> - void addImpossibleFulfillments ( CanGenericTypeParamType arg ) { <nl> - for ( auto depTy : getAllDependentTypes ( ) ) { <nl> - / / Is this a dependent member ? <nl> - auto depMemTy = dyn_cast < DependentMemberType > ( CanType ( depTy ) ) ; <nl> - if ( ! depMemTy ) <nl> - continue ; <nl> - <nl> - / / Is it rooted in the protocol Self type ? <nl> - CanType rootTy ; <nl> - do { <nl> - rootTy = depMemTy . getBase ( ) ; <nl> - } while ( ( depMemTy = dyn_cast < DependentMemberType > ( rootTy ) ) ) ; <nl> - <nl> - auto rootParamTy = dyn_cast < GenericTypeParamType > ( rootTy ) ; <nl> - if ( ! rootParamTy ) <nl> - continue ; <nl> - <nl> - / / If so , suppress providing metadata for the type by making up a bogus <nl> - / / fulfillment . <nl> - if ( rootParamTy = = arg ) { <nl> - MetadataPath path ; <nl> - path . addImpossibleComponent ( ) ; <nl> - unsigned source = Sources . size ( ) - 1 ; <nl> - Fulfillments . addFulfillment ( { depTy , nullptr } , source , <nl> - MetadataPath ( path ) ) ; <nl> - for ( auto protocol : getConformsTo ( depTy ) ) { <nl> - Fulfillments . addFulfillment ( { depTy , protocol } , source , <nl> - MetadataPath ( path ) ) ; <nl> - } <nl> - } <nl> - } <nl> - } <nl> - <nl> void addSelfMetadataFulfillment ( CanGenericTypeParamType arg ) { <nl> assert ( arg - > getDepth ( ) = = 0 & & arg - > getIndex ( ) = = 0 ) ; <nl> <nl>
|
Remove some now - unnecessary code , since associated types
|
apple/swift
|
565fb1d78bd3e41306084ba4ea0aa1c68a7206ae
|
2016-02-22T21:45:58Z
|
mmm a / include / swift / AST / Types . h <nl> ppp b / include / swift / AST / Types . h <nl> class SILParameterInfo { <nl> return getWithType ( fn ( getType ( ) ) ) ; <nl> } <nl> <nl> - / / / Replace references to substitutable types with new , concrete types and <nl> - / / / return the substituted result . <nl> - / / / <nl> - / / / The API is comparable to Type : : subst . <nl> - SILParameterInfo subst ( ModuleDecl * module , TypeSubstitutionMap & substitutions , <nl> - SubstOptions options ) const { <nl> - Type type = getType ( ) . subst ( module , substitutions , options ) ; <nl> - return getWithType ( type - > getCanonicalType ( ) ) ; <nl> - } <nl> - <nl> void profile ( llvm : : FoldingSetNodeID & id ) { <nl> id . AddPointer ( Ty . getPointer ( ) ) ; <nl> id . AddInteger ( ( unsigned ) Convention ) ; <nl> class SILResultInfo { <nl> return getWithType ( fn ( getType ( ) ) ) ; <nl> } <nl> <nl> - / / / Replace references to substitutable types with new , concrete types and <nl> - / / / return the substituted result . <nl> - / / / <nl> - / / / The API is comparable to Type : : subst . <nl> - SILResultInfo subst ( ModuleDecl * module , TypeSubstitutionMap & substitutions , <nl> - SubstOptions options ) const { <nl> - Type type = getType ( ) . subst ( module , substitutions , options ) ; <nl> - return getWithType ( type - > getCanonicalType ( ) ) ; <nl> - } <nl> - <nl> void profile ( llvm : : FoldingSetNodeID & id ) { <nl> id . AddPointer ( TypeAndConvention . getOpaqueValue ( ) ) ; <nl> } <nl>
|
Remove unused SILParameterInfo / SILResultInfo : : subst helpers .
|
apple/swift
|
ddc05a39a07b6b756468cc3a51ccbdb49e99b04a
|
2016-02-04T21:45:22Z
|
mmm a / lib / Sema / TypeCheckConstraints . cpp <nl> ppp b / lib / Sema / TypeCheckConstraints . cpp <nl> CheckedCastKind TypeChecker : : typeCheckCheckedCast ( Type fromType , <nl> else <nl> fromRequiresClass = fromType - > mayHaveSuperclass ( ) ; <nl> <nl> - / / Casts between protocol metatypes only succeed if the type is existential <nl> - / / or if it involves generic types because they may be protocol conformances <nl> - / / we can ' t know at compile time . <nl> + / / Casts between metatypes only succeed if none of the types are existentials <nl> + / / or if one is an existential and the other is a generic type because there <nl> + / / may be protocol conformances unknown at compile time . <nl> if ( metatypeCast ) { <nl> if ( ( toExistential | | fromExistential ) & & ! ( fromArchetype | | toArchetype ) ) <nl> return failed ( ) ; <nl>
|
Merge pull request from LucianoPAlmeida / comment - fix
|
apple/swift
|
6a1534d5b0780e000dfb0c761e512f5c2516c342
|
2020-06-09T21:53:02Z
|
mmm a / lang / src / backends / codegen_llvm . h <nl> ppp b / lang / src / backends / codegen_llvm . h <nl> class CodeGenLLVM : public IRVisitor , public ModuleBuilder { <nl> } <nl> <nl> FunctionType gen ( ) { <nl> - emit_to_module ( ) ; <nl> - return compile_module_to_executable ( ) ; <nl> + / / emit_to_module ( ) ; <nl> + compile_module_to_executable ( ) ; <nl> + TC_NOT_IMPLEMENTED <nl> } <nl> <nl> template < typename . . . Args > <nl> mmm a / lang / src / backends / llvm_gpu . cpp <nl> ppp b / lang / src / backends / llvm_gpu . cpp <nl> using namespace llvm ; <nl> <nl> / / NVVM IR Spec : <nl> / / https : / / docs . nvidia . com / cuda / archive / 10 . 0 / pdf / NVVM_IR_Specification . pdf <nl> + int compile_ptx_and_launch2 ( ) { <nl> + printf ( " 123321 \ n " ) ; <nl> + / / return 1 ; <nl> + } <nl> <nl> class CodeGenLLVMGPU : public CodeGenLLVM { <nl> public : <nl> class CodeGenLLVMGPU : public CodeGenLLVM { <nl> } <nl> <nl> FunctionType compile_module_to_executable ( ) override { <nl> - llvm : : Function * func = module - > getFunction ( " test_kernel " ) ; <nl> + / / llvm : : Function * func = module - > getFunction ( " test_kernel " ) ; <nl> <nl> / * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * <nl> Example annotation from llvm PTX doc : <nl> class CodeGenLLVMGPU : public CodeGenLLVM { <nl> / / Mark kernel function as a CUDA __global__ function <nl> / / Add the nvvm annotation that it is considered a kernel function . <nl> <nl> + / * <nl> llvm : : Metadata * md_args [ ] = { <nl> llvm : : ValueAsMetadata : : get ( func ) , <nl> MDString : : get ( * llvm_context , " kernel " ) , <nl> llvm : : ValueAsMetadata : : get ( tlctx - > get_constant ( 1 ) ) } ; <nl> <nl> MDNode * md_node = MDNode : : get ( * llvm_context , md_args ) ; <nl> - <nl> module - > getOrInsertNamedMetadata ( " nvvm . annotations " ) - > addOperand ( md_node ) ; <nl> - <nl> - auto ptx = compile_module_to_ptx ( module ) ; <nl> - compile_ptx_and_launch ( ptx , " test_kernel " , & get_current_program ( ) . context ) ; <nl> - TC_NOT_IMPLEMENTED <nl> + * / <nl> + <nl> + / / auto ptx = compile_module_to_ptx ( module ) ; <nl> + / / TC_TAG ; <nl> + printf ( " 123 \ n " ) ; <nl> + compile_ptx_and_launch2 ( ) ; <nl> + printf ( " 456 \ n " ) ; <nl> + / / TC_TAG ; <nl> + / / TC_NOT_IMPLEMENTED <nl> return nullptr ; <nl> } <nl> <nl> mmm a / lang / src / backends / llvm_jit . cpp <nl> ppp b / lang / src / backends / llvm_jit . cpp <nl> const char * get_error_name ( CUresult err ) { <nl> } <nl> } <nl> <nl> - class CUDAContext { <nl> - CUdevice device ; <nl> - CUmodule cudaModule ; <nl> - CUcontext context ; <nl> - CUfunction function ; <nl> - CUlinkState linker ; <nl> - int devCount ; <nl> - <nl> - public : <nl> - CUDAContext ( ) { <nl> - / / CUDA initialization <nl> - checkCudaErrors ( cuInit ( 0 ) ) ; <nl> - checkCudaErrors ( cuDeviceGetCount ( & devCount ) ) ; <nl> - checkCudaErrors ( cuDeviceGet ( & device , 0 ) ) ; <nl> - <nl> - char name [ 128 ] ; <nl> - checkCudaErrors ( cuDeviceGetName ( name , 128 , device ) ) ; <nl> - std : : cout < < " Using CUDA Device [ 0 ] : " < < name < < " \ n " ; <nl> - <nl> - int devMajor , devMinor ; <nl> - checkCudaErrors ( cuDeviceComputeCapability ( & devMajor , & devMinor , device ) ) ; <nl> - std : : cout < < " Device Compute Capability : " < < devMajor < < " . " < < devMinor <nl> - < < " \ n " ; <nl> - if ( devMajor < 2 ) { <nl> - TC_ERROR ( " Device 0 is not SM 2 . 0 or greater " ) ; <nl> - } <nl> - / / Create driver context <nl> - checkCudaErrors ( cuCtxCreate ( & context , 0 , device ) ) ; <nl> - } <nl> - <nl> - void run ( const std : : string & ptx , <nl> - const std : : string & kernel_name , <nl> - void * context_ptr ) { <nl> - / * <nl> - / / TC_TRACE ( " Compiling PTX : \ n { } " , ptx ) ; <nl> - <nl> - unsigned blockSizeX = 16 ; <nl> - unsigned blockSizeY = 1 ; <nl> - unsigned blockSizeZ = 1 ; <nl> - unsigned gridSizeX = 1 ; <nl> - unsigned gridSizeY = 1 ; <nl> - unsigned gridSizeZ = 1 ; <nl> - <nl> - / / Kernel parameters <nl> - void * KernelParams [ ] = { context_ptr } ; <nl> - <nl> - / / Create module for object <nl> - checkCudaErrors ( cuModuleLoadDataEx ( & cudaModule , ptx . c_str ( ) , 0 , 0 , 0 ) ) ; <nl> - <nl> - / / TC_TRACE ( " Loading symbol { } " , kernel_name ) ; <nl> - / / Get kernel function <nl> - checkCudaErrors ( <nl> - cuModuleGetFunction ( & function , cudaModule , kernel_name . c_str ( ) ) ) ; <nl> - / / Kernel launch <nl> - checkCudaErrors ( cuLaunchKernel ( function , gridSizeX , gridSizeY , gridSizeZ , <nl> - blockSizeX , blockSizeY , blockSizeZ , 0 , <nl> - nullptr , KernelParams , nullptr ) ) ; <nl> - cuCtxSynchronize ( ) ; <nl> - TC_TAG ; <nl> - checkCudaErrors ( cuModuleUnload ( cudaModule ) ) ; <nl> - TC_TAG ; <nl> - checkCudaErrors ( cuCtxDestroy ( context ) ) ; <nl> - TC_TAG ; <nl> - * / <nl> - } <nl> - <nl> - ~ CUDAContext ( ) { <nl> - / / Clean - up <nl> - } <nl> - } ; <nl> - <nl> / / static CUDAContext cuda_context ; / / TODO : . . <nl> <nl> int compile_ptx_and_launch ( const std : : string & ptx , <nl> const std : : string & kernel_name , <nl> - void * context_ptr ) { <nl> - / / cuda_context . run ( ptx , kernel_name , context_ptr ) ; <nl> - TC_TAG ; <nl> + Context * context_ptr ) { <nl> } <nl> # else <nl> std : : string compile_module_to_ptx ( std : : unique_ptr < llvm : : Module > & module ) { <nl> std : : string compile_module_to_ptx ( std : : unique_ptr < llvm : : Module > & module ) { <nl> <nl> int compile_ptx_and_launch ( const std : : string & ptx , <nl> const std : : string & kernel_name , <nl> - void * ) { <nl> + Context * ) { <nl> TC_NOT_IMPLEMENTED <nl> } <nl> # endif <nl> mmm a / lang / src / backends / llvm_jit . h <nl> ppp b / lang / src / backends / llvm_jit . h <nl> using namespace llvm : : orc ; <nl> std : : string compile_module_to_ptx ( std : : unique_ptr < llvm : : Module > & module ) ; <nl> int compile_ptx_and_launch ( const std : : string & ptx , <nl> const std : : string & kernel_name , <nl> - void * ) ; <nl> + Context * ) ; <nl> <nl> class TaichiLLVMJIT { <nl> private : <nl>
|
int compile_ptx_and_launch2 without return 1 leads to segmetation fault
|
taichi-dev/taichi
|
189f04e60803e1283d7e3726890a3d286a9d9403
|
2019-10-03T21:31:45Z
|
mmm a / bindings / common / CNTKValueExtend . i <nl> ppp b / bindings / common / CNTKValueExtend . i <nl> <nl> / / Value <nl> / / <nl> % extend CNTK : : Value { <nl> - static CNTK : : ValuePtr CNTK : : Value : : CreateDenseFloat ( const CNTK : : NDShape & sampleShape , const std : : vector < std : : vector < float > > & sequences , <nl> + static CNTK : : ValuePtr CNTK : : Value : : CreateDenseFloat ( const CNTK : : NDShape & sampleShape , const std : : vector < std : : vector < float > > & sequences , <nl> const CNTK : : DeviceDescriptor & device , bool readOnly = false ) { <nl> return CNTK : : Value : : Create < float > ( sampleShape , sequences , device , readOnly ) ; <nl> } <nl> <nl> - static CNTK : : ValuePtr CNTK : : Value : : CreateDenseDouble ( const CNTK : : NDShape & sampleShape , const std : : vector < std : : vector < double > > & sequences , <nl> + static CNTK : : ValuePtr CNTK : : Value : : CreateDenseDouble ( const CNTK : : NDShape & sampleShape , const std : : vector < std : : vector < double > > & sequences , <nl> const CNTK : : DeviceDescriptor & device , bool readOnly = false ) { <nl> return CNTK : : Value : : Create < double > ( sampleShape , sequences , device , readOnly ) ; <nl> } <nl> <nl> + static CNTK : : ValuePtr CNTK : : Value : : CreateDenseFloat ( const CNTK : : NDShape & sampleShape , const std : : vector < std : : vector < float > > & sequences , <nl> + const std : : vector < bool > & sequenceStartFlags , const CNTK : : DeviceDescriptor & device , bool readOnly = false ) { <nl> + return CNTK : : Value : : Create < float > ( sampleShape , sequences , sequenceStartFlags , device , readOnly ) ; <nl> + } <nl> + <nl> + static CNTK : : ValuePtr CNTK : : Value : : CreateDenseDouble ( const CNTK : : NDShape & sampleShape , const std : : vector < std : : vector < double > > & sequences , <nl> + const std : : vector < bool > & sequenceStartFlags , const CNTK : : DeviceDescriptor & device , bool readOnly = false ) { <nl> + return CNTK : : Value : : Create < double > ( sampleShape , sequences , sequenceStartFlags , device , readOnly ) ; <nl> + } <nl> + <nl> static CNTK : : ValuePtr CNTK : : Value : : CreateOneHotFloat ( size_t vocabularySize , const std : : vector < std : : vector < size_t > > & oneHotSequences , <nl> const CNTK : : DeviceDescriptor & device , bool readOnly = false ) { <nl> return CNTK : : Value : : Create < float > ( vocabularySize , oneHotSequences , device , readOnly ) ; <nl> <nl> const CNTK : : DeviceDescriptor & device , bool readOnly = false ) { <nl> return CNTK : : Value : : Create < double > ( vocabularySize , oneHotSequences , device , readOnly ) ; <nl> } <nl> + <nl> + static CNTK : : ValuePtr CNTK : : Value : : CreateOneHotFloat ( size_t vocabularySize , const std : : vector < std : : vector < size_t > > & oneHotSequences , <nl> + const std : : vector < bool > & sequenceStartFlags , const CNTK : : DeviceDescriptor & device , bool readOnly = false ) { <nl> + return CNTK : : Value : : Create < float > ( vocabularySize , oneHotSequences , sequenceStartFlags , device , readOnly ) ; <nl> + } <nl> + <nl> + static CNTK : : ValuePtr CNTK : : Value : : CreateOneHotDouble ( size_t vocabularySize , const std : : vector < std : : vector < size_t > > & oneHotSequences , <nl> + const std : : vector < bool > & sequenceStartFlags , const CNTK : : DeviceDescriptor & device , bool readOnly = false ) { <nl> + return CNTK : : Value : : Create < double > ( vocabularySize , oneHotSequences , sequenceStartFlags , device , readOnly ) ; <nl> + } <nl> } <nl> \ No newline at end of file <nl> mmm a / bindings / csharp / CSEvalV2Library / CSEvalV2Library . csproj <nl> ppp b / bindings / csharp / CSEvalV2Library / CSEvalV2Library . csproj <nl> <nl> < TreatWarningsAsErrors > true < / TreatWarningsAsErrors > <nl> < AppDesignerFolder > Properties < / AppDesignerFolder > <nl> < RootNamespace > CNTK < / RootNamespace > <nl> - < AssemblyName > CSEvalV2Library < / AssemblyName > <nl> + < AssemblyName > CNTKLibraryManaged - 2 . 0 . dll < / AssemblyName > <nl> < TargetFrameworkVersion > v4 . 5 < / TargetFrameworkVersion > <nl> < FileAlignment > 512 < / FileAlignment > <nl> < / PropertyGroup > <nl> mmm a / bindings / csharp / CSEvalV2Library / Properties / AssemblyInfo . cs <nl> ppp b / bindings / csharp / CSEvalV2Library / Properties / AssemblyInfo . cs <nl> <nl> / / General Information about an assembly is controlled through the following <nl> / / set of attributes . Change these attribute values to modify the information <nl> / / associated with an assembly . <nl> - [ assembly : AssemblyTitle ( " CSEvalV2Library " ) ] <nl> + [ assembly : AssemblyTitle ( " CNTKLibraryManaged - 2 . 0 . dll " ) ] <nl> [ assembly : AssemblyDescription ( " " ) ] <nl> [ assembly : AssemblyConfiguration ( " " ) ] <nl> [ assembly : AssemblyCompany ( " " ) ] <nl> mmm a / bindings / csharp / Swig / CSharpBindings . vcxproj <nl> ppp b / bindings / csharp / Swig / CSharpBindings . vcxproj <nl> <nl> < ItemGroup Condition = " $ ( HasSwig ) " > <nl> < ClCompile Include = " cntk_cs_wrap . cxx " / > <nl> < / ItemGroup > <nl> - < ItemGroup Condition = " $ ( HasSwig ) " > <nl> + < ItemGroup Condition = " $ ( HasSwig ) " > <nl> < ClInclude Include = " . . \ . . \ . . \ Source \ CNTKv2LibraryDll \ API \ CNTKLibrary . h " / > <nl> < ClInclude Include = " . . \ . . \ . . \ Source \ CNTKv2LibraryDll \ API \ CNTKLibraryInternals . h " / > <nl> < ClInclude Include = " cntk_cs_wrap . h " / > <nl> < / ItemGroup > <nl> + < ItemGroup > <nl> + < None Include = " . . \ . . \ common \ CNTKValueExtend . i " / > <nl> + < / ItemGroup > <nl> < Target Name = " CheckDependencies " Condition = " ! $ ( HasSwig ) " > <nl> < Warning Condition = " ! $ ( HasSwig ) " Text = " The project requires SWIG to be installed . " / > <nl> < / Target > <nl> mmm a / bindings / csharp / Swig / CSharpBindings . vcxproj . filters <nl> ppp b / bindings / csharp / Swig / CSharpBindings . vcxproj . filters <nl> <nl> < Filter > Header Files < / Filter > <nl> < / ClInclude > <nl> < / ItemGroup > <nl> + < ItemGroup > <nl> + < None Include = " . . \ . . \ common \ CNTKValueExtend . i " / > <nl> + < / ItemGroup > <nl> < / Project > <nl> \ No newline at end of file <nl> mmm a / bindings / csharp / Swig / cntk_cs . i <nl> ppp b / bindings / csharp / Swig / cntk_cs . i <nl> <nl> } <nl> <nl> / / Create Value object from dense input : batch , sequence or batch of sequences . <nl> - <nl> - public static Value CreateBatch < T > ( NDShape shape , System . Collections . Generic . List < T > batch , DeviceDescriptor computeDevice ) <nl> + public static Value CreateBatch < T > ( NDShape shape , System . Collections . Generic . List < T > batch , DeviceDescriptor device , bool readOnly = false ) <nl> { <nl> - throw new System . ArgumentException ( " Not implemented yet . " ) ; <nl> + var input = new System . Collections . Generic . List < System . Collections . Generic . List < T > > ( ) ; <nl> + var shapeSize = shape . TotalSize ; <nl> + int i = 0 ; <nl> + System . Collections . Generic . List < T > seq = null ; <nl> + foreach ( var element in batch ) <nl> + { <nl> + if ( + + i % shapeSize = = 0 ) <nl> + { <nl> + seq = new System . Collections . Generic . List < T > ( ) ; <nl> + input . Add ( seq ) ; <nl> + } <nl> + seq . Add ( element ) ; <nl> + } <nl> + return Create ( shape , input , device , readOnly ) ; <nl> } <nl> <nl> - public static Value CreateSequence < T > ( NDShape shape , System . Collections . Generic . List < T > sequence , <nl> - bool seqStartFalg , <nl> - DeviceDescriptor computeDevice ) <nl> + public static Value CreateSequence < T > ( NDShape shape , <nl> + System . Collections . Generic . List < T > sequence , <nl> + bool seqStartFlag , <nl> + DeviceDescriptor device , <nl> + bool readOnly = false ) <nl> { <nl> - throw new System . ArgumentException ( " Not implemented yet . " ) ; <nl> + var input = new System . Collections . Generic . List < System . Collections . Generic . List < T > > ( 1 ) { sequence } ; <nl> + return Create ( shape , input , new System . Collections . Generic . List < bool > ( 1 ) { seqStartFlag } , device , readOnly ) ; <nl> } <nl> <nl> public static Value CreateBatchOfSequences < T > ( NDShape shape , <nl> System . Collections . Generic . List < System . Collections . Generic . List < T > > batchOfSequences , <nl> - System . Collections . Generic . List < bool > seqStartFalg , <nl> - DeviceDescriptor computeDevice ) <nl> + System . Collections . Generic . List < bool > seqStartFlags , <nl> + DeviceDescriptor device , <nl> + bool readOnly = false ) <nl> + { <nl> + return Create ( shape , batchOfSequences , seqStartFlags , device , readOnly ) ; <nl> + } <nl> + <nl> + / / Create Value object from OneHotVector input : batch , sequence or batch of sequences <nl> + public static Value CreateBatch < T > ( uint dimension , System . Collections . Generic . List < uint > batch , DeviceDescriptor device , bool readOnly = false ) <nl> + { <nl> + / / Is CreateBatch for OneHot really useful ? <nl> + var input = new System . Collections . Generic . List < System . Collections . Generic . List < uint > > ( ) ; <nl> + batch . ForEach ( element = > input . Add ( new System . Collections . Generic . List < uint > ( 1 ) { element } ) ) ; <nl> + <nl> + return Create < T > ( dimension , input , device , readOnly ) ; <nl> + } <nl> + <nl> + public static Value CreateSequence < T > ( uint dimension , <nl> + System . Collections . Generic . List < uint > sequence , <nl> + bool seqStartFlag , <nl> + DeviceDescriptor device , <nl> + bool readOnly = false ) <nl> { <nl> - var dim = shape . TotalSize ; <nl> + var input = new System . Collections . Generic . List < System . Collections . Generic . List < uint > > ( 1 ) { sequence } ; <nl> + return Create < T > ( dimension , input , new System . Collections . Generic . List < bool > ( 1 ) { seqStartFlag } , device , readOnly ) ; <nl> + } <nl> <nl> - / / Todo : deal with seqStartFlag <nl> + public static Value CreateBatchOfSequences < T > ( uint dimension , <nl> + System . Collections . Generic . List < System . Collections . Generic . List < uint > > batchOfSequences , <nl> + System . Collections . Generic . List < bool > seqStartFlags , <nl> + DeviceDescriptor device , <nl> + bool readOnly = false ) <nl> + { <nl> + return Create < T > ( dimension , batchOfSequences , seqStartFlags , device , readOnly ) ; <nl> + } <nl> + <nl> + public static Value Create ( NDShape sampleShape , <nl> + System . Collections . Generic . List < NDArrayView > sequences , <nl> + System . Collections . Generic . List < bool > sequenceStartFlags , <nl> + DeviceDescriptor device , <nl> + bool readOnly = false ) <nl> + { <nl> + var seqVector = new NDArrayViewVector ( sequences ) ; <nl> + var startVector = new BoolVector ( sequenceStartFlags ) ; <nl> + return Create ( sampleShape , seqVector , startVector , device , false ) ; <nl> + } <nl> + <nl> + public static Value Create ( NDShape sampleShape , <nl> + System . Collections . Generic . List < NDArrayView > sequences , <nl> + DeviceDescriptor device , <nl> + bool readOnly = false ) <nl> + { <nl> + return Create ( sampleShape , sequences , new System . Collections . Generic . List < bool > ( 0 ) , device , readOnly ) ; <nl> + } <nl> + <nl> + public static Value Create < T > ( NDShape sampleShape , <nl> + System . Collections . Generic . List < System . Collections . Generic . List < T > > sequences , <nl> + System . Collections . Generic . List < bool > sequenceStartFlags , <nl> + DeviceDescriptor device , <nl> + bool readOnly = false ) <nl> + { <nl> + var seqFlags = new BoolVector ( sequenceStartFlags ) ; <nl> if ( typeof ( T ) . Equals ( typeof ( float ) ) ) <nl> { <nl> var inputSeqVector = new FloatVectorVector ( ) ; <nl> - foreach ( var seq in batchOfSequences ) <nl> + foreach ( var seq in sequences ) <nl> { <nl> - if ( seq . Count % dim ! = 0 ) <nl> - { <nl> - throw new System . ArgumentException ( " the number of data in sequences does not match the input dimension " ) ; <nl> - } <nl> - var samples = new FloatVector ( seq ) ; <nl> - inputSeqVector . Add ( samples ) ; <nl> + inputSeqVector . Add ( new FloatVector ( seq ) ) ; <nl> } <nl> - return Value . CreateDenseFloat ( shape , inputSeqVector , computeDevice ) ; <nl> + return Value . CreateDenseFloat ( sampleShape , inputSeqVector , seqFlags , device , readOnly ) ; <nl> } <nl> else if ( typeof ( T ) . Equals ( typeof ( double ) ) ) <nl> { <nl> var inputSeqVector = new DoubleVectorVector ( ) ; <nl> - foreach ( var seq in batchOfSequences ) <nl> + foreach ( var seq in sequences ) <nl> { <nl> - if ( seq . Count % dim ! = 0 ) <nl> - { <nl> - throw new System . ArgumentException ( " the number of data in sequences does not match the input dimension " ) ; <nl> - } <nl> - var samples = new DoubleVector ( seq ) ; <nl> - inputSeqVector . Add ( samples ) ; <nl> + inputSeqVector . Add ( new DoubleVector ( seq ) ) ; <nl> } <nl> - return Value . CreateDenseDouble ( shape , inputSeqVector , computeDevice ) ; <nl> + return Value . CreateDenseDouble ( sampleShape , inputSeqVector , seqFlags , device , readOnly ) ; <nl> } <nl> else <nl> { <nl> <nl> } <nl> } <nl> <nl> - / / Create Value object from OneHotVector input : batch , sequence or batch of sequences <nl> - public static Value CreateBatch < T > ( uint vacabSize , System . Collections . Generic . List < uint > batch , DeviceDescriptor computeDevice ) <nl> - { <nl> - throw new System . ArgumentException ( " Not implemented yet . " ) ; <nl> - } <nl> - <nl> - public static Value CreateSequence < T > ( uint vacabSize , <nl> - System . Collections . Generic . List < uint > sequence , <nl> - bool seqStartFalg , <nl> - DeviceDescriptor computeDevice ) <nl> + public static Value Create < T > ( NDShape sampleShape , <nl> + System . Collections . Generic . List < System . Collections . Generic . List < T > > sequences , <nl> + DeviceDescriptor device , <nl> + bool readOnly = false ) <nl> { <nl> - throw new System . ArgumentException ( " Not implemented yet . " ) ; <nl> + return Create < T > ( sampleShape , sequences , new System . Collections . Generic . List < bool > ( 0 ) , device , readOnly ) ; <nl> } <nl> <nl> - public static Value CreateBatchOfSequences < T > ( uint vacabSize , <nl> - System . Collections . Generic . List < System . Collections . Generic . List < uint > > batchOfSequences , <nl> - System . Collections . Generic . List < bool > seqStartFalg , <nl> - DeviceDescriptor computeDevice ) <nl> + public static Value Create < T > ( uint dimension , <nl> + System . Collections . Generic . List < System . Collections . Generic . List < uint > > sequences , <nl> + System . Collections . Generic . List < bool > sequenceStartFlags , <nl> + DeviceDescriptor device , <nl> + bool readOnly = false ) <nl> { <nl> - throw new System . NotImplementedException ( " Not implemented " ) ; <nl> - } <nl> - <nl> - / / Create Value object from sparse input : batch , sequence or batch of sequences . <nl> - public static Value CreateBatch < T > ( NDShape shape , <nl> - System . Collections . Generic . List < T > data , <nl> - System . Collections . Generic . List < uint > indexes , <nl> - System . Collections . Generic . List < uint > nnzCounts , <nl> - DeviceDescriptor computeDevice ) <nl> - { <nl> - throw new System . ArgumentException ( " Not implemented yet . " ) ; <nl> - } <nl> - <nl> - public static Value CreateSequence < T > ( NDShape shape , <nl> - System . Collections . Generic . List < T > data , <nl> - System . Collections . Generic . List < uint > indexes , <nl> - System . Collections . Generic . List < uint > nnzCounts , <nl> - bool SequenceStartFlag , <nl> - DeviceDescriptor computeDevice ) <nl> - { <nl> - throw new System . ArgumentException ( " Not implemented yet . " ) ; <nl> + var seqFlags = new BoolVector ( sequenceStartFlags ) ; <nl> + if ( typeof ( T ) . Equals ( typeof ( float ) ) ) <nl> + { <nl> + var inputSeqVector = new SizeTVectorVector ( ) ; <nl> + foreach ( var seq in sequences ) <nl> + { <nl> + inputSeqVector . Add ( new SizeTVector ( seq ) ) ; <nl> + } <nl> + return Value . CreateOneHotFloat ( dimension , inputSeqVector , seqFlags , device , readOnly ) ; <nl> + } <nl> + else if ( typeof ( T ) . Equals ( typeof ( double ) ) ) <nl> + { <nl> + var inputSeqVector = new SizeTVectorVector ( ) ; <nl> + foreach ( var seq in sequences ) <nl> + { <nl> + inputSeqVector . Add ( new SizeTVector ( seq ) ) ; <nl> + } <nl> + return Value . CreateOneHotDouble ( dimension , inputSeqVector , seqFlags , device , readOnly ) ; <nl> + } <nl> + else <nl> + { <nl> + throw new System . ArgumentException ( " The data type " + typeof ( T ) . ToString ( ) + " is not supported . Only float or double is supported by CNTK . " ) ; <nl> + } <nl> } <nl> <nl> - / / Create Value based on sparse input <nl> - / / Todo : could this be a extension to Value class ? ? <nl> - / / Todo : use Variable instead of varName . VarName as extension method <nl> - public static Value CreateBatchOfSequences < T > ( NDShape shape , <nl> - System . Collections . Generic . List < System . Collections . Generic . List < T > > data , <nl> - System . Collections . Generic . List < System . Collections . Generic . List < uint > > indexes , <nl> - System . Collections . Generic . List < System . Collections . Generic . List < uint > > nnzCounts , <nl> - System . Collections . Generic . List < bool > SequenceStartFlag , <nl> - DeviceDescriptor computeDevice ) <nl> + public static Value Create < T > ( uint dimension , <nl> + System . Collections . Generic . List < System . Collections . Generic . List < uint > > sequences , <nl> + DeviceDescriptor device , <nl> + bool readOnly = false ) <nl> { <nl> - throw new System . NotImplementedException ( " Not implemented " ) ; <nl> + return Create < T > ( dimension , sequences , new System . Collections . Generic . List < bool > ( 0 ) , device , readOnly ) ; <nl> } <nl> % } <nl> <nl>
|
complete Create { Batch | Sequence | BatchOfSequences } and other Creates at C #
|
microsoft/CNTK
|
23a5cacea2cdce1bdf99fe6dfa64ece01d071cde
|
2017-01-07T09:29:56Z
|
mmm a / docs / ru / faq / general / mapreduce . md <nl> ppp b / docs / ru / faq / general / mapreduce . md <nl> toc_priority : 110 <nl> <nl> # # Почему бы не использовать системы типа MapReduce ? { # pochemu - by - ne - ispolzovat - sistemy - tipa - mapreduce } <nl> <nl> - Системами типа MapReduce будем называть системы распределённых вычислений , в которых операция reduce сделана на основе распределённой сортировки . Наиболее распространённым opensource решением данного класса <nl> + Системами типа MapReduce будем называть системы распределённых вычислений , в которых операция reduce сделана на основе распределённой сортировки . Наиболее распространённым opensource решением данного класса является [ Apache Hadoop ] ( http : / / hadoop . apache . org ) . Яндекс использует собственное решение — YT . <nl> <nl> Такие системы не подходят для онлайн запросов в силу слишком большой latency . То есть , не могут быть использованы в качестве бэкенда для веб - интерфейса . <nl> Такие системы не подходят для обновления данных в реальном времени . <nl> mmm a / docs / ru / faq / integration / oracle - odbc . md <nl> ppp b / docs / ru / faq / integration / oracle - odbc . md <nl> toc_priority : 20 <nl> <nl> # # Что делать , если у меня проблема с кодировками при использовании Oracle через ODBC ? { # oracle - odbc - encodings - rus } <nl> <nl> - Если вы используете Oracle через драйвер ODBC в качестве источника внешних словарей , необходимо задать правильное значение для переменной окружения ` NLS_LANG ` в ` / etc / default / clickhouse ` . Подробнее читайте в <nl> \ No newline at end of file <nl> + Если вы используете Oracle через драйвер ODBC в качестве источника внешних словарей , необходимо задать правильное значение для переменной окружения ` NLS_LANG ` в ` / etc / default / clickhouse ` . Подробнее читайте в [ Oracle NLS_LANG FAQ ] ( https : / / www . oracle . com / technetwork / products / globalization / nls - lang - 099431 . html ) . <nl> + <nl> + * * Пример * * <nl> + <nl> + ` ` ` sql <nl> + NLS_LANG = RUSSIAN_RUSSIA . UTF8 <nl> + ` ` ` <nl> \ No newline at end of file <nl> mmm a / docs / ru / sql - reference / dictionaries / external - dictionaries / external - dicts - dict - sources . md <nl> ppp b / docs / ru / sql - reference / dictionaries / external - dictionaries / external - dicts - dict - sources . md <nl> SOURCE ( ODBC ( <nl> <nl> ClickHouse получает от ODBC - драйвера информацию о квотировании и квотирует настройки в запросах к драйверу , поэтому имя таблицы нужно указывать в соответствии с регистром имени таблицы в базе данных . <nl> <nl> - Если у вас есть проблемы с кодировками при использовании Oracle , ознакомьтесь с соответствующим разделом FAQ . <nl> + Если у вас есть проблемы с кодировками при использовании Oracle , ознакомьтесь с соответствующим разделом [ FAQ ] ( . . / . . / . . / faq / integration / oracle - odbc . md ) . <nl> <nl> # # # Выявленная уязвимость в функционировании ODBC словарей { # vyiavlennaia - uiazvimost - v - funktsionirovanii - odbc - slovarei } <nl> <nl>
|
polishing links
|
ClickHouse/ClickHouse
|
60b916fe0b72509a0151eb5fd2c0556db34a0257
|
2020-12-16T18:24:06Z
|
mmm a / lib / SIL / SILPrinter . cpp <nl> ppp b / lib / SIL / SILPrinter . cpp <nl> void SILDeclRef : : dump ( ) const { <nl> static void printGenericSpecializationInfo ( <nl> raw_ostream & OS , StringRef Kind , StringRef Name , <nl> const GenericSpecializationInformation * SpecializationInfo , <nl> - SubstitutionList Subs = SubstitutionList ( ) ) { <nl> + SubstitutionMap Subs = { } ) { <nl> if ( ! SpecializationInfo ) <nl> return ; <nl> <nl> - auto PrintSubstitutions = [ & ] ( SubstitutionList Subs ) { <nl> + auto PrintSubstitutions = [ & ] ( SubstitutionMap Subs ) { <nl> OS < < ' < ' ; <nl> - interleave ( Subs , <nl> - [ & ] ( const Substitution & s ) { OS < < s . getReplacement ( ) ; } , <nl> + interleave ( Subs . getReplacementTypes ( ) , <nl> + [ & ] ( Type type ) { OS < < type ; } , <nl> [ & ] { OS < < " , " ; } ) ; <nl> OS < < ' > ' ; <nl> } ; <nl> static void printGenericSpecializationInfo ( <nl> OS < < " / / Caller : " < < SpecializationInfo - > getCaller ( ) - > getName ( ) < < ' \ n ' ; <nl> OS < < " / / Parent : " < < SpecializationInfo - > getParent ( ) - > getName ( ) < < ' \ n ' ; <nl> OS < < " / / Substitutions : " ; <nl> - PrintSubstitutions ( SpecializationInfo - > getSubstitutions ( ) . toList ( ) ) ; <nl> + PrintSubstitutions ( SpecializationInfo - > getSubstitutions ( ) ) ; <nl> OS < < ' \ n ' ; <nl> OS < < " / / \ n " ; <nl> if ( ! SpecializationInfo - > getCaller ( ) - > isSpecialization ( ) ) <nl> class SILPrinter : public SILInstructionVisitor < SILPrinter > { <nl> if ( AI . getSpecializationInfo ( ) & & AI . getCalleeFunction ( ) ) <nl> printGenericSpecializationInfo ( <nl> PrintState . OS , " call - site " , AI . getCalleeFunction ( ) - > getName ( ) , <nl> - AI . getSpecializationInfo ( ) , AI . getSubstitutions ( ) ) ; <nl> + AI . getSpecializationInfo ( ) , AI . getSubstitutionMap ( ) ) ; <nl> } <nl> print ( & I ) ; <nl> } <nl>
|
[ SILPrinter ] Eliminate SubstitutionList .
|
apple/swift
|
482f55dc2aaa0c469f558aa0696620e465dd1c91
|
2018-05-12T00:37:26Z
|
mmm a / tensorflow / compiler / mlir / xla / transforms / legalize_tf_with_tf2xla . cc <nl> ppp b / tensorflow / compiler / mlir / xla / transforms / legalize_tf_with_tf2xla . cc <nl> bool IsOpAllowedTf2XlaFallback ( Operation * op ) { <nl> TypeID : : get < TF : : IgammaOp > ( ) , <nl> TypeID : : get < TF : : IgammacOp > ( ) , <nl> TypeID : : get < TF : : IgammaGradAOp > ( ) , <nl> + TypeID : : get < TF : : InTopKV2Op > ( ) , <nl> TypeID : : get < TF : : InvertOp > ( ) , <nl> TypeID : : get < TF : : InvOp > ( ) , <nl> TypeID : : get < TF : : LRNOp > ( ) , <nl> bool IsOpAllowedTf2XlaFallback ( Operation * op ) { <nl> TypeID : : get < TF : : MulOp > ( ) , <nl> TypeID : : get < TF : : MultinomialOp > ( ) , <nl> TypeID : : get < TF : : NegOp > ( ) , <nl> + TypeID : : get < TF : : NextAfterOp > ( ) , <nl> TypeID : : get < TF : : NonMaxSuppressionV4Op > ( ) , <nl> TypeID : : get < TF : : NotEqualOp > ( ) , <nl> TypeID : : get < TF : : PadOp > ( ) , <nl> bool IsOpAllowedTf2XlaFallback ( Operation * op ) { <nl> TypeID : : get < TF : : XlaDynamicSliceOp > ( ) , <nl> TypeID : : get < TF : : XlaDynamicUpdateSliceOp > ( ) , <nl> TypeID : : get < TF : : XlaEinsumOp > ( ) , <nl> + TypeID : : get < TF : : XlaKeyValueSortOp > ( ) , <nl> TypeID : : get < TF : : XlaPadOp > ( ) , <nl> TypeID : : get < TF : : Xlog1pyOp > ( ) , <nl> TypeID : : get < TF : : XlogyOp > ( ) <nl> mmm a / tensorflow / compiler / tests / BUILD <nl> ppp b / tensorflow / compiler / tests / BUILD <nl> tf_xla_py_test ( <nl> name = " reduce_ops_test " , <nl> size = " medium " , <nl> srcs = [ " reduce_ops_test . py " ] , <nl> + enable_mlir_bridge = True , <nl> python_version = " PY3 " , <nl> shard_count = 5 , <nl> tags = [ <nl> tf_xla_py_test ( <nl> name = " sort_ops_test " , <nl> size = " medium " , <nl> srcs = [ " sort_ops_test . py " ] , <nl> + enable_mlir_bridge = True , <nl> python_version = " PY3 " , <nl> shard_count = 1 , <nl> # Times out in fastbuild mode . <nl> mmm a / tensorflow / compiler / tests / binary_ops_test . py <nl> ppp b / tensorflow / compiler / tests / binary_ops_test . py <nl> def testNumericOps ( self ) : <nl> expected = np . array ( [ 1 < < 32 , 1 < < 36 , 1 < < 32 , 1 < < 36 ] , <nl> dtype = np . int64 ) ) <nl> <nl> - @ test_util . disable_mlir_bridge ( " Enable tf . NextAfter Compilation " ) <nl> def testNextAfter ( self ) : <nl> for dtype in self . numeric_types : <nl> if dtype in [ np . float32 , np . float64 ] : <nl>
|
Whitelist InTopKV2 , NextAfter and XlaKeyValueSort ops for the fallback path
|
tensorflow/tensorflow
|
07e0f88dd1ea60039267f4aeb57d6e24128e8c3b
|
2020-10-05T09:45:36Z
|
mmm a / modules / dnn / src / onnx / onnx_graph_simplifier . cpp <nl> ppp b / modules / dnn / src / onnx / onnx_graph_simplifier . cpp <nl> class ONNXGraphWrapper : public ImportGraphWrapper <nl> class SoftMaxSubgraph : public Subgraph <nl> { <nl> public : <nl> - SoftMaxSubgraph ( ) <nl> + SoftMaxSubgraph ( ) : axis ( 1 ) <nl> { <nl> int input = addNodeToMatch ( " " ) ; <nl> int inpExp = addNodeToMatch ( " Exp " , input ) ; <nl>
|
Merge pull request from dkurt : uninitialized_value
|
opencv/opencv
|
7cd3615f9f17baa8b8e86518c324078d8657198f
|
2020-01-15T14:49:45Z
|
mmm a / src / app / app . cpp <nl> ppp b / src / app / app . cpp <nl> int App : : run ( ) <nl> <nl> / / Destroy all documents in the UIContext . <nl> const doc : : Documents & docs = m_modules - > m_ui_context . documents ( ) ; <nl> - while ( ! docs . empty ( ) ) <nl> - delete docs . back ( ) ; <nl> + while ( ! docs . empty ( ) ) { <nl> + doc : : Document * doc = docs . back ( ) ; <nl> + <nl> + / / First we close the document . In this way we receive recent <nl> + / / notifications related to the document as an app : : Document . If <nl> + / / we delete the document directly , we destroy the app : : Document <nl> + / / too early , and then doc : : ~ Document ( ) call <nl> + / / DocumentsObserver : : onRemoveDocument ( ) . In this way , observers <nl> + / / could think that they have a fully created app : : Document when <nl> + / / in reality it ' s a doc : : Document ( in the middle of a <nl> + / / destruction process ) . <nl> + / / <nl> + / / TODO : This problem is because we ' re extending doc : : Document , <nl> + / / in the future , we should remove app : : Document . <nl> + doc - > close ( ) ; <nl> + delete doc ; <nl> + } <nl> <nl> / / Destroy the window . <nl> m_mainWindow . reset ( NULL ) ; <nl> mmm a / src / app / document . cpp <nl> ppp b / src / app / document . cpp <nl> Document : : Document ( Sprite * sprite ) <nl> <nl> Document : : ~ Document ( ) <nl> { <nl> + / / We cannot be in a context at this moment . If we were in a <nl> + / / context , doc : : ~ Document ( ) would remove the document from the <nl> + / / context and it would generate onRemoveDocument ( ) notifications , <nl> + / / which could result in serious problems for observers expecting a <nl> + / / fully created app : : Document . <nl> + ASSERT ( context ( ) = = NULL ) ; <nl> + <nl> if ( m_bound . seg ) <nl> base_free ( m_bound . seg ) ; <nl> <nl>
|
Fix problem deleting app : : Document that are inside a Context
|
aseprite/aseprite
|
03a085d1e53dc30877679d991e12823ad9b95f7e
|
2014-07-29T04:29:04Z
|
mmm a / jstests / mmap_v1 / capped8 . js <nl> ppp b / jstests / mmap_v1 / capped8 . js <nl> function debug ( x ) { <nl> <nl> / * * Generate an object with a string field of specified length * / <nl> function obj ( size , x ) { <nl> - return { X : x , a : new Array ( size + 1 ) . toString ( ) } ; ; <nl> + return { X : x , a : new Array ( size + 1 ) . toString ( ) } ; <nl> } <nl> <nl> function withinTwo ( a , b ) { <nl> - assert ( Math . abs ( a - b ) < = 2 , " not within one : " + a + " , " + b ) <nl> + assert ( Math . abs ( a - b ) < = 2 , " not within one : " + a + " , " + b ) ; <nl> } <nl> <nl> var X = 0 ; <nl> mmm a / jstests / mmap_v1 / capped_max . js <nl> ppp b / jstests / mmap_v1 / capped_max . js <nl> sz = 1024 * 16 ; <nl> <nl> t . drop ( ) ; <nl> db . createCollection ( t . getName ( ) , { capped : true , size : sz } ) ; <nl> - assert . lt ( Math . pow ( 2 , 62 ) , t . stats ( ) . max . floatApprox ) <nl> + assert . lt ( Math . pow ( 2 , 62 ) , t . stats ( ) . max . floatApprox ) ; <nl> <nl> t . drop ( ) ; <nl> db . createCollection ( t . getName ( ) , { capped : true , size : sz , max : 123456 } ) ; <nl> assert . eq ( NumberLong ( " 9223372036854775807 " ) , t . stats ( ) . max ) ; <nl> t . drop ( ) ; <nl> res = db . createCollection ( t . getName ( ) , { capped : true , size : sz , max : Math . pow ( 2 , 31 ) } ) ; <nl> assert . eq ( 0 , res . ok , tojson ( res ) ) ; <nl> - assert . eq ( 0 , t . stats ( ) . ok ) <nl> + assert . eq ( 0 , t . stats ( ) . ok ) ; <nl> <nl> mmm a / jstests / mmap_v1 / capped_server2639 . js <nl> ppp b / jstests / mmap_v1 / capped_server2639 . js <nl> <nl> <nl> - name = " server2639 " <nl> + name = " server2639 " ; <nl> <nl> t = db . getCollection ( name ) ; <nl> t . drop ( ) ; <nl> mmm a / jstests / mmap_v1 / collmod . js <nl> ppp b / jstests / mmap_v1 / collmod . js <nl> debug ( res ) ; <nl> assert . eq ( res . ok , 0 , " collMod shouldn ' t return ok with unrecognized value " ) ; <nl> <nl> / / add a TTL index <nl> - t . ensureIndex ( { a : 1 } , { " expireAfterSeconds " : 50 } ) <nl> + t . ensureIndex ( { a : 1 } , { " expireAfterSeconds " : 50 } ) ; <nl> assert . eq ( 1 , db . system . indexes . count ( { key : { a : 1 } , expireAfterSeconds : 50 } ) , <nl> " TTL index not added " ) ; <nl> <nl> assert . eq ( 1 , db . system . indexes . count ( { key : { a : 1 } , expireAfterSeconds : 100 } <nl> <nl> / / try to modify a faulty TTL index with a non - numeric expireAfterSeconds field <nl> t . dropIndex ( { a : 1 } ) ; <nl> - t . ensureIndex ( { a : 1 } , { " expireAfterSeconds " : " 50 " } ) <nl> + t . ensureIndex ( { a : 1 } , { " expireAfterSeconds " : " 50 " } ) ; <nl> var res = db . runCommand ( { " collMod " : coll , <nl> " index " : { " keyPattern " : { a : 1 } , " expireAfterSeconds " : 100 } } ) ; <nl> debug ( res ) ; <nl> assert . eq ( 0 , res . ok , " shouldn ' t be able to modify faulty index spec " ) ; <nl> <nl> / / try with new index , this time set both expireAfterSeconds and the usePowerOf2Sizes flag <nl> t . dropIndex ( { a : 1 } ) ; <nl> - t . ensureIndex ( { a : 1 } , { " expireAfterSeconds " : 50 } ) <nl> + t . ensureIndex ( { a : 1 } , { " expireAfterSeconds " : 50 } ) ; <nl> var res = db . runCommand ( { " collMod " : coll , <nl> " usePowerOf2Sizes " : true , <nl> " index " : { " keyPattern " : { a : 1 } , " expireAfterSeconds " : 100 } } ) ; <nl> mmm a / jstests / mmap_v1 / compactPreservePadding . js <nl> ppp b / jstests / mmap_v1 / compactPreservePadding . js <nl> for ( i = 0 ; i < 10000 ; i + + ) { <nl> } <nl> <nl> / / remove half the entries <nl> - t . remove ( { useLargerKeyName : { $ mod : [ 2 , 0 ] } } ) <nl> + t . remove ( { useLargerKeyName : { $ mod : [ 2 , 0 ] } } ) ; <nl> printjson ( t . stats ( ) ) ; <nl> originalSize = t . stats ( ) . size ; <nl> originalStorage = t . stats ( ) . storageSize ; <nl> mmm a / jstests / mmap_v1 / datasize3 . js <nl> ppp b / jstests / mmap_v1 / datasize3 . js <nl> <nl> <nl> t = db . datasize3 ; <nl> - t . drop ( ) <nl> + t . drop ( ) ; <nl> <nl> function run ( options ) { <nl> var c = { dataSize : " test . datasize3 " } ; <nl> function run ( options ) { <nl> return db . runCommand ( c ) ; <nl> } <nl> <nl> - t . insert ( { x : 1 } ) <nl> + t . insert ( { x : 1 } ) ; <nl> <nl> - a = run ( ) <nl> - b = run ( { estimate : true } ) <nl> + a = run ( ) ; <nl> + b = run ( { estimate : true } ) ; <nl> printjson ( t . stats ( ) ) ; <nl> assert . eq ( a . size , b . size ) ; <nl> <nl> <nl> - t . ensureIndex ( { x : 1 } ) <nl> + t . ensureIndex ( { x : 1 } ) ; <nl> <nl> for ( i = 2 ; i < 100 ; i + + ) <nl> - t . insert ( { x : i } ) <nl> + t . insert ( { x : i } ) ; <nl> <nl> - a = run ( { min : { x : 20 } , max : { x : 50 } } ) . size <nl> - b = run ( { min : { x : 20 } , max : { x : 50 } , estimate : true } ) . size <nl> + a = run ( { min : { x : 20 } , max : { x : 50 } } ) . size ; <nl> + b = run ( { min : { x : 20 } , max : { x : 50 } , estimate : true } ) . size ; <nl> <nl> ratio = Math . min ( a , b ) / Math . max ( a , b ) ; <nl> <nl> mmm a / jstests / mmap_v1 / disk_reuse1 . js <nl> ppp b / jstests / mmap_v1 / disk_reuse1 . js <nl> s = " " ; <nl> while ( s . length < 1024 ) <nl> s + = " abc " ; <nl> <nl> - state = { } <nl> + state = { } ; <nl> <nl> var bulk = t . initializeUnorderedBulkOp ( ) ; <nl> for ( var i = 0 ; i < N ; i + + ) { <nl> for ( i = 0 ; i < N ; i + + ) { <nl> } <nl> assert . writeOK ( bulk . execute ( ) ) ; <nl> <nl> - assert . eq ( orig . storageSize , t . stats ( ) . storageSize , " A " ) <nl> + assert . eq ( orig . storageSize , t . stats ( ) . storageSize , " A " ) ; <nl> <nl> for ( j = 0 ; j < 100 ; j + + ) { <nl> for ( i = 0 ; i < N ; i + + ) { <nl> for ( j = 0 ; j < 100 ; j + + ) { <nl> } <nl> <nl> assert . writeOK ( bulk . execute ( ) ) ; <nl> - assert . eq ( orig . storageSize , t . stats ( ) . storageSize , " B " + j ) <nl> + assert . eq ( orig . storageSize , t . stats ( ) . storageSize , " B " + j ) ; <nl> } <nl> <nl> test . stop ( ) ; <nl> mmm a / jstests / mmap_v1 / dur_big_atomic_update . js <nl> ppp b / jstests / mmap_v1 / dur_big_atomic_update . js <nl> assert . writeOK ( bulk . execute ( ) ) ; <nl> / / Do it again but in a db . eval <nl> d . eval ( <nl> function ( big_string ) { <nl> - new Mongo ( ) . getDB ( " test " ) . foo . update ( { } , { $ set : { big_string : big_string } } , false , / * multi * / true ) <nl> + new Mongo ( ) . getDB ( " test " ) . foo . update ( { } , { $ set : { big_string : big_string } } , false , / * multi * / true ) ; <nl> } , big_string ) ; / / Can ' t pass in connection or DB objects <nl> <nl> err = d . getLastErrorObj ( ) ; <nl> mmm a / jstests / mmap_v1 / extent2 . js <nl> ppp b / jstests / mmap_v1 / extent2 . js <nl> mydb . dropDatabase ( ) ; <nl> t = mydb . foo ; <nl> <nl> function insert ( ) { <nl> - t . insert ( { _id : 1 , x : 1 } ) <nl> - t . insert ( { _id : 2 , x : 1 } ) <nl> - t . insert ( { _id : 3 , x : 1 } ) <nl> + t . insert ( { _id : 1 , x : 1 } ) ; <nl> + t . insert ( { _id : 2 , x : 1 } ) ; <nl> + t . insert ( { _id : 3 , x : 1 } ) ; <nl> t . ensureIndex ( { x : 1 } ) ; <nl> } <nl> <nl> for ( i = 0 ; i < 100 ; i + + ) { <nl> end = mydb . stats ( ) ; <nl> <nl> printjson ( start ) ; <nl> - printjson ( end ) <nl> + printjson ( end ) ; <nl> assert . eq ( start . extentFreeList . num , end . extentFreeList . num ) ; <nl> <nl> / / 3 : 1 data , 1 _id idx , 1 x idx <nl> mmm a / jstests / mmap_v1 / list_collections2 . js <nl> ppp b / jstests / mmap_v1 / list_collections2 . js <nl> assert . eq ( foo . name , mydb . foo . getName ( ) ) ; <nl> <nl> assert ( mydb . bar . temp , tojson ( bar ) ) ; <nl> <nl> - getCollectionName = function ( infoObj ) { return infoObj . name ; } <nl> + getCollectionName = function ( infoObj ) { return infoObj . name ; } ; <nl> <nl> assert . eq ( mydb . _getCollectionInfosSystemNamespaces ( ) . map ( getCollectionName ) , <nl> mydb . _getCollectionInfosCommand ( ) . map ( getCollectionName ) ) ; <nl> mmm a / jstests / mmap_v1 / update . js <nl> ppp b / jstests / mmap_v1 / update . js <nl> for ( var i = 0 ; i < 10 ; i + + ) { <nl> txt = txt + txt ; <nl> } <nl> <nl> - var iterations = _isWindows ( ) ? 2500 : 5000 <nl> + var iterations = _isWindows ( ) ? 2500 : 5000 ; <nl> <nl> / / fill db <nl> for ( var i = 1 ; i < = iterations ; i + + ) { <nl>
|
SERVER - 22341 fix jslint errors in jstests / mmap_v1 with eslint - - fix
|
mongodb/mongo
|
a3be230c5af98b8ca149cb89544345654a2ca7d1
|
2016-02-05T20:00:50Z
|
mmm a / tensorflow / stream_executor / cuda / cuda_platform . cc <nl> ppp b / tensorflow / stream_executor / cuda / cuda_platform . cc <nl> static void InitializeCudaPlatform ( ) { <nl> <nl> REGISTER_MODULE_INITIALIZER ( cuda_platform , <nl> perftools : : gputools : : InitializeCudaPlatform ( ) ) ; <nl> + <nl> + DECLARE_MODULE_INITIALIZER ( multi_platform_manager ) ; <nl> + / / Note that module initialization sequencing is not supported in the <nl> + / / open - source project , so this will be a no - op there . <nl> + REGISTER_MODULE_INITIALIZER_SEQUENCE ( cuda_platform , multi_platform_manager ) ; <nl> mmm a / tensorflow / stream_executor / host / host_platform . cc <nl> ppp b / tensorflow / stream_executor / host / host_platform . cc <nl> static void InitializeHostPlatform ( ) { <nl> <nl> REGISTER_MODULE_INITIALIZER ( <nl> host_platform , perftools : : gputools : : host : : InitializeHostPlatform ( ) ) ; <nl> + <nl> + DECLARE_MODULE_INITIALIZER ( multi_platform_manager ) ; <nl> + / / Note that module initialization sequencing is not supported in the <nl> + / / open - source project , so this will be a no - op there . <nl> + REGISTER_MODULE_INITIALIZER_SEQUENCE ( host_platform , multi_platform_manager ) ; <nl> mmm a / tensorflow / stream_executor / lib / initialize . h <nl> ppp b / tensorflow / stream_executor / lib / initialize . h <nl> limitations under the License . <nl> # else <nl> <nl> # undef REGISTER_MODULE_INITIALIZER <nl> + # undef DECLARE_MODULE_INITIALIZER <nl> + # undef REGISTER_MODULE_INITIALIZER_SEQUENCE <nl> <nl> namespace perftools { <nl> namespace gputools { <nl> class Initializer { <nl> public : <nl> typedef void ( * InitializerFunc ) ( ) ; <nl> explicit Initializer ( InitializerFunc func ) { func ( ) ; } <nl> + <nl> + struct Dependency { <nl> + Dependency ( const char * n , Initializer * i ) : name ( n ) , initializer ( i ) { } <nl> + const char * const name ; <nl> + Initializer * const initializer ; <nl> + } ; <nl> + <nl> + struct DependencyRegisterer { <nl> + DependencyRegisterer ( const char * type , const char * name , <nl> + Initializer * initializer , <nl> + const Dependency & dependency ) ; <nl> + } ; <nl> } ; <nl> <nl> } / / namespace port <nl> class Initializer { <nl> # define REGISTER_MODULE_INITIALIZER ( name , body ) \ <nl> REGISTER_INITIALIZER ( module , name , body ) <nl> <nl> + # define DECLARE_INITIALIZER ( type , name ) \ <nl> + extern perftools : : gputools : : port : : Initializer \ <nl> + google_initializer_ # # type # # _ # # name <nl> + <nl> + # define DECLARE_MODULE_INITIALIZER ( name ) DECLARE_INITIALIZER ( module , name ) <nl> + <nl> + # define REGISTER_MODULE_INITIALIZER_SEQUENCE ( name1 , name2 ) <nl> + <nl> # endif / / ! defined ( PLATFORM_GOOGLE ) <nl> <nl> # endif / / TENSORFLOW_STREAM_EXECUTOR_LIB_INITIALIZE_H_ <nl> mmm a / tensorflow / stream_executor / multi_platform_manager . cc <nl> ppp b / tensorflow / stream_executor / multi_platform_manager . cc <nl> limitations under the License . <nl> # include " tensorflow / stream_executor / multi_platform_manager . h " <nl> <nl> # include " tensorflow / stream_executor / lib / error . h " <nl> + # include " tensorflow / stream_executor / lib / initialize . h " <nl> # include " tensorflow / stream_executor / lib / str_util . h " <nl> # include " tensorflow / stream_executor / lib / stringprintf . h " <nl> <nl> namespace gputools { <nl> <nl> } / / namespace gputools <nl> } / / namespace perftools <nl> + <nl> + REGISTER_MODULE_INITIALIZER ( <nl> + multi_platform_manager , <nl> + { <nl> + / / Nothing - - this is just a module initializer <nl> + / / definition to reference for sequencing <nl> + / / purposes from Platform subclasses that register <nl> + / / themselves with the MultiPlatformManager . <nl> + } ) ; <nl>
|
Add hooks for StreamExecutor module initialization ordering
|
tensorflow/tensorflow
|
a7b60a8206554270c1d066fd66242b1d90574a14
|
2017-01-19T22:44:52Z
|
mmm a / README . md <nl> ppp b / README . md <nl> <nl> # [ PhantomJS ] ( http : / / phantomjs . org ) - Scriptable Headless WebKit <nl> <nl> - PhantomJS ( [ www . phantomjs . org ] ( http : / / phantomjs . org ) ) is a headless WebKit scriptable with JavaScript or CoffeeScript . It is used by hundreds of [ developers ] ( https : / / github . com / ariya / phantomjs / wiki / Buzz ) and dozens of [ organizations ] ( https : / / github . com / ariya / phantomjs / wiki / Users ) for web - related development workflow . <nl> + PhantomJS ( [ www . phantomjs . org ] ( http : / / phantomjs . org ) ) is a headless WebKit scriptable with JavaScript or CoffeeScript . It is used by hundreds of [ developers ] ( http : / / phantomjs . org / buzz . html ) and dozens of [ organizations ] ( http : / / phantomjs . org / users . html ) for web - related development workflow . <nl> <nl> The latest [ stable release ] ( http : / / phantomjs . org / release - 1 . 9 . html ) is version 1 . 9 ( codenamed < a href = " http : / / phantomjs . org / release - names . html " > " Sakura " < / a > ) . Follow the official Twitter stream [ @ PhantomJS ] ( http : / / twitter . com / PhantomJS ) to get the frequent development updates . <nl> <nl> The latest [ stable release ] ( http : / / phantomjs . org / release - 1 . 9 . html ) is version 1 . <nl> <nl> # # Use Cases <nl> <nl> - - * * Headless web testing * * . Lightning - fast testing without the browser is now possible ! Various [ test frameworks ] ( https : / / github . com / ariya / phantomjs / wiki / Headless - Testing ) such as Jasmine , Capybara , QUnit , Mocha , WebDriver , YUI Test , BusterJS , FuncUnit , Robot Framework , and many others are supported . <nl> - - * * Page automation * * . [ Access and manipulate ] ( https : / / github . com / ariya / phantomjs / wiki / Page - Automation ) web pages with the standard DOM API , or with usual libraries like jQuery . <nl> - - * * Screen capture * * . Programmatically [ capture web contents ] ( https : / / github . com / ariya / phantomjs / wiki / Screen - Capture ) , including CSs , SVG and Canvas . Build server - side web graphics apps , from a screenshot service to a vector chart rasterizer . <nl> - - * * Network monitoring * * . Automate performance analysis , track [ page loading ] ( https : / / github . com / ariya / phantomjs / wiki / Network - Monitoring ) and export as standard HAR format . <nl> + - * * Headless web testing * * . Lightning - fast testing without the browser is now possible ! Various [ test frameworks ] ( http : / / phantomjs . org / headless - testing . html ) such as Jasmine , Capybara , QUnit , Mocha , WebDriver , YUI Test , BusterJS , FuncUnit , Robot Framework , and many others are supported . <nl> + - * * Page automation * * . [ Access and manipulate ] ( http : / / phantomjs . org / page - automation . html ) web pages with the standard DOM API , or with usual libraries like jQuery . <nl> + - * * Screen capture * * . Programmatically [ capture web contents ] ( http : / / phantomjs . org / screen - capture . html ) , including CSS , SVG and Canvas . Build server - side web graphics apps , from a screenshot service to a vector chart rasterizer . <nl> + - * * Network monitoring * * . Automate performance analysis , track [ page loading ] ( http : / / phantomjs . org / network - monitoring . html ) and export as standard HAR format . <nl> <nl> # # Features <nl> <nl> PhantomJS needs not be used only as a stand - alone tool . Check also some excellen <nl> - [ PhantomRobot ] ( https : / / github . com / datakurre / phantomrobot ) runs Robot Framework acceptance tests in the background via PhantomJS . <nl> - [ Mocha - PhantomJS ] ( https : / / github . com / metaskills / mocha - phantomjs ) run Mocha tests using PhantomJS . <nl> <nl> - and many others [ related projects ] ( https : / / github . com / ariya / phantomjs / wiki / Related - Projects ) . <nl> + and many others [ related projects ] ( http : / / phantomjs . org / related - projects . html ) . <nl> <nl> # # Questions ? <nl> <nl> - - Explore the complete [ documentation ] ( https : / / github . com / ariya / phantomjs / wiki ) <nl> - - Read tons of [ user articles ] ( https : / / github . com / ariya / phantomjs / wiki / Buzz ) on using PhantomJS . <nl> + - Explore the complete [ documentation ] ( http : / / phantomjs . org / documentation / ) . <nl> + - Read tons of [ user articles ] ( http : / / phantomjs . org / buzz . html ) on using PhantomJS . <nl> - Join the [ mailing - list ] ( http : / / groups . google . com / group / phantomjs ) and discuss with other PhantomJS fans . <nl> <nl> PhantomJS is free software / open source , and is distributed under the [ BSD license ] ( http : / / opensource . org / licenses / BSD - 3 - Clause ) . It contains third - party code , see the included ` third - party . txt ` file for the license information on third - party code . <nl>
|
Obsolete links to any wiki page .
|
ariya/phantomjs
|
2681756efda4aad7207e90cea630de0650c6a41a
|
2014-08-19T14:27:39Z
|
mmm a / tools / setup_helpers / cmake . py <nl> ppp b / tools / setup_helpers / cmake . py <nl> def generate ( self , version , cmake_python_library , build_python , build_test , my_e <nl> var : var for var in <nl> ( ' BLAS ' , <nl> ' BUILDING_WITH_TORCH_LIBS ' , <nl> + ' CUDA_HOST_COMPILER ' , <nl> ' CUDA_NVCC_EXECUTABLE ' , <nl> ' CUDNN_LIBRARY ' , <nl> ' CUDNN_INCLUDE_DIR ' , <nl> + ' CUDNN_ROOT ' , <nl> ' EXPERIMENTAL_SINGLE_THREAD_POOL ' , <nl> ' INSTALL_TEST ' , <nl> ' JAVA_HOME ' , <nl>
|
let user specify CUDA_HOST_COMPILER
|
pytorch/pytorch
|
27e1fecabd1941b70eaa54b65d921452b613de69
|
2020-02-04T22:32:12Z
|
mmm a / build / fbcode_builder / README . md <nl> ppp b / build / fbcode_builder / README . md <nl> host or virtual machine that can run a reasonably modern version of Docker : <nl> ` ` ` sh <nl> . / make_docker_context . py - - help # See available options for OS & compiler <nl> # Tiny wrapper that starts a Travis - like build with compile caching : <nl> - os_image = ubuntu : 14 . 04 \ <nl> - gcc_version = 4 . 9 \ <nl> + os_image = ubuntu : 16 . 04 \ <nl> + gcc_version = 5 \ <nl> make_parallelism = 2 \ <nl> travis_cache_dir = ~ / travis_ccache \ <nl> . / travis_docker_build . sh & > build_at_ $ ( date + ' % Y % m % d_ % H % M % S ' ) . log <nl>
|
update example to more modern os and gcc
|
facebook/folly
|
cf10ed795b1d15dc09e3ec5ccc838cafc883ea51
|
2018-03-21T18:40:43Z
|
mmm a / lib / SILOptimizer / PassManager / PassPipeline . cpp <nl> ppp b / lib / SILOptimizer / PassManager / PassPipeline . cpp <nl> static void addMandatoryOptPipeline ( SILPassPipelinePlan & P , <nl> <nl> P . addAllocBoxToStack ( ) ; <nl> P . addNoReturnFolding ( ) ; <nl> - P . addOwnershipModelEliminator ( ) ; <nl> P . addMarkUninitializedFixup ( ) ; <nl> + P . addOwnershipModelEliminator ( ) ; <nl> P . addDefiniteInitialization ( ) ; <nl> P . addMandatoryInlining ( ) ; <nl> P . addPredictableMemoryOptimizations ( ) ; <nl> mmm a / test / SILOptimizer / mark_uninitialized_fixup . sil <nl> ppp b / test / SILOptimizer / mark_uninitialized_fixup . sil <nl> bb0 ( % 0 : @ trivial $ Builtin . Int1 , % 1 : @ trivial $ @ thin Bool . Type ) : <nl> destroy_value % 3 : $ { var Bool } <nl> return % 8 : $ Bool <nl> } <nl> + <nl> + / / This is a simulation of the type of callee generated by capture promotion . <nl> + sil @ capture_promotion_generated_callee : $ @ convention ( thin ) ( @ in Bool ) - > ( ) <nl> + <nl> + / / CHECK - LABEL : sil @ test_copyvalue_use_of_projectbox : $ @ convention ( thin ) ( Builtin . Int1 ) - > ( ) { <nl> + / / CHECK : bb0 ( [ [ ARG : % . * ] ] : @ trivial $ Builtin . Int1 ) : <nl> + / / CHECK : [ [ BOX : % . * ] ] = alloc_box $ { var Bool } , var , name " self " <nl> + / / CHECK : [ [ PB : % . * ] ] = project_box [ [ BOX ] ] <nl> + / / CHECK : [ [ MUI : % . * ] ] = mark_uninitialized [ rootself ] [ [ PB ] ] <nl> + / / CHECK : [ [ BOX_COPY : % . * ] ] = copy_value [ [ BOX ] ] <nl> + / / CHECK : [ [ PB_BOX_COPY : % . * ] ] = project_box [ [ BOX_COPY ] ] <nl> + / / CHECK : destroy_value [ [ BOX_COPY ] ] <nl> + / / CHECK : destroy_value [ [ BOX ] ] <nl> + sil @ test_copyvalue_use_of_projectbox : $ @ convention ( thin ) ( Builtin . Int1 ) - > ( ) { <nl> + bb0 ( % 0 : @ trivial $ Builtin . Int1 ) : <nl> + / / Initial initialization . <nl> + % 1 = alloc_box $ { var Bool } , var , name " self " <nl> + % 2 = mark_uninitialized [ rootself ] % 1 : $ { var Bool } <nl> + % 3 = project_box % 2 : $ { var Bool } , 0 <nl> + % 4 = struct_element_addr % 3 : $ * Bool , # Bool . _value <nl> + store % 0 to [ trivial ] % 4 : $ * Builtin . Int1 <nl> + <nl> + / / copy + project_box for function_call . This can happen via <nl> + / / capture_promotion . <nl> + % 5 = function_ref @ capture_promotion_generated_callee : $ @ convention ( thin ) ( @ in Bool ) - > ( ) <nl> + % 6 = copy_value % 2 : $ { var Bool } <nl> + % 7 = project_box % 6 : $ { var Bool } , 0 <nl> + % 8 = apply % 5 ( % 7 ) : $ @ convention ( thin ) ( @ in Bool ) - > ( ) <nl> + destroy_value % 6 : $ { var Bool } <nl> + <nl> + / / Epilog <nl> + destroy_value % 2 : $ { var Bool } <nl> + % 9999 = tuple ( ) <nl> + return % 9999 : $ ( ) <nl> + } <nl>
|
Merge remote - tracking branch ' origin / master ' into master - next
|
apple/swift
|
6b60652ac51b708f0966831322fdf064e6ebb312
|
2017-08-31T04:09:23Z
|
mmm a / include / mlir / EDSC / Types . h <nl> ppp b / include / mlir / EDSC / Types . h <nl> namespace edsc { <nl> namespace detail { <nl> <nl> struct ExprStorage ; <nl> - struct UnaryExprStorage ; <nl> - struct BinaryExprStorage ; <nl> - struct TernaryExprStorage ; <nl> - struct VariadicExprStorage ; <nl> - <nl> struct StmtStorage ; <nl> <nl> } / / namespace detail <nl> struct Expr { <nl> template < typename U > U dyn_cast ( ) const ; <nl> template < typename U > U cast ( ) const ; <nl> <nl> - MLIRContext * getContext ( ) const ; <nl> - <nl> / / / Returns the classification for this type . <nl> ExprKind getKind ( ) const ; <nl> unsigned getId ( ) const ; <nl> struct Bindable : public Expr { <nl> } ; <nl> <nl> struct UnaryExpr : public Expr { <nl> - using ImplType = detail : : UnaryExprStorage ; <nl> friend class Expr ; <nl> <nl> UnaryExpr ( ExprKind kind , Expr expr ) ; <nl> struct UnaryExpr : public Expr { <nl> } ; <nl> <nl> struct BinaryExpr : public Expr { <nl> - using ImplType = detail : : BinaryExprStorage ; <nl> friend class Expr ; <nl> BinaryExpr ( ExprKind kind , Expr lhs , Expr rhs ) ; <nl> Expr getLHS ( ) const ; <nl> struct BinaryExpr : public Expr { <nl> } ; <nl> <nl> struct TernaryExpr : public Expr { <nl> - using ImplType = detail : : TernaryExprStorage ; <nl> friend class Expr ; <nl> TernaryExpr ( ExprKind kind , Expr cond , Expr lhs , Expr rhs ) ; <nl> Expr getCond ( ) const ; <nl> struct TernaryExpr : public Expr { <nl> } ; <nl> <nl> struct VariadicExpr : public Expr { <nl> - using ImplType = detail : : VariadicExprStorage ; <nl> friend class Expr ; <nl> VariadicExpr ( ExprKind kind , llvm : : ArrayRef < Expr > exprs , <nl> llvm : : ArrayRef < Type > types = { } ) ; <nl> struct VariadicExpr : public Expr { <nl> } ; <nl> <nl> struct StmtBlockLikeExpr : public Expr { <nl> - using ImplType = detail : : VariadicExprStorage ; / / same storage as variadic <nl> friend class Expr ; <nl> StmtBlockLikeExpr ( ExprKind kind , llvm : : ArrayRef < Expr > exprs , <nl> llvm : : ArrayRef < Type > types = { } ) ; <nl> mmm a / lib / EDSC / Types . cpp <nl> ppp b / lib / EDSC / Types . cpp <nl> namespace edsc { <nl> namespace detail { <nl> <nl> struct ExprStorage { <nl> - ExprStorage ( ExprKind kind , unsigned id = Expr : : newId ( ) ) <nl> - : kind ( kind ) , id ( id ) { } <nl> + / / Note : this structure is similar to OperationState , but stores lists in a <nl> + / / EDSC bump allocator . <nl> ExprKind kind ; <nl> unsigned id ; <nl> - } ; <nl> - <nl> - struct UnaryExprStorage : public ExprStorage { <nl> - UnaryExprStorage ( ExprKind k , Expr expr ) : ExprStorage ( k ) , expr ( expr ) { } <nl> - Expr expr ; <nl> - } ; <nl> <nl> - struct BinaryExprStorage : public ExprStorage { <nl> - BinaryExprStorage ( ExprKind k , Expr lhs , Expr rhs ) <nl> - : ExprStorage ( k ) , lhs ( lhs ) , rhs ( rhs ) { } <nl> - Expr lhs , rhs ; <nl> - } ; <nl> + ArrayRef < Expr > operands ; <nl> + ArrayRef < Type > resultTypes ; <nl> + ArrayRef < NamedAttribute > attributes ; <nl> + <nl> + ExprStorage ( ExprKind kind , ArrayRef < Type > results , ArrayRef < Expr > children , <nl> + ArrayRef < NamedAttribute > attrs , unsigned exprId = Expr : : newId ( ) ) <nl> + : kind ( kind ) , id ( exprId ) { <nl> + if ( ! children . empty ( ) ) { <nl> + auto exprStorage = <nl> + Expr : : globalAllocator ( ) - > Allocate < Expr > ( children . size ( ) ) ; <nl> + std : : uninitialized_copy ( children . begin ( ) , children . end ( ) , exprStorage ) ; <nl> + operands = llvm : : makeArrayRef ( exprStorage , children . size ( ) ) ; <nl> + } else { <nl> + operands = ArrayRef < Expr > ( ) ; <nl> + } <nl> <nl> - struct TernaryExprStorage : public ExprStorage { <nl> - TernaryExprStorage ( ExprKind k , Expr cond , Expr lhs , Expr rhs ) <nl> - : ExprStorage ( k ) , cond ( cond ) , lhs ( lhs ) , rhs ( rhs ) { } <nl> - Expr cond , lhs , rhs ; <nl> - } ; <nl> + if ( ! results . empty ( ) ) { <nl> + auto typeStorage = <nl> + Expr : : globalAllocator ( ) - > Allocate < Type > ( results . size ( ) ) ; <nl> + std : : uninitialized_copy ( results . begin ( ) , results . end ( ) , typeStorage ) ; <nl> + resultTypes = llvm : : makeArrayRef ( typeStorage , results . size ( ) ) ; <nl> + } else { <nl> + resultTypes = ArrayRef < Type > ( ) ; <nl> + } <nl> <nl> - struct VariadicExprStorage : public ExprStorage { <nl> - VariadicExprStorage ( ExprKind k , ArrayRef < Expr > exprs , ArrayRef < Type > types ) <nl> - : ExprStorage ( k ) , exprs ( exprs . begin ( ) , exprs . end ( ) ) , <nl> - types ( types . begin ( ) , types . end ( ) ) { } <nl> - ArrayRef < Expr > exprs ; <nl> - ArrayRef < Type > types ; <nl> + if ( ! attrs . empty ( ) ) { <nl> + auto attrStorage = <nl> + Expr : : globalAllocator ( ) - > Allocate < NamedAttribute > ( attrs . size ( ) ) ; <nl> + std : : uninitialized_copy ( attrs . begin ( ) , attrs . end ( ) , attrStorage ) ; <nl> + attributes = llvm : : makeArrayRef ( attrStorage , attrs . size ( ) ) ; <nl> + } else { <nl> + attributes = ArrayRef < NamedAttribute > ( ) ; <nl> + } <nl> + } <nl> } ; <nl> <nl> struct StmtStorage { <nl> mlir : : edsc : : ScopedEDSCContext : : ~ ScopedEDSCContext ( ) { <nl> mlir : : edsc : : Expr : : Expr ( ) { <nl> / / Initialize with placement new . <nl> storage = Expr : : globalAllocator ( ) - > Allocate < detail : : ExprStorage > ( ) ; <nl> - new ( storage ) detail : : ExprStorage ( ExprKind : : Unbound ) ; <nl> + new ( storage ) detail : : ExprStorage ( ExprKind : : Unbound , { } , { } , { } ) ; <nl> } <nl> <nl> ExprKind mlir : : edsc : : Expr : : getKind ( ) const { return storage - > kind ; } <nl> llvm : : raw_ostream & mlir : : edsc : : operator < < ( llvm : : raw_ostream & os , <nl> edsc_expr_t makeBindable ( ) { return Bindable ( Expr ( ) ) ; } <nl> <nl> mlir : : edsc : : UnaryExpr : : UnaryExpr ( ExprKind kind , Expr expr ) <nl> - : Expr ( Expr : : globalAllocator ( ) - > Allocate < detail : : UnaryExprStorage > ( ) ) { <nl> + : Expr ( Expr : : globalAllocator ( ) - > Allocate < detail : : ExprStorage > ( ) ) { <nl> / / Initialize with placement new . <nl> - new ( storage ) detail : : UnaryExprStorage { kind , expr } ; <nl> + new ( storage ) detail : : ExprStorage ( kind , { } , { expr } , { } ) ; <nl> } <nl> Expr mlir : : edsc : : UnaryExpr : : getExpr ( ) const { <nl> - return static_cast < ImplType * > ( storage ) - > expr ; <nl> + return static_cast < ImplType * > ( storage ) - > operands . front ( ) ; <nl> } <nl> <nl> mlir : : edsc : : BinaryExpr : : BinaryExpr ( ExprKind kind , Expr lhs , Expr rhs ) <nl> - : Expr ( Expr : : globalAllocator ( ) - > Allocate < detail : : BinaryExprStorage > ( ) ) { <nl> + : Expr ( Expr : : globalAllocator ( ) - > Allocate < detail : : ExprStorage > ( ) ) { <nl> / / Initialize with placement new . <nl> - new ( storage ) detail : : BinaryExprStorage { kind , lhs , rhs } ; <nl> + new ( storage ) detail : : ExprStorage ( kind , { } , { lhs , rhs } , { } ) ; <nl> } <nl> Expr mlir : : edsc : : BinaryExpr : : getLHS ( ) const { <nl> - return static_cast < ImplType * > ( storage ) - > lhs ; <nl> + return static_cast < ImplType * > ( storage ) - > operands . front ( ) ; <nl> } <nl> Expr mlir : : edsc : : BinaryExpr : : getRHS ( ) const { <nl> - return static_cast < ImplType * > ( storage ) - > rhs ; <nl> + return static_cast < ImplType * > ( storage ) - > operands . back ( ) ; <nl> } <nl> <nl> mlir : : edsc : : TernaryExpr : : TernaryExpr ( ExprKind kind , Expr cond , Expr lhs , <nl> Expr rhs ) <nl> - : Expr ( Expr : : globalAllocator ( ) - > Allocate < detail : : TernaryExprStorage > ( ) ) { <nl> + : Expr ( Expr : : globalAllocator ( ) - > Allocate < detail : : ExprStorage > ( ) ) { <nl> / / Initialize with placement new . <nl> - new ( storage ) detail : : TernaryExprStorage { kind , cond , lhs , rhs } ; <nl> + new ( storage ) detail : : ExprStorage ( kind , { } , { cond , lhs , rhs } , { } ) ; <nl> } <nl> Expr mlir : : edsc : : TernaryExpr : : getCond ( ) const { <nl> - return static_cast < ImplType * > ( storage ) - > cond ; <nl> + return static_cast < ImplType * > ( storage ) - > operands [ 0 ] ; <nl> } <nl> Expr mlir : : edsc : : TernaryExpr : : getLHS ( ) const { <nl> - return static_cast < ImplType * > ( storage ) - > lhs ; <nl> + return static_cast < ImplType * > ( storage ) - > operands [ 1 ] ; <nl> } <nl> Expr mlir : : edsc : : TernaryExpr : : getRHS ( ) const { <nl> - return static_cast < ImplType * > ( storage ) - > rhs ; <nl> + return static_cast < ImplType * > ( storage ) - > operands [ 2 ] ; <nl> } <nl> <nl> mlir : : edsc : : VariadicExpr : : VariadicExpr ( ExprKind kind , ArrayRef < Expr > exprs , <nl> ArrayRef < Type > types ) <nl> - : Expr ( Expr : : globalAllocator ( ) - > Allocate < detail : : VariadicExprStorage > ( ) ) { <nl> + : Expr ( Expr : : globalAllocator ( ) - > Allocate < detail : : ExprStorage > ( ) ) { <nl> / / Initialize with placement new . <nl> - auto exprStorage = Expr : : globalAllocator ( ) - > Allocate < Expr > ( exprs . size ( ) ) ; <nl> - std : : uninitialized_copy ( exprs . begin ( ) , exprs . end ( ) , exprStorage ) ; <nl> - auto typeStorage = Expr : : globalAllocator ( ) - > Allocate < Type > ( types . size ( ) ) ; <nl> - std : : uninitialized_copy ( types . begin ( ) , types . end ( ) , typeStorage ) ; <nl> - new ( storage ) detail : : VariadicExprStorage { <nl> - kind , ArrayRef < Expr > ( exprStorage , exprs . size ( ) ) , <nl> - ArrayRef < Type > ( typeStorage , types . size ( ) ) } ; <nl> + new ( storage ) detail : : ExprStorage ( kind , types , exprs , { } ) ; <nl> } <nl> ArrayRef < Expr > mlir : : edsc : : VariadicExpr : : getExprs ( ) const { <nl> - return static_cast < ImplType * > ( storage ) - > exprs ; <nl> + return static_cast < ImplType * > ( storage ) - > operands ; <nl> } <nl> ArrayRef < Type > mlir : : edsc : : VariadicExpr : : getTypes ( ) const { <nl> - return static_cast < ImplType * > ( storage ) - > types ; <nl> + return static_cast < ImplType * > ( storage ) - > resultTypes ; <nl> } <nl> <nl> mlir : : edsc : : StmtBlockLikeExpr : : StmtBlockLikeExpr ( ExprKind kind , <nl> ArrayRef < Expr > exprs , <nl> ArrayRef < Type > types ) <nl> - : Expr ( Expr : : globalAllocator ( ) - > Allocate < detail : : VariadicExprStorage > ( ) ) { <nl> + : Expr ( Expr : : globalAllocator ( ) - > Allocate < detail : : ExprStorage > ( ) ) { <nl> / / Initialize with placement new . <nl> - auto exprStorage = Expr : : globalAllocator ( ) - > Allocate < Expr > ( exprs . size ( ) ) ; <nl> - std : : uninitialized_copy ( exprs . begin ( ) , exprs . end ( ) , exprStorage ) ; <nl> - auto typeStorage = Expr : : globalAllocator ( ) - > Allocate < Type > ( types . size ( ) ) ; <nl> - std : : uninitialized_copy ( types . begin ( ) , types . end ( ) , typeStorage ) ; <nl> - new ( storage ) detail : : VariadicExprStorage { <nl> - kind , ArrayRef < Expr > ( exprStorage , exprs . size ( ) ) , <nl> - ArrayRef < Type > ( typeStorage , types . size ( ) ) } ; <nl> + new ( storage ) detail : : ExprStorage ( kind , types , exprs , { } ) ; <nl> } <nl> ArrayRef < Expr > mlir : : edsc : : StmtBlockLikeExpr : : getExprs ( ) const { <nl> - return static_cast < ImplType * > ( storage ) - > exprs ; <nl> + return static_cast < ImplType * > ( storage ) - > operands ; <nl> } <nl> <nl> mlir : : edsc : : Stmt : : Stmt ( const Bindable & lhs , const Expr & rhs , <nl>
|
EDSC : unify Expr storage
|
tensorflow/tensorflow
|
c96f0d8fc61d090a377ad8048a3589a17f21f36d
|
2019-03-29T23:26:37Z
|
mmm a / src / arm / full - codegen - arm . cc <nl> ppp b / src / arm / full - codegen - arm . cc <nl> void FullCodeGenerator : : VisitArrayLiteral ( ArrayLiteral * expr ) { <nl> <nl> AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites <nl> ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE ; <nl> - if ( has_constant_fast_elements & & ! FLAG_allocation_site_pretenuring ) { <nl> + if ( has_fast_elements & & ! FLAG_allocation_site_pretenuring ) { <nl> / / If the only customer of allocation sites is transitioning , then <nl> / / we can turn it off if we don ' t have anywhere else to transition to . <nl> allocation_site_mode = DONT_TRACK_ALLOCATION_SITE ; <nl> mmm a / src / mips / full - codegen - mips . cc <nl> ppp b / src / mips / full - codegen - mips . cc <nl> void FullCodeGenerator : : VisitArrayLiteral ( ArrayLiteral * expr ) { <nl> <nl> AllocationSiteMode allocation_site_mode = FLAG_track_allocation_sites <nl> ? TRACK_ALLOCATION_SITE : DONT_TRACK_ALLOCATION_SITE ; <nl> - if ( has_constant_fast_elements & & ! FLAG_allocation_site_pretenuring ) { <nl> + if ( has_fast_elements & & ! FLAG_allocation_site_pretenuring ) { <nl> / / If the only customer of allocation sites is transitioning , then <nl> / / we can turn it off if we don ' t have anywhere else to transition to . <nl> allocation_site_mode = DONT_TRACK_ALLOCATION_SITE ; <nl>
|
ARM / MIPS compilation error .
|
v8/v8
|
d18a103e561b4a048915c863fc458530e144ca13
|
2013-11-27T14:32:35Z
|
mmm a / docs / api / auto - updater . md <nl> ppp b / docs / api / auto - updater . md <nl> <nl> - # auto - updater <nl> + # autoUpdater <nl> <nl> * * This module has only been implemented for OS X . * * <nl> <nl> appropriate format . <nl> <nl> ` pub_date ` ( if present ) must be formatted according to ISO 8601 . <nl> <nl> - # # Event : error <nl> + # # Events <nl> + <nl> + The ` autoUpdater ` object emits the following events : <nl> + <nl> + # # # Event : ' error ' <nl> + <nl> + Returns : <nl> <nl> * ` event ` Event <nl> * ` message ` String <nl> <nl> Emitted when there is an error while updating . <nl> <nl> - # # Event : checking - for - update <nl> + # # # Event : ' checking - for - update ' <nl> <nl> Emitted when checking if an update has started . <nl> <nl> - # # Event : update - available <nl> + # # # Event : ' update - available ' <nl> <nl> Emitted when there is an available update . The update is downloaded <nl> automatically . <nl> <nl> - # # Event : update - not - available <nl> + # # # Event : ' update - not - available ' <nl> <nl> Emitted when there is no available update . <nl> <nl> - # # Event : update - downloaded <nl> + # # # Event : ' update - downloaded ' <nl> + <nl> + Returns : <nl> <nl> * ` event ` Event <nl> * ` releaseNotes ` String <nl> Emitted when there is no available update . <nl> Emitted when an update has been downloaded . Calling ` quitAndUpdate ( ) ` will restart <nl> the application and install the update . <nl> <nl> - # # autoUpdater . setFeedUrl ( url ) <nl> + # # Methods <nl> + <nl> + The ` autoUpdater ` object has the following methods : <nl> + <nl> + # # # ` autoUpdater . setFeedUrl ( url ) ` <nl> <nl> * ` url ` String <nl> <nl> Set the ` url ` and initialize the auto updater . The ` url ` cannot be changed <nl> once it is set . <nl> <nl> - # # autoUpdater . checkForUpdates ( ) <nl> + # # # ` autoUpdater . checkForUpdates ( ) ` <nl> <nl> Ask the server whether there is an update . You must call ` setFeedUrl ` before <nl> using this API . <nl>
|
Standardize auto - updater . md
|
electron/electron
|
454413f69ab6a33e9bc6baa7429390246ed529f0
|
2015-08-19T16:55:11Z
|
mmm a / tensorflow / python / distribute / keras_save_load_test . py <nl> ppp b / tensorflow / python / distribute / keras_save_load_test . py <nl> def _load_and_run_model ( self , <nl> distribution , <nl> saved_dir , <nl> predict_dataset , <nl> - experimental_run_tf_function , <nl> output_name = ' output_1 ' ) : <nl> restored_keras_model = save . load_model ( saved_dir ) <nl> - restored_keras_model . _experimental_run_tf_function = ( <nl> - experimental_run_tf_function ) <nl> return restored_keras_model . predict ( <nl> predict_dataset , steps = test_base . PREDICT_STEPS ) <nl> <nl> @ combinations . generate ( test_base . simple_models_with_strategies ( ) ) <nl> def test_save_no_strategy_restore_strategy ( self , model_and_input , <nl> - distribution , <nl> - experimental_run_tf_function ) : <nl> + distribution ) : <nl> self . run_test_save_no_strategy_restore_strategy ( <nl> - model_and_input , distribution , experimental_run_tf_function ) <nl> + model_and_input , distribution ) <nl> <nl> @ combinations . generate ( <nl> combinations . times ( test_base . simple_models_with_strategies ( ) , <nl> combinations . combine ( save_in_scope = [ True , False ] ) ) ) <nl> def test_save_strategy_restore_no_strategy ( self , model_and_input , <nl> - distribution , save_in_scope , <nl> - experimental_run_tf_function ) : <nl> + distribution , save_in_scope ) : <nl> self . run_test_save_strategy_restore_no_strategy ( <nl> - model_and_input , distribution , save_in_scope , <nl> - experimental_run_tf_function ) <nl> + model_and_input , distribution , save_in_scope ) <nl> <nl> @ combinations . generate ( <nl> combinations . times ( test_base . simple_models_with_strategy_pairs ( ) , <nl> def test_save_strategy_restore_no_strategy ( self , model_and_input , <nl> def test_save_strategy_restore_strategy ( self , model_and_input , <nl> distribution_for_saving , <nl> distribution_for_restoring , <nl> - save_in_scope , <nl> - experimental_run_tf_function ) : <nl> + save_in_scope ) : <nl> self . run_test_save_strategy_restore_strategy ( model_and_input , <nl> distribution_for_saving , <nl> distribution_for_restoring , <nl> - save_in_scope , <nl> - experimental_run_tf_function ) <nl> + save_in_scope ) <nl> <nl> <nl> if __name__ = = ' __main__ ' : <nl> mmm a / tensorflow / python / distribute / model_collection / simple_models . py <nl> ppp b / tensorflow / python / distribute / model_collection / simple_models . py <nl> def get_model ( self , * * kwargs ) : <nl> <nl> model = keras . Model ( inputs = x , outputs = y ) <nl> optimizer = gradient_descent . SGD ( learning_rate = 0 . 001 ) <nl> - experimental_run_tf_function = kwargs . pop ( ' experimental_run_tf_function ' , <nl> - None ) <nl> - assert experimental_run_tf_function is not None <nl> model . compile ( <nl> loss = ' mse ' , <nl> metrics = [ ' mae ' ] , <nl> - optimizer = optimizer , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + optimizer = optimizer ) <nl> <nl> return model <nl> <nl> def get_model ( self , * * kwargs ) : <nl> 5 , dtype = dtypes . float32 , name = output_name , input_dim = 3 ) <nl> model . add ( y ) <nl> optimizer = gradient_descent . SGD ( learning_rate = 0 . 001 ) <nl> - experimental_run_tf_function = kwargs . pop ( ' experimental_run_tf_function ' , <nl> - None ) <nl> - assert experimental_run_tf_function is not None <nl> model . compile ( <nl> loss = ' mse ' , <nl> metrics = [ ' mae ' ] , <nl> - optimizer = optimizer , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + optimizer = optimizer ) <nl> <nl> return model <nl> <nl> class SimpleSubclassModel ( model_collection_base . ModelAndInput ) : <nl> def get_model ( self , * * kwargs ) : <nl> model = _SimpleModel ( ) <nl> optimizer = gradient_descent . SGD ( learning_rate = 0 . 001 ) <nl> - experimental_run_tf_function = kwargs . pop ( ' experimental_run_tf_function ' , <nl> - None ) <nl> - assert experimental_run_tf_function is not None <nl> model . compile ( <nl> loss = ' mse ' , <nl> metrics = [ ' mae ' ] , <nl> cloning = False , <nl> - optimizer = optimizer , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + optimizer = optimizer ) <nl> <nl> return model <nl> <nl> mmm a / tensorflow / python / distribute / saved_model_mixed_api_test . py <nl> ppp b / tensorflow / python / distribute / saved_model_mixed_api_test . py <nl> def _load_and_run_model ( self , <nl> distribution , <nl> saved_dir , <nl> predict_dataset , <nl> - experimental_run_tf_function , <nl> output_name = ' output_1 ' ) : <nl> return test_base . load_and_run_with_saved_model_api ( distribution , saved_dir , <nl> predict_dataset , <nl> def _load_and_run_model ( self , <nl> <nl> @ combinations . generate ( test_base . simple_models_with_strategies ( ) ) <nl> def test_save_no_strategy_restore_strategy ( self , model_and_input , <nl> - distribution , <nl> - experimental_run_tf_function ) : <nl> + distribution ) : <nl> self . run_test_save_no_strategy_restore_strategy ( <nl> - model_and_input , distribution , experimental_run_tf_function ) <nl> + model_and_input , distribution ) <nl> <nl> @ combinations . generate ( <nl> combinations . times ( test_base . simple_models_with_strategies ( ) , <nl> combinations . combine ( save_in_scope = [ True , False ] ) ) ) <nl> def test_save_strategy_restore_no_strategy ( self , model_and_input , <nl> - distribution , save_in_scope , <nl> - experimental_run_tf_function ) : <nl> + distribution , save_in_scope ) : <nl> self . run_test_save_strategy_restore_no_strategy ( <nl> - model_and_input , distribution , save_in_scope , <nl> - experimental_run_tf_function ) <nl> + model_and_input , distribution , save_in_scope ) <nl> <nl> @ combinations . generate ( <nl> combinations . times ( test_base . simple_models_with_strategy_pairs ( ) , <nl> def test_save_strategy_restore_no_strategy ( self , model_and_input , <nl> def test_save_strategy_restore_strategy ( self , model_and_input , <nl> distribution_for_saving , <nl> distribution_for_restoring , <nl> - save_in_scope , <nl> - experimental_run_tf_function ) : <nl> + save_in_scope ) : <nl> self . run_test_save_strategy_restore_strategy ( model_and_input , <nl> distribution_for_saving , <nl> distribution_for_restoring , <nl> - save_in_scope , <nl> - experimental_run_tf_function ) <nl> + save_in_scope ) <nl> <nl> <nl> if __name__ = = ' __main__ ' : <nl> mmm a / tensorflow / python / distribute / saved_model_save_load_test . py <nl> ppp b / tensorflow / python / distribute / saved_model_save_load_test . py <nl> def _load_and_run_model ( self , <nl> distribution , <nl> saved_dir , <nl> predict_dataset , <nl> - experimental_run_tf_function , <nl> output_name = ' output_1 ' ) : <nl> return test_base . load_and_run_with_saved_model_api ( distribution , saved_dir , <nl> predict_dataset , <nl> def _load_and_run_model ( self , <nl> <nl> @ combinations . generate ( test_base . simple_models_with_strategies ( ) ) <nl> def test_save_no_strategy_restore_strategy ( self , model_and_input , <nl> - distribution , <nl> - experimental_run_tf_function ) : <nl> + distribution ) : <nl> self . run_test_save_no_strategy_restore_strategy ( <nl> - model_and_input , distribution , experimental_run_tf_function ) <nl> + model_and_input , distribution ) <nl> <nl> @ combinations . generate ( <nl> combinations . times ( test_base . simple_models_with_strategies ( ) , <nl> combinations . combine ( save_in_scope = [ True , False ] ) ) ) <nl> def test_save_strategy_restore_no_strategy ( self , model_and_input , <nl> - distribution , save_in_scope , <nl> - experimental_run_tf_function ) : <nl> + distribution , save_in_scope ) : <nl> self . run_test_save_strategy_restore_no_strategy ( <nl> - model_and_input , distribution , save_in_scope , <nl> - experimental_run_tf_function ) <nl> + model_and_input , distribution , save_in_scope ) <nl> <nl> @ combinations . generate ( <nl> combinations . times ( test_base . simple_models_with_strategy_pairs ( ) , <nl> def test_save_strategy_restore_no_strategy ( self , model_and_input , <nl> def test_save_strategy_restore_strategy ( self , model_and_input , <nl> distribution_for_saving , <nl> distribution_for_restoring , <nl> - save_in_scope , <nl> - experimental_run_tf_function ) : <nl> + save_in_scope ) : <nl> self . run_test_save_strategy_restore_strategy ( model_and_input , <nl> distribution_for_saving , <nl> distribution_for_restoring , <nl> - save_in_scope , <nl> - experimental_run_tf_function ) <nl> + save_in_scope ) <nl> <nl> <nl> class SavedModelTFModuleTest ( test_base . TestSavedModelBase ) : <nl> def _load_and_run_model ( self , <nl> distribution , <nl> saved_dir , <nl> predict_dataset , <nl> - experimental_run_tf_function , <nl> output_name = ' output_1 ' ) : <nl> - del output_name , experimental_run_tf_function <nl> + del output_name <nl> model = saved_model . load ( saved_dir ) <nl> return self . _predict_with_model ( distribution , model , predict_dataset ) <nl> <nl> @ combinations . generate ( test_base . tfmodule_models_with_strategies ( ) ) <nl> def test_save_no_strategy_restore_strategy ( self , model_and_input , <nl> - distribution , <nl> - experimental_run_tf_function ) : <nl> + distribution ) : <nl> self . run_test_save_no_strategy_restore_strategy ( <nl> - model_and_input , distribution , experimental_run_tf_function ) <nl> + model_and_input , distribution ) <nl> <nl> @ combinations . generate ( <nl> combinations . times ( test_base . tfmodule_models_with_strategies ( ) , <nl> combinations . combine ( save_in_scope = [ True , False ] ) ) ) <nl> def test_save_strategy_restore_no_strategy ( <nl> - self , model_and_input , distribution , save_in_scope , <nl> - experimental_run_tf_function ) : <nl> + self , model_and_input , distribution , save_in_scope ) : <nl> self . run_test_save_strategy_restore_no_strategy ( <nl> - model_and_input , distribution , save_in_scope , <nl> - experimental_run_tf_function ) <nl> + model_and_input , distribution , save_in_scope ) <nl> <nl> @ combinations . generate ( <nl> combinations . times ( test_base . tfmodule_models_with_strategy_pairs ( ) , <nl> def test_save_strategy_restore_no_strategy ( <nl> def test_save_strategy_restore_strategy ( self , model_and_input , <nl> distribution_for_saving , <nl> distribution_for_restoring , <nl> - save_in_scope , <nl> - experimental_run_tf_function ) : <nl> + save_in_scope ) : <nl> self . run_test_save_strategy_restore_strategy ( model_and_input , <nl> distribution_for_saving , <nl> distribution_for_restoring , <nl> - save_in_scope , <nl> - experimental_run_tf_function ) <nl> + save_in_scope ) <nl> <nl> <nl> if __name__ = = ' __main__ ' : <nl> mmm a / tensorflow / python / distribute / saved_model_test_base . py <nl> ppp b / tensorflow / python / distribute / saved_model_test_base . py <nl> def simple_models_with_strategies ( ) : <nl> return combinations . combine ( <nl> model_and_input = simple_models , <nl> distribution = strategies , <nl> - mode = [ ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) <nl> + mode = [ ' eager ' ] ) <nl> <nl> <nl> def simple_models_with_strategy_pairs ( ) : <nl> def simple_models_with_strategy_pairs ( ) : <nl> model_and_input = simple_models , <nl> distribution_for_saving = strategies , <nl> distribution_for_restoring = strategies , <nl> - mode = [ ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) <nl> + mode = [ ' eager ' ] ) <nl> <nl> <nl> def tfmodule_models_with_strategies ( ) : <nl> return combinations . combine ( <nl> model_and_input = [ model_combinations . simple_tfmodule_model ] , <nl> distribution = strategies , <nl> - mode = [ ' eager ' ] , <nl> - experimental_run_tf_function = [ True ] ) <nl> + mode = [ ' eager ' ] ) <nl> <nl> <nl> def tfmodule_models_with_strategy_pairs ( ) : <nl> def tfmodule_models_with_strategy_pairs ( ) : <nl> model_and_input = [ model_combinations . simple_tfmodule_model ] , <nl> distribution_for_saving = strategies , <nl> distribution_for_restoring = strategies , <nl> - mode = [ ' eager ' ] , <nl> - experimental_run_tf_function = [ True ] ) <nl> + mode = [ ' eager ' ] ) <nl> <nl> <nl> def load_and_run_with_saved_model_api ( distribution , saved_dir , predict_dataset , <nl> def _load_and_run_model ( self , <nl> distribution , <nl> saved_dir , <nl> predict_dataset , <nl> - experimental_run_tf_function , <nl> output_name = ' output_1 ' ) : <nl> " " " Load the model and run 1 step of predict with it . <nl> <nl> def _load_and_run_model ( self , <nl> saved_dir : the string representing the path where the model is saved . <nl> predict_dataset : the data used to do the predict on the model for <nl> cross_replica context . <nl> - experimental_run_tf_function : Whether to use the single execution path <nl> - for models . <nl> output_name : the string representing the name of the output layer of the <nl> model . <nl> " " " <nl> def _get_predict_dataset ( self , x_predict , batch_size ) : <nl> return predict_dataset <nl> <nl> def run_test_save_no_strategy_restore_strategy ( self , model_and_input , <nl> - distribution , <nl> - experimental_run_tf_function ) : <nl> + distribution ) : <nl> " " " Save a model without DS , and restore it with DS . " " " <nl> <nl> saved_dir = os . path . join ( self . get_temp_dir ( ) , ' 0 ' ) <nl> <nl> - model = model_and_input . get_model ( <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + model = model_and_input . get_model ( ) <nl> x_train , y_train , x_predict = model_and_input . get_data ( ) <nl> batch_size = model_and_input . get_batch_size ( ) <nl> predict_dataset = self . _get_predict_dataset ( x_predict , batch_size ) <nl> def run_test_save_no_strategy_restore_strategy ( self , model_and_input , <nl> result_after_save = self . _load_and_run_model ( <nl> distribution = distribution , <nl> saved_dir = saved_dir , <nl> - predict_dataset = predict_dataset , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + predict_dataset = predict_dataset ) <nl> <nl> tolerance = get_tolerance ( None , distribution ) <nl> self . assertAllClose ( result_before_save , result_after_save , atol = tolerance ) <nl> <nl> def run_test_save_strategy_restore_no_strategy ( self , model_and_input , <nl> - distribution , save_in_scope , <nl> - experimental_run_tf_function ) : <nl> + distribution , save_in_scope ) : <nl> " " " Save a model with DS , and restore it without DS . " " " <nl> <nl> saved_dir = os . path . join ( self . get_temp_dir ( ) , ' 1 ' ) <nl> <nl> with distribution . scope ( ) : <nl> - model = model_and_input . get_model ( <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + model = model_and_input . get_model ( ) <nl> x_train , y_train , x_predict = model_and_input . get_data ( ) <nl> batch_size = model_and_input . get_batch_size ( ) <nl> <nl> def run_test_save_strategy_restore_no_strategy ( self , model_and_input , <nl> load_result = self . _load_and_run_model ( <nl> distribution = None , <nl> saved_dir = saved_dir , <nl> - predict_dataset = predict_dataset , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + predict_dataset = predict_dataset ) <nl> <nl> tolerance = get_tolerance ( distribution , None ) <nl> self . assertAllClose ( result_before_save , load_result , atol = tolerance ) <nl> def run_test_save_strategy_restore_no_strategy ( self , model_and_input , <nl> def run_test_save_strategy_restore_strategy ( self , model_and_input , <nl> distribution_for_saving , <nl> distribution_for_restoring , <nl> - save_in_scope , <nl> - experimental_run_tf_function ) : <nl> + save_in_scope ) : <nl> " " " Save a model with DS , and restore it with potentially different DS . " " " <nl> saved_dir = os . path . join ( self . get_temp_dir ( ) , ' 2 ' ) <nl> <nl> with distribution_for_saving . scope ( ) : <nl> - model = model_and_input . get_model ( <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + model = model_and_input . get_model ( ) <nl> x_train , y_train , x_predict = model_and_input . get_data ( ) <nl> batch_size = model_and_input . get_batch_size ( ) <nl> <nl> def run_test_save_strategy_restore_strategy ( self , model_and_input , <nl> load_result = self . _load_and_run_model ( <nl> distribution = distribution_for_restoring , <nl> saved_dir = saved_dir , <nl> - predict_dataset = predict_dataset , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + predict_dataset = predict_dataset ) <nl> <nl> tolerance = get_tolerance ( distribution_for_saving , <nl> distribution_for_restoring ) <nl> mmm a / tensorflow / python / keras / callbacks_test . py <nl> ppp b / tensorflow / python / keras / callbacks_test . py <nl> def _get_model ( self ) : <nl> model . compile ( <nl> adam . AdamOptimizer ( 0 . 001 ) , <nl> ' binary_crossentropy ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> @ parameterized . named_parameters ( ( ' with_numpy ' , _get_numpy ( ) ) , <nl> def _get_model ( self , input_shape = None ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ keras . metrics . CategoricalAccuracy ( name = ' my_acc ' ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> @ keras_parameterized . run_with_all_model_types <nl> def _get_model ( self ) : <nl> model . compile ( <nl> opt , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> def test_TensorBoard_default_logdir ( self ) : <nl> def test_TensorBoard_weight_images ( self ) : <nl> ) <nl> <nl> def test_custom_summary ( self ) : <nl> - if not testing_utils . should_run_tf_function ( ) : <nl> + if not context . executing_eagerly ( ) : <nl> self . skipTest ( ' Custom summaries only supported in V2 code path . ' ) <nl> <nl> def scalar_v2_mock ( name , data , step = None ) : <nl> def call ( self , x ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> tb_cbk = keras . callbacks . TensorBoard ( self . logdir , update_freq = 1 ) <nl> x , y = np . ones ( ( 10 , 5 ) ) , np . ones ( ( 10 , 5 ) ) <nl> model . fit ( x , y , batch_size = 2 , validation_data = ( x , y ) , callbacks = [ tb_cbk ] ) <nl> def _get_seq_model ( self ) : <nl> model . compile ( <nl> opt , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> def _get_trace_file ( self , logdir ) : <nl> mmm a / tensorflow / python / keras / distribute / distribute_strategy_test . py <nl> ppp b / tensorflow / python / keras / distribute / distribute_strategy_test . py <nl> def all_strategy_combinations ( ) : <nl> def all_strategy_combinations_plus_run_distributed ( ) : <nl> return ( combinations . combine ( <nl> distribution = strategies_minus_tpu , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) + combinations . combine ( <nl> + mode = [ ' graph ' , ' eager ' ] ) + combinations . combine ( <nl> distribution = tpu_strategies , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ False ] ) ) <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> <nl> <nl> def all_strategy_minus_default_and_tpu_combinations ( ) : <nl> def strategy_and_optimizer_combinations ( ) : <nl> strategy_combinations . nadam_optimizer_keras_v2_fn , <nl> strategy_combinations . rmsprop_optimizer_keras_v2_fn , <nl> strategy_combinations . ftrl_optimizer_keras_v2_fn <nl> - ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> + ] ) ) <nl> tpu_strategies_graph = combinations . combine ( <nl> distribution = tpu_strategies , <nl> mode = [ ' graph ' ] , <nl> - experimental_run_tf_function = [ True ] , <nl> optimizer = [ <nl> strategy_combinations . adagrad_optimizer_v1_fn , <nl> strategy_combinations . adam_optimizer_v1_fn , <nl> def strategy_and_optimizer_combinations ( ) : <nl> tpu_strategies_eager = combinations . combine ( <nl> distribution = tpu_strategies , <nl> mode = [ ' eager ' ] , <nl> - experimental_run_tf_function = [ False ] , <nl> optimizer = [ <nl> strategy_combinations . adagrad_optimizer_keras_v2_fn , <nl> strategy_combinations . adam_optimizer_keras_v2_fn , <nl> def test_calculating_input_params_with_steps_with_batch_size ( <nl> distribution , 64 , steps = 10 , batch_size = 13 ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> - def test_calling_model_with_numpy_arrays ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + def test_calling_model_with_numpy_arrays ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> def test_calling_model_with_numpy_arrays ( self , distribution , <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> inputs = np . zeros ( ( 64 , 3 ) , dtype = np . float32 ) <nl> targets = np . zeros ( ( 64 , 4 ) , dtype = np . float32 ) <nl> def test_calling_model_with_numpy_arrays ( self , distribution , <nl> model . predict ( inputs , batch_size = 8 ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> - def test_calling_model_with_mixed_precision ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + def test_calling_model_with_mixed_precision ( self , distribution ) : <nl> if isinstance ( distribution , <nl> ( tpu_strategy . TPUStrategy , tpu_strategy . TPUStrategyV1 ) ) : <nl> policy_name = ' mixed_bfloat16 ' <nl> def test_calling_model_with_mixed_precision ( self , distribution , <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> # We need to pass float32 since TPUs do not support float64 , even though <nl> # these arrays will immediately be casted to bfloat16 on TPUs . We also <nl> def test_calling_model_with_mixed_precision ( self , distribution , <nl> model . predict ( inputs , batch_size = 8 ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> - def test_operator_overload_mixed_precision ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + def test_operator_overload_mixed_precision ( self , distribution ) : <nl> # Regression test that tests a fixed bug does not reoccur . Adding an <nl> # AutoCastVariable to a tensor on a TPU , where the variable was the LHS of <nl> # the ' + ' operator , used to cause the gradient w . r . t . the variable to be <nl> def test_optimizer_in_cross_replica_context_raises_error ( self , distribution ) : <nl> optimizer . apply_gradients ( zip ( gradients , model . trainable_variables ) ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> - def test_calling_model_with_nested_numpy_arrays ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + def test_calling_model_with_nested_numpy_arrays ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> def test_calling_model_with_nested_numpy_arrays ( self , distribution , <nl> loss = ' mse ' <nl> model . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> input_a_np = np . asarray ( np . random . random ( ( 64 , 3 ) ) , dtype = np . float32 ) <nl> input_b_np = np . asarray ( np . random . random ( ( 64 , 5 ) ) , dtype = np . float32 ) <nl> def test_calling_model_with_nested_numpy_arrays ( self , distribution , <nl> @ combinations . generate ( <nl> combinations . combine ( <nl> distribution = strategies_minus_tpu , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> - def test_numpy_with_sample_weights ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> + def test_numpy_with_sample_weights ( self , distribution ) : <nl> with self . cached_session ( ) , distribution . scope ( ) : <nl> model = get_sample_weights_model ( ) <nl> optimizer = rmsprop . RMSPropOptimizer ( learning_rate = 0 . 001 ) <nl> loss = ' mse ' <nl> model . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> inputs = np . array ( [ [ 0 ] , [ 1 ] , [ 2 ] , [ 3 ] ] , np . float32 ) <nl> targets = np . array ( [ [ 2 ] , [ 4 ] , [ 6 ] , [ 8 ] ] , np . float32 ) <nl> def test_numpy_with_sample_weights ( self , distribution , <nl> self . assertAllClose ( result , 13 . 5 ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> - def test_flatten_predict_outputs ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + def test_flatten_predict_outputs ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> model = multi_input_output_model ( ) <nl> def test_flatten_predict_outputs ( self , distribution , <nl> loss = ' mse ' <nl> model . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> # We take 6 input samples with each input having a dimension of 3 or 5 . <nl> input_a_np = np . asarray ( np . random . random ( ( 6 , 3 ) ) , dtype = np . float32 ) <nl> def test_evaluate_with_partial_batch ( self , distribution , batch_size ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - tpu_strategy_combinations_graph_only ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> - def test_predict_with_partial_batch ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + tpu_strategy_combinations_graph_only ( ) ) ) <nl> + def test_predict_with_partial_batch ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 001 ) <nl> loss = ' mse ' <nl> def test_predict_with_partial_batch ( self , distribution , <nl> model_with_ds_strategy = get_model ( ) <nl> model_with_ds_strategy . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> cpu_model = get_model ( ) <nl> cpu_model . compile ( optimizer , loss ) <nl> def call ( self , inputs , training = None ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - tpu_strategy_combinations_graph_only ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> + tpu_strategy_combinations_graph_only ( ) ) ) <nl> def test_predict_multi_output_model_with_partial_batch ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with self . cached_session ( ) : <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 001 ) <nl> loss = ' mse ' <nl> def test_predict_multi_output_model_with_partial_batch ( <nl> model_with_ds_strategy = simple_multi_inputs_multi_outputs_model ( ) <nl> model_with_ds_strategy . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> cpu_model = simple_multi_inputs_multi_outputs_model ( ) <nl> cpu_model . compile ( optimizer , loss ) <nl> class TestDistributionStrategyWithDatasets ( test . TestCase , <nl> parameterized . TestCase ) : <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> - def test_calling_model_on_same_dataset ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + def test_calling_model_on_same_dataset ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> def test_calling_model_on_same_dataset ( self , distribution , <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> dataset = get_dataset ( distribution ) <nl> <nl> def test_calling_model_on_same_dataset ( self , distribution , <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> def test_model_interleaved_eval_same_as_direct_eval ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> def test_model_interleaved_eval_same_as_direct_eval ( <nl> user_controlled_model . compile ( <nl> optimizer_fn ( 0 . 001 ) , <nl> loss = ' mse ' , <nl> - metrics = [ ' mae ' , keras . metrics . CategoricalAccuracy ( ) ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' mae ' , keras . metrics . CategoricalAccuracy ( ) ] ) <nl> <nl> interleaved_model = get_model ( ) <nl> interleaved_model . set_weights ( user_controlled_model . get_weights ( ) ) <nl> interleaved_model . compile ( <nl> optimizer_fn ( 0 . 001 ) , <nl> loss = ' mse ' , <nl> - metrics = [ ' mae ' , keras . metrics . CategoricalAccuracy ( ) ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' mae ' , keras . metrics . CategoricalAccuracy ( ) ] ) <nl> <nl> dataset = get_dataset ( distribution ) <nl> <nl> def test_model_interleaved_eval_same_as_direct_eval ( <nl> [ x [ 2 ] for x in user_controlled_output ] ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> - def test_fit_with_tuple_and_dict_dataset_inputs ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + def test_fit_with_tuple_and_dict_dataset_inputs ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> def test_fit_with_tuple_and_dict_dataset_inputs ( self , distribution , <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> input_a_np = np . random . random ( ( 10 , 3 ) ) . astype ( ' float32 ' ) <nl> input_b_np = np . random . random ( ( 10 , 5 ) ) . astype ( ' float32 ' ) <nl> def test_fit_with_tuple_and_dict_dataset_inputs ( self , distribution , <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> def test_fit_with_dictionary_in_the_dataset_b135161171 ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> <nl> def custom_loss ( predict , label , weight ) : <nl> bce = keras . losses . binary_crossentropy ( label , predict ) <nl> def custom_loss ( predict , label , weight ) : <nl> outputs = [ predict , my_loss ] ) <nl> model . add_loss ( model . get_layer ( ' my_loss ' ) . output ) <nl> model . compile ( <nl> - optimizer = ' adam ' , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + optimizer = ' adam ' ) <nl> <nl> if context . executing_eagerly ( ) : <nl> <nl> def map_fn ( img , lbl , weight ) : <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> def test_fit_eval_and_predict_methods_on_dataset_without_steps ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> def test_fit_eval_and_predict_methods_on_dataset_without_steps ( <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> inputs = np . zeros ( ( 1000 , 3 ) , dtype = np . float32 ) <nl> targets = np . zeros ( ( 1000 , 4 ) , dtype = np . float32 ) <nl> def test_fit_eval_and_predict_methods_on_dataset_without_steps ( <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - strategy_minus_tpu_combinations ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> + strategy_minus_tpu_combinations ( ) ) ) <nl> def test_on_dataset_with_unknown_cardinality_without_steps ( <nl> - self , distribution , experimental_run_tf_function , mode ) : <nl> + self , distribution , mode ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> def test_on_dataset_with_unknown_cardinality_without_steps ( <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> inputs = np . zeros ( ( 1000 , 3 ) , dtype = np . float32 ) <nl> targets = np . zeros ( ( 1000 , 4 ) , dtype = np . float32 ) <nl> def test_on_dataset_with_unknown_cardinality_without_steps ( <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - tpu_strategy_combinations ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> - def test_on_dataset_with_unknown_cardinality ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + tpu_strategy_combinations ( ) ) ) <nl> + def test_on_dataset_with_unknown_cardinality ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> model = get_model ( ) <nl> def test_on_dataset_with_unknown_cardinality ( self , distribution , <nl> model . compile ( <nl> gradient_descent . GradientDescentOptimizer ( 0 . 001 ) , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> inputs = np . zeros ( ( 1000 , 3 ) , dtype = np . float32 ) <nl> targets = np . zeros ( ( 1000 , 4 ) , dtype = np . float32 ) <nl> def test_on_dataset_with_unknown_cardinality ( self , distribution , <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> def test_fit_eval_and_predict_methods_on_dataset ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> def test_fit_eval_and_predict_methods_on_dataset ( <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> dataset = get_dataset ( distribution ) <nl> <nl> def test_fit_eval_and_predict_methods_on_dataset ( <nl> model . predict ( get_predict_dataset ( distribution ) , steps = 2 ) <nl> <nl> @ combinations . generate ( strategy_and_optimizer_combinations ( ) ) <nl> - def test_fit_eval_and_predict_with_optimizer ( self , distribution , optimizer , <nl> - experimental_run_tf_function ) : <nl> + def test_fit_eval_and_predict_with_optimizer ( self , distribution , optimizer ) : <nl> with self . cached_session ( ) : <nl> <nl> with distribution . scope ( ) : <nl> def test_fit_eval_and_predict_with_optimizer ( self , distribution , optimizer , <nl> loss = ' mse ' <nl> model . compile ( <nl> optimizer ( ) , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> dataset = get_dataset ( distribution ) <nl> <nl> def test_fit_eval_and_predict_with_optimizer ( self , distribution , optimizer , <nl> strategy_combinations . mirrored_strategy_with_gpu_and_cpu , <nl> strategy_combinations . one_device_strategy <nl> ] , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> - def test_dataset_wrong_input_shape ( self , distribution , <nl> - experimental_run_tf_function , mode ) : <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> + def test_dataset_wrong_input_shape ( self , distribution , mode ) : <nl> if mode = = ' graph ' : <nl> self . skipTest ( <nl> ' TODO ( b / 120943676 , b / 120957836 ) : Re - enable for graph once the ' <nl> def test_dataset_wrong_input_shape ( self , distribution , <nl> loss = ' mse ' <nl> model . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> # Wrong input shape <nl> inputs = np . zeros ( ( 10 , 5 ) , dtype = np . float32 ) <nl> def test_dataset_wrong_input_shape ( self , distribution , <nl> distribution = [ <nl> strategy_combinations . mirrored_strategy_with_gpu_and_cpu <nl> ] , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> def test_dataset_external_batch_input_validation ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> def test_dataset_external_batch_input_validation ( <nl> loss = ' mse ' <nl> model . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> # Batching is done outside tf . data ' s ` batch ` <nl> inputs = np . zeros ( ( 100 , 10 , 3 ) , dtype = np . float32 ) <nl> def test_dataset_external_batch_input_validation ( <nl> strategy_combinations . mirrored_strategy_with_gpu_and_cpu , <nl> strategy_combinations . mirrored_strategy_with_two_gpus <nl> ] , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> - def test_learning_phase_value ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> + def test_learning_phase_value ( self , distribution ) : <nl> # TODO ( anjalisridhar ) : Modify this test to use Lambdas since we can compare <nl> # meaningful values . Currently we don ' t pass the learning phase if the <nl> # Lambda layer uses the learning phase . <nl> def test_learning_phase_value ( self , distribution , <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> batch_size = 8 <nl> if isinstance ( distribution , mirrored_strategy . MirroredStrategy ) : <nl> def test_learning_phase_value ( self , distribution , <nl> self . assertArrayNear ( output , ref_output , 1e - 1 ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> - def testOptimizerWithCallbacks ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + def testOptimizerWithCallbacks ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> model = get_model ( ) <nl> def testOptimizerWithCallbacks ( self , distribution , <nl> loss = ' mse ' <nl> model . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> dataset = get_dataset ( distribution ) <nl> <nl> def test_evaluate_with_dataset_with_partial_batch ( self , distribution , <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - tpu_strategy_combinations_graph_only ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> + tpu_strategy_combinations_graph_only ( ) ) ) <nl> def test_predict_with_dataset_with_partial_batch ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with self . cached_session ( ) : <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 001 ) <nl> loss = ' mse ' <nl> def test_predict_with_dataset_with_partial_batch ( <nl> model_with_ds_strategy = get_model ( ) <nl> model_with_ds_strategy . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> cpu_model = get_model ( ) <nl> cpu_model . compile ( optimizer , loss ) <nl> def test_predict_with_dataset_with_partial_batch ( <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - tpu_strategy_combinations_graph_only ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> + tpu_strategy_combinations_graph_only ( ) ) ) <nl> def test_predict_multi_output_model_with_dataset_with_partial_batch ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with self . cached_session ( ) : <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 001 ) <nl> loss = ' mse ' <nl> def test_predict_multi_output_model_with_dataset_with_partial_batch ( <nl> model_with_ds_strategy = simple_multi_inputs_multi_outputs_model ( ) <nl> model_with_ds_strategy . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> cpu_model = simple_multi_inputs_multi_outputs_model ( ) <nl> cpu_model . compile ( optimizer , loss ) <nl> def _create_model_input_output_tensors ( ) : <nl> @ combinations . generate ( <nl> combinations . combine ( <nl> distribution = strategies_minus_tpu , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> - def test_dataset_with_sample_weights ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> + def test_dataset_with_sample_weights ( self , distribution ) : <nl> with self . cached_session ( ) , distribution . scope ( ) : <nl> model = get_sample_weights_model ( ) <nl> optimizer = rmsprop . RMSPropOptimizer ( learning_rate = 0 . 001 ) <nl> loss = ' mse ' <nl> model . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> inputs = np . array ( [ [ 0 ] , [ 1 ] , [ 2 ] , [ 3 ] ] , np . float32 ) <nl> targets = np . array ( [ [ 2 ] , [ 4 ] , [ 6 ] , [ 8 ] ] , np . float32 ) <nl> def loss_fn ( _ , y_pred ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - strategy_combinations . all_strategy_combinations_minus_default ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> - def test_regularizer_loss ( self , distribution , experimental_run_tf_function ) : <nl> + strategy_combinations . all_strategy_combinations_minus_default ( ) ) ) <nl> + def test_regularizer_loss ( self , distribution ) : <nl> batch_size = 2 <nl> if not distributed_training_utils . global_batch_size_supported ( distribution ) : <nl> batch_size / / = distribution . num_replicas_in_sync <nl> def test_regularizer_loss ( self , distribution , experimental_run_tf_function ) : <nl> opt = gradient_descent_keras . SGD ( 1 . ) <nl> model . compile ( <nl> opt , <nl> - loss = TestRegularizerLoss . loss_fn , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss = TestRegularizerLoss . loss_fn ) <nl> model . fit ( <nl> x = np . array ( [ [ 1 . ] , [ 1 . ] ] , dtype = np . float32 ) , <nl> y = np . array ( [ [ 1 . ] , [ 1 . ] ] , dtype = np . float32 ) , <nl> class TestDistributionStrategyWithKerasModels ( test . TestCase , <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> def test_distribution_strategy_on_sequential_model ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> optimizer = optimizer_fn ( learning_rate = 0 . 001 ) <nl> def test_distribution_strategy_on_sequential_model ( <nl> loss = ' mse ' <nl> model . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> inputs = np . zeros ( ( 20 , 10 ) , np . float32 ) <nl> targets = np . zeros ( ( 20 , 2 ) , np . float32 ) <nl> def test_distribution_strategy_on_sequential_model ( <nl> <nl> @ combinations . generate ( all_strategy_combinations_plus_run_distributed ( ) ) <nl> def test_distribution_strategy_on_functional_model ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with distribution . scope ( ) : <nl> optimizer_fn = gradient_descent_keras . SGD <nl> optimizer = optimizer_fn ( learning_rate = 0 . 001 ) <nl> def test_distribution_strategy_on_functional_model ( <nl> loss = ' mse ' <nl> model . compile ( <nl> optimizer , <nl> - loss , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss ) <nl> <nl> inputs = np . zeros ( ( 64 , 3 ) , dtype = np . float32 ) <nl> targets = np . zeros ( ( 64 , 4 ) , dtype = np . float32 ) <nl> def test_distribution_strategy_on_functional_model ( <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - all_strategy_combinations_minus_default ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> - def test_distribution_strategy_one_dimensional ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + all_strategy_combinations_minus_default ( ) ) ) <nl> + def test_distribution_strategy_one_dimensional ( self , distribution ) : <nl> with distribution . scope ( ) : <nl> inp = keras . layers . Input ( shape = ( 10 , ) ) <nl> out = keras . layers . Dense ( 3 , activation = ' softmax ' ) ( inp ) <nl> def test_distribution_strategy_one_dimensional ( self , distribution , <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' sparse_categorical_crossentropy ' , <nl> - metrics = [ ' sparse_categorical_accuracy ' ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' sparse_categorical_accuracy ' ] ) <nl> <nl> x = np . random . random ( ( 64 , 10 ) ) . astype ( ' float32 ' ) <nl> y = np . random . randint ( 3 , size = 64 ) <nl> def test_distribution_strategy_one_dimensional ( self , distribution , <nl> strategy_combinations . mirrored_strategy_with_two_gpus <nl> ] , <nl> mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] , <nl> reduction = [ <nl> loss_reduction . ReductionV2 . AUTO , <nl> loss_reduction . ReductionV2 . SUM_OVER_BATCH_SIZE , <nl> loss_reduction . ReductionV2 . SUM <nl> ] ) ) <nl> def test_distribution_strategy_with_loss_reduction_types ( <nl> - self , distribution , experimental_run_tf_function , reduction ) : <nl> + self , distribution , reduction ) : <nl> np . random . seed ( _RANDOM_SEED ) <nl> <nl> def _get_model ( ) : <nl> def _get_model ( ) : <nl> ds_model = _get_model ( ) <nl> ds_model . compile ( <nl> ' sgd ' , <nl> - loss = keras . losses . MeanSquaredError ( reduction = reduction ) , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + loss = keras . losses . MeanSquaredError ( reduction = reduction ) ) <nl> ds_history = ds_model . fit ( <nl> dataset , steps_per_epoch = 2 , epochs = 1 , shuffle = False ) <nl> self . assertArrayNear ( history . history [ ' loss ' ] , ds_history . history [ ' loss ' ] , <nl> def _get_model ( ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - all_strategy_combinations_minus_default ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> + all_strategy_combinations_minus_default ( ) ) ) <nl> def test_distribution_strategy_with_symbolic_add_loss ( <nl> - self , mode , distribution , experimental_run_tf_function ) : <nl> + self , mode , distribution ) : <nl> <nl> def _make_model_with_add_loss ( ) : <nl> inputs = keras . Input ( ( 10 , ) ) <nl> def _make_model_with_add_loss ( ) : <nl> with distribution . scope ( ) : <nl> ds_model = _make_model_with_add_loss ( ) <nl> ds_model . compile ( <nl> - ' sgd ' , experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' sgd ' ) <nl> ds_history = ds_model . fit ( x , epochs = 1 ) <nl> <nl> self . assertAllClose ( history . history , ds_history . history ) <nl> def _make_model ( ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - all_strategy_minus_default_and_tpu_combinations ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> + all_strategy_minus_default_and_tpu_combinations ( ) ) ) <nl> def test_distribution_strategy_with_add_metric_in_call ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> <nl> class Bias ( keras . layers . Layer ) : <nl> <nl> def _make_model_with_add_metric ( ) : <nl> self . assertLen ( ds_model . metrics , 1 ) <nl> ds_model . compile ( <nl> ' sgd ' , <nl> - ' mse ' , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' mse ' ) <nl> ds_history = ds_model . fit ( <nl> x , y , validation_data = ( x , y ) , validation_steps = 2 , epochs = 2 ) <nl> # includes stateful loss metric in eager . <nl> def _make_model_with_add_metric ( ) : <nl> strategy_combinations . mirrored_strategy_with_gpu_and_cpu , <nl> strategy_combinations . mirrored_strategy_with_two_gpus , <nl> ] , <nl> - mode = [ ' eager ' ] , <nl> - experimental_run_tf_function = [ False ] ) ) <nl> + mode = [ ' eager ' ] ) ) <nl> def test_distribution_strategy_with_add_metric_object ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> <nl> class Bias ( keras . layers . Layer ) : <nl> <nl> def _make_model_with_add_metric_object ( ) : <nl> self . assertLen ( ds_model . metrics , 1 ) <nl> ds_model . compile ( <nl> ' sgd ' , <nl> - ' mse ' , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' mse ' ) <nl> ds_history = ds_model . fit ( <nl> x , y , validation_data = ( x , y ) , validation_steps = 2 , epochs = 2 ) <nl> # includes stateful loss metric in eager . <nl> def _make_model_with_add_metric_object ( ) : <nl> @ combinations . generate ( <nl> # TODO ( phillypham ) : Why does validation_steps > 1 not work on TPUs ? <nl> combinations . times ( <nl> - all_strategy_minus_default_and_tpu_combinations ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> + all_strategy_minus_default_and_tpu_combinations ( ) ) ) <nl> def test_distribution_strategy_with_add_metric_outside_call ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> <nl> def _make_model_with_add_metric ( ) : <nl> inputs = keras . Input ( ( 10 , ) ) <nl> def _make_model_with_add_metric ( ) : <nl> self . assertLen ( ds_model . metrics , 1 ) <nl> ds_model . compile ( <nl> ' sgd ' , <nl> - ' mse ' , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' mse ' ) <nl> ds_history = ds_model . fit ( <nl> x , y , validation_data = ( x , y ) , validation_steps = 2 , epochs = 2 ) <nl> # includes stateful loss metric in eager . <nl> def _make_model_with_add_metric ( ) : <nl> @ combinations . generate ( <nl> combinations . combine ( <nl> distribution = strategies_minus_tpu , <nl> - mode = [ ' eager ' ] , <nl> - experimental_run_tf_function = [ True ] ) ) <nl> - def test_sparse_tensor_outputs ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + mode = [ ' eager ' ] ) ) <nl> + def test_sparse_tensor_outputs ( self , distribution ) : <nl> <nl> class ToSparse ( keras . layers . Layer ) : <nl> " " " Create a sparse tensor based on a given dense tensor . " " " <nl> def call ( self , inputs ) : <nl> return sparse_tensor . SparseTensor ( indices , values , dense_shape = shape ) <nl> <nl> model = keras . Sequential ( [ ToSparse ( ) ] ) <nl> - model . _experimental_run_tf_function = experimental_run_tf_function <nl> <nl> # Define some input data with additional padding . <nl> input_data = np . array ( [ [ 1 , 0 , 0 ] , [ 2 , 3 , 0 ] ] ) <nl> def call ( self , inputs ) : <nl> @ combinations . generate ( <nl> combinations . combine ( <nl> distribution = strategies_minus_tpu , <nl> - mode = [ ' eager ' ] , <nl> - experimental_run_tf_function = [ True ] ) ) <nl> - def test_ragged_tensor_outputs ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + mode = [ ' eager ' ] ) ) <nl> + def test_ragged_tensor_outputs ( self , distribution ) : <nl> <nl> class ToRagged ( keras . layers . Layer ) : <nl> " " " Create a ragged tensor based on a given dense tensor . " " " <nl> def call ( self , inputs ) : <nl> inputs , padding = self . _padding , ragged_rank = self . _ragged_rank ) <nl> <nl> model = keras . Sequential ( [ ToRagged ( padding = 0 ) ] ) <nl> - model . _experimental_run_tf_function = experimental_run_tf_function <nl> <nl> # Define some input data with additional padding . <nl> input_data = np . array ( [ [ 1 , 0 , 0 ] , [ 2 , 3 , 0 ] ] ) <nl> mmm a / tensorflow / python / keras / distribute / keras_correctness_test_base . py <nl> ppp b / tensorflow / python / keras / distribute / keras_correctness_test_base . py <nl> def graph_mode_test_configuration ( ) : <nl> def all_strategy_and_input_config_combinations ( ) : <nl> return ( combinations . times ( <nl> combinations . combine ( <nl> - distribution = all_strategies , <nl> - experimental_run_tf_function = [ True , False ] ) , <nl> + distribution = all_strategies ) , <nl> eager_mode_test_configuration ( ) + graph_mode_test_configuration ( ) ) ) <nl> <nl> <nl> def test_combinations_for_embedding_model ( ) : <nl> <nl> return ( combinations . times ( <nl> combinations . combine ( <nl> - distribution = strategies_for_embedding_models ( ) , <nl> - experimental_run_tf_function = [ True , False ] ) , <nl> + distribution = strategies_for_embedding_models ( ) ) , <nl> ( graph_mode_test_configuration ( ) ) ) + combinations . times ( <nl> combinations . combine ( <nl> - distribution = eager_mode_strategies , <nl> - experimental_run_tf_function = [ False ] ) , <nl> + distribution = eager_mode_strategies ) , <nl> ( eager_mode_test_configuration ( ) ) ) ) <nl> <nl> <nl> def get_correctness_test_inputs ( use_numpy , use_validation_data , <nl> def fit_eval_and_predict ( initial_weights , <nl> input_fn , <nl> model_fn , <nl> - experimental_run_tf_function = None , <nl> distribution = None , <nl> is_stateful_model = False ) : <nl> " " " Generates results for fit / predict / evaluate for given model . " " " <nl> training_inputs , eval_inputs , predict_inputs = input_fn ( ) <nl> model = model_fn ( <nl> - experimental_run_tf_function = experimental_run_tf_function , <nl> initial_weights = initial_weights , <nl> distribution = distribution , <nl> input_shapes = get_shapes ( training_inputs [ ' x ' ] ) ) <nl> def get_input_for_correctness_test ( self , * * kwargs ) : <nl> <nl> def get_model ( self , <nl> distribution = None , <nl> - experimental_run_tf_function = None , <nl> input_shapes = None ) : <nl> raise NotImplementedError <nl> <nl> def run_correctness_test ( self , <nl> distribution , <nl> use_numpy , <nl> use_validation_data , <nl> - experimental_run_tf_function = None , <nl> with_batch_norm = None , <nl> is_stateful_model = False , <nl> partial_last_batch = None , <nl> def run_correctness_test ( self , <nl> # This is used to initialize the model for both the distribution and <nl> # non - distribution run . <nl> model = self . get_model ( <nl> - experimental_run_tf_function = experimental_run_tf_function , <nl> input_shapes = get_shapes ( x_train ) ) <nl> initial_weights = model . get_weights ( ) <nl> <nl> def run_correctness_test ( self , <nl> initial_weights , <nl> input_fn = ds_input_fn , <nl> model_fn = self . get_model , <nl> - experimental_run_tf_function = experimental_run_tf_function , <nl> distribution = distribution , <nl> is_stateful_model = is_stateful_model ) <nl> results_without_ds = fit_eval_and_predict ( <nl> initial_weights , <nl> input_fn = nods_input_fn , <nl> model_fn = self . get_model , <nl> - experimental_run_tf_function = experimental_run_tf_function , <nl> distribution = None , <nl> is_stateful_model = is_stateful_model ) <nl> <nl> def get_input_for_dynamic_lr_test ( self , * * kwargs ) : <nl> return training_input , None , None <nl> <nl> def run_dynamic_lr_test ( self , <nl> - distribution , <nl> - experimental_run_tf_function = None ) : <nl> + distribution ) : <nl> with self . cached_session ( ) : <nl> self . set_up_test_config ( ) <nl> <nl> x_train , y_train , _ = self . get_data ( ) <nl> model = self . get_model ( <nl> - experimental_run_tf_function = experimental_run_tf_function , <nl> input_shapes = get_shapes ( x_train ) ) <nl> initial_weights = model . get_weights ( ) <nl> update_freq = None <nl> def run_dynamic_lr_test ( self , <nl> initial_weights , <nl> input_fn = ds_input_fn , <nl> model_fn = self . get_model , <nl> - experimental_run_tf_function = experimental_run_tf_function , <nl> distribution = distribution ) <nl> results_without_ds = fit_eval_and_predict ( <nl> initial_weights , <nl> input_fn = nods_input_fn , <nl> model_fn = self . get_model , <nl> - experimental_run_tf_function = experimental_run_tf_function , <nl> distribution = None ) <nl> compare_results ( <nl> results_with_ds , results_without_ds , distribution , testcase = self ) <nl> mmm a / tensorflow / python / keras / distribute / keras_dnn_correctness_test . py <nl> ppp b / tensorflow / python / keras / distribute / keras_dnn_correctness_test . py <nl> <nl> def all_strategy_combinations_with_eager_and_graph_modes ( ) : <nl> return ( combinations . combine ( <nl> distribution = keras_correctness_test_base . all_strategies , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> <nl> <nl> def all_strategy_combinations_with_graph_mode ( ) : <nl> return ( combinations . combine ( <nl> distribution = keras_correctness_test_base . all_strategies , <nl> - mode = [ ' graph ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> + mode = [ ' graph ' ] ) ) <nl> <nl> <nl> def is_default_strategy ( strategy ) : <nl> class TestDistributionStrategyDnnCorrectness ( <nl> keras_correctness_test_base . TestDistributionStrategyCorrectnessBase ) : <nl> <nl> def get_model ( self , <nl> - experimental_run_tf_function , <nl> initial_weights = None , <nl> distribution = None , <nl> input_shapes = None ) : <nl> def get_model ( self , <nl> model . compile ( <nl> loss = keras . losses . mean_squared_error , <nl> optimizer = gradient_descent_keras . SGD ( 0 . 05 ) , <nl> - metrics = [ ' mse ' ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' mse ' ] ) <nl> return model <nl> <nl> def get_data ( self ) : <nl> def get_data_with_partial_last_batch_eval ( self ) : <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . all_strategy_and_input_config_combinations ( ) ) <nl> - def test_dnn_correctness ( self , distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) : <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + def test_dnn_correctness ( self , distribution , use_numpy , use_validation_data ) : <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . test_combinations_with_tpu_strategies ( ) ) <nl> def test_dnn_correctness_with_partial_last_batch ( self , distribution , <nl> training_epochs = 1 ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_with_graph_mode ( ) ) <nl> - def test_dnn_with_dynamic_learning_rate ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> - self . run_dynamic_lr_test ( distribution , experimental_run_tf_function ) <nl> + def test_dnn_with_dynamic_learning_rate ( self , distribution ) : <nl> + self . run_dynamic_lr_test ( distribution ) <nl> <nl> <nl> class TestDistributionStrategyDnnMetricCorrectness ( <nl> keras_correctness_test_base . TestDistributionStrategyCorrectnessBase ) : <nl> <nl> def get_model ( self , <nl> - experimental_run_tf_function , <nl> distribution = None , <nl> input_shapes = None ) : <nl> with distribution . scope ( ) : <nl> def get_model ( self , <nl> model . compile ( <nl> loss = keras . losses . mean_squared_error , <nl> optimizer = gradient_descent_keras . SGD ( 0 . 05 ) , <nl> - metrics = [ keras . metrics . BinaryAccuracy ( ) ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ keras . metrics . BinaryAccuracy ( ) ] ) <nl> return model <nl> <nl> - def run_metric_correctness_test ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + def run_metric_correctness_test ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> self . set_up_test_config ( ) <nl> <nl> x_train , y_train , _ = self . get_data ( ) <nl> model = self . get_model ( <nl> - experimental_run_tf_function , distribution = distribution ) <nl> + distribution = distribution ) <nl> <nl> batch_size = 64 <nl> batch_size = ( <nl> def run_metric_correctness_test ( self , distribution , <nl> self . assertEqual ( history . history [ ' binary_accuracy ' ] , [ 1 . 0 , 1 . 0 ] ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_with_eager_and_graph_modes ( ) ) <nl> - def test_simple_dnn_metric_correctness ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> - self . run_metric_correctness_test ( distribution , experimental_run_tf_function ) <nl> + def test_simple_dnn_metric_correctness ( self , distribution ) : <nl> + self . run_metric_correctness_test ( distribution ) <nl> <nl> <nl> class TestDistributionStrategyDnnMetricEvalCorrectness ( <nl> keras_correctness_test_base . TestDistributionStrategyCorrectnessBase ) : <nl> <nl> def get_model ( self , <nl> - experimental_run_tf_function , <nl> distribution = None , <nl> input_shapes = None ) : <nl> with distribution . scope ( ) : <nl> def get_model ( self , <nl> model . compile ( <nl> loss = ' mae ' , <nl> metrics = [ ' accuracy ' , keras . metrics . BinaryAccuracy ( ) ] , <nl> - optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 001 ) , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 001 ) ) <nl> return model <nl> <nl> - def run_eval_metrics_correctness_test ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + def run_eval_metrics_correctness_test ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> self . set_up_test_config ( ) <nl> <nl> model = self . get_model ( <nl> - experimental_run_tf_function , distribution = distribution ) <nl> + distribution = distribution ) <nl> <nl> # verify correctness of stateful and stateless metrics . <nl> x = np . ones ( ( 100 , 4 ) ) . astype ( ' float32 ' ) <nl> def run_eval_metrics_correctness_test ( self , distribution , <nl> self . assertEqual ( outs [ 2 ] , 0 . ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_with_eager_and_graph_modes ( ) ) <nl> - def test_identity_model_metric_eval_correctness ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> - self . run_eval_metrics_correctness_test ( distribution , <nl> - experimental_run_tf_function ) <nl> + def test_identity_model_metric_eval_correctness ( self , distribution ) : <nl> + self . run_eval_metrics_correctness_test ( distribution ) <nl> <nl> <nl> class SubclassedModel ( keras . Model ) : <nl> class TestDistributionStrategyDnnCorrectnessWithSubclassedModel ( <nl> TestDistributionStrategyDnnCorrectness ) : <nl> <nl> def get_model ( self , <nl> - experimental_run_tf_function , <nl> initial_weights = None , <nl> distribution = None , <nl> input_shapes = None ) : <nl> def get_model ( self , <nl> model . compile ( <nl> loss = keras . losses . mean_squared_error , <nl> optimizer = gradient_descent_keras . SGD ( 0 . 05 ) , <nl> - metrics = [ ' mse ' ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' mse ' ] ) <nl> return model <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . all_strategy_and_input_config_combinations ( ) ) <nl> - def test_dnn_correctness ( self , distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) : <nl> + def test_dnn_correctness ( self , distribution , use_numpy , use_validation_data ) : <nl> if ( context . executing_eagerly ( ) ) or is_default_strategy ( distribution ) : <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> elif K . is_tpu_strategy ( distribution ) and not context . executing_eagerly ( ) : <nl> with self . assertRaisesRegexp ( <nl> ValueError , <nl> ' Expected ` model ` argument to be a functional ` Model ` instance , ' <nl> ' but got a subclass model instead . ' ) : <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> else : <nl> with self . assertRaisesRegexp ( <nl> ValueError , <nl> ' We currently do not support distribution strategy with a ' <nl> ' ` Sequential ` model that is created without ` input_shape ` / ' <nl> ' ` input_dim ` set in its first layer or a subclassed model . ' ) : <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> <nl> @ combinations . generate ( all_strategy_combinations_with_graph_mode ( ) ) <nl> - def test_dnn_with_dynamic_learning_rate ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> - if ( ( not experimental_run_tf_function and context . executing_eagerly ( ) and <nl> - not K . is_tpu_strategy ( distribution ) ) or <nl> + def test_dnn_with_dynamic_learning_rate ( self , distribution ) : <nl> + if ( ( context . executing_eagerly ( ) and not K . is_tpu_strategy ( distribution ) ) or <nl> is_default_strategy ( distribution ) ) : <nl> - self . run_dynamic_lr_test ( distribution , experimental_run_tf_function ) <nl> + self . run_dynamic_lr_test ( distribution ) <nl> elif K . is_tpu_strategy ( distribution ) : <nl> with self . assertRaisesRegexp ( <nl> ValueError , <nl> ' Expected ` model ` argument to be a functional ` Model ` instance , ' <nl> ' but got a subclass model instead . ' ) : <nl> - self . run_dynamic_lr_test ( distribution , experimental_run_tf_function ) <nl> + self . run_dynamic_lr_test ( distribution ) <nl> else : <nl> with self . assertRaisesRegexp ( <nl> ValueError , <nl> ' We currently do not support distribution strategy with a ' <nl> ' ` Sequential ` model that is created without ` input_shape ` / ' <nl> ' ` input_dim ` set in its first layer or a subclassed model . ' ) : <nl> - self . run_dynamic_lr_test ( distribution , experimental_run_tf_function ) <nl> + self . run_dynamic_lr_test ( distribution ) <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . test_combinations_with_tpu_strategies ( ) ) <nl> mmm a / tensorflow / python / keras / distribute / keras_embedding_model_correctness_test . py <nl> ppp b / tensorflow / python / keras / distribute / keras_embedding_model_correctness_test . py <nl> def get_model ( self , <nl> max_words = 10 , <nl> initial_weights = None , <nl> distribution = None , <nl> - experimental_run_tf_function = None , <nl> input_shapes = None ) : <nl> del input_shapes <nl> with keras_correctness_test_base . MaybeDistributionScope ( distribution ) : <nl> def get_model ( self , <nl> model . compile ( <nl> optimizer = gradient_descent_keras . SGD ( learning_rate = 0 . 1 ) , <nl> loss = ' sparse_categorical_crossentropy ' , <nl> - metrics = [ ' sparse_categorical_accuracy ' ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' sparse_categorical_accuracy ' ] ) <nl> return model <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . test_combinations_for_embedding_model ( ) ) <nl> def test_embedding_model_correctness ( self , distribution , use_numpy , <nl> - use_validation_data , <nl> - experimental_run_tf_function ) : <nl> + use_validation_data ) : <nl> <nl> self . use_distributed_dense = False <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . test_combinations_for_embedding_model ( ) ) <nl> def test_embedding_time_distributed_model_correctness ( <nl> - self , distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) : <nl> + self , distribution , use_numpy , use_validation_data ) : <nl> self . use_distributed_dense = True <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> <nl> <nl> class DistributionStrategySiameseEmbeddingModelCorrectnessTest ( <nl> def get_model ( self , <nl> max_words = 10 , <nl> initial_weights = None , <nl> distribution = None , <nl> - experimental_run_tf_function = None , <nl> input_shapes = None ) : <nl> del input_shapes <nl> with keras_correctness_test_base . MaybeDistributionScope ( distribution ) : <nl> def submodel ( embedding , word_ids ) : <nl> model . compile ( <nl> optimizer = gradient_descent_keras . SGD ( learning_rate = 0 . 1 ) , <nl> loss = ' mse ' , <nl> - experimental_run_tf_function = experimental_run_tf_function , <nl> metrics = [ ' mse ' ] ) <nl> return model <nl> <nl> def get_data ( self , <nl> @ combinations . generate ( <nl> keras_correctness_test_base . test_combinations_for_embedding_model ( ) ) <nl> def test_siamese_embedding_model_correctness ( self , distribution , use_numpy , <nl> - use_validation_data , <nl> - experimental_run_tf_function ) : <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + use_validation_data ) : <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> <nl> <nl> if __name__ = = ' __main__ ' : <nl> mmm a / tensorflow / python / keras / distribute / keras_image_model_correctness_test . py <nl> ppp b / tensorflow / python / keras / distribute / keras_image_model_correctness_test . py <nl> class DistributionStrategyCnnCorrectnessTest ( <nl> def get_model ( self , <nl> initial_weights = None , <nl> distribution = None , <nl> - experimental_run_tf_function = None , <nl> input_shapes = None ) : <nl> del input_shapes <nl> with keras_correctness_test_base . MaybeDistributionScope ( distribution ) : <nl> def get_model ( self , <nl> model . compile ( <nl> optimizer = gradient_descent . SGD ( learning_rate = 0 . 1 ) , <nl> loss = ' sparse_categorical_crossentropy ' , <nl> - metrics = [ ' sparse_categorical_accuracy ' ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' sparse_categorical_accuracy ' ] ) <nl> <nl> return model <nl> <nl> def get_data_with_partial_last_batch_eval ( self ) : <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . all_strategy_and_input_config_combinations ( ) ) <nl> - def test_cnn_correctness ( self , distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) : <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + def test_cnn_correctness ( self , distribution , use_numpy , use_validation_data ) : <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . all_strategy_and_input_config_combinations ( ) ) <nl> def test_cnn_with_batch_norm_correctness ( self , distribution , use_numpy , <nl> - use_validation_data , <nl> - experimental_run_tf_function ) : <nl> + use_validation_data ) : <nl> self . skipTest ( ' Flakily times out , b / 134670856 ' ) <nl> self . run_correctness_test ( <nl> distribution , <nl> use_numpy , <nl> use_validation_data , <nl> - with_batch_norm = ' regular ' , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + with_batch_norm = ' regular ' ) <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . all_strategy_and_input_config_combinations ( ) ) <nl> def test_cnn_with_sync_batch_norm_correctness ( self , distribution , use_numpy , <nl> - use_validation_data , <nl> - experimental_run_tf_function ) : <nl> - if not context . executing_eagerly ( ) or not experimental_run_tf_function : <nl> + use_validation_data ) : <nl> + if not context . executing_eagerly ( ) : <nl> self . skipTest ( ' SyncBatchNorm is not enabled in graph mode . ' ) <nl> <nl> self . run_correctness_test ( <nl> distribution , <nl> use_numpy , <nl> use_validation_data , <nl> - with_batch_norm = ' sync ' , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + with_batch_norm = ' sync ' ) <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . test_combinations_with_tpu_strategies ( ) + <nl> mmm a / tensorflow / python / keras / distribute / keras_optimizer_v2_test . py <nl> ppp b / tensorflow / python / keras / distribute / keras_optimizer_v2_test . py <nl> def train_fn ( ) : <nl> distribution = [ <nl> strategy_combinations . central_storage_strategy_with_two_gpus , <nl> ] , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> - def testOptimizerWithKerasModelAndNumpyArrays ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> + def testOptimizerWithKerasModelAndNumpyArrays ( self , distribution ) : <nl> self . skipTest ( ' b / 130309197 ' ) <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> def testOptimizerWithKerasModelAndNumpyArrays ( self , distribution , <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> inputs = np . zeros ( ( 64 , 3 ) , dtype = np . float32 ) <nl> targets = np . zeros ( ( 64 , 4 ) , dtype = np . float32 ) <nl> mmm a / tensorflow / python / keras / distribute / keras_premade_models_test . py <nl> ppp b / tensorflow / python / keras / distribute / keras_premade_models_test . py <nl> def test_linear_model ( self , distribution , data_fn ) : <nl> with distribution . scope ( ) : <nl> model = linear . LinearModel ( ) <nl> opt = gradient_descent . SGD ( learning_rate = 0 . 1 ) <nl> - model . compile ( opt , ' mse ' , experimental_run_tf_function = True ) <nl> + model . compile ( opt , ' mse ' ) <nl> if data_fn = = get_numpy : <nl> inputs , output = get_numpy ( ) <nl> hist = model . fit ( inputs , output , epochs = 5 ) <nl> def test_wide_deep_model ( self , distribution , data_fn ) : <nl> dnn_opt = adagrad . Adagrad ( learning_rate = 0 . 1 ) <nl> wide_deep_model . compile ( <nl> optimizer = [ linear_opt , dnn_opt ] , <nl> - loss = ' mse ' , <nl> - experimental_run_tf_function = True ) <nl> + loss = ' mse ' ) <nl> if data_fn = = get_numpy : <nl> inputs , output = get_numpy ( ) <nl> hist = wide_deep_model . fit ( inputs , output , epochs = 5 ) <nl> mmm a / tensorflow / python / keras / distribute / keras_rnn_model_correctness_test . py <nl> ppp b / tensorflow / python / keras / distribute / keras_rnn_model_correctness_test . py <nl> def get_model ( self , <nl> max_words = 10 , <nl> initial_weights = None , <nl> distribution = None , <nl> - experimental_run_tf_function = None , <nl> input_shapes = None ) : <nl> del input_shapes <nl> rnn_cls = self . _get_layer_class ( ) <nl> def get_model ( self , <nl> model . compile ( <nl> optimizer = optimizer_fn ( learning_rate = 0 . 1 ) , <nl> loss = ' sparse_categorical_crossentropy ' , <nl> - metrics = [ ' sparse_categorical_accuracy ' ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' sparse_categorical_accuracy ' ] ) <nl> return model <nl> <nl> <nl> def _get_layer_class ( self ) : <nl> @ combinations . generate ( <nl> keras_correctness_test_base . test_combinations_for_embedding_model ( ) ) <nl> def test_gru_model_correctness ( self , distribution , use_numpy , <nl> - use_validation_data , <nl> - experimental_run_tf_function ) : <nl> + use_validation_data ) : <nl> self . skipTest ( ' Test is sensitive to TF random seed , b / TBD ' ) <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> <nl> <nl> class DistributionStrategyLstmModelCorrectnessTest ( <nl> def _get_layer_class ( self ) : <nl> @ combinations . generate ( <nl> keras_correctness_test_base . test_combinations_for_embedding_model ( ) ) <nl> def test_lstm_model_correctness ( self , distribution , use_numpy , <nl> - use_validation_data , <nl> - experimental_run_tf_function ) : <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + use_validation_data ) : <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> <nl> @ combinations . generate ( <nl> keras_correctness_test_base . test_combinations_for_embedding_model ( ) ) <nl> @ testing_utils . enable_v2_dtype_behavior <nl> def test_lstm_model_correctness_mixed_precision ( self , distribution , use_numpy , <nl> - use_validation_data , <nl> - experimental_run_tf_function ) : <nl> + use_validation_data ) : <nl> if isinstance ( distribution , <nl> ( tpu_strategy . TPUStrategy , tpu_strategy . TPUStrategyV1 ) ) : <nl> policy_name = ' mixed_bfloat16 ' <nl> def test_lstm_model_correctness_mixed_precision ( self , distribution , use_numpy , <nl> policy_name = ' mixed_float16 ' <nl> <nl> with policy . policy_scope ( policy_name ) : <nl> - self . run_correctness_test ( distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) <nl> + self . run_correctness_test ( distribution , use_numpy , use_validation_data ) <nl> <nl> <nl> if __name__ = = ' __main__ ' : <nl> mmm a / tensorflow / python / keras / distribute / keras_stateful_lstm_model_correctness_test . py <nl> ppp b / tensorflow / python / keras / distribute / keras_stateful_lstm_model_correctness_test . py <nl> def test_combinations_for_stateful_embedding_model ( ) : <nl> distribution = strategies_for_stateful_embedding_model ( ) , <nl> mode = ' graph ' , <nl> use_numpy = False , <nl> - use_validation_data = False , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> + use_validation_data = False ) ) <nl> <nl> <nl> class DistributionStrategyStatefulLstmModelCorrectnessTest ( <nl> def get_model ( self , <nl> max_words = 10 , <nl> initial_weights = None , <nl> distribution = None , <nl> - experimental_run_tf_function = None , <nl> input_shapes = None ) : <nl> del input_shapes <nl> batch_size = keras_correctness_test_base . _GLOBAL_BATCH_SIZE <nl> def get_model ( self , <nl> # doesn ' t work and enable for DistributionStrategy more generally . <nl> @ combinations . generate ( test_combinations_for_stateful_embedding_model ( ) ) <nl> def disabled_test_stateful_lstm_model_correctness ( <nl> - self , distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) : <nl> + self , distribution , use_numpy , use_validation_data ) : <nl> self . run_correctness_test ( <nl> distribution , <nl> use_numpy , <nl> use_validation_data , <nl> - is_stateful_model = True , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + is_stateful_model = True ) <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - keras_correctness_test_base . test_combinations_with_tpu_strategies ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> + keras_correctness_test_base . test_combinations_with_tpu_strategies ( ) ) ) <nl> def test_incorrectly_use_multiple_cores_for_stateful_lstm_model ( <nl> - self , distribution , use_numpy , use_validation_data , <nl> - experimental_run_tf_function ) : <nl> + self , distribution , use_numpy , use_validation_data ) : <nl> with self . assertRaisesRegexp ( <nl> ValueError , <nl> ' RNNs with stateful = True not yet supported with ' <nl> def test_incorrectly_use_multiple_cores_for_stateful_lstm_model ( <nl> distribution , <nl> use_numpy , <nl> use_validation_data , <nl> - is_stateful_model = True , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + is_stateful_model = True ) <nl> <nl> <nl> if __name__ = = ' __main__ ' : <nl> mmm a / tensorflow / python / keras / distribute / keras_utils_test . py <nl> ppp b / tensorflow / python / keras / distribute / keras_utils_test . py <nl> class TestDistributionStrategyWithCallbacks ( test . TestCase , <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - keras_test_lib . all_strategy_combinations ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> - def test_callbacks_in_fit ( self , distribution , experimental_run_tf_function ) : <nl> + keras_test_lib . all_strategy_combinations ( ) ) ) <nl> + def test_callbacks_in_fit ( self , distribution ) : <nl> with distribution . scope ( ) : <nl> model = keras_test_lib . get_model ( ) <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> - metrics = [ ' mae ' ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' mae ' ] ) <nl> <nl> dataset = keras_test_lib . get_dataset ( distribution ) <nl> counter = Counter ( ) <nl> def test_callbacks_in_fit ( self , distribution , experimental_run_tf_function ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - keras_test_lib . all_strategy_combinations ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> - def test_callbacks_in_eval ( self , distribution , experimental_run_tf_function ) : <nl> + keras_test_lib . all_strategy_combinations ( ) ) ) <nl> + def test_callbacks_in_eval ( self , distribution ) : <nl> with distribution . scope ( ) : <nl> model = keras_test_lib . get_model ( ) <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> - metrics = [ ' mae ' ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' mae ' ] ) <nl> <nl> dataset = keras_test_lib . get_dataset ( distribution ) <nl> counter = Counter ( ) <nl> def test_callbacks_in_eval ( self , distribution , experimental_run_tf_function ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - keras_test_lib . all_strategy_combinations ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> - def test_callbacks_in_predict ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + keras_test_lib . all_strategy_combinations ( ) ) ) <nl> + def test_callbacks_in_predict ( self , distribution ) : <nl> with distribution . scope ( ) : <nl> model = keras_test_lib . get_model ( ) <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> - metrics = [ ' mae ' ] , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = [ ' mae ' ] ) <nl> <nl> dataset = keras_test_lib . get_dataset ( distribution ) <nl> counter = Counter ( ) <nl> def test_validating_dataset_input_tensors_with_dtype_mismatch ( <nl> distribution = [ <nl> strategy_combinations . mirrored_strategy_with_gpu_and_cpu , <nl> ] , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> - def test_unsupported_features ( self , distribution , <nl> - experimental_run_tf_function , mode ) : <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> + def test_unsupported_features ( self , distribution , mode ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> model = keras_test_lib . get_model ( ) <nl> def test_unsupported_features ( self , distribution , <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> dataset = keras_test_lib . get_dataset ( distribution ) <nl> # Test with validation split <nl> def test_unsupported_features ( self , distribution , <nl> strategy_combinations . mirrored_strategy_with_gpu_and_cpu , <nl> strategy_combinations . one_device_strategy , <nl> ] , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> def test_distribution_strategy_on_subclassed_model ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with distribution . scope ( ) : <nl> <nl> class _SimpleMLP ( keras . Model ) : <nl> def call ( self , inputs ) : <nl> ' ` Sequential ` model that is created without ` input_shape ` / ' <nl> ' ` input_dim ` set in its first layer or a subclassed model . ' ) : <nl> model . compile ( <nl> - ' sgd ' , experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' sgd ' ) <nl> else : <nl> model . compile ( <nl> - ' sgd ' , experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' sgd ' ) <nl> <nl> @ combinations . generate ( <nl> combinations . combine ( <nl> def call ( self , inputs ) : <nl> strategy_combinations . mirrored_strategy_with_gpu_and_cpu , <nl> strategy_combinations . one_device_strategy , <nl> ] , <nl> - mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] ) ) <nl> + mode = [ ' graph ' , ' eager ' ] ) ) <nl> def test_distribution_strategy_on_deferred_sequential_model ( <nl> - self , distribution , experimental_run_tf_function ) : <nl> + self , distribution ) : <nl> with distribution . scope ( ) : <nl> model = keras . models . Sequential ( ) <nl> model . add ( keras . layers . Dense ( 16 , activation = ' relu ' ) ) <nl> def test_distribution_strategy_on_deferred_sequential_model ( <nl> <nl> if context . executing_eagerly ( ) : <nl> model . compile ( <nl> - ' sgd ' , experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' sgd ' ) <nl> else : <nl> with self . assertRaisesRegexp ( <nl> ValueError , <nl> def test_distribution_strategy_on_deferred_sequential_model ( <nl> ' ` input_shape ` / ` input_dim ` set in its first layer or ' <nl> ' a subclassed model . ' ) : <nl> model . compile ( <nl> - ' sgd ' , experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' sgd ' ) <nl> <nl> @ combinations . generate ( <nl> keras_test_lib . all_strategy_combinations_minus_default ( ) ) <nl> class TestDistributionStrategyWithLossMasking ( test . TestCase , <nl> strategy_combinations . mirrored_strategy_with_gpu_and_cpu , <nl> ] , <nl> mode = [ ' graph ' , ' eager ' ] , <nl> - experimental_run_tf_function = [ True , False ] , <nl> optimizer = strategy_combinations . gradient_descent_optimizer_keras_v2_fn <nl> ) ) <nl> - def test_masking ( self , distribution , experimental_run_tf_function , optimizer ) : <nl> + def test_masking ( self , distribution , optimizer ) : <nl> with self . cached_session ( ) : <nl> np . random . seed ( 1337 ) <nl> x = np . array ( [ [ [ 1 ] , [ 1 ] ] , [ [ 0 ] , [ 0 ] ] ] ) <nl> def test_masking ( self , distribution , experimental_run_tf_function , optimizer ) : <nl> keras . layers . Dense ( 1 , kernel_initializer = ' one ' ) ) ) <nl> model . compile ( <nl> loss = ' mse ' , <nl> - optimizer = optimizer ( ) , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + optimizer = optimizer ( ) ) <nl> y = np . array ( [ [ [ 1 ] , [ 1 ] ] , [ [ 1 ] , [ 1 ] ] ] ) <nl> dataset = dataset_ops . Dataset . from_tensor_slices ( ( x , y ) ) <nl> dataset = dataset . repeat ( 100 ) <nl> class TestDistributionStrategyWithNormalizationLayer ( test . TestCase , <nl> keras_test_lib . all_strategy_combinations ( ) , <nl> combinations . combine ( <nl> fused = [ True , False ] , <nl> - experimental_run_tf_function = [ True , False ] , <nl> optimizer = strategy_combinations <nl> . gradient_descent_optimizer_keras_v2_fn ) ) ) <nl> - def test_batchnorm_correctness ( self , distribution , fused , optimizer , <nl> - experimental_run_tf_function ) : <nl> + def test_batchnorm_correctness ( self , distribution , fused , optimizer ) : <nl> with self . cached_session ( ) : <nl> with distribution . scope ( ) : <nl> model = keras . models . Sequential ( ) <nl> def test_batchnorm_correctness ( self , distribution , fused , optimizer , <nl> model . add ( norm ) <nl> model . compile ( <nl> loss = ' mse ' , <nl> - optimizer = optimizer ( ) , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + optimizer = optimizer ( ) ) <nl> <nl> # centered on 5 . 0 , variance 10 . 0 <nl> x = np . random . normal ( loc = 5 . 0 , scale = 10 . 0 , size = ( 1000 , 10 , 20 , 30 ) ) <nl> class TestDistributionStrategySaveLoadWeights ( test . TestCase , <nl> combinations . times ( <nl> keras_test_lib . all_strategy_combinations_minus_default ( ) , <nl> combinations . combine ( <nl> - experimental_run_tf_function = [ True , False ] , <nl> optimizer = strategy_combinations . rmsprop_optimizer_keras_v2_fn ) ) ) <nl> - def test_save_load_h5 ( self , distribution , optimizer , <nl> - experimental_run_tf_function ) : <nl> + def test_save_load_h5 ( self , distribution , optimizer ) : <nl> with self . cached_session ( ) : <nl> dataset = keras_test_lib . get_dataset ( distribution ) <nl> with distribution . scope ( ) : <nl> model = keras_test_lib . get_model ( ) <nl> model . compile ( <nl> optimizer ( ) , <nl> - ' mse ' , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' mse ' ) <nl> model . fit ( dataset , epochs = 1 , steps_per_epoch = 1 ) <nl> <nl> weights_file = tempfile . mktemp ( ' . h5 ' ) <nl> def test_save_load_h5 ( self , distribution , optimizer , <nl> model_2 = keras_test_lib . get_model ( ) <nl> model_2 . compile ( <nl> optimizer ( ) , <nl> - ' mse ' , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' mse ' ) <nl> model_2 . load_weights ( weights_file ) <nl> model_2 . predict ( <nl> keras_test_lib . get_predict_dataset ( distribution ) , steps = 2 ) <nl> def test_save_load_h5 ( self , distribution , optimizer , <nl> combinations . times ( <nl> keras_test_lib . all_strategy_combinations_minus_default ( ) , <nl> combinations . combine ( <nl> - experimental_run_tf_function = [ True , False ] , <nl> optimizer = strategy_combinations . rmsprop_optimizer_keras_v2_fn ) ) ) <nl> - def test_save_load_trackable ( self , distribution , optimizer , <nl> - experimental_run_tf_function ) : <nl> + def test_save_load_trackable ( self , distribution , optimizer ) : <nl> # TODO ( b / 123533246 ) : Enable the test for TPU once bug is fixed <nl> if ( isinstance ( distribution , <nl> ( tpu_strategy . TPUStrategy , tpu_strategy . TPUStrategyV1 ) ) and <nl> def test_save_load_trackable ( self , distribution , optimizer , <nl> model = keras_test_lib . get_model ( ) <nl> model . compile ( <nl> optimizer ( ) , <nl> - ' mse ' , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' mse ' ) <nl> model . fit ( dataset , epochs = 1 , steps_per_epoch = 1 ) <nl> <nl> weights_file = tempfile . mktemp ( ) <nl> def test_save_load_trackable ( self , distribution , optimizer , <nl> model_2 = keras_test_lib . get_model ( ) <nl> model_2 . compile ( <nl> optimizer ( ) , <nl> - ' mse ' , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + ' mse ' ) <nl> model_2 . load_weights ( weights_file ) <nl> model_2 . predict ( <nl> keras_test_lib . get_predict_dataset ( distribution ) , steps = 2 ) <nl> class TestDistributionStrategyValidation ( test . TestCase , parameterized . TestCase ) : <nl> <nl> @ combinations . generate ( <nl> combinations . times ( <nl> - keras_test_lib . all_strategy_combinations_minus_default ( ) , <nl> - combinations . combine ( experimental_run_tf_function = [ True , False ] ) ) ) <nl> - def test_layer_outside_scope ( self , distribution , <nl> - experimental_run_tf_function ) : <nl> + keras_test_lib . all_strategy_combinations_minus_default ( ) ) ) <nl> + def test_layer_outside_scope ( self , distribution ) : <nl> with self . cached_session ( ) : <nl> with self . assertRaisesRegexp ( <nl> ValueError , ' was not created in the distribution strategy ' ) : <nl> def test_layer_outside_scope ( self , distribution , <nl> model . compile ( <nl> optimizer , <nl> loss , <nl> - metrics = metrics , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + metrics = metrics ) <nl> <nl> @ combinations . generate ( <nl> keras_test_lib . all_strategy_combinations_minus_default ( ) ) <nl> mmm a / tensorflow / python / keras / engine / base_layer_test . py <nl> ppp b / tensorflow / python / keras / engine / base_layer_test . py <nl> def call ( self , inputs ) : <nl> def get_learning_phase_value ( ) : <nl> model = keras . models . Sequential ( [ LearningPhaseLayer ( input_shape = ( 1 , ) ) ] ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = ( <nl> - testing_utils . should_run_tf_function ( ) ) <nl> return np . sum ( model ( np . ones ( ( 1 , 1 ) ) ) ) <nl> <nl> self . assertEqual ( get_learning_phase_value ( ) , 0 ) <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x , y = np . ones ( ( 10 , 10 ) ) , np . ones ( ( 10 , 10 ) ) <nl> # Checks that variables get initialized . <nl> model . fit ( x , y , batch_size = 2 , epochs = 2 ) <nl> def test_passing_initial_weights_values ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> inputs = np . random . random ( ( 3 , 10 ) ) <nl> out = model . predict ( inputs ) <nl> self . assertAllClose ( model . layers [ - 1 ] . get_weights ( ) [ 0 ] , kernel_value ) <nl> def call ( self , inputs , training = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> train_loss = model . train_on_batch ( np . ones ( ( 2 , 3 ) ) , np . ones ( ( 2 , 3 ) ) ) <nl> self . assertEqual ( train_loss , 0 . ) <nl> test_loss = model . test_on_batch ( np . ones ( ( 2 , 3 ) ) , np . ones ( ( 2 , 3 ) ) ) <nl> def call ( self , inputs , training = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> train_loss = model . train_on_batch ( np . ones ( ( 2 , 3 ) ) , np . ones ( ( 2 , 3 ) ) ) <nl> self . assertEqual ( train_loss , 2 * 3 ) <nl> test_loss = model . test_on_batch ( np . ones ( ( 2 , 3 ) ) , np . ones ( ( 2 , 3 ) ) ) <nl> def call ( self , inputs , training = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> for _ in range ( 3 ) : <nl> _ , train_metric = model . train_on_batch ( np . ones ( ( 2 , 3 ) ) , <nl> np . ones ( ( 2 , 3 ) ) ) <nl> def call ( self , inputs , training = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . ones ( ( 2 , 3 ) ) , np . ones ( ( 2 , 3 ) ) ) <nl> self . assertEqual ( keras . backend . get_value ( layer . counter ) , 1 . ) <nl> <nl> def compute_output_shape ( self , input_shape ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . ones ( ( 2 , 3 ) ) , np . ones ( ( 2 , 3 ) ) ) <nl> self . assertEqual ( keras . backend . get_value ( layer . counter ) , 6 . ) <nl> else : <nl> def compute_output_shape ( self , input_shape ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> loss = model . train_on_batch ( np . ones ( ( 2 , 3 ) ) , np . ones ( ( 2 , 3 ) ) ) <nl> self . assertEqual ( loss , 2 * 3 ) <nl> else : <nl> def test_conditional_callable_losses ( self ) : <nl> 1 , kernel_regularizer = keras . regularizers . l2 ( 1e - 4 ) , input_shape = ( 1 , ) ) <nl> ] ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> def assert_graph ( t ) : <nl> if not context . executing_eagerly ( ) : <nl> def compute_output_shape ( self , input_shape ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( np . ones ( ( 2 , 3 ) ) , np . ones ( ( 2 , 3 ) ) ) <nl> self . assertEqual ( history . history [ ' sum ' ] [ - 1 ] , 2 * 3 ) <nl> else : <nl> def call ( self , x , training = None ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( shape = ( 10 , 1 ) ) <nl> y = np . ones ( shape = ( 10 , 2 ) ) <nl> def call ( self , x , training = None ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( shape = ( 10 , 3 , 4 ) ) <nl> y = np . ones ( shape = ( 10 , 3 , 2 ) ) <nl> mmm a / tensorflow / python / keras / engine / base_preprocessing_layer_test . py <nl> ppp b / tensorflow / python / keras / engine / base_preprocessing_layer_test . py <nl> def test_setter_update ( self ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> layer . set_total ( 15 ) <nl> <nl> def test_pre_build_adapt_update_numpy ( self ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> self . assertAllEqual ( [ [ 16 ] , [ 17 ] , [ 18 ] ] , model . predict ( [ 1 . , 2 . , 3 . ] ) ) <nl> <nl> def test_post_build_adapt_update_numpy ( self ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> layer . adapt ( input_dataset ) <nl> <nl> def test_pre_build_injected_update ( self ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> self . assertAllEqual ( [ [ 16 ] , [ 17 ] , [ 18 ] ] , model . predict ( [ 1 . , 2 . , 3 . ] ) ) <nl> <nl> def test_post_build_injected_update ( self ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> combiner = layer . _combiner <nl> updates = combiner . extract ( combiner . compute ( input_dataset ) ) <nl> def test_pre_build_adapt_update_dataset ( self ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> self . assertAllEqual ( [ [ 16 ] , [ 17 ] , [ 18 ] ] , model . predict ( [ 1 . , 2 . , 3 . ] ) ) <nl> <nl> def test_post_build_adapt_update_dataset ( self ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> layer . adapt ( input_dataset ) <nl> <nl> def test_further_tuning ( self ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> self . assertAllEqual ( [ [ 16 ] , [ 17 ] , [ 18 ] ] , model . predict ( [ 1 . , 2 . , 3 . ] ) ) <nl> <nl> def test_further_tuning_post_injection ( self ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> combiner = layer . _combiner <nl> updates = combiner . extract ( combiner . compute ( input_dataset ) ) <nl> def get_model ( ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = ( <nl> - testing_utils . should_run_tf_function ( ) ) <nl> return ( model , layer ) <nl> <nl> input_dataset = np . array ( [ 1 , 2 , 3 , 4 , 5 ] ) <nl> def get_model ( ) : <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = ( <nl> - testing_utils . should_run_tf_function ( ) ) <nl> return ( model , layer ) <nl> <nl> input_dataset = np . array ( [ 1 , 2 , 3 , 4 , 5 ] ) <nl> mmm a / tensorflow / python / keras / engine / correctness_test . py <nl> ppp b / tensorflow / python / keras / engine / correctness_test . py <nl> def _get_simple_bias_model ( self ) : <nl> model . compile ( <nl> keras . optimizer_v2 . gradient_descent . SGD ( 0 . 1 ) , <nl> ' mae ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> def test_simple_bias_fit ( self ) : <nl> def _get_multiple_input_model ( self , subclassed = True ) : <nl> model . compile ( <nl> keras . optimizer_v2 . gradient_descent . SGD ( 0 . 1 ) , <nl> ' mae ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> @ parameterized . named_parameters ( ( ' subclassed ' , True ) , ( ' functional ' , False ) ) <nl> mmm a / tensorflow / python / keras / engine / feature_columns_integration_test . py <nl> ppp b / tensorflow / python / keras / engine / feature_columns_integration_test . py <nl> def test_sequential_model ( self ) : <nl> optimizer = ' rmsprop ' , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ' accuracy ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = { ' a ' : np . random . random ( ( 10 , 1 ) ) } <nl> y = np . random . randint ( 20 , size = ( 10 , 1 ) ) <nl> def test_sequential_model_with_ds_input ( self ) : <nl> optimizer = ' rmsprop ' , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ' accuracy ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> y = np . random . randint ( 20 , size = ( 100 , 1 ) ) <nl> y = np_utils . to_categorical ( y , num_classes = 20 ) <nl> def test_subclassed_model_with_feature_columns ( self ) : <nl> optimizer = ' rmsprop ' , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ' accuracy ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = { ' a ' : np . random . random ( ( 10 , 1 ) ) , ' b ' : np . random . random ( ( 10 , 1 ) ) } <nl> y = np . random . randint ( 20 , size = ( 10 , 1 ) ) <nl> def test_subclassed_model_with_feature_columns_with_ds_input ( self ) : <nl> optimizer = ' rmsprop ' , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ' accuracy ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> y = np . random . randint ( 20 , size = ( 100 , 1 ) ) <nl> y = np_utils . to_categorical ( y , num_classes = 20 ) <nl> mmm a / tensorflow / python / keras / engine / network_test . py <nl> ppp b / tensorflow / python / keras / engine / network_test . py <nl> def test_layer_sharing_at_heterogenous_depth ( self ) : <nl> output = a ( b ( a ( b ( x ) ) ) ) <nl> m = keras . models . Model ( x , output ) <nl> m . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - m . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> output_val = m . predict ( x_val ) <nl> <nl> def test_layer_sharing_at_heterogenous_depth_with_concat ( self ) : <nl> <nl> m = keras . models . Model ( inputs = input_layer , outputs = output ) <nl> m . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - m . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> x_val = np . random . random ( ( 10 , 16 , 9 , 3 ) ) <nl> output_val = m . predict ( x_val ) <nl> def test_explicit_training_argument ( self ) : <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> loss = model . train_on_batch ( x , y ) <nl> self . assertEqual ( loss , 0 ) # In inference mode , output is equal to input . <nl> <nl> def test_mask_derived_from_keras_layer ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( <nl> x = [ np . ones ( ( 10 , 5 , 10 ) ) , np . zeros ( ( 10 , 5 ) ) ] , <nl> y = np . zeros ( ( 10 , 100 ) ) , <nl> def test_mask_derived_from_keras_layer ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( <nl> x = [ np . ones ( ( 10 , 5 , 10 ) ) , np . zeros ( ( 10 , 5 ) ) ] , <nl> y = np . zeros ( ( 10 , 100 ) ) , <nl> def call ( self , x1 , x2 ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( <nl> x = [ 3 * np . ones ( ( 10 , 10 ) ) , 7 * np . ones ( ( 10 , 10 ) ) ] , <nl> y = 10 * np . ones ( ( 10 , 10 ) ) , <nl> def call ( self , x1 , x2 ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( <nl> x = [ 3 * np . ones ( ( 10 , 10 ) ) , 7 * np . ones ( ( 10 , 10 ) ) ] , <nl> y = 10 * np . ones ( ( 10 , 10 ) ) , <nl> def call ( self , x1 , x2 = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( <nl> x = [ 3 * np . ones ( ( 10 , 10 ) ) , 7 * np . ones ( ( 10 , 10 ) ) ] , <nl> y = 10 * np . ones ( ( 10 , 10 ) ) , <nl> def call ( self , x1 , x2 = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( <nl> x = [ 3 * np . ones ( ( 10 , 10 ) ) , 7 * np . ones ( ( 10 , 10 ) ) ] , <nl> y = 10 * np . ones ( ( 10 , 10 ) ) , <nl> def call ( self , x1 , x2 = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> input_data = [ <nl> ragged_factory_ops . constant ( [ [ 3 . 0 , 3 . 0 ] , [ 3 . 0 , 3 . 0 ] , [ 3 . 0 ] ] ) , <nl> ragged_factory_ops . constant ( [ [ 7 . 0 , 7 . 0 ] , [ 7 . 0 , 7 . 0 ] , [ 7 . 0 ] ] ) <nl> def call ( self , x1 , x2 = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( x = input_data , y = expected_data ) <nl> # Check that second input was correctly added to first . <nl> self . assertEqual ( history . history [ ' loss ' ] [ 0 ] , 0 . 0 ) <nl> def call ( self , x1 , x2 , x3 = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( <nl> x = [ np . ones ( ( 10 , 10 ) ) , 2 * np . ones ( ( 10 , 10 ) ) , 3 * np . ones ( ( 10 , 10 ) ) ] , <nl> y = 15 * np . ones ( ( 10 , 10 ) ) , <nl> def call ( self , x1 , x2 , x3 = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( <nl> x = [ np . ones ( ( 10 , 10 ) ) , 2 * np . ones ( ( 10 , 10 ) ) , 3 * np . ones ( ( 10 , 10 ) ) ] , <nl> y = 15 * np . ones ( ( 10 , 10 ) ) , <nl> def output_shape ( input_shape ) : <nl> o = keras . layers . add ( o ) <nl> model = keras . Model ( i , o ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> i2 = keras . layers . Input ( shape = ( 3 , 2 , 1 ) ) <nl> o2 = model ( i2 ) <nl> model2 = keras . Model ( i2 , o2 ) <nl> model2 . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model2 . _experimental_run_tf_function = testing_utils . should_run_tf_function ( <nl> - ) <nl> <nl> x = np . random . random ( ( 4 , 3 , 2 , 1 ) ) <nl> out = model2 . predict ( x ) <nl> def test_constant_initializer_with_numpy ( self ) : <nl> loss = ' mse ' , <nl> optimizer = ' sgd ' , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> json_str = model . to_json ( ) <nl> keras . models . model_from_json ( json_str ) <nl> def test_sequential_as_downstream_of_masking_layer ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model_input = np . random . randint ( <nl> low = 1 , high = 5 , size = ( 10 , 3 , 4 ) ) . astype ( ' float32 ' ) <nl> def test_add_loss_outside_call_only_loss ( self ) : <nl> x = np . ones ( ( 10 , 10 ) ) <nl> model . compile ( <nl> ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , batch_size = 2 , epochs = 1 ) <nl> <nl> model2 = model . from_config ( model . get_config ( ) ) <nl> model2 . compile ( <nl> ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model2 . set_weights ( initial_weights ) <nl> model2 . fit ( x , batch_size = 2 , epochs = 1 ) <nl> <nl> def test_add_loss_outside_call_multiple_losses ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , batch_size = 2 , epochs = 1 ) <nl> <nl> model2 = model . from_config ( model . get_config ( ) ) <nl> model2 . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model2 . set_weights ( initial_weights ) <nl> model2 . fit ( x , y , batch_size = 2 , epochs = 1 ) <nl> <nl> mmm a / tensorflow / python / keras / engine / sequential_test . py <nl> ppp b / tensorflow / python / keras / engine / sequential_test . py <nl> def test_sequential_pop ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . random . random ( ( batch_size , input_dim ) ) <nl> y = np . random . random ( ( batch_size , num_classes ) ) <nl> model . fit ( x , y , epochs = 1 ) <nl> def test_sequential_pop ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> y = np . random . random ( ( batch_size , num_hidden ) ) <nl> model . fit ( x , y , epochs = 1 ) <nl> <nl> def test_sequential_deferred_build_with_np_arrays ( self ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ keras . metrics . CategoricalAccuracy ( ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> self . assertEqual ( len ( model . layers ) , 2 ) <nl> with self . assertRaisesRegexp ( <nl> ValueError , ' Weights for model . * have not yet been created ' ) : <nl> def test_sequential_deferred_build_with_dataset_iterators ( self ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ keras . metrics . CategoricalAccuracy ( ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> self . assertEqual ( len ( model . layers ) , 2 ) <nl> with self . assertRaisesRegexp ( <nl> ValueError , ' Weights for model . * have not yet been created ' ) : <nl> def test_sequential_deferred_build_serialization ( self ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ keras . metrics . CategoricalAccuracy ( ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> self . assertFalse ( model . built ) <nl> <nl> x = np . random . random ( ( batch_size , input_dim ) ) <nl> def test_sequential_deferred_build_serialization ( self ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ keras . metrics . CategoricalAccuracy ( ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . random . random ( ( batch_size , input_dim ) ) <nl> y = np . random . random ( ( batch_size , num_classes ) ) <nl> new_model . train_on_batch ( x , y ) <nl> def test_sequential_deferred_manual_build ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 1 , 2 ) ) , np . zeros ( ( 1 , 5 ) ) ) <nl> <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_sequential_nesting ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . random . random ( ( 2 , 6 ) ) <nl> y = np . random . random ( ( 2 , 5 ) ) <nl> model . fit ( x , y , epochs = 1 ) <nl> def test_string_input ( self ) : <nl> keras . layers . Lambda ( lambda x : x [ 0 ] ) <nl> ] ) <nl> seq . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - seq . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> preds = seq . predict ( [ [ ' tensorflow eager ' ] ] ) <nl> self . assertEqual ( preds . shape , ( 1 , ) ) <nl> <nl> def __init__ ( self , name = None ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . random . random ( ( 2 , 6 ) ) <nl> y = np . random . random ( ( 2 , 5 ) ) <nl> def test_build_before_fit ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . build ( ( None , 6 ) ) <nl> <nl> mmm a / tensorflow / python / keras / engine / training_arrays_test . py <nl> ppp b / tensorflow / python / keras / engine / training_arrays_test . py <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> loss = " mae " , <nl> optimizer = " adam " , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . fit ( <nl> x = { <nl> mmm a / tensorflow / python / keras / engine / training_dataset_test . py <nl> ppp b / tensorflow / python / keras / engine / training_dataset_test . py <nl> def test_calling_model_on_same_dataset ( self ) : <nl> optimizer , <nl> loss , <nl> metrics = metrics , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . zeros ( ( 10 , 3 ) , np . float32 ) <nl> targets = np . zeros ( ( 10 , 4 ) , np . float32 ) <nl> def test_training_and_eval_methods_on_dataset ( self ) : <nl> optimizer , <nl> loss , <nl> metrics = metrics , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . zeros ( ( 10 , 3 ) , np . float32 ) <nl> targets = np . zeros ( ( 10 , 4 ) , np . float32 ) <nl> def test_training_and_eval_methods_on_multi_input_output_dataset ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> input_a_np = np . random . random ( ( 10 , 3 ) ) . astype ( dtype = np . float32 ) <nl> input_b_np = np . random . random ( ( 10 , 3 ) ) . astype ( dtype = np . float32 ) <nl> def test_dataset_with_sample_weights ( self ) : <nl> optimizer , <nl> loss , <nl> metrics = metrics , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . zeros ( ( 10 , 3 ) , np . float32 ) <nl> targets = np . zeros ( ( 10 , 4 ) , np . float32 ) <nl> def test_dataset_with_sparse_labels ( self ) : <nl> model . compile ( <nl> optimizer , <nl> loss = ' sparse_categorical_crossentropy ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . zeros ( ( 10 , 3 ) , dtype = np . float32 ) <nl> targets = np . random . randint ( 0 , 4 , size = 10 , dtype = np . int32 ) <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> loss = ' mae ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . zeros ( ( 40 , 2 ) , dtype = np . float32 ) <nl> inputs [ 10 : 20 , : ] = 2 <nl> def test_finite_dataset_known_cardinality_no_steps_arg ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . zeros ( ( 100 , 3 ) , dtype = np . float32 ) <nl> targets = np . random . randint ( 0 , 4 , size = 100 , dtype = np . int32 ) <nl> def test_finite_dataset_unknown_cardinality_no_steps_arg ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . zeros ( ( 100 , 3 ) , dtype = np . float32 ) <nl> targets = np . random . randint ( 0 , 4 , size = 100 , dtype = np . int32 ) <nl> def __exit__ ( self , * args ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . zeros ( ( 100 , 3 ) , dtype = np . float32 ) <nl> targets = np . random . randint ( 0 , 4 , size = 100 , dtype = np . int32 ) <nl> def test_finite_dataset_unknown_cardinality_out_of_data ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . zeros ( ( 100 , 3 ) , dtype = np . float32 ) <nl> targets = np . random . randint ( 0 , 4 , size = 100 , dtype = np . int32 ) <nl> def test_train_eval_with_steps ( self ) : <nl> model = keras . Model ( inp , out ) <nl> model . compile ( <nl> ' rmsprop ' , loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . zeros ( ( 100 , 4 ) , dtype = np . float32 ) <nl> targets = np . random . randint ( 0 , 2 , size = 100 , dtype = np . int32 ) <nl> def test_metrics_correctness_with_dataset ( self ) : <nl> loss = ' binary_crossentropy ' , <nl> metrics = [ ' accuracy ' , metrics_module . BinaryAccuracy ( ) ] , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> np . random . seed ( 123 ) <nl> x = np . random . randint ( 10 , size = ( 100 , 4 ) ) . astype ( np . float32 ) <nl> mmm a / tensorflow / python / keras / engine / training_eager_test . py <nl> ppp b / tensorflow / python / keras / engine / training_eager_test . py <nl> def call ( self , inputs ) : <nl> model = DynamicModel ( ) <nl> model . compile ( <nl> ' rmsprop ' , ' mae ' , <nl> - run_eagerly = True , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = True ) <nl> hist = model . fit ( np . zeros ( ( 1 , 1 ) ) , np . zeros ( ( 1 , 1 ) ) ) <nl> self . assertEqual ( hist . history [ ' loss ' ] [ - 1 ] , 1 ) <nl> self . assertEqual ( len ( model . trainable_weights ) , 2 ) <nl> def test_model_methods_with_eager_tensors_multi_io ( self ) : <nl> metrics = metrics , <nl> loss_weights = loss_weights , <nl> run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) , <nl> sample_weight_mode = None ) <nl> <nl> input_a = array_ops . zeros ( shape = ( 10 , 3 ) ) <nl> def test_model_methods_with_eager_tensors_single_io ( self ) : <nl> optimizer , <nl> loss , <nl> metrics = metrics , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = array_ops . zeros ( shape = ( 10 , 3 ) ) <nl> targets = array_ops . zeros ( shape = ( 10 , 4 ) ) <nl> def test_loss_correctness ( self , optimizer_kwargs ) : <nl> model . compile ( <nl> loss = ' sparse_categorical_crossentropy ' , <nl> optimizer = rmsprop . RMSprop ( learning_rate = 0 . 001 , * * optimizer_kwargs ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . ones ( ( 100 , 4 ) ) <nl> np . random . seed ( 123 ) <nl> y = np . random . randint ( 0 , 1 , size = ( 100 , 1 ) ) <nl> def test_loss_correctness_clipvalue_zero ( self ) : <nl> model . compile ( <nl> loss = ' sparse_categorical_crossentropy ' , <nl> optimizer = rmsprop . RMSprop ( learning_rate = 0 . 001 , clipvalue = 0 . 0 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . ones ( ( 100 , 4 ) ) <nl> np . random . seed ( 123 ) <nl> y = np . random . randint ( 0 , 1 , size = ( 100 , 1 ) ) <nl> def test_loss_correctness_with_iterator ( self ) : <nl> model . compile ( <nl> loss = ' sparse_categorical_crossentropy ' , <nl> optimizer = rmsprop . RMSprop ( learning_rate = 0 . 001 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . ones ( ( 100 , 4 ) , dtype = np . float32 ) <nl> np . random . seed ( 123 ) <nl> y = np . random . randint ( 0 , 1 , size = ( 100 , 1 ) ) <nl> mmm a / tensorflow / python / keras / engine / training_generator_test . py <nl> ppp b / tensorflow / python / keras / engine / training_generator_test . py <nl> def test_evaluate_generator_method ( self ) : <nl> loss = ' mse ' , <nl> optimizer = rmsprop . RMSprop ( 1e - 3 ) , <nl> metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . evaluate_generator ( custom_generator_threads ( ) , <nl> steps = 5 , <nl> def test_predict_generator_method ( self ) : <nl> model = testing_utils . get_small_mlp ( <nl> num_hidden = 3 , num_classes = 4 , input_dim = 2 ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> model . predict_generator ( custom_generator_threads ( ) , <nl> steps = 5 , <nl> def test_generator_methods_with_sample_weights ( self ) : <nl> loss = ' mse ' , <nl> optimizer = rmsprop . RMSprop ( 1e - 3 ) , <nl> metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . fit_generator ( custom_generator ( mode = 3 ) , <nl> steps_per_epoch = 5 , <nl> def invalid_generator ( ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = rmsprop . RMSprop ( 1e - 3 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> with self . assertRaises ( ValueError ) : <nl> model . fit_generator ( invalid_generator ( ) , <nl> def ones_generator ( ) : <nl> model . compile ( <nl> rmsprop . RMSprop ( 0 . 001 ) , <nl> ' binary_crossentropy ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( <nl> ones_generator ( ) , <nl> steps_per_epoch = 2 , <nl> def ones_generator ( ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = rmsprop . RMSprop ( 1e - 3 ) , <nl> - metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] ) <nl> model . fit_generator ( custom_generator_changing_batch_size ( ) , <nl> steps_per_epoch = 5 , <nl> epochs = 1 , <nl> mmm a / tensorflow / python / keras / engine / training_integration_test . py <nl> ppp b / tensorflow / python / keras / engine / training_integration_test . py <nl> def _run_fit_eval_predict ( self , layer_to_test , input_shape , data_shape , <nl> layer_kwargs ) : <nl> batch_size = 2 <nl> run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> def map_fn ( _ ) : <nl> x = keras . backend . random_uniform ( shape = data_shape ) <nl> def map_fn ( _ ) : <nl> layer = keras . layers . Dense ( 1 , activation = None ) ( layer ) <nl> model = keras . models . Model ( inp , layer ) <nl> <nl> - model . compile ( loss = ' mse ' , optimizer = ' sgd ' , run_eagerly = run_eagerly , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + model . compile ( loss = ' mse ' , optimizer = ' sgd ' , run_eagerly = run_eagerly ) <nl> model . fit ( dataset , verbose = 2 , epochs = 2 ) <nl> <nl> - model . compile ( loss = ' mse ' , optimizer = ' sgd ' , run_eagerly = run_eagerly , <nl> - experimental_run_tf_function = experimental_run_tf_function ) <nl> + model . compile ( loss = ' mse ' , optimizer = ' sgd ' , run_eagerly = run_eagerly ) <nl> model . fit ( dataset . repeat ( 2 ) , verbose = 2 , epochs = 2 , steps_per_epoch = 2 ) <nl> <nl> eval_dataset = dataset_ops . DatasetV2 . range ( 4 ) . map ( map_fn ) . batch ( batch_size ) <nl> mmm a / tensorflow / python / keras / engine / training_test . py <nl> ppp b / tensorflow / python / keras / engine / training_test . py <nl> def call ( self , inputs , training ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> hist = model . fit ( x = np . array ( [ 0 . ] ) , y = np . array ( [ 0 . ] ) ) <nl> self . assertAllClose ( hist . history [ ' loss ' ] [ 0 ] , 10000 ) <nl> <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> ' sgd ' , <nl> loss = ' mae ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . ones ( ( 40 , 2 ) , dtype = np . float32 ) <nl> targets = np . ones ( ( 40 , 1 ) , dtype = np . float32 ) <nl> def call ( self , inputs , training = None ) : <nl> model . compile ( <nl> ' sgd ' , <nl> loss = ' mae ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . ones ( ( 40 , 2 ) , dtype = np . float32 ) <nl> targets = np . ones ( ( 40 , 1 ) , dtype = np . float32 ) <nl> def loss_fn ( labels , preds ) : <nl> model . compile ( <nl> ' sgd ' , <nl> loss = loss_fn , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( inputs , targets ) <nl> model . test_on_batch ( inputs , targets ) <nl> self . assertEqual ( model . predict ( inputs ) . dtype , np . float64 ) <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> ' sgd ' , <nl> loss = ' mae ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . ones ( ( 40 , 2 ) , dtype = np . float32 ) <nl> targets = np . ones ( ( 40 , 1 ) , dtype = np . float32 ) <nl> def test_fit_on_arrays ( self ) : <nl> loss , <nl> metrics = [ metrics_module . CategoricalAccuracy ( ) , ' mae ' ] , <nl> loss_weights = loss_weights , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> input_a_np = np . random . random ( ( 10 , 3 ) ) <nl> input_b_np = np . random . random ( ( 10 , 3 ) ) <nl> def test_fit_on_arrays ( self ) : <nl> optimizer , <nl> loss , <nl> metrics = [ metrics_module . CategoricalAccuracy ( ) , ' mae ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( <nl> [ input_a_np , input_b_np ] , [ output_d_np , output_e_np ] , <nl> epochs = 1 , <nl> def test_fit_on_arrays ( self ) : <nl> loss , <nl> metrics = metrics , <nl> loss_weights = loss_weights , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( <nl> [ input_a_np , input_b_np ] , [ output_d_np , output_e_np ] , <nl> epochs = 1 , <nl> def test_fit_on_arrays ( self ) : <nl> model . compile ( <nl> optimizer , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> # This will work <nl> model . fit ( [ input_a_np ] , output_d_np , epochs = 1 ) <nl> <nl> def test_fit_on_arrays ( self ) : <nl> <nl> # Test execution on inputs that are lists of scalars . <nl> # TF2 and TF1 have slightly different semantics : <nl> - if ( testing_utils . should_run_tf_function ( ) <nl> - or testing_utils . should_run_eagerly ( ) ) : <nl> + if context . executing_eagerly ( ) : <nl> # In TF2 to avoid any ambiguity when there are nested lists <nl> # the entire input gets converted to a <nl> # single numpy array ( & it only works in the case of a single io model ) <nl> def test_evaluate_predict_on_arrays ( self ) : <nl> metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> loss_weights = loss_weights , <nl> sample_weight_mode = None , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> input_a_np = np . random . random ( ( 10 , 3 ) ) <nl> input_b_np = np . random . random ( ( 10 , 3 ) ) <nl> def __len__ ( self ) : <nl> ) <nl> def test_sequence_input_types ( self , input_type ) : <nl> " " " Ensure that namedtuples and tuples are plumbed identically . " " " <nl> - if not testing_utils . should_run_tf_function ( ) : <nl> + if not context . executing_eagerly ( ) : <nl> self . skipTest ( ' Improved checking is only present in data_adapter . ' ) <nl> <nl> xy_function , x_function = self . _make_sequence_input_functions ( input_type ) <nl> def test_sequence_input_types ( self , input_type ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . fit ( xy_function ( use_namedtuple = False ) , * * fit_kwargs ) <nl> model . evaluate ( xy_function ( use_namedtuple = False ) , * * evaluate_kwargs ) <nl> def test_compile_with_sparse_placeholders ( self ) : <nl> loss = ' binary_crossentropy ' , <nl> optimizer = ' adam ' , <nl> metrics = [ ' accuracy ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_that_trainable_disables_updates ( self ) : <nl> def test_that_trainable_disables_updates ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> assert not model . updates <nl> <nl> x1 = model . predict ( val_a ) <nl> def test_that_trainable_disables_updates ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> assert model . updates <nl> <nl> model . train_on_batch ( val_a , val_out ) <nl> def test_that_trainable_disables_updates ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> assert not model . updates <nl> <nl> x1 = model . predict ( val_a ) <nl> def test_mismatched_output_shape_and_target_shape ( self ) : <nl> model . compile ( <nl> RMSPropOptimizer ( learning_rate = 0 . 001 ) , <nl> loss = ' sparse_categorical_crossentropy ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> # Test with Numpy data <nl> x_train = np . random . random ( ( 10 , 3 , 4 ) ) . astype ( np . float32 ) <nl> y_train = np . random . randint ( 0 , 5 , size = ( 10 , 3 ) ) . astype ( np . float32 ) <nl> def test_logging ( self ) : <nl> model . compile ( <nl> RMSPropOptimizer ( learning_rate = 0 . 001 ) , <nl> loss = ' binary_crossentropy ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> with test . mock . patch . object ( sys , ' stdout ' , mock_stdout ) : <nl> model . fit ( <nl> np . ones ( ( 10 , 10 ) , ' float32 ' ) , np . ones ( ( 10 , 1 ) , ' float32 ' ) , epochs = 10 ) <nl> def test_validation_freq ( self , validation_freq , expected_runs ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> class ValCounter ( keras . callbacks . Callback ) : <nl> <nl> def test_validation_steps_without_data ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> with self . assertRaisesRegexp ( <nl> ValueError , ' ` validation_steps ` should not be specified if ' <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( ( 10 , 10 ) ) <nl> y = np . ones ( ( 10 , 10 ) ) <nl> def test_model_input_dtype ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . ones ( ( 10 , 10 ) ) . astype ( np . float64 ) <nl> y = np . ones ( ( 10 , 10 ) ) . astype ( np . float64 ) <nl> dataset = dataset_ops . Dataset . from_tensor_slices ( ( x , y ) ) . batch ( 2 ) <nl> def call ( self , inputs , training = None ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , x , epochs = 1 ) <nl> <nl> - if ( testing_utils . should_run_eagerly ( ) or <nl> - testing_utils . should_run_tf_function ( ) ) : <nl> + if context . executing_eagerly ( ) : <nl> expected_training_arg = True <nl> else : <nl> expected_training_arg = keras . backend . symbolic_learning_phase ( ) <nl> def test_compile_warning_for_loss_missing_output ( self ) : <nl> ' dense_2 ' : ' categorical_accuracy ' , <nl> ' dense_1 ' : metrics_module . CategoricalAccuracy ( ) , <nl> } , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> @ keras_parameterized . run_with_all_model_types <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_class_weights ( self ) : <nl> metrics = [ ' acc ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> weighted_metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> optimizer = RMSPropOptimizer ( learning_rate = learning_rate ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> np . random . seed ( 1337 ) <nl> ( x_train , y_train ) , ( x_test , y_test ) = testing_utils . get_test_data ( <nl> def test_sample_weights ( self ) : <nl> metrics = [ ' acc ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> weighted_metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> loss = ' categorical_crossentropy ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> np . random . seed ( 43 ) <nl> ( x_train , y_train ) , ( x_test , y_test ) = testing_utils . get_test_data ( <nl> def test_temporal_sample_weights ( self ) : <nl> metrics = [ ' acc ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> weighted_metrics = [ ' mae ' , metrics_module . CategoricalAccuracy ( ) ] , <nl> sample_weight_mode = ' temporal ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . fit ( <nl> temporal_x_train , <nl> def test_fit_with_incorrect_weights ( self ) : <nl> model . compile ( <nl> optimizer = ' adam ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . random . random ( ( 10 , 3 ) ) <nl> y = np . random . random ( ( 10 , 2 ) ) <nl> <nl> def test_default_sample_weight ( self ) : <nl> optimizer , <nl> loss = ' mse ' , <nl> sample_weight_mode = [ None ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , epochs = 1 , batch_size = 10 ) <nl> <nl> # sample_weight_mode is a list and mode value is ` temporal ` <nl> def test_default_sample_weight ( self ) : <nl> optimizer , <nl> loss = ' mse ' , <nl> sample_weight_mode = [ ' temporal ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , epochs = 1 , batch_size = 10 ) <nl> <nl> # sample_weight_mode is a dict and mode value is None <nl> def test_default_sample_weight ( self ) : <nl> optimizer , <nl> loss = ' mse ' , <nl> sample_weight_mode = { ' time_distributed ' : None } , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , epochs = 1 , batch_size = 10 ) <nl> <nl> # sample_weight_mode is a dict and mode value is ` temporal ` <nl> def test_default_sample_weight ( self ) : <nl> optimizer , <nl> loss = ' mse ' , <nl> sample_weight_mode = { ' time_distributed ' : ' temporal ' } , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , epochs = 1 , batch_size = 10 ) <nl> <nl> # sample_weight_mode is a not a list / dict and mode value is None <nl> def test_default_sample_weight ( self ) : <nl> optimizer , <nl> loss = ' mse ' , <nl> sample_weight_mode = None , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , epochs = 1 , batch_size = 10 ) <nl> <nl> # sample_weight_mode is a not a list / dict and mode value is ` temporal ` <nl> def test_default_sample_weight ( self ) : <nl> optimizer , <nl> loss = ' mse ' , <nl> sample_weight_mode = ' temporal ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , epochs = 1 , batch_size = 10 ) <nl> <nl> def test_sample_weight_tensor ( self ) : <nl> def _get_model ( self , input_shape = None ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = RMSPropOptimizer ( learning_rate = 0 . 001 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> @ keras_parameterized . run_with_all_model_types <nl> def compute_output_shape ( self , input_shape ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = RMSPropOptimizer ( learning_rate = 0 . 001 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> y = np . random . random ( ( 5 , 3 ) ) <nl> model . train_on_batch ( x , y ) <nl> <nl> def test_trainable_warning ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . trainable = True <nl> model . train_on_batch ( x , y ) <nl> self . assertRaises ( Warning ) <nl> def test_trainable_argument ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> out = model . predict ( x ) <nl> model . train_on_batch ( x , y ) <nl> out_2 = model . predict ( x ) <nl> def test_trainable_argument ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> out = model . predict ( x ) <nl> model . train_on_batch ( x , y ) <nl> out_2 = model . predict ( x ) <nl> def test_gan_workflow ( self ) : <nl> model1 . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs2 = keras . Input ( 10 ) <nl> outputs2 = shared_layer ( inputs2 ) <nl> def test_gan_workflow ( self ) : <nl> model2 . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x , y = np . ones ( ( 10 , 10 ) ) , np . ones ( ( 10 , 10 ) ) <nl> <nl> def test_toggle_value ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( ( 10 , 1 ) ) <nl> y = 5 * x + 2 <nl> def test_metrics_names ( self ) : <nl> optimizer , <nl> loss = ' mae ' , <nl> metrics = metrics , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> mse_metric = ' mse ' if context . executing_eagerly ( ) else ' mean_squared_error ' <nl> reference_metric_names = [ <nl> def test_metric_state_reset_between_fit_and_evaluate ( self ) : <nl> loss = ' mae ' , <nl> metrics = [ acc_obj ] , <nl> optimizer = RMSPropOptimizer ( learning_rate = 0 . 001 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x_train = np . random . random ( ( 100 , 4 ) ) <nl> y_train = np . random . random ( ( 100 , 1 ) ) <nl> def test_metrics_valid_compile_input_formats ( self ) : <nl> loss = ' mse ' , <nl> metrics = [ keras . metrics . MeanSquaredError ( ) ] , <nl> weighted_metrics = [ keras . metrics . MeanSquaredError ( ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # list of list of metrics . <nl> model . compile ( <nl> def test_metrics_valid_compile_input_formats ( self ) : <nl> [ keras . metrics . MeanSquaredError ( ) , <nl> keras . metrics . Accuracy ( ) ] <nl> ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # dict of metrics . <nl> model . compile ( <nl> def test_metrics_valid_compile_input_formats ( self ) : <nl> keras . metrics . Accuracy ( ) <nl> ] , <nl> } , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_metrics_masking ( self ) : <nl> def test_metrics_masking ( self ) : <nl> RMSPropOptimizer ( learning_rate = 0 . 001 ) , <nl> loss = ' mse ' , <nl> weighted_metrics = [ ' accuracy ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # verify that masking is applied . <nl> x = np . array ( [ [ [ 1 ] , [ 1 ] ] , [ [ 1 ] , [ 1 ] ] , [ [ 0 ] , [ 0 ] ] ] ) <nl> def test_add_metric_with_tensor_on_model ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . ones ( shape = ( 10 , 1 ) ) <nl> targets = np . ones ( shape = ( 10 , 1 ) ) <nl> def call ( self , x ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = RMSPropOptimizer ( 0 . 01 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( shape = ( 10 , 1 ) ) <nl> y = np . ones ( shape = ( 10 , 2 ) ) <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = RMSPropOptimizer ( 0 . 01 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( shape = ( 10 , 1 ) ) <nl> y = np . ones ( shape = ( 10 , 2 ) ) <nl> def call ( self , inputs ) : <nl> ' sgd ' , <nl> loss = ' mse ' , <nl> metrics = [ metrics_module . Accuracy ( ' metric_4 ' ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . fit ( np . ones ( ( 10 , 1 ) ) , np . ones ( ( 10 , 1 ) ) , batch_size = 10 ) <nl> <nl> def call ( self , x ) : <nl> loss = ' mse ' , <nl> optimizer = RMSPropOptimizer ( 0 . 01 ) , <nl> metrics = [ metrics_module . Accuracy ( ' acc ' ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . ones ( shape = ( 10 , 1 ) ) <nl> y = np . ones ( shape = ( 10 , 2 ) ) <nl> model . fit ( x , y , epochs = 2 , batch_size = 5 , validation_data = ( x , y ) ) <nl> def call ( self , x ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = RMSPropOptimizer ( 0 . 01 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( shape = ( 10 , 1 ) ) <nl> y = np . ones ( shape = ( 10 , 2 ) ) <nl> def call ( self , x ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = RMSPropOptimizer ( 0 . 01 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( shape = ( 10 , 1 ) ) <nl> y = np . ones ( shape = ( 10 , 2 ) ) <nl> def call ( self , x ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = RMSPropOptimizer ( 0 . 01 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . ones ( shape = ( 10 , 1 ) ) <nl> y = np . ones ( shape = ( 10 , 2 ) ) <nl> <nl> def call ( self , inputs ) : <nl> loss = ' mae ' , <nl> optimizer = keras . optimizer_v2 . gradient_descent . SGD ( 0 . 1 ) , <nl> metrics = [ metrics_module . MeanAbsoluteError ( name = ' mae_3 ' ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . array ( [ [ 0 . ] , [ 1 . ] , [ 2 . ] ] ) <nl> y = np . array ( [ [ 0 . 5 ] , [ 2 . ] , [ 3 . 5 ] ] ) <nl> def call ( self , inputs , training = None , mask = None ) : <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( dataset_train , epochs = 3 ) <nl> self . assertDictEqual ( <nl> history . history , { <nl> def call ( self , inputs ) : <nl> ' sgd ' , <nl> loss = ' mse ' , <nl> metrics = [ metrics_module . Accuracy ( ' acc ' ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> inner_model . fit ( np . ones ( ( 10 , 1 ) ) , np . ones ( ( 10 , 1 ) ) , batch_size = 10 ) <nl> <nl> self . assertEqual ( [ m . name for m in inner_model . metrics ] , <nl> def call ( self , inputs ) : <nl> ' sgd ' , <nl> loss = ' mse ' , <nl> metrics = [ metrics_module . Accuracy ( ' acc2 ' ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> outer_model . fit ( np . ones ( ( 10 , 1 ) ) , np . ones ( ( 10 , 1 ) ) , batch_size = 10 ) <nl> self . assertEqual ( [ m . name for m in outer_model . metrics ] , <nl> [ ' loss ' , ' acc2 ' , ' mean ' , ' mean1 ' , ' mean2 ' ] ) <nl> def test_updates_in_model ( self , layer_builder ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , batch_size = 2 , epochs = 1 ) <nl> self . assertEqual ( self . evaluate ( layer . counter ) , 5 ) <nl> <nl> def test_lambda_updates_trainable_false ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , batch_size = 2 , epochs = 1 ) <nl> self . assertEqual ( self . evaluate ( layer . counter ) , 5 ) <nl> layer . trainable = False <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , batch_size = 2 , epochs = 1 ) <nl> self . assertEqual ( self . evaluate ( layer . counter ) , 5 ) <nl> <nl> def test_subgraph_updates_in_model ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , batch_size = 2 , epochs = 1 ) <nl> self . assertEqual ( self . evaluate ( layer . counter ) , 5 ) <nl> <nl> def test_batchnorm_trainable_false ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x , y = np . ones ( ( 10 , 10 ) ) , np . ones ( ( 10 , 1 ) ) <nl> model . fit ( x , y , batch_size = 2 , epochs = 1 ) <nl> self . assertAllEqual ( self . evaluate ( bn . moving_mean ) , np . zeros ( ( 10 , ) ) ) <nl> mmm a / tensorflow / python / keras / layers / advanced_activations_test . py <nl> ppp b / tensorflow / python / keras / layers / advanced_activations_test . py <nl> def test_layer_as_activation ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( np . ones ( ( 10 , 10 ) ) , np . ones ( ( 10 , 1 ) ) , batch_size = 2 ) <nl> <nl> <nl> mmm a / tensorflow / python / keras / layers / convolutional_recurrent_test . py <nl> ppp b / tensorflow / python / keras / layers / convolutional_recurrent_test . py <nl> def test_conv_lstm_with_initial_state ( self ) : <nl> <nl> model . compile ( <nl> optimizer = ' sgd ' , loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x_1 = np . random . rand ( num_samples , sequence_len , 32 , 32 , 3 ) <nl> x_2 = np . random . rand ( num_samples , sequence_len , 32 , 32 , 4 ) <nl> y = np . random . rand ( num_samples , 32 , 32 , 1 ) <nl> mmm a / tensorflow / python / keras / layers / core_test . py <nl> ppp b / tensorflow / python / keras / layers / core_test . py <nl> def lambda_fn ( x , v ) : <nl> model . compile ( <nl> keras . optimizer_v2 . gradient_descent . SGD ( 0 . 1 ) , <nl> ' mae ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x , y = np . ones ( ( 10 , 10 ) , ' float32 ' ) , 2 * np . ones ( ( 10 , 10 ) , ' float32 ' ) <nl> model . fit ( x , y , batch_size = 2 , epochs = 2 , validation_data = ( x , y ) ) <nl> self . assertLen ( model . trainable_weights , 1 ) <nl> mmm a / tensorflow / python / keras / layers / cudnn_recurrent_test . py <nl> ppp b / tensorflow / python / keras / layers / cudnn_recurrent_test . py <nl> def test_return_state ( self , layer_class ) : <nl> self . assertEqual ( len ( state ) , num_states ) <nl> model = keras . models . Model ( inputs , state [ 0 ] ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> inputs = np . random . random ( ( num_samples , timesteps , input_size ) ) <nl> state = model . predict ( inputs ) <nl> def test_specify_initial_state_keras_tensor ( self , layer_class ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = RMSprop ( learning_rate = 0 . 001 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . random . random ( ( num_samples , timesteps , input_size ) ) <nl> initial_state = [ <nl> mmm a / tensorflow / python / keras / layers / embeddings_test . py <nl> ppp b / tensorflow / python / keras / layers / embeddings_test . py <nl> def test_embedding_correctness ( self ) : <nl> <nl> layer . set_weights ( [ np . array ( [ [ 1 , 1 ] , [ 2 , 2 ] ] ) ] ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> outputs = model . predict ( np . array ( [ [ 0 , 1 , 0 ] ] , dtype = ' int32 ' ) ) <nl> self . assertAllClose ( outputs , [ [ [ 1 , 1 ] , [ 2 , 2 ] , [ 1 , 1 ] ] ] ) <nl> <nl> def test_embedding_with_ragged_input ( self ) : <nl> outputs = layer ( outputs ) <nl> <nl> model = keras . Model ( inputs , outputs ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> outputs = model . predict ( <nl> ragged_factory_ops . constant ( [ [ 1 . , 2 . , 2 . ] , [ 0 . ] , [ 1 . , 2 . ] ] , <nl> mmm a / tensorflow / python / keras / layers / gru_test . py <nl> ppp b / tensorflow / python / keras / layers / gru_test . py <nl> def test_dynamic_behavior_GRU ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x = np . random . random ( ( num_samples , timesteps , embedding_dim ) ) <nl> y = np . random . random ( ( num_samples , units ) ) <nl> model . train_on_batch ( x , y ) <nl> def test_reset_after_GRU ( self ) : <nl> gru_model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> gru_model . fit ( x_train , y_train ) <nl> gru_model . predict ( x_train ) <nl> <nl> def test_with_masking_layer_GRU ( self ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( inputs , targets , epochs = 1 , batch_size = 2 , verbose = 1 ) <nl> <nl> def test_statefulness_GRU ( self ) : <nl> def test_statefulness_GRU ( self ) : <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> out1 = model . predict ( np . ones ( ( num_samples , timesteps ) ) ) <nl> self . assertEqual ( out1 . shape , ( num_samples , units ) ) <nl> <nl> mmm a / tensorflow / python / keras / layers / gru_v2_test . py <nl> ppp b / tensorflow / python / keras / layers / gru_v2_test . py <nl> def test_statefulness_GRU ( self ) : <nl> model . compile ( <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 01 ) , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> out1 = model . predict ( np . ones ( ( num_samples , timesteps ) ) ) <nl> self . assertEqual ( out1 . shape , ( num_samples , units ) ) <nl> <nl> def test_stateful_GRU_training ( self ) : <nl> model . compile ( <nl> optimizer = ' adam ' , <nl> loss = ' sparse_categorical_crossentropy ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , epochs = 1 , shuffle = False ) <nl> <nl> @ test_util . run_v2_only <nl> def _test_runtime_with_model ( self , model ) : <nl> <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> - loss = [ ' categorical_crossentropy ' , None ] , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + loss = [ ' categorical_crossentropy ' , None ] ) <nl> <nl> existing_loss = 0 <nl> for _ in range ( self . epoch ) : <nl> def test_GRU_runtime_with_mask ( self ) : <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = [ ' categorical_crossentropy ' , None ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . fit ( x_train , y_train ) <nl> <nl> mmm a / tensorflow / python / keras / layers / lstm_test . py <nl> ppp b / tensorflow / python / keras / layers / lstm_test . py <nl> def test_dynamic_behavior_LSTM ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . random . random ( ( num_samples , timesteps , embedding_dim ) ) <nl> y = np . random . random ( ( num_samples , units ) ) <nl> def test_with_masking_layer_LSTM ( self , unroll ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( inputs , targets , epochs = 1 , batch_size = 2 , verbose = 1 ) <nl> <nl> @ parameterized . parameters ( [ True , False ] ) <nl> def test_masking_with_stacking_LSTM ( self , unroll ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( inputs , targets , epochs = 1 , batch_size = 2 , verbose = 1 ) <nl> <nl> def test_from_config_LSTM ( self ) : <nl> def test_specify_initial_state_keras_tensor ( self ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = adam . AdamOptimizer ( ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . random . random ( ( num_samples , timesteps , embedding_dim ) ) <nl> initial_state = [ np . random . random ( ( num_samples , units ) ) <nl> def test_specify_initial_state_non_keras_tensor ( self ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = adam . AdamOptimizer ( ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . random . random ( ( num_samples , timesteps , embedding_dim ) ) <nl> targets = np . random . random ( ( num_samples , units ) ) <nl> def test_specify_state_with_masking ( self ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> inputs = np . random . random ( ( num_samples , timesteps , embedding_dim ) ) <nl> initial_state = [ np . random . random ( ( num_samples , units ) ) <nl> def test_initial_states_as_other_inputs ( self ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = adam . AdamOptimizer ( ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> main_inputs = np . random . random ( ( num_samples , timesteps , embedding_dim ) ) <nl> initial_state = [ np . random . random ( ( num_samples , units ) ) <nl> def test_statefulness_LSTM ( self ) : <nl> model . compile ( <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 01 ) , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> out1 = model . predict ( np . ones ( ( num_samples , timesteps ) ) ) <nl> self . assertEqual ( out1 . shape , ( num_samples , units ) ) <nl> <nl> mmm a / tensorflow / python / keras / layers / lstm_v2_test . py <nl> ppp b / tensorflow / python / keras / layers / lstm_v2_test . py <nl> def test_statefulness_LSTM ( self ) : <nl> model . compile ( <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 01 ) , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> out1 = model . predict ( np . ones ( ( num_samples , timesteps ) ) ) <nl> self . assertEqual ( out1 . shape , ( num_samples , units ) ) <nl> <nl> def test_stateful_LSTM_training ( self ) : <nl> model . compile ( <nl> optimizer = ' adam ' , <nl> loss = ' sparse_categorical_crossentropy ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , epochs = 1 , shuffle = False ) <nl> <nl> def test_dropout_LSTM ( self ) : <nl> def _test_runtime_with_model ( self , model ) : <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = [ ' categorical_crossentropy ' , None ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> existing_loss = 0 <nl> for _ in range ( self . epoch ) : <nl> def test_LSTM_runtime_with_mask ( self ) : <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = [ ' categorical_crossentropy ' , None ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . fit ( x_train , y_train ) <nl> <nl> mmm a / tensorflow / python / keras / layers / merge_test . py <nl> ppp b / tensorflow / python / keras / layers / merge_test . py <nl> def test_merge_add ( self ) : <nl> self . assertListEqual ( o . shape . as_list ( ) , [ None , 4 , 5 ] ) <nl> model = keras . models . Model ( [ i1 , i2 , i3 ] , o ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> x1 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> x2 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> def test_merge_subtract ( self ) : <nl> self . assertListEqual ( o . shape . as_list ( ) , [ None , 4 , 5 ] ) <nl> model = keras . models . Model ( [ i1 , i2 ] , o ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> x1 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> x2 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> def test_merge_multiply ( self ) : <nl> self . assertListEqual ( o . shape . as_list ( ) , [ None , 4 , 5 ] ) <nl> model = keras . models . Model ( [ i1 , i2 , i3 ] , o ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> x1 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> x2 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> def test_merge_average ( self ) : <nl> self . assertListEqual ( o . shape . as_list ( ) , [ None , 4 , 5 ] ) <nl> model = keras . models . Model ( [ i1 , i2 ] , o ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> x1 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> x2 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> def test_merge_maximum ( self ) : <nl> self . assertListEqual ( o . shape . as_list ( ) , [ None , 4 , 5 ] ) <nl> model = keras . models . Model ( [ i1 , i2 ] , o ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> x1 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> x2 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> def test_merge_minimum ( self ) : <nl> self . assertListEqual ( o . shape . as_list ( ) , [ None , 4 , 5 ] ) <nl> model = keras . models . Model ( [ i1 , i2 ] , o ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> x1 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> x2 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> def test_merge_concatenate ( self ) : <nl> self . assertListEqual ( o . shape . as_list ( ) , [ None , 8 , 5 ] ) <nl> model = keras . models . Model ( [ i1 , i2 ] , o ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> <nl> x1 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> x2 = np . random . random ( ( 2 , 4 , 5 ) ) <nl> def test_merge_dot ( self ) : <nl> self . assertListEqual ( o . shape . as_list ( ) , [ None , 1 ] ) <nl> model = keras . models . Model ( [ i1 , i2 ] , o ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> _ = keras . layers . Dot ( axes = 1 ) . get_config ( ) <nl> <nl> x1 = np . random . random ( ( 2 , 4 ) ) <nl> def test_merge_dot ( self ) : <nl> self . assertListEqual ( o . shape . as_list ( ) , [ None , 1 ] ) <nl> model = keras . models . Model ( [ i1 , i2 ] , o ) <nl> model . run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> out = model . predict ( [ x1 , x2 ] ) <nl> self . assertEqual ( out . shape , ( 2 , 1 ) ) <nl> self . assertAllClose ( out , expected , atol = 1e - 4 ) <nl> mmm a / tensorflow / python / keras / layers / normalization_test . py <nl> ppp b / tensorflow / python / keras / layers / normalization_test . py <nl> def test_batchnorm_convnet ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 01 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # centered on 5 . 0 , variance 10 . 0 <nl> x = np . random . normal ( loc = 5 . 0 , scale = 10 . 0 , size = ( 1000 , 3 , 4 , 4 ) ) <nl> def test_batchnorm_convnet_channel_last ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 01 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # centered on 5 . 0 , variance 10 . 0 <nl> x = np . random . normal ( loc = 5 . 0 , scale = 10 . 0 , size = ( 1000 , 4 , 4 , 3 ) ) <nl> def test_batchnorm_non_trainable_with_fit ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( np . random . random ( ( 100 , 3 ) ) , np . random . random ( ( 100 , 3 ) ) ) <nl> <nl> test_data = np . random . random ( ( 10 , 3 ) ) <nl> def test_batchnorm_non_trainable_with_fit ( self ) : <nl> model . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> train_loss = model . train_on_batch ( test_data , test_targets ) <nl> self . assertAlmostEqual ( test_loss , train_loss ) <nl> <nl> def _run_batchnorm_correctness_test ( layer , dtype = ' float32 ' , fused = False ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 01 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # centered on 5 . 0 , variance 10 . 0 <nl> x = ( np . random . normal ( loc = 5 . 0 , scale = 10 . 0 , size = ( 1000 , 2 , 2 , 2 ) ) <nl> def _run_layernorm_correctness_test ( layer , dtype = ' float32 ' ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 01 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # centered on 5 . 0 , variance 10 . 0 <nl> x = ( np . random . normal ( loc = 5 . 0 , scale = 10 . 0 , size = ( 1000 , 2 , 2 , 2 ) ) <nl> def test_layernorm_convnet_channel_last ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 01 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # centered on 5 . 0 , variance 10 . 0 <nl> x = np . random . normal ( loc = 5 . 0 , scale = 10 . 0 , size = ( 1000 , 4 , 4 , 3 ) ) <nl> mmm a / tensorflow / python / keras / layers / preprocessing / normalization_test . py <nl> ppp b / tensorflow / python / keras / layers / preprocessing / normalization_test . py <nl> def test_layer_computation ( self , adapt_data , axis , test_data , use_dataset , <nl> output = layer ( input_data ) <nl> model = keras . Model ( input_data , output ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> output_data = model . predict ( test_data ) <nl> self . assertAllClose ( expected , output_data ) <nl> <nl> mmm a / tensorflow / python / keras / layers / recurrent_test . py <nl> ppp b / tensorflow / python / keras / layers / recurrent_test . py <nl> def call ( self , inputs , states ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> # Test stacking . <nl> def call ( self , inputs , states ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> def test_minimal_rnn_cell_non_layer_multiple_states ( self ) : <nl> def call ( self , inputs , states ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> # Test stacking . <nl> def call ( self , inputs , states ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> def test_minimal_rnn_cell_layer ( self ) : <nl> def get_config ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> # Test basic case serialization . <nl> def get_config ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> # Test stacked RNN serialization . <nl> def output_size ( self ) : <nl> model . compile ( <nl> optimizer = " rmsprop " , <nl> loss = " mse " , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> # Test stacking . <nl> def output_size ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> def test_rnn_with_time_major ( self ) : <nl> def test_rnn_with_time_major ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> np . zeros ( ( batch , time_step , embedding_dim ) ) , <nl> np . zeros ( ( batch , time_step , units ) ) ) <nl> def test_rnn_with_time_major ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> np . zeros ( ( batch , time_step , embedding_dim ) ) , <nl> np . zeros ( ( batch , time_step , cell_units [ - 1 ] ) ) ) <nl> def test_rnn_with_time_major ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> np . zeros ( ( batch , time_step , embedding_dim ) ) , <nl> np . zeros ( ( batch , time_step , units ) ) ) <nl> def test_rnn_with_time_major ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> np . zeros ( ( batch , time_step , embedding_dim ) ) , <nl> np . zeros ( ( batch , time_step , units ) ) ) <nl> def test_rnn_cell_with_constants_layer ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> [ np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 3 ) ) ] , <nl> np . zeros ( ( 6 , 32 ) ) <nl> def test_rnn_cell_with_constants_layer ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> [ np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 3 ) ) ] , <nl> np . zeros ( ( 6 , 32 ) ) <nl> def test_rnn_cell_with_constants_layer ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> [ np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 3 ) ) ] , <nl> np . zeros ( ( 6 , 32 ) ) <nl> def test_rnn_cell_with_non_keras_constants ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> # Test stacking . <nl> def test_rnn_cell_with_non_keras_constants ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> def test_rnn_cell_with_constants_layer_passing_initial_state ( self ) : <nl> def test_rnn_cell_with_constants_layer_passing_initial_state ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> [ np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) , np . zeros ( ( 6 , 3 ) ) ] , <nl> np . zeros ( ( 6 , 32 ) ) <nl> def test_rnn_cell_with_non_keras_constants_and_initial_state ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> # Test stacking . <nl> def test_rnn_cell_with_non_keras_constants_and_initial_state ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 32 ) ) ) <nl> <nl> def test_stacked_rnn_attributes ( self ) : <nl> def test_builtin_rnn_cell_serialization ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # Test basic case serialization . <nl> x_np = np . random . random ( ( 6 , 5 , 5 ) ) <nl> def test_builtin_rnn_cell_serialization ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # Test stacked RNN serialization . <nl> x_np = np . random . random ( ( 6 , 5 , 5 ) ) <nl> def test_rnn_dropout ( self , layer , unroll ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x_np = np . random . random ( ( 6 , 5 , 5 ) ) <nl> y_np = np . random . random ( ( 6 , 3 ) ) <nl> model . train_on_batch ( x_np , y_np ) <nl> def test_stacked_rnn_dropout ( self , cell , unroll ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> x_np = np . random . random ( ( 6 , 5 , 5 ) ) <nl> y_np = np . random . random ( ( 6 , 3 ) ) <nl> model . train_on_batch ( x_np , y_np ) <nl> def test_trackable_dependencies ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , epochs = 1 , batch_size = 1 ) <nl> <nl> # check whether the model variables are present in the <nl> def test_high_dimension_RNN ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> np . zeros ( ( batch , time_step , input_a , input_b ) ) , <nl> np . zeros ( ( batch , unit_a , unit_b ) ) ) <nl> def test_high_dimension_RNN ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> np . zeros ( ( batch , time_step , input_a , input_b ) ) , <nl> np . zeros ( ( batch , unit_a * 4 , unit_b * 4 ) ) ) <nl> def test_high_dimension_RNN_with_init_state ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( [ <nl> np . zeros ( ( batch , time_step , input_a , input_b ) ) , <nl> np . zeros ( ( batch , unit_a , unit_b ) ) <nl> def test_inconsistent_output_state_size ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> np . zeros ( ( batch , time_step , input_size ) ) , <nl> np . zeros ( ( batch , input_size ) ) ) <nl> def test_nested_input_output ( self , stateful ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> [ np . zeros ( ( batch , t , i1 ) ) , np . zeros ( ( batch , t , i2 , i3 ) ) ] , <nl> [ np . zeros ( ( batch , o1 ) ) , np . zeros ( ( batch , o2 , o3 ) ) ] ) <nl> def test_nested_input_output ( self , stateful ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> [ np . zeros ( ( batch , t , i1 ) ) , <nl> np . zeros ( ( batch , t , i2 , i3 ) ) ] , <nl> def test_nested_input_output_with_state ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> [ np . zeros ( ( batch , t , i1 ) ) , <nl> np . zeros ( ( batch , t , i2 , i3 ) ) ] , <nl> def test_nested_input_output_with_state ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> [ np . zeros ( ( batch , t , i1 ) ) , <nl> np . zeros ( ( batch , t , i2 , i3 ) ) ] , <nl> def test_nest_input_output_with_init_state ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> [ np . zeros ( ( batch , t , i1 ) ) , <nl> np . zeros ( ( batch , t , i2 , i3 ) ) , <nl> def test_nest_input_output_with_init_state ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> [ np . zeros ( ( batch , t , i1 ) ) , <nl> np . zeros ( ( batch , t , i2 , i3 ) ) , <nl> def call ( self , inputs , states ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # last time step masked <nl> x_np = np . array ( [ [ [ 1 . ] , [ 2 . ] , [ 0 . ] ] ] ) <nl> def test_zero_output_for_masking ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> np_x = np . ones ( ( 6 , 5 , 5 ) ) <nl> result_1 = model . predict ( np_x ) <nl> def test_unroll_single_step ( self ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> np_x = np . ones ( ( 6 , 1 , 5 ) ) <nl> result = model . predict ( np_x ) <nl> def test_stateful_rnn_with_stacking ( self , cell ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> np . zeros ( ( batch , timesteps , input_dim ) ) , <nl> np . zeros ( ( batch , output_dim ) ) ) <nl> def make_model ( stateful = False , with_initial_state = False ) : <nl> model = keras . Model ( input_layer , rnn_output ) <nl> model . compile ( <nl> optimizer = ' rmsprop ' , loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> # Define a model with a constant state initialization <nl> def create_cell ( ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( <nl> np . zeros ( ( batch , timesteps , input_dim ) ) , <nl> np . zeros ( ( batch , output_dim ) ) ) <nl> def test_rnn_with_ragged_input ( self , layer ) : <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( ragged_data , label_data ) <nl> <nl> # Test stateful and full shape specification <nl> def test_rnn_with_ragged_input ( self , layer ) : <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( ragged_data , label_data ) <nl> <nl> # Must raise error when unroll is set to True <nl> def call ( self , inputs , states ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( np . zeros ( ( 6 , 5 , 5 ) ) , np . zeros ( ( 6 , 5 ) ) ) <nl> <nl> @ parameterized . parameters ( <nl> mmm a / tensorflow / python / keras / layers / recurrent_v2_test . py <nl> ppp b / tensorflow / python / keras / layers / recurrent_v2_test . py <nl> def test_device_placement ( self , layer ) : <nl> model . compile ( <nl> optimizer = ' adam ' , <nl> loss = ' sparse_categorical_crossentropy ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , epochs = 1 , shuffle = False ) <nl> <nl> @ parameterized . parameters ( [ rnn_v2 . LSTM , rnn_v2 . GRU ] ) <nl> mmm a / tensorflow / python / keras / layers / simplernn_test . py <nl> ppp b / tensorflow / python / keras / layers / simplernn_test . py <nl> def test_statefulness_SimpleRNN ( self ) : <nl> model . compile ( <nl> optimizer = gradient_descent . GradientDescentOptimizer ( 0 . 01 ) , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> out1 = model . predict ( np . ones ( ( num_samples , timesteps ) ) ) <nl> self . assertEqual ( out1 . shape , ( num_samples , units ) ) <nl> <nl> mmm a / tensorflow / python / keras / layers / tensorflow_op_layer_test . py <nl> ppp b / tensorflow / python / keras / layers / tensorflow_op_layer_test . py <nl> def test_autolambda ( self , model_fn ) : <nl> model . compile ( <nl> adam . Adam ( 0 . 001 ) , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> np_inputs = nest . map_structure ( <nl> lambda x : np . ones ( ( 10 , ) + tuple ( x . shape [ 1 : ] ) , ' float32 ' ) , model . inputs ) <nl> def test_autolambda ( self , model_fn ) : <nl> new_model . compile ( <nl> adam . Adam ( 0 . 001 ) , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> new_model . fit ( np_inputs , np_outputs , batch_size = 2 ) <nl> new_model ( np_inputs ) # Test calling the new model directly on inputs . <nl> # Assert that metrics are preserved and in the right order . <nl> mmm a / tensorflow / python / keras / layers / wrappers_test . py <nl> ppp b / tensorflow / python / keras / layers / wrappers_test . py <nl> def test_TimeDistributed_with_mask_first_implementation ( self ) : <nl> model_1 . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> output_with_mask = model_1 . predict ( data , steps = 1 ) <nl> <nl> y = keras . layers . TimeDistributed ( rnn_layer ) ( x ) <nl> def test_TimeDistributed_with_mask_first_implementation ( self ) : <nl> model_2 . compile ( <nl> ' rmsprop ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> output = model_2 . predict ( data , steps = 1 ) <nl> <nl> self . assertNotAllClose ( output_with_mask , output , atol = 1e - 7 ) <nl> def test_TimeDistributed_with_mask_first_implementation ( self ) : <nl> layer = [ keras . layers . LSTM , <nl> keras . layers . Dense ] ) ) <nl> def test_TimeDistributed_with_ragged_input ( self , layer ) : <nl> - if testing_utils . should_run_tf_function ( ) : <nl> + if context . executing_eagerly ( ) : <nl> self . skipTest ( ' b / 143103634 ' ) <nl> np . random . seed ( 100 ) <nl> layer = layer ( 4 ) <nl> def test_TimeDistributed_with_ragged_input ( self , layer ) : <nl> x_ragged = keras . Input ( shape = ( None , 2 , 1 ) , dtype = ' float32 ' , ragged = True ) <nl> y_ragged = keras . layers . TimeDistributed ( layer ) ( x_ragged ) <nl> model_1 = keras . models . Model ( x_ragged , y_ragged ) <nl> - model_1 . _experimental_run_tf_function = ( <nl> - testing_utils . should_run_tf_function ( ) ) <nl> model_1 . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> output_ragged = model_1 . predict ( ragged_data , steps = 1 ) <nl> <nl> def test_TimeDistributed_with_ragged_input ( self , layer ) : <nl> y_dense = keras . layers . TimeDistributed ( layer ) ( masking ) <nl> model_2 = keras . models . Model ( x_dense , y_dense ) <nl> dense_data = ragged_data . to_tensor ( ) <nl> - model_2 . _experimental_run_tf_function = ( <nl> - testing_utils . should_run_tf_function ( ) ) <nl> model_2 . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> output_dense = model_2 . predict ( dense_data , steps = 1 ) <nl> <nl> mmm a / tensorflow / python / keras / metrics_correctness_test . py <nl> ppp b / tensorflow / python / keras / metrics_correctness_test . py <nl> def _get_compiled_multi_io_model ( self ) : <nl> weighted_metrics = [ <nl> metrics . MeanSquaredError ( name = ' mean_squared_error_2 ' ) <nl> ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> def setUp ( self ) : <nl> def _get_model ( self ) : <nl> weighted_metrics = [ <nl> metrics . MeanSquaredError ( name = ' mean_squared_error_2 ' ) <nl> ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> def _custom_generator ( self , sample_weight = None ) : <nl> def _get_compiled_multi_io_model ( self , loss ) : <nl> model . compile ( <nl> optimizer = ' rmsprop ' , <nl> loss = loss , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> def setUp ( self ) : <nl> mmm a / tensorflow / python / keras / metrics_test . py <nl> ppp b / tensorflow / python / keras / metrics_test . py <nl> def _get_model ( compile_metrics ) : <nl> loss = ' mae ' , <nl> metrics = compile_metrics , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> <nl> mmm a / tensorflow / python / keras / mixed_precision / experimental / BUILD <nl> ppp b / tensorflow / python / keras / mixed_precision / experimental / BUILD <nl> cuda_py_test ( <nl> size = " medium " , <nl> srcs = [ " keras_test . py " ] , <nl> python_version = " PY3 " , <nl> - shard_count = 4 , <nl> + shard_count = 10 , <nl> tags = [ " no_windows " ] , # b / 139083295 : bfloat16 tests fail on Windows <nl> deps = [ <nl> " : test_util " , <nl> mmm a / tensorflow / python / keras / mixed_precision / experimental / keras_test . py <nl> ppp b / tensorflow / python / keras / mixed_precision / experimental / keras_test . py <nl> def _skip_if_save_format_unsupported ( self , save_format ) : <nl> ' strategy_fn ' : create_central_storage_strategy , <nl> ' use_regularizer ' : True , <nl> ' save_format ' : ' tf ' <nl> - } , { <nl> - ' testcase_name ' : ' norun_distributed ' , <nl> - ' strategy_fn ' : create_mirrored_strategy , <nl> - ' experimental_run_tf_function ' : False <nl> } ) <nl> def test_model ( self , <nl> strategy_fn , <nl> def test_model ( self , <nl> policy_name = ' mixed_float16 ' , <nl> get_config = False , <nl> save_format = None , <nl> - use_input_spec = False , <nl> - experimental_run_tf_function = True ) : <nl> + use_input_spec = False ) : <nl> self . _skip_if_strategy_unsupported ( strategy_fn ) <nl> self . _skip_if_save_format_unsupported ( save_format ) <nl> regularizer = ( mp_test_util . IdentityRegularizer ( ) if use_regularizer <nl> def loss_fn ( y_true , y_pred ) : <nl> model . compile ( <nl> opt , <nl> loss = loss_fn , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( ( 2 , 1 ) ) <nl> y = np . ones ( ( 2 , 1 ) ) <nl> def _test_saving ( self , model , dataset , save_format , use_regularizer ) : <nl> } , { <nl> ' testcase_name ' : ' distribute ' , <nl> ' strategy_fn ' : create_mirrored_strategy , <nl> - } , { <nl> - ' testcase_name ' : ' norun_distributed ' , <nl> - ' strategy_fn ' : create_mirrored_strategy , <nl> - ' experimental_run_tf_function ' : False , <nl> } ) <nl> def test_fixed_loss_scaling ( self , <nl> - strategy_fn , <nl> - experimental_run_tf_function = True ) : <nl> + strategy_fn ) : <nl> # Note : We do not test mixed precision in this method , only loss scaling . <nl> loss_scale = 8 . <nl> batch_size = 4 <nl> def loss_fn ( y_true , y_pred ) : <nl> model . compile ( <nl> opt , <nl> loss = loss_fn , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> self . assertEqual ( backend . eval ( layer . v ) , 1 ) <nl> x = np . ones ( ( batch_size , 1 ) ) <nl> def loss_fn ( y_true , y_pred ) : <nl> model . compile ( <nl> opt , <nl> loss = loss_fn , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( ( 2 , 1 ) ) <nl> y = np . ones ( ( 2 , 1 ) ) <nl> def loss_fn ( y_true , y_pred ) : <nl> ' testcase_name ' : ' central_storage ' , <nl> ' strategy_fn ' : create_central_storage_strategy , <nl> ' get_config ' : True , <nl> - } , { <nl> - ' testcase_name ' : ' norun_distributed ' , <nl> - ' strategy_fn ' : create_mirrored_strategy , <nl> - ' experimental_run_tf_function ' : False , <nl> } ) <nl> def test_dynamic_loss_scaling ( self , <nl> strategy_fn , <nl> pass_loss_scale_to_policy = False , <nl> - get_config = False , <nl> - experimental_run_tf_function = True ) : <nl> + get_config = False ) : <nl> strategy = strategy_fn ( ) <nl> initial_loss_scale = 2 . <nl> batch_size = 4 <nl> def loss_fn ( y_true , y_pred ) : <nl> model . compile ( <nl> opt , <nl> loss = loss_fn , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> self . assertEqual ( backend . eval ( layer . v ) , 1 ) <nl> x = np . ones ( ( batch_size , 1 ) ) <nl> def test_save_slot_variables_with_autocast_vars ( self , <nl> model . compile ( <nl> optimizer = opt , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . fit ( np . ones ( ( 2 , 2 ) ) , np . zeros ( ( 2 , 2 ) ) , batch_size = 2 ) <nl> weights_file = os . path . join ( self . get_temp_dir ( ) , ' weights ' ) <nl> def test_save_weights_with_dynamic_loss_scaling ( self , strategy_fn ) : <nl> model . compile ( <nl> optimizer = opt , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> # Run for 3 steps ( 6 examples with a batch size of 2 ) <nl> model . fit ( np . zeros ( ( 6 , 2 ) ) , np . zeros ( ( 6 , 2 ) ) , batch_size = 2 ) <nl> self . assertEqual ( backend . get_value ( loss_scale ( ) ) , 2 ) <nl> def test_save_model_with_dynamic_loss_scaling ( self , strategy_fn , h5 = False ) : <nl> model . compile ( <nl> optimizer = opt , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> # Run for 3 steps ( 6 examples with a batch size of 2 ) <nl> model . fit ( np . ones ( ( 6 , 2 ) ) , np . zeros ( ( 6 , 2 ) ) , batch_size = 2 ) <nl> self . assertEqual ( backend . get_value ( loss_scale ( ) ) , 2 ) <nl> mmm a / tensorflow / python / keras / models_test . py <nl> ppp b / tensorflow / python / keras / models_test . py <nl> def test_clone_functional_model ( self , share_weights ) : <nl> new_model . compile ( <nl> testing_utils . get_v2_optimizer ( ' rmsprop ' ) , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> new_model . train_on_batch ( [ val_a , val_b ] , val_out ) <nl> <nl> # On top of new tensors <nl> def test_clone_functional_model ( self , share_weights ) : <nl> new_model . compile ( <nl> testing_utils . get_v2_optimizer ( ' rmsprop ' ) , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> new_model . train_on_batch ( [ val_a , val_b ] , val_out ) <nl> <nl> # On top of new , non - Keras tensors <nl> def test_clone_functional_model ( self , share_weights ) : <nl> new_model . compile ( <nl> testing_utils . get_v2_optimizer ( ' rmsprop ' ) , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> new_model . train_on_batch ( None , val_out ) <nl> <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_clone_functional_with_masking ( self , share_weights ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = testing_utils . get_v2_optimizer ( ' adam ' ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> y = np . array ( [ [ [ 1 ] , [ 1 ] ] , [ [ 1 ] , [ 1 ] ] ] ) <nl> loss = model . train_on_batch ( x , y ) <nl> self . assertEqual ( float ( loss ) , 0 . ) <nl> def test_optimizer_dependency ( self ) : <nl> model . compile ( <nl> optimizer = opt , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> model . fit ( <nl> x = np . array ( [ [ 1 . , 2 . , 3 . , 4 . ] ] ) , <nl> def test_model_backend_float64_use_cases ( self ) : <nl> model . compile ( <nl> testing_utils . get_v2_optimizer ( ' rmsprop ' ) , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> keras . backend . set_floatx ( floatx ) <nl> <nl> def test_clone_and_build_non_compiled_model ( self ) : <nl> new_model . compile ( <nl> testing_utils . get_v2_optimizer ( ' rmsprop ' ) , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> new_model . train_on_batch ( inp , out ) <nl> <nl> # Create new tensors for inputs . <nl> def test_clone_and_build_non_compiled_model ( self ) : <nl> new_model . compile ( <nl> testing_utils . get_v2_optimizer ( ' rmsprop ' ) , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> new_model . train_on_batch ( inp , out ) <nl> <nl> def _assert_same_compile_params ( self , model ) : <nl> def test_clone_and_build_compiled ( self ) : <nl> testing_utils . get_v2_optimizer ( ' rmsprop ' ) , <nl> ' mse ' , <nl> metrics = [ ' acc ' , metrics . categorical_accuracy ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> self . _clone_and_build_test_helper ( model , testing_utils . get_model_type ( ) ) <nl> <nl> def test_clone_and_build_sequential_without_inputs_defined ( self ) : <nl> testing_utils . get_v2_optimizer ( ' rmsprop ' ) , <nl> ' mse ' , <nl> metrics = [ ' acc ' , metrics . categorical_accuracy ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> self . _clone_and_build_test_helper ( model , ' sequential ' ) <nl> <nl> inp = np . random . random ( ( 10 , 4 ) ) <nl> def assert_optimizer_iterations_increases ( self , optimizer ) : <nl> optimizer , <nl> ' mse ' , <nl> metrics = [ ' acc ' , metrics . categorical_accuracy ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> global_step = keras . backend . variable ( 123 , dtype = dtypes . int64 ) <nl> clone_model = models . clone_and_build_model ( <nl> mmm a / tensorflow / python / keras / optimizer_v2 / optimizer_v2_test . py <nl> ppp b / tensorflow / python / keras / optimizer_v2 / optimizer_v2_test . py <nl> def testAggregationFalse ( self ) : <nl> @ keras_parameterized . run_all_keras_modes <nl> class OptimizersCompatibilityTest ( keras_parameterized . TestCase ) : <nl> <nl> - # After experimental_run_tf_function is turned on , optimizer v1 can no longer <nl> - # work in eager mode , skipping the test if so . <nl> def _testOptimizersCompatibility ( self , opt_v1 , opt_v2 , test_weights = True ) : <nl> - if testing_utils . should_run_tf_function ( ) or context . executing_eagerly ( ) : <nl> + if context . executing_eagerly ( ) : <nl> self . skipTest ( <nl> - ' v1 optimizer does not run in experimental_run_tf_function mode or ' <nl> - ' eager mode ' ) <nl> + ' v1 optimizer does not run in eager mode ' ) <nl> np . random . seed ( 1331 ) <nl> with test_util . use_gpu ( ) : <nl> train_samples = 20 <nl> def _testOptimizersCompatibility ( self , opt_v1 , opt_v2 , test_weights = True ) : <nl> opt_v1 , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model_v1 . fit ( x , y , batch_size = 5 , epochs = 1 ) <nl> <nl> model_v2 = testing_utils . get_small_sequential_mlp ( <nl> def _testOptimizersCompatibility ( self , opt_v1 , opt_v2 , test_weights = True ) : <nl> opt_v2 , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model_v2 . _make_train_function ( ) <nl> if test_weights : <nl> opt_v2 . set_weights ( opt_v1 . get_weights ( ) ) <nl> def testSGDCompatibility ( self ) : <nl> self . _testOptimizersCompatibility ( opt_v1 , opt_v2 , False ) <nl> <nl> def testNumericEquivalenceForNesterovMomentum ( self ) : <nl> - if testing_utils . should_run_tf_function ( ) or context . executing_eagerly ( ) : <nl> + if context . executing_eagerly ( ) : <nl> self . skipTest ( <nl> - ' v1 optimizer does not run in experimental_run_tf_function mode or ' <nl> - ' eager mode ' ) <nl> + ' v1 optimizer does not run in eager mode ' ) <nl> np . random . seed ( 1331 ) <nl> with test_util . use_gpu ( ) : <nl> train_samples = 20 <nl> def testNumericEquivalenceForNesterovMomentum ( self ) : <nl> opt_k_v1 , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model_k_v2 . compile ( <nl> opt_k_v2 , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model_tf . compile ( <nl> opt_tf , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> hist_k_v1 = model_k_v1 . fit ( x , y , batch_size = 5 , epochs = 10 , shuffle = False ) <nl> hist_k_v2 = model_k_v2 . fit ( x , y , batch_size = 5 , epochs = 10 , shuffle = False ) <nl> def testNumericEquivalenceForNesterovMomentum ( self ) : <nl> <nl> def testNumericEquivalenceForAmsgrad ( self ) : <nl> self . skipTest ( ' b / 150382655 ' ) <nl> - if testing_utils . should_run_tf_function ( ) or context . executing_eagerly ( ) : <nl> + if context . executing_eagerly ( ) : <nl> self . skipTest ( <nl> - ' v1 optimizer does not run in experimental_run_tf_function mode or ' <nl> - ' eager mode ' ) <nl> + ' v1 optimizer does not run in eager mode ' ) <nl> np . random . seed ( 1331 ) <nl> with test_util . use_gpu ( ) : <nl> train_samples = 20 <nl> def testNumericEquivalenceForAmsgrad ( self ) : <nl> opt_k_v1 , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model_k_v2 . compile ( <nl> opt_k_v2 , <nl> loss = ' categorical_crossentropy ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> hist_k_v1 = model_k_v1 . fit ( x , y , batch_size = 5 , epochs = 10 , shuffle = False ) <nl> hist_k_v2 = model_k_v2 . fit ( x , y , batch_size = 5 , epochs = 10 , shuffle = False ) <nl> mmm a / tensorflow / python / keras / optimizers_test . py <nl> ppp b / tensorflow / python / keras / optimizers_test . py <nl> def _get_model ( input_dim , num_hidden , output_dim ) : <nl> @ keras_parameterized . run_all_keras_modes <nl> class KerasOptimizersTest ( keras_parameterized . TestCase ) : <nl> <nl> - # After experimental_run_tf_function is turned on , optimizer v1 can no longer <nl> - # work in eager mode , skipping the test if so . <nl> def _test_optimizer ( self , optimizer , target = 0 . 75 ) : <nl> - if testing_utils . should_run_tf_function ( ) or context . executing_eagerly ( ) : <nl> + if context . executing_eagerly ( ) : <nl> self . skipTest ( <nl> - ' v1 optimizer does not run in experimental_run_tf_function mode or ' <nl> - ' eager mode ' ) <nl> + ' v1 optimizer does not run in eager mode ' ) <nl> np . random . seed ( 1337 ) <nl> ( x_train , y_train ) , _ = testing_utils . get_test_data ( <nl> train_samples = 1000 , test_samples = 200 , input_shape = ( 10 , ) , num_classes = 2 ) <nl> def _test_optimizer ( self , optimizer , target = 0 . 75 ) : <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = optimizer , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> np . testing . assert_equal ( <nl> keras . backend . get_value ( model . optimizer . iterations ) , 0 ) <nl> history = model . fit ( x_train , y_train , epochs = 2 , batch_size = 16 , verbose = 0 ) <nl> def _test_optimizer ( self , optimizer , target = 0 . 75 ) : <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = optimizer , <nl> metrics = [ ' accuracy ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> np . testing . assert_equal ( <nl> keras . backend . get_value ( model . optimizer . iterations ) , <nl> 126 ) # Using same optimizer from before <nl> def test_clipvalue ( self ) : <nl> keras . optimizers . SGD ( lr = 0 . 01 , momentum = 0 . 9 , clipvalue = 0 . 5 ) ) <nl> <nl> def test_tf_optimizer ( self ) : <nl> - if testing_utils . should_run_tf_function ( ) or context . executing_eagerly ( ) : <nl> + if context . executing_eagerly ( ) : <nl> self . skipTest ( <nl> - ' v1 optimizer does not run in experimental_run_tf_function mode or ' <nl> - ' eager mode ' ) <nl> + ' v1 optimizer does not run in eager mode ' ) <nl> optimizer = keras . optimizers . TFOptimizer ( AdamOptimizer ( 0 . 01 ) ) <nl> model = keras . models . Sequential ( ) <nl> model . add ( keras . layers . Dense ( <nl> def test_tf_optimizer ( self ) : <nl> model . compile ( <nl> loss = ' mean_squared_error ' , <nl> optimizer = optimizer , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> keras . backend . track_tf_optimizer ( optimizer ) <nl> model . fit ( np . random . random ( ( 5 , 3 ) ) , <nl> np . random . random ( ( 5 , 2 ) ) , <nl> def test_tf_optimizer ( self ) : <nl> optimizer . from_config ( None ) <nl> <nl> def test_optimizer_garbage_collection ( self ) : <nl> - if testing_utils . should_run_tf_function ( ) or context . executing_eagerly ( ) : <nl> + if context . executing_eagerly ( ) : <nl> self . skipTest ( <nl> - ' v1 optimizer does not run in experimental_run_tf_function mode or ' <nl> - ' eager mode ' ) <nl> + ' v1 optimizer does not run in eager mode ' ) <nl> graph = ops . Graph ( ) <nl> with graph . as_default ( ) : <nl> optimizer = keras . optimizers . TFOptimizer ( AdamOptimizer ( 0 . 01 ) ) <nl> def test_optimizer_garbage_collection ( self ) : <nl> self . assertIs ( optimizer_weak ( ) , None ) <nl> <nl> def test_tf_optimizer_iterations ( self ) : <nl> - if testing_utils . should_run_tf_function ( ) or context . executing_eagerly ( ) : <nl> + if context . executing_eagerly ( ) : <nl> self . skipTest ( <nl> - ' v1 optimizer does not run in experimental_run_tf_function mode or ' <nl> - ' eager mode ' ) <nl> + ' v1 optimizer does not run in eager mode ' ) <nl> with self . cached_session ( ) : <nl> optimizer = keras . optimizers . TFOptimizer ( AdamOptimizer ( 0 . 01 ) ) <nl> model = keras . models . Sequential ( ) <nl> def test_tf_optimizer_iterations ( self ) : <nl> model . compile ( <nl> loss = ' mean_squared_error ' , <nl> optimizer = optimizer , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> keras . backend . track_tf_optimizer ( optimizer ) <nl> self . assertEqual ( keras . backend . get_value ( model . optimizer . iterations ) , 0 ) <nl> <nl> mmm a / tensorflow / python / keras / premade / wide_deep_test . py <nl> ppp b / tensorflow / python / keras / premade / wide_deep_test . py <nl> def test_wide_deep_model ( self ) : <nl> optimizer = [ ' sgd ' , ' adam ' ] , <nl> loss = ' mse ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> wide_deep_model . fit ( inputs , output , epochs = 5 ) <nl> self . assertTrue ( wide_deep_model . built ) <nl> <nl> def test_wide_deep_model_backprop ( self ) : <nl> optimizer = [ linear_opt , dnn_opt ] , <nl> loss = ' mse ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> self . evaluate ( variables . global_variables_initializer ( ) ) <nl> wide_deep_model . fit ( inputs , output , epochs = 1 ) <nl> self . assertAllClose ( <nl> def test_wide_deep_model_with_single_input ( self ) : <nl> optimizer = [ ' sgd ' , ' adam ' ] , <nl> loss = ' mse ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> wide_deep_model . fit ( inputs , output , epochs = 5 ) <nl> <nl> def test_wide_deep_model_with_multi_outputs ( self ) : <nl> def test_wide_deep_model_with_single_optimizer ( self ) : <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> wide_deep_model . fit ( inputs , output , epochs = 5 ) <nl> self . assertTrue ( wide_deep_model . built ) <nl> <nl> def test_wide_deep_model_as_layer ( self ) : <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( [ linear_input_np , dnn_input_np , input_b_np ] , output_np , epochs = 5 ) <nl> <nl> def test_wide_deep_model_with_sub_model_trained ( self ) : <nl> def test_wide_deep_model_with_sub_model_trained ( self ) : <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> dnn_model . compile ( <nl> optimizer = ' adam ' , <nl> loss = ' mse ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> linear_model . fit ( linear_inp , output , epochs = 50 ) <nl> dnn_model . fit ( dnn_inp , output , epochs = 50 ) <nl> wide_deep_model . compile ( <nl> optimizer = [ ' sgd ' , ' adam ' ] , <nl> loss = ' mse ' , <nl> metrics = [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> wide_deep_model . fit ( inputs , output , epochs = 50 ) <nl> <nl> # This test is an example for cases where linear and dnn model accepts <nl> def test_wide_deep_model_with_single_feature_column ( self ) : <nl> combined . compile ( <nl> opt , <nl> ' mse ' , [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> combined . fit ( x = { ' symbol ' : data } , y = y , batch_size = 32 , epochs = 10 ) <nl> <nl> # This test is an example for cases where linear and dnn model accepts <nl> def test_wide_deep_model_with_two_feature_columns ( self ) : <nl> wide_deep_model . compile ( <nl> opt , <nl> ' mse ' , [ ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> wide_deep_model . fit ( x = { ' symbol ' : data } , y = y , batch_size = 32 , epochs = 10 ) <nl> <nl> def test_config ( self ) : <nl> mmm a / tensorflow / python / keras / regularizers_test . py <nl> ppp b / tensorflow / python / keras / regularizers_test . py <nl> def test_kernel_regularization ( self , regularizer ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> self . assertEqual ( len ( model . losses ) , 1 ) <nl> model . fit ( x_train , y_train , batch_size = 10 , epochs = 1 , verbose = 0 ) <nl> <nl> def test_activity_regularization ( self , regularizer ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> self . assertEqual ( len ( model . losses ) , 1 if context . executing_eagerly ( ) else 1 ) <nl> model . fit ( x_train , y_train , batch_size = 10 , epochs = 1 , verbose = 0 ) <nl> <nl> def test_zero_regularization ( self ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , batch_size = 5 , epochs = 1 ) <nl> <nl> def test_custom_regularizer_saving ( self ) : <nl> def test_regularization_shared_layer ( self , regularizer ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> self . assertLen ( model . losses , 5 ) <nl> <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_regularization_shared_model ( self , regularizer ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> self . assertLen ( model . losses , 6 ) <nl> <nl> @ keras_parameterized . run_all_keras_modes <nl> def test_regularization_shared_layer_in_different_models ( self , regularizer ) : <nl> model . compile ( <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # We expect to see 9 losses on the model : <nl> # - 2 from the 2 add_loss calls on the outer model . <nl> mmm a / tensorflow / python / keras / saving / losses_serialization_test . py <nl> ppp b / tensorflow / python / keras / saving / losses_serialization_test . py <nl> def test_serializing_model_with_loss_with_custom_object_scope ( self , value ) : <nl> model . compile ( <nl> optimizer_v2 . gradient_descent . SGD ( 0 . 1 ) , <nl> loss = value , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( [ self . x , self . x ] , [ self . y , self . y ] , <nl> batch_size = 3 , <nl> epochs = 3 , <nl> def test_serializing_model_with_loss_with_custom_objects ( self , value ) : <nl> model . compile ( <nl> optimizer_v2 . gradient_descent . SGD ( 0 . 1 ) , <nl> loss = value , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( [ self . x , self . x ] , [ self . y , self . y ] , <nl> batch_size = 3 , <nl> epochs = 3 , <nl> mmm a / tensorflow / python / keras / saving / metrics_serialization_test . py <nl> ppp b / tensorflow / python / keras / saving / metrics_serialization_test . py <nl> def get_instance ( x ) : <nl> ' mae ' , <nl> metrics = metric_input , <nl> weighted_metrics = weighted_metric_input , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( [ self . x , self . x ] , [ self . y , self . y ] , <nl> batch_size = 3 , <nl> epochs = 3 , <nl> def get_instance ( x ) : <nl> ' mae ' , <nl> metrics = metric_input , <nl> weighted_metrics = weighted_metric_input , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( [ self . x , self . x ] , [ self . y , self . y ] , <nl> batch_size = 3 , <nl> epochs = 3 , <nl> mmm a / tensorflow / python / keras / saving / saving_utils_test . py <nl> ppp b / tensorflow / python / keras / saving / saving_utils_test . py <nl> def test_trace_model_outputs_after_fitting ( self ) : <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( <nl> x = np . random . random ( ( 8 , 5 ) ) . astype ( np . float32 ) , <nl> y = np . random . random ( ( 8 , 3 ) ) . astype ( np . float32 ) , <nl> def test_trace_multi_io_model_outputs ( self ) : <nl> model . compile ( <nl> optimizer = ' sgd ' , <nl> loss = ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x = [ np . random . random ( ( 8 , input_dim ) ) . astype ( np . float32 ) , <nl> np . random . random ( ( 8 , input_dim ) ) . astype ( np . float32 ) ] , <nl> y = [ np . random . random ( ( 8 , num_classes ) ) . astype ( np . float32 ) , <nl> mmm a / tensorflow / python / keras / tests / add_loss_correctness_test . py <nl> ppp b / tensorflow / python / keras / tests / add_loss_correctness_test . py <nl> def test_loss_on_model_fit ( self ) : <nl> model . add_loss ( math_ops . reduce_mean ( mae ( targets , outputs ) ) ) <nl> model . compile ( <nl> optimizer_v2 . gradient_descent . SGD ( 0 . 05 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> history = model . fit ( [ self . x , self . y ] , batch_size = 3 , epochs = 5 ) <nl> self . assertAllClose ( history . history [ ' loss ' ] , [ 2 . , 1 . 8 , 1 . 6 , 1 . 4 , 1 . 2 ] , 1e - 3 ) <nl> def callable_loss ( ) : <nl> model . add_loss ( callable_loss ) <nl> model . compile ( <nl> optimizer_v2 . gradient_descent . SGD ( 0 . 1 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> history = model . fit ( self . x , batch_size = 3 , epochs = 5 ) <nl> self . assertAllClose ( history . history [ ' loss ' ] , [ 0 . , - . 1 , - . 2 , - . 3 , - . 4 ] , 1e - 3 ) <nl> def test_loss_with_sample_weight_on_model_fit ( self ) : <nl> model . add_loss ( 3 * math_ops . reduce_mean ( sw * mae ( targets , outputs ) ) ) <nl> model . compile ( <nl> optimizer_v2 . gradient_descent . SGD ( 0 . 025 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> history = model . fit ( [ self . x , self . y , self . w ] , batch_size = 3 , epochs = 5 ) <nl> self . assertAllClose ( history . history [ ' loss ' ] , [ 4 . , 3 . 6 , 3 . 2 , 2 . 8 , 2 . 4 ] , 1e - 3 ) <nl> def call ( self , inputs ) : <nl> model . predict ( [ self . x , self . y , self . w ] ) <nl> model . compile ( <nl> optimizer_v2 . gradient_descent . SGD ( 0 . 05 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> history = model . fit ( [ self . x , self . y , self . w ] , batch_size = 3 , epochs = 5 ) <nl> self . assertEqual ( len ( model . losses ) , 2 ) <nl> def call ( self , inputs ) : <nl> model . predict ( [ self . x , self . y , self . w ] ) <nl> model . compile ( <nl> optimizer_v2 . gradient_descent . SGD ( 0 . 05 ) , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> history = model . fit ( [ self . x , self . y , self . w ] , batch_size = 3 , epochs = 5 ) <nl> self . assertAllClose ( history . history [ ' loss ' ] , [ 2 . , 1 . 8 , 1 . 6 , 1 . 4 , 1 . 2 ] , 1e - 3 ) <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> loss = model . train_on_batch ( np . ones ( ( 2 , 3 ) ) , np . ones ( ( 2 , 3 ) ) ) <nl> self . assertEqual ( loss , 2 * 3 ) <nl> <nl> def test_activity_regularizer ( self ) : <nl> model . compile ( <nl> optimizer , <nl> ' binary_crossentropy ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x , y , batch_size = 2 , epochs = 5 ) <nl> loss [ reg ] = model . evaluate ( x , y ) <nl> self . assertLess ( loss [ None ] , loss [ ' l2 ' ] ) <nl> def test_activity_regularizer_loss_value ( self ) : <nl> optimizer = RMSPropOptimizer ( learning_rate = 0 . 001 ) <nl> model . compile ( <nl> optimizer , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> loss = model . test_on_batch ( x ) <nl> self . assertAlmostEqual ( 0 . 01 , loss , places = 4 ) <nl> <nl> def test_activity_regularizer_batch_independent ( self ) : <nl> optimizer = RMSPropOptimizer ( learning_rate = 0 . 001 ) <nl> model . compile ( <nl> optimizer , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> loss_small_batch = model . test_on_batch ( np . ones ( ( 10 , 10 ) , ' float32 ' ) ) <nl> loss_big_batch = model . test_on_batch ( np . ones ( ( 20 , 10 ) , ' float32 ' ) ) <nl> mmm a / tensorflow / python / keras / tests / integration_test . py <nl> ppp b / tensorflow / python / keras / tests / integration_test . py <nl> def test_vector_classification ( self ) : <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = keras . optimizer_v2 . adam . Adam ( 0 . 005 ) , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( x_train , y_train , epochs = 10 , batch_size = 10 , <nl> validation_data = ( x_train , y_train ) , <nl> verbose = 2 ) <nl> def test_vector_classification_shared_model ( self ) : <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = keras . optimizer_v2 . adam . Adam ( 0 . 005 ) , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> if not testing_utils . should_run_eagerly ( ) : <nl> self . assertEqual ( len ( model . get_losses_for ( None ) ) , 2 ) <nl> self . assertEqual ( len ( model . get_updates_for ( x ) ) , 2 ) <nl> def test_sequential_save_and_pop ( self ) : <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = keras . optimizer_v2 . adam . Adam ( 0 . 005 ) , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x_train , y_train , epochs = 1 , batch_size = 10 , <nl> validation_data = ( x_train , y_train ) , <nl> verbose = 2 ) <nl> def test_sequential_save_and_pop ( self ) : <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = keras . optimizer_v2 . adam . Adam ( 0 . 005 ) , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( x_train , y_train , epochs = 10 , batch_size = 10 , <nl> validation_data = ( x_train , y_train ) , <nl> verbose = 2 ) <nl> def test_timeseries_classification ( self ) : <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = keras . optimizer_v2 . adam . Adam ( 0 . 005 ) , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( x_train , y_train , epochs = 15 , batch_size = 10 , <nl> validation_data = ( x_train , y_train ) , <nl> verbose = 2 ) <nl> def test_timeseries_classification_sequential_tf_rnn ( self ) : <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = keras . optimizer_v2 . adam . Adam ( 0 . 005 ) , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> history = model . fit ( x_train , y_train , epochs = 15 , batch_size = 10 , <nl> validation_data = ( x_train , y_train ) , <nl> def test_image_classification ( self ) : <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = keras . optimizer_v2 . adam . Adam ( 0 . 005 ) , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> history = model . fit ( x_train , y_train , epochs = 10 , batch_size = 10 , <nl> validation_data = ( x_train , y_train ) , <nl> verbose = 2 ) <nl> def test_serialization_v2_model ( self ) : <nl> loss = ' categorical_crossentropy ' , <nl> optimizer = keras . optimizer_v2 . adam . Adam ( 0 . 005 ) , <nl> metrics = [ ' accuracy ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( x_train , y_train , epochs = 2 , batch_size = 10 , <nl> validation_data = ( x_train , y_train ) , <nl> verbose = 2 ) <nl> mmm a / tensorflow / python / keras / tests / model_subclassing_compiled_test . py <nl> ppp b / tensorflow / python / keras / tests / model_subclassing_compiled_test . py <nl> def test_single_io_workflow_with_np_arrays ( self ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ ' acc ' , keras . metrics . CategoricalAccuracy ( ) ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( ( num_samples , input_dim ) ) <nl> y = np . zeros ( ( num_samples , num_classes ) ) <nl> def test_multi_io_workflow_with_np_arrays ( self ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x1 = np . ones ( ( num_samples , input_dim ) ) <nl> x2 = np . ones ( ( num_samples , input_dim ) ) <nl> def test_single_io_workflow_with_datasets ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( ( num_samples , input_dim ) , dtype = np . float32 ) <nl> y = np . zeros ( ( num_samples , num_classes ) , dtype = np . float32 ) <nl> def test_attributes ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( [ x1 , x2 ] , [ y1 , y2 ] ) <nl> <nl> self . assertEqual ( model . built , True ) <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> y_ref = model . predict ( x ) <nl> <nl> model . train_on_batch ( x , y ) <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> loss = model . train_on_batch ( x , y ) <nl> self . assertGreater ( loss , 0 . 1 ) <nl> <nl> def test_training_methods ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( [ x1 , x2 ] , [ y1 , y2 ] , epochs = 2 , batch_size = 32 , verbose = 0 ) <nl> model . fit ( { ' input_1 ' : x1 , ' input_2 ' : x2 } , <nl> { ' output_1 ' : y1 , ' output_2 ' : y2 } , <nl> def test_training_methods ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . train_on_batch ( [ x1 , x2 ] , [ y1 , y2 ] ) <nl> model . train_on_batch ( { ' input_1 ' : x1 , ' input_2 ' : x2 } , <nl> { ' output_1 ' : y1 , ' output_2 ' : y2 } ) <nl> def test_inference_methods ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . evaluate ( [ x1 , x2 ] , [ y1 , y2 ] ) <nl> model . test_on_batch ( [ x1 , x2 ] , [ y1 , y2 ] ) <nl> <nl> def test_saving ( self ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( [ x1 , x2 ] , [ y1 , y2 ] , epochs = 2 , batch_size = 32 , verbose = 0 ) <nl> y_ref_1 , y_ref_2 = model . predict ( [ x1 , x2 ] ) <nl> <nl> def test_subclass_nested_in_subclass ( self ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( ( num_samples , input_dim ) ) <nl> y = np . zeros ( ( num_samples , num_classes ) ) <nl> def test_graph_nested_in_subclass ( self ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( ( num_samples , input_dim ) ) <nl> y = np . zeros ( ( num_samples , num_classes ) ) <nl> def test_subclass_nested_in_graph ( self ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( ( num_samples , input_dim ) ) <nl> y = np . zeros ( ( num_samples , num_classes ) ) <nl> def call ( self , inputs ) : <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> metrics = [ ' acc ' ] , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> x = np . ones ( ( num_samples , input_dim ) ) <nl> y = np . zeros ( ( num_samples , num_classes ) ) <nl> def call ( self , inputs , training = False ) : <nl> model . compile ( <nl> loss = ' mse ' , <nl> optimizer = ' rmsprop ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> loss = model . train_on_batch ( x , y ) <nl> self . assertGreater ( loss , 0 . 1 ) <nl> <nl> mmm a / tensorflow / python / keras / tests / model_subclassing_test . py <nl> ppp b / tensorflow / python / keras / tests / model_subclassing_test . py <nl> def call ( self , inputs ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> model . fit ( np . ones ( ( 10 , 10 ) ) , np . ones ( ( 10 , 1 ) ) , batch_size = 2 , epochs = 2 ) <nl> self . assertLen ( model . layers , 2 ) <nl> self . assertLen ( model . trainable_variables , 4 ) <nl> def call ( self , x ) : <nl> model . compile ( <nl> ' sgd ' , <nl> ' mse ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> data = dataset_ops . DatasetV2 . from_tensor_slices ( ( { <nl> ' a ' : np . ones ( ( 32 , 10 ) ) , <nl> mmm a / tensorflow / python / keras / tests / temporal_sample_weights_correctness_test . py <nl> ppp b / tensorflow / python / keras / tests / temporal_sample_weights_correctness_test . py <nl> def get_compiled_multi_io_model_temporal ( sample_weight_mode ) : <nl> metrics = [ metrics . MeanAbsoluteError ( name = ' mae ' ) ] , <nl> weighted_metrics = [ metrics . MeanAbsoluteError ( name = ' mae_2 ' ) ] , <nl> sample_weight_mode = sample_weight_mode , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> return model <nl> <nl> <nl> mmm a / tensorflow / python / keras / utils / composite_tensor_support_test . py <nl> ppp b / tensorflow / python / keras / utils / composite_tensor_support_test . py <nl> def get_model_from_layers_with_input ( layers , <nl> <nl> def get_test_mode_kwargs ( ) : <nl> run_eagerly = testing_utils . should_run_eagerly ( ) <nl> - # Certain things weren ' t supported correctly in the old path , therefore <nl> - # with these changes , some tests now only pass in the single code path in V2 . <nl> - if run_eagerly or context . executing_eagerly ( ) : <nl> - experimental_run_tf_function = True <nl> - else : <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> return { <nl> " run_eagerly " : run_eagerly , <nl> - " experimental_run_tf_function " : experimental_run_tf_function <nl> } <nl> <nl> <nl> def test_ragged_tensor_outputs ( self ) : <nl> # converts the ragged tensor back to a dense tensor . <nl> layers = [ ToRagged ( padding = 0 ) ] <nl> model = testing_utils . get_model_from_layers ( layers , input_shape = ( None , ) ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> <nl> # Define some input data with additional padding . <nl> def test_ragged_tensor_rebatched_outputs ( self ) : <nl> # converts the ragged tensor back to a dense tensor . <nl> layers = [ ToRagged ( padding = 0 ) ] <nl> model = testing_utils . get_model_from_layers ( layers , input_shape = ( None , ) ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> <nl> # Define some input data with additional padding . <nl> def test_sparse_tensor_outputs ( self ) : <nl> # converts the ragged tensor back to a dense tensor . <nl> layers = [ ToSparse ( ) ] <nl> model = testing_utils . get_model_from_layers ( layers , input_shape = ( None , ) ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> <nl> # Define some input data with additional padding . <nl> def test_sparse_tensor_rebatched_outputs ( self ) : <nl> # converts the ragged tensor back to a dense tensor . <nl> layers = [ ToSparse ( ) ] <nl> model = testing_utils . get_model_from_layers ( layers , input_shape = ( None , ) ) <nl> - model . _experimental_run_tf_function = testing_utils . should_run_tf_function ( ) <nl> model . _run_eagerly = testing_utils . should_run_eagerly ( ) <nl> <nl> # Define some input data with additional padding . <nl> def test_sparse_scipy_eval_inputs ( self ) : <nl> model . compile ( <nl> optimizer = " sgd " , <nl> loss = " mse " , <nl> - metrics = [ " accuracy " ] , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + metrics = [ " accuracy " ] ) <nl> <nl> input_data = scipy . sparse . coo_matrix ( ( [ 1 , 2 , 3 ] , ( [ 0 , 1 , 1 ] , [ 0 , 0 , 1 ] ) ) , <nl> shape = [ 2 , 3 ] ) <nl> def test_sparse_scipy_eval_input_dicts ( self ) : <nl> model . compile ( <nl> optimizer = " sgd " , <nl> loss = " mse " , <nl> - metrics = [ " accuracy " ] , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + metrics = [ " accuracy " ] ) <nl> <nl> input_data = { <nl> input_name : <nl> mmm a / tensorflow / python / keras / utils / io_utils_test . py <nl> ppp b / tensorflow / python / keras / utils / io_utils_test . py <nl> def test_HDF5Matrix ( self ) : <nl> model . compile ( <nl> loss = ' binary_crossentropy ' , <nl> optimizer = ' sgd ' , <nl> - run_eagerly = testing_utils . should_run_eagerly ( ) , <nl> - experimental_run_tf_function = testing_utils . should_run_tf_function ( ) ) <nl> + run_eagerly = testing_utils . should_run_eagerly ( ) ) <nl> <nl> # Note : you have to use shuffle = ' batch ' or False with HDF5Matrix <nl> model . fit ( x_train , y_train , batch_size = 32 , shuffle = ' batch ' , verbose = False ) <nl> mmm a / tensorflow / python / saved_model / load_test . py <nl> ppp b / tensorflow / python / saved_model / load_test . py <nl> def test_dense_features_layer_fit ( self , cycles ) : <nl> [ feature_column_lib . DenseFeatures ( columns ) , <nl> core . Dense ( 1 ) ] ) <nl> model_input = { " x " : constant_op . constant ( [ [ 1 . ] ] ) } <nl> - model . compile ( optimizer = " adam " , loss = " mse " , run_eagerly = True , <nl> - experimental_run_tf_function = True ) <nl> + model . compile ( optimizer = " adam " , loss = " mse " , run_eagerly = True ) <nl> model . fit ( model_input , constant_op . constant ( [ [ 3 . ] ] ) ) <nl> loaded = cycle ( model , cycles ) <nl> loaded . _default_save_signature ( model_input ) <nl>
|
Remove passing experimental_run_tf_function in most tests .
|
tensorflow/tensorflow
|
b7014702fde795b37a7d1d98c98086c60abf7a65
|
2020-02-27T21:34:09Z
|
mmm a / osquery / database / plugins / rocksdb . cpp <nl> ppp b / osquery / database / plugins / rocksdb . cpp <nl> Status RocksDBDatabasePlugin : : setUp ( ) { <nl> <nl> if ( ! initialized_ ) { <nl> initialized_ = true ; <nl> - options_ . OptimizeForSmallDb ( ) ; <nl> <nl> / / Set meta - data ( mostly ) handling options . <nl> options_ . create_if_missing = true ; <nl>
|
Fix rocksdb crash
|
osquery/osquery
|
a31d7582f411efffc6b0f1af422f8001ddf0cb2a
|
2018-12-07T16:00:46Z
|
mmm a / lib / Sema / TypeCheckDeclPrimary . cpp <nl> ppp b / lib / Sema / TypeCheckDeclPrimary . cpp <nl> Expr * DefaultArgumentExprRequest : : evaluate ( Evaluator & evaluator , <nl> <nl> / / Walk the checked initializer and contextualize any closures <nl> / / we saw there . <nl> - ( void ) TypeChecker : : contextualizeInitializer ( dc , initExpr ) ; <nl> + TypeChecker : : contextualizeInitializer ( dc , initExpr ) ; <nl> return initExpr ; <nl> } <nl> <nl> class DeclChecker : public DeclVisitor < DeclChecker > { <nl> if ( initContext ) { <nl> / / Check safety of error - handling in the declaration , too . <nl> TypeChecker : : checkInitializerErrorHandling ( initContext , init ) ; <nl> - ( void ) TypeChecker : : contextualizeInitializer ( initContext , init ) ; <nl> + TypeChecker : : contextualizeInitializer ( initContext , init ) ; <nl> } <nl> } <nl> } <nl> mmm a / lib / Sema / TypeCheckStmt . cpp <nl> ppp b / lib / Sema / TypeCheckStmt . cpp <nl> namespace { <nl> unsigned nextDiscriminator = 0 ) <nl> : ParentDC ( parent ) , NextDiscriminator ( nextDiscriminator ) { } <nl> <nl> - bool hasAutoClosures ( ) const { <nl> - return NextDiscriminator ! = 0 ; <nl> - } <nl> - <nl> std : : pair < bool , Expr * > walkToExprPre ( Expr * E ) override { <nl> / / Autoclosures need to be numbered and potentially reparented . <nl> / / Reparenting is required with : <nl> namespace { <nl> } ; <nl> } / / end anonymous namespace <nl> <nl> - static void setAutoClosureDiscriminators ( DeclContext * DC , Stmt * S ) { <nl> - S - > walk ( ContextualizeClosures ( DC ) ) ; <nl> - } <nl> - <nl> - bool TypeChecker : : contextualizeInitializer ( Initializer * DC , Expr * E ) { <nl> + void TypeChecker : : contextualizeInitializer ( Initializer * DC , Expr * E ) { <nl> ContextualizeClosures CC ( DC ) ; <nl> E - > walk ( CC ) ; <nl> - return CC . hasAutoClosures ( ) ; <nl> } <nl> <nl> void TypeChecker : : contextualizeTopLevelCode ( TopLevelCodeDecl * TLCD ) { <nl> class StmtChecker : public StmtVisitor < StmtChecker , Stmt * > { <nl> / / / Type - check an entire function body . <nl> bool typeCheckBody ( BraceStmt * & S ) { <nl> bool HadError = typeCheckStmt ( S ) ; <nl> - setAutoClosureDiscriminators ( DC , S ) ; <nl> + S - > walk ( ContextualizeClosures ( DC ) ) ; <nl> return HadError ; <nl> } <nl> <nl> mmm a / lib / Sema / TypeChecker . h <nl> ppp b / lib / Sema / TypeChecker . h <nl> void checkPatternBindingCaptures ( IterableDeclContext * DC ) ; <nl> <nl> / / / Change the context of closures in the given initializer <nl> / / / expression to the given context . <nl> - / / / <nl> - / / / \ returns true if any closures were found <nl> - bool contextualizeInitializer ( Initializer * DC , Expr * init ) ; <nl> + void contextualizeInitializer ( Initializer * DC , Expr * init ) ; <nl> void contextualizeTopLevelCode ( TopLevelCodeDecl * TLCD ) ; <nl> <nl> / / / Retrieve the default type for the given protocol . <nl>
|
Sema : Return value of TypeChecker : : contextualizeInitializer ( ) was unused
|
apple/swift
|
391fc45559fa8c8e2a5e7a42408da17a34c089a5
|
2020-04-01T19:08:12Z
|
mmm a / programs / local / LocalServer . cpp <nl> ppp b / programs / local / LocalServer . cpp <nl> void LocalServer : : processQueries ( ) <nl> if ( ! parse_res . second ) <nl> throw Exception ( " Cannot parse and execute the following part of query : " + String ( parse_res . first ) , ErrorCodes : : SYNTAX_ERROR ) ; <nl> <nl> - context - > makeSessionContext ( ) ; <nl> - context - > makeQueryContext ( ) ; <nl> + / / / we can ' t mutate global context ( due to possible races ) , so we can ' t reuse it safely as a query context <nl> + / / / so we need a copy here <nl> + auto query_context = Context ( context ) ; <nl> <nl> - context - > setUser ( " default " , " " , Poco : : Net : : SocketAddress { } ) ; <nl> - context - > setCurrentQueryId ( " " ) ; <nl> + query_context - > makeSessionContext ( ) ; <nl> + query_context - > makeQueryContext ( ) ; <nl> + <nl> + query_context - > setUser ( " default " , " " , Poco : : Net : : SocketAddress { } ) ; <nl> + query_context - > setCurrentQueryId ( " " ) ; <nl> applyCmdSettings ( ) ; <nl> <nl> / / / Use the same query_id ( and thread group ) for all queries <nl> - CurrentThread : : QueryScope query_scope_holder ( * context ) ; <nl> + CurrentThread : : QueryScope query_scope_holder ( * query_context ) ; <nl> <nl> bool echo_queries = config ( ) . hasOption ( " echo " ) | | config ( ) . hasOption ( " verbose " ) ; <nl> std : : exception_ptr exception ; <nl> void LocalServer : : processQueries ( ) <nl> <nl> try <nl> { <nl> - executeQuery ( read_buf , write_buf , / * allow_into_outfile = * / true , * context , { } ) ; <nl> + executeQuery ( read_buf , write_buf , / * allow_into_outfile = * / true , * query_context , { } ) ; <nl> } <nl> catch ( . . . ) <nl> { <nl>
|
Attempt to fix the race
|
ClickHouse/ClickHouse
|
748ff404f94e46917c4231adc08fff59e66bfdc6
|
2020-10-21T18:36:01Z
|
mmm a / jstests / tool / dumprestoreWithNoOptions . js <nl> ppp b / jstests / tool / dumprestoreWithNoOptions . js <nl> t = new ToolTest ( " dumprestoreWithNoOptions " ) ; <nl> t . startDB ( " foo " ) ; <nl> db = t . db ; <nl> <nl> + / / We turn this off to prevent the server from touching the ' options ' field in system . namespaces . <nl> + / / This is important because we check exact values of the ' options ' field in this test . <nl> + db . adminCommand ( { setParameter : 1 , newCollectionsUsePowerOf2Sizes : false } ) ; <nl> + <nl> dbname = db . getName ( ) ; <nl> dbname2 = " NOT_ " + dbname ; <nl> <nl> t . runTool ( " restore " , " - - dir " , t . ext , " - - noOptionsRestore " ) ; <nl> <nl> assert . eq ( 1 , db . capped . count ( ) , " wrong number of docs restored to capped " ) ; <nl> assert ( true ! = = db . capped . stats ( ) . capped , " restore options were not ignored " ) ; <nl> - assert ( undefined = = = db . capped . exists ( ) . options , <nl> + assert . eq ( undefined , db . capped . exists ( ) . options , <nl> " restore options not ignored : " + tojson ( db . capped . exists ( ) ) ) ; <nl> <nl> / / Dump / restore single DB <nl>
|
SERVER - 13680 Fix failing test
|
mongodb/mongo
|
6d255ac0173267dca1131d9d1871ee52214bc93c
|
2014-04-29T15:11:16Z
|
mmm a / python / caffe / pycaffe . cpp <nl> ppp b / python / caffe / pycaffe . cpp <nl> <nl> # include < numpy / arrayobject . h > <nl> # include " caffe / caffe . hpp " <nl> <nl> - / / Temporary solution for numpy < 1 . 7 versions : old macro . <nl> + / / Temporary solution for numpy < 1 . 7 versions : old macro , no promises . <nl> + / / You ' re strongly advised to upgrade to > = 1 . 7 . <nl> # ifndef NPY_ARRAY_C_CONTIGUOUS <nl> # define NPY_ARRAY_C_CONTIGUOUS NPY_C_CONTIGUOUS <nl> + # define PyArray_SetBaseObject ( arr , x ) ( PyArray_BASE ( arr ) = ( x ) ) <nl> # endif <nl> <nl> <nl>
|
add macro for numpy < 1 . 7
|
BVLC/caffe
|
73c10a1ae12b8b1e328c19b8f6080cad3105e790
|
2014-02-14T23:33:00Z
|
mmm a / CHANGELOG <nl> ppp b / CHANGELOG <nl> <nl> cocos2d - x - 3 . 0rc0 Feb . ? ? 2014 <nl> [ All ] <nl> - [ NEW ] Adds more console commands : director resume | pause | stopanimation | startanimation . <nl> - [ NEW ] Adds Dutch Language support . <nl> + [ NEW ] Action : RotateBy supports 3D rotations <nl> + [ NEW ] Bindings : Using python to automatically generate script bindings <nl> + [ NEW ] Bindings : Added JS bindings support for Linux <nl> [ NEW ] Console : Added ' resolution ' , ' projection ' commands . Improved API <nl> + [ NEW ] Console : Added more commands : director resume | pause | stopanimation | startanimation . <nl> [ NEW ] Director : Displays ' Vertices drawn ' in the stats . Useful to measure performance . <nl> - [ NEW ] Using python to automatically generate script bindings codes . <nl> - [ NEW ] Linux javascript bindings support . <nl> - <nl> + [ NEW ] Node : Added set / get Position3D ( ) and set / get Rotation3D ( ) <nl> + Node : Calculates rotation X and Y correctly . <nl> + Node : set / get VertexZ ( ) - > set / get PositionZ ( ) <nl> + Node : setRotationX ( ) - > setRotationSkewX ( ) <nl> + Node : setRotationY ( ) - > setRotationSkewY ( ) <nl> + [ NEW ] Language : Added Dutch support . <nl> + [ NEW ] Sprite : Added auto - culling support <nl> + <nl> [ FIX ] Character would not be aligned on the baseline when label using distance field . <nl> [ FIX ] Adds a macro to disable inserting script binding relevant codes . <nl> [ FIX ] Removing child from TMXLayer may cause crash . <nl> mmm a / cocos / 2d / CCDirector . cpp <nl> ppp b / cocos / 2d / CCDirector . cpp <nl> void Director : : setProjection ( Projection projection ) <nl> <nl> / / issue # 1334 <nl> kmMat4PerspectiveProjection ( & matrixPerspective , 60 , ( GLfloat ) size . width / size . height , 10 , zeye + size . height / 2 ) ; <nl> - / / kmMat4PerspectiveProjection ( & matrixPerspective , 60 , ( GLfloat ) size . width / size . height , 0 . 1f , 1500 ) ; <nl> + / / kmMat4PerspectiveProjection ( & matrixPerspective , 60 , ( GLfloat ) size . width / size . height , 0 . 1f , 1500 ) ; <nl> <nl> kmGLMultMatrix ( & matrixPerspective ) ; <nl> <nl> - kmGLMatrixMode ( KM_GL_MODELVIEW ) ; <nl> - kmGLLoadIdentity ( ) ; <nl> kmVec3 eye , center , up ; <nl> kmVec3Fill ( & eye , size . width / 2 , size . height / 2 , zeye ) ; <nl> kmVec3Fill ( & center , size . width / 2 , size . height / 2 , 0 . 0f ) ; <nl> kmVec3Fill ( & up , 0 . 0f , 1 . 0f , 0 . 0f ) ; <nl> kmMat4LookAt ( & matrixLookup , & eye , & center , & up ) ; <nl> kmGLMultMatrix ( & matrixLookup ) ; <nl> + <nl> + kmGLMatrixMode ( KM_GL_MODELVIEW ) ; <nl> + kmGLLoadIdentity ( ) ; <nl> break ; <nl> } <nl> <nl> mmm a / cocos / 2d / CCNode . h <nl> ppp b / cocos / 2d / CCNode . h <nl> class CC_DLL Node : public Ref <nl> virtual void setPositionY ( float y ) ; <nl> virtual float getPositionY ( void ) const ; <nl> <nl> + / * * <nl> + * Sets the X , Y , and Z axis position <nl> + * / <nl> virtual void setPosition3D ( const Vertex3F & position ) ; <nl> + / * * <nl> + * returns the X , Y and Z axis position <nl> + * / <nl> virtual Vertex3F getPosition3D ( ) const ; <nl> + <nl> / * * <nl> * Sets the ' z ' axis in the position . It is the OpenGL Z vertex value . <nl> * <nl> class CC_DLL Node : public Ref <nl> / * * <nl> * Changes the X skew angle of the node in degrees . <nl> * <nl> + * The difference between ` setRotationalSkew ( ) ` and ` setSkew ( ) ` is that the first one simulate Flash ' s skew functionality <nl> + * while the second one uses the real skew funciton . <nl> + * <nl> * This angle describes the shear distortion in the X direction . <nl> * Thus , it is the angle between the Y axis and the left edge of the shape <nl> * The default skewX angle is 0 . Positive values distort the node in a CW direction . <nl> * <nl> - * @ param fSkewX The X skew angle of the node in degrees . <nl> + * @ param skewX The X skew angle of the node in degrees . <nl> * / <nl> - virtual void setSkewX ( float fSkewX ) ; <nl> + virtual void setSkewX ( float skewX ) ; <nl> / * * <nl> * Returns the X skew angle of the node in degrees . <nl> * <nl> class CC_DLL Node : public Ref <nl> / * * <nl> * Changes the Y skew angle of the node in degrees . <nl> * <nl> + * The difference between ` setRotationalSkew ( ) ` and ` setSkew ( ) ` is that the first one simulate Flash ' s skew functionality <nl> + * while the second one uses the real skew funciton . <nl> + * <nl> * This angle describes the shear distortion in the Y direction . <nl> * Thus , it is the angle between the X axis and the bottom edge of the shape <nl> * The default skewY angle is 0 . Positive values distort the node in a CCW direction . <nl> * <nl> - * @ param fSkewY The Y skew angle of the node in degrees . <nl> + * @ param skewY The Y skew angle of the node in degrees . <nl> * / <nl> - virtual void setSkewY ( float fSkewY ) ; <nl> + virtual void setSkewY ( float skewY ) ; <nl> / * * <nl> * Returns the Y skew angle of the node in degrees . <nl> * <nl> class CC_DLL Node : public Ref <nl> * / <nl> virtual float getRotation ( ) const ; <nl> <nl> + / * * <nl> + * Sets the X , Y and Z axis rotation <nl> + * Useful for 3d rotations <nl> + * / <nl> virtual void setRotation3D ( const Vertex3F & rotation ) ; <nl> + / * * <nl> + * returns the X , Y and Z axis rotation <nl> + * / <nl> virtual Vertex3F getRotation3D ( ) const ; <nl> <nl> / * * <nl> * Sets the X rotation ( angle ) of the node in degrees which performs a horizontal rotational skew . <nl> * <nl> + * The difference between setRotationalSkew ( ) and setSkew ( ) is that the first one simulate Flash ' s skew functionality <nl> + * while the second one uses the real skew funciton . <nl> + * <nl> * 0 is the default rotation angle . <nl> * Positive values rotate node clockwise , and negative values for anti - clockwise . <nl> * <nl> class CC_DLL Node : public Ref <nl> / * * <nl> * Sets the Y rotation ( angle ) of the node in degrees which performs a vertical rotational skew . <nl> * <nl> + * The difference between setRotationalSkew ( ) and setSkew ( ) is that the first one simulate Flash ' s skew functionality <nl> + * while the second one uses the real skew funciton . <nl> + * <nl> * 0 is the default rotation angle . <nl> * Positive values rotate node clockwise , and negative values for anti - clockwise . <nl> * <nl> mmm a / cocos / 2d / CCSprite . cpp <nl> ppp b / cocos / 2d / CCSprite . cpp <nl> void Sprite : : updateTransform ( void ) <nl> Point ( _quad . tr . vertices . x , _quad . tr . vertices . y ) , <nl> Point ( _quad . tl . vertices . x , _quad . tl . vertices . y ) , <nl> } ; <nl> - ccDrawPoly ( vertices , 4 , true ) ; <nl> + DrawPrimitives : : drawPoly ( vertices , 4 , true ) ; <nl> # endif / / CC_SPRITE_DEBUG_DRAW <nl> } <nl> <nl> void Sprite : : draw ( void ) <nl> bool Sprite : : culling ( ) const <nl> { <nl> Size s = Director : : getInstance ( ) - > getWinSize ( ) ; <nl> - kmVec3 v3 = { _contentSize . width * 0 . 5f , _contentSize . height * 0 . 5f , 0 } ; <nl> - kmVec3Transform ( & v3 , & v3 , & _modelViewTransform ) ; <nl> + float hcsx = _contentSize . width * 0 . 5f ; <nl> + float hcsy = _contentSize . height * 0 . 5f ; <nl> <nl> - float cshw = _contentSize . width * fmaxf ( fabsf ( _modelViewTransform . mat [ 0 ] + _modelViewTransform . mat [ 4 ] ) , fabsf ( _modelViewTransform . mat [ 0 ] - _modelViewTransform . mat [ 4 ] ) ) ; <nl> - float cshh = _contentSize . height * fmaxf ( fabsf ( _modelViewTransform . mat [ 1 ] + _modelViewTransform . mat [ 5 ] ) , fabsf ( _modelViewTransform . mat [ 1 ] - _modelViewTransform . mat [ 5 ] ) ) ; <nl> + / / convert to world coordinates <nl> + float x = hcsx * _modelViewTransform . mat [ 0 ] + hcsy * _modelViewTransform . mat [ 4 ] + _modelViewTransform . mat [ 12 ] ; <nl> + float y = hcsx * _modelViewTransform . mat [ 1 ] + hcsy * _modelViewTransform . mat [ 5 ] + _modelViewTransform . mat [ 13 ] ; <nl> <nl> - return ( ( fabsf ( v3 . x ) - cshw ) < s . width / 2 & & ( fabsf ( v3 . y ) - cshh ) < s . height / 2 ) ; <nl> - } <nl> + / / center of screen is ( 0 , 0 ) <nl> + x - = s . width / 2 ; <nl> + y - = s . height / 2 ; <nl> <nl> + / / convert content size to world coordinates <nl> + float wchw = hcsx * fmaxf ( fabsf ( _modelViewTransform . mat [ 0 ] + _modelViewTransform . mat [ 4 ] ) , fabsf ( _modelViewTransform . mat [ 0 ] - _modelViewTransform . mat [ 4 ] ) ) ; <nl> + float wchh = hcsy * fmaxf ( fabsf ( _modelViewTransform . mat [ 1 ] + _modelViewTransform . mat [ 5 ] ) , fabsf ( _modelViewTransform . mat [ 1 ] - _modelViewTransform . mat [ 5 ] ) ) ; <nl> <nl> + float tmpx = ( fabsf ( x ) - wchw ) ; <nl> + float tmpy = ( fabsf ( y ) - wchh ) ; <nl> + return ( tmpx < s . width / 2 & & tmpy < s . height / 2 ) ; <nl> + } <nl> <nl> / / Node overrides <nl> - <nl> void Sprite : : addChild ( Node * child , int zOrder , int tag ) <nl> { <nl> CCASSERT ( child ! = nullptr , " Argument must be non - nullptr " ) ; <nl> void Sprite : : setRotation ( float rotation ) <nl> SET_DIRTY_RECURSIVELY ( ) ; <nl> } <nl> <nl> - void Sprite : : setRotationX ( float fRotationX ) <nl> + void Sprite : : setRotationSkewX ( float fRotationX ) <nl> { <nl> - Node : : setRotationX ( fRotationX ) ; <nl> + Node : : setRotationSkewX ( fRotationX ) ; <nl> SET_DIRTY_RECURSIVELY ( ) ; <nl> } <nl> <nl> - void Sprite : : setRotationY ( float fRotationY ) <nl> + void Sprite : : setRotationSkewY ( float fRotationY ) <nl> { <nl> - Node : : setRotationY ( fRotationY ) ; <nl> + Node : : setRotationSkewY ( fRotationY ) ; <nl> SET_DIRTY_RECURSIVELY ( ) ; <nl> } <nl> <nl> void Sprite : : setScale ( float scaleX , float scaleY ) <nl> SET_DIRTY_RECURSIVELY ( ) ; <nl> } <nl> <nl> - void Sprite : : setVertexZ ( float fVertexZ ) <nl> + void Sprite : : setPositionZ ( float fVertexZ ) <nl> { <nl> - Node : : setVertexZ ( fVertexZ ) ; <nl> + Node : : setPositionZ ( fVertexZ ) ; <nl> SET_DIRTY_RECURSIVELY ( ) ; <nl> } <nl> <nl> mmm a / cocos / 2d / CCSprite . h <nl> ppp b / cocos / 2d / CCSprite . h <nl> class CC_DLL Sprite : public Node , public TextureProtocol <nl> virtual void setPosition ( const Point & pos ) override ; <nl> virtual void setPosition ( float x , float y ) override ; <nl> virtual void setRotation ( float rotation ) override ; <nl> - virtual void setRotationX ( float rotationX ) override ; <nl> - virtual void setRotationY ( float rotationY ) override ; <nl> + virtual void setRotationSkewX ( float rotationX ) override ; <nl> + virtual void setRotationSkewY ( float rotationY ) override ; <nl> virtual void setSkewX ( float sx ) override ; <nl> virtual void setSkewY ( float sy ) override ; <nl> virtual void removeChild ( Node * child , bool cleanup ) override ; <nl> class CC_DLL Sprite : public Node , public TextureProtocol <nl> virtual void addChild ( Node * child , int zOrder , int tag ) override ; <nl> virtual void sortAllChildren ( ) override ; <nl> virtual void setScale ( float scale ) override ; <nl> - virtual void setVertexZ ( float vertexZ ) override ; <nl> + virtual void setPositionZ ( float positionZ ) override ; <nl> virtual void setAnchorPoint ( const Point & anchor ) override ; <nl> virtual void ignoreAnchorPointForPosition ( bool value ) override ; <nl> virtual void setVisible ( bool bVisible ) override ; <nl>
|
culling working for both 2d and 3d projections
|
cocos2d/cocos2d-x
|
04460750b894354c047eabdc8038cc95999cc626
|
2014-02-23T09:09:52Z
|
mmm a / tools / run_tests / artifact_targets . py <nl> ppp b / tools / run_tests / artifact_targets . py <nl> def build_jobspec ( self ) : <nl> if self . platform = = ' windows ' : <nl> raise Exception ( ' Not supported yet . ' ) <nl> else : <nl> + environ = { } <nl> if self . platform = = ' linux ' : <nl> - environ = { } <nl> if self . arch = = ' x86 ' : <nl> environ [ ' SETARCH_CMD ' ] = ' linux32 ' <nl> return create_docker_jobspec ( self . name , <nl> def build_jobspec ( self ) : <nl> ' tools / run_tests / build_artifact_python . sh ' , <nl> environ = environ ) <nl> else : <nl> + environ [ ' SKIP_PIP_INSTALL ' ] = ' TRUE ' <nl> return create_jobspec ( self . name , <nl> - [ ' tools / run_tests / build_artifact_python . sh ' ] ) <nl> + [ ' tools / run_tests / build_artifact_python . sh ' ] , <nl> + environ = environ ) <nl> <nl> def __str__ ( self ) : <nl> return self . name <nl> def targets ( ) : <nl> for arch in ( ' x86 ' , ' x64 ' ) ] + <nl> [ PythonArtifact ( ' linux ' , ' x86 ' ) , <nl> PythonArtifact ( ' linux ' , ' x64 ' ) , <nl> + PythonArtifact ( ' macos ' , ' x64 ' ) , <nl> RubyArtifact ( ' linux ' , ' x86 ' ) , <nl> RubyArtifact ( ' linux ' , ' x64 ' ) , <nl> RubyArtifact ( ' macos ' , ' x64 ' ) ] ) <nl> mmm a / tools / run_tests / build_artifact_python . sh <nl> ppp b / tools / run_tests / build_artifact_python . sh <nl> set - ex <nl> <nl> cd $ ( dirname $ 0 ) / . . / . . <nl> <nl> - pip install - - upgrade six <nl> - pip install - - upgrade setuptools <nl> - <nl> - pip install - rrequirements . txt <nl> + if [ " $ SKIP_PIP_INSTALL " = = " " ] <nl> + then <nl> + pip install - - upgrade six <nl> + pip install - - upgrade setuptools <nl> + pip install - rrequirements . txt <nl> + fi <nl> <nl> GRPC_PYTHON_BUILD_WITH_CYTHON = 1 $ { SETARCH_CMD } python setup . py \ <nl> bdist_wheel \ <nl> old mode 100644 <nl> new mode 100755 <nl>
|
Merge pull request from jtattermusch / python_mac_artifact
|
grpc/grpc
|
bf9ac1fcc78d2bf82165258463e08af481b939d7
|
2016-02-04T16:43:12Z
|
mmm a / V8 / v8 - line - editor . cpp <nl> ppp b / V8 / v8 - line - editor . cpp <nl> static char * * AttemptedCompletion ( char const * text , int start , int end ) { <nl> <nl> if ( result [ 0 ] [ n - 1 ] = = ' ) ' ) { <nl> result [ 0 ] [ n - 1 ] = ' \ 0 ' ; <nl> + <nl> + # if RL_READLINE_VERSION < 0x0500 <nl> rl_completion_suppress_append = 1 ; <nl> + # endif <nl> } <nl> } <nl> <nl>
|
readline
|
arangodb/arangodb
|
9a8565a19ac2aa68797c5e0fa239038aac4ec2c0
|
2012-03-13T15:21:38Z
|
mmm a / test / ParseableInterface / swift_build_sdk_interfaces / find - modules . test - sh <nl> ppp b / test / ParseableInterface / swift_build_sdk_interfaces / find - modules . test - sh <nl> RUN : % swift_build_sdk_interfaces - sdk % S / Inputs / mock - sdk / - v - n - o % t / output > % <nl> RUN : % FileCheck % s < % t . txt <nl> RUN : % FileCheck - check - prefix NEGATIVE % s < % t . txt <nl> <nl> - CHECK - DAG : System / Library / Frameworks / Simple . framework / Modules / Simple . swiftmodule / xyz . swiftinterface - o { { . + } } output / Simple . swiftmodule / xyz . swiftmodule <nl> - CHECK - DAG : usr / lib / swift / Flat . swiftinterface - o { { . + } } output / Flat . swiftmodule <nl> - CHECK - DAG : usr / lib / swift / Normal . swiftmodule / xyz . swiftinterface - o { { . + } } output / Normal . swiftmodule / xyz . swiftmodule <nl> - CHECK - DAG : System / iOSSupport / System / Library / Frameworks / Simple . framework / Modules / Simple . swiftmodule / xyzzy . swiftinterface - o { { . + } } output / Simple . swiftmodule / xyzzy . swiftmodule <nl> - CHECK - DAG : System / iOSSupport / usr / lib / swift / Caramel . swiftmodule / xyz . swiftinterface - o { { . + } } output / Caramel . swiftmodule / xyz . swiftmodule <nl> + CHECK - DAG : System / Library / Frameworks { { \ \ | / } } Simple . framework { { \ \ | / } } Modules { { \ \ | / } } Simple . swiftmodule { { \ \ | / } } xyz . swiftinterface - o { { . + } } output { { \ \ | / } } Simple . swiftmodule { { \ \ | / } } xyz . swiftmodule <nl> + CHECK - DAG : usr / lib / swift { { \ \ | / } } Flat . swiftinterface - o { { . + } } output { { \ \ | / } } Flat . swiftmodule <nl> + CHECK - DAG : usr / lib / swift { { \ \ | / } } Normal . swiftmodule { { \ \ | / } } xyz . swiftinterface - o { { . + } } output { { \ \ | / } } Normal . swiftmodule { { \ \ | / } } xyz . swiftmodule <nl> + CHECK - DAG : System / iOSSupport / System / Library / Frameworks { { \ \ | / } } Simple . framework { { \ \ | / } } Modules { { \ \ | / } } Simple . swiftmodule { { \ \ | / } } xyzzy . swiftinterface - o { { . + } } output { { \ \ | / } } Simple . swiftmodule { { \ \ | / } } xyzzy . swiftmodule <nl> + CHECK - DAG : System / iOSSupport / usr / lib / swift { { \ \ | / } } Caramel . swiftmodule { { \ \ | / } } xyz . swiftinterface - o { { . + } } output { { \ \ | / } } Caramel . swiftmodule { { \ \ | / } } xyz . swiftmodule <nl> <nl> NEGATIVE - NOT : BAD <nl> <nl> RUN : touch % t / sdk / usr / lib / swift / Swift . swiftmodule / def . swiftinterface <nl> RUN : % swift_build_sdk_interfaces - sdk % t / sdk - v - n - o % t / output | % FileCheck - check - prefix CHECK - WITH - STDLIB % s <nl> <nl> CHECK - WITH - STDLIB - NOT : . swiftinterface - o <nl> - CHECK - WITH - STDLIB : Swift . swiftmodule / { { abc | def } } . swiftinterface - o <nl> + CHECK - WITH - STDLIB : Swift . swiftmodule { { \ \ | / } } { { abc | def } } . swiftinterface - o <nl> CHECK - WITH - STDLIB - NOT : . swiftinterface - o <nl> - CHECK - WITH - STDLIB : Swift . swiftmodule / { { abc | def } } . swiftinterface - o <nl> + CHECK - WITH - STDLIB : Swift . swiftmodule { { \ \ | / } } { { abc | def } } . swiftinterface - o <nl> CHECK - WITH - STDLIB : . swiftinterface - o <nl> <nl> # . . . unless we pass - skip - stdlib . <nl> RUN : % swift_build_sdk_interfaces - sdk % S / Inputs / mock - sdk / - v - n - o % t / output Sys <nl> RUN : % FileCheck - check - prefix CHECK - CUSTOM - PATHS % s < % t . txt <nl> RUN : % FileCheck - check - prefix NEGATIVE - CUSTOM - PATHS % s < % t . txt <nl> <nl> - CHECK - CUSTOM - PATHS - DAG : System / Library / PrivateFrameworks / PrivateSimple . framework / Modules / PrivateSimple . swiftmodule / xyz . swiftinterface - o { { . + } } output / PrivateSimple . swiftmodule / xyz . swiftmodule <nl> - CHECK - CUSTOM - PATHS - DAG : usr / lib / swift / Flat . swiftinterface - o { { . + } } output / Flat . swiftmodule <nl> - CHECK - CUSTOM - PATHS - DAG : usr / lib / swift / Normal . swiftmodule / xyz . swiftinterface - o { { . + } } output / Normal . swiftmodule / xyz . swiftmodule <nl> - CHECK - CUSTOM - PATHS - DAG : System / iOSSupport / usr / lib / swift / Caramel . swiftmodule / xyz . swiftinterface - o { { . + } } output / Caramel . swiftmodule / xyz . swiftmodule <nl> + CHECK - CUSTOM - PATHS - DAG : System / Library / PrivateFrameworks { { \ \ | / } } PrivateSimple . framework { { \ \ | / } } Modules { { \ \ | / } } PrivateSimple . swiftmodule { { \ \ | / } } xyz . swiftinterface - o { { . + } } output { { \ \ | / } } PrivateSimple . swiftmodule { { \ \ | / } } xyz . swiftmodule <nl> + CHECK - CUSTOM - PATHS - DAG : usr / lib / swift { { \ \ | / } } Flat . swiftinterface - o { { . + } } output { { \ \ | / } } Flat . swiftmodule <nl> + CHECK - CUSTOM - PATHS - DAG : usr / lib / swift { { \ \ | / } } Normal . swiftmodule { { \ \ | / } } xyz . swiftinterface - o { { . + } } output { { \ \ | / } } Normal . swiftmodule { { \ \ | / } } xyz . swiftmodule <nl> + CHECK - CUSTOM - PATHS - DAG : System / iOSSupport / usr / lib / swift { { \ \ | / } } Caramel . swiftmodule { { \ \ | / } } xyz . swiftinterface - o { { . + } } output { { \ \ | / } } Caramel . swiftmodule { { \ \ | / } } xyz . swiftmodule <nl> NEGATIVE - CUSTOM - PATHS - NOT : System / Library / Frameworks / <nl> <nl> RUN : % swift_build_sdk_interfaces - sdk % S / Inputs / mock - sdk / - v - n - o % t / output System / Library / Frameworks System / Library / PrivateFrameworks > % t . txt <nl> RUN : % FileCheck - check - prefix CHECK - CUSTOM - PATHS - check - prefix CHECK - NORMAL - PATHS % s < % t . txt <nl> RUN : % FileCheck - check - prefix NEGATIVE % s < % t . txt <nl> <nl> - CHECK - NORMAL - PATHS - DAG : System / Library / Frameworks / Simple . framework / Modules / Simple . swiftmodule / xyz . swiftinterface - o { { . + } } output / Simple . swiftmodule / xyz . swiftmodule <nl> + CHECK - NORMAL - PATHS - DAG : System / Library / Frameworks { { \ \ | / } } Simple . framework { { \ \ | / } } Modules { { \ \ | / } } Simple . swiftmodule { { \ \ | / } } xyz . swiftinterface - o { { . + } } output { { \ \ | / } } Simple . swiftmodule { { \ \ | / } } xyz . swiftmodule <nl> mmm a / test / ParseableInterface / swift_build_sdk_interfaces / ignore - non - stdlib - failures . test - sh <nl> ppp b / test / ParseableInterface / swift_build_sdk_interfaces / ignore - non - stdlib - failures . test - sh <nl> <nl> RUN : not % swift_build_sdk_interfaces - sdk % S / Inputs / xfails - sdk / - v - o % t / output | % FileCheck % s <nl> <nl> - CHECK - DAG : # ( FAIL ) { { . + } } / Bad . swiftinterface <nl> - CHECK - DAG : # ( PASS ) { { . + } } / Good . swiftinterface <nl> + CHECK - DAG : # ( FAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> + CHECK - DAG : # ( PASS ) { { . + } } { { \ \ | / } } Good . swiftinterface <nl> <nl> RUN : % swift_build_sdk_interfaces - sdk % S / Inputs / xfails - sdk / - v - o % t / output - ignore - non - stdlib - failures | % FileCheck - check - prefix = CHECK - IGNORING - FAILURES % s <nl> <nl> - CHECK - IGNORING - FAILURES - DAG : # ( XFAIL ) { { . + } } / Bad . swiftinterface <nl> - CHECK - IGNORING - FAILURES - DAG : # ( UPASS ) { { . + } } / Good . swiftinterface <nl> + CHECK - IGNORING - FAILURES - DAG : # ( XFAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> + CHECK - IGNORING - FAILURES - DAG : # ( UPASS ) { { . + } } { { \ \ | / } } Good . swiftinterface <nl> <nl> RUN : not % swift_build_sdk_interfaces - sdk % S / Inputs / broken - stdlib - sdk / - v - o % t / output | % FileCheck - check - prefix CHECK - BROKEN - STDLIB % s <nl> RUN : not % swift_build_sdk_interfaces - sdk % S / Inputs / broken - stdlib - sdk / - v - o % t / output - ignore - non - stdlib - failures | % FileCheck - check - prefix CHECK - BROKEN - STDLIB % s <nl> <nl> - CHECK - BROKEN - STDLIB : # ( FAIL ) { { . + } } / Swift . swiftinterface <nl> + CHECK - BROKEN - STDLIB : # ( FAIL ) { { . + } } { { \ \ | / } } Swift . swiftinterface <nl> CHECK - BROKEN - STDLIB - NOT : { { ^ } } # <nl> <nl> RUN : not % swift_build_sdk_interfaces - sdk % S / Inputs / broken - stdlib - sdk / - v - o % t / output - skip - stdlib | % FileCheck % s <nl> mmm a / test / ParseableInterface / swift_build_sdk_interfaces / iosmac . test - sh <nl> ppp b / test / ParseableInterface / swift_build_sdk_interfaces / iosmac . test - sh <nl> RUN : % swift_build_sdk_interfaces - sdk % S / Inputs / iosmac - sdk / MacOSX . sdk / - Fsystem - <nl> RUN : % FileCheck % s < % t . txt <nl> RUN : % FileCheck - check - prefix NEGATIVE % s < % t . txt <nl> <nl> - CHECK - DAG : MacOSX . sdk / System / Library / Frameworks / FMWK . framework / Modules / FMWK . swiftmodule / x86_64 . swiftinterface - o { { . + } } / output / FMWK . swiftmodule / x86_64 - apple - macos . swiftmodule <nl> - CHECK - DAG : - Fsystem SECRET_SEARCH_PATH - Fsystem { { . + } } MacOSX . sdk / System / iOSSupport / System / Library / Frameworks { { . + } } MacOSX . sdk / System / iOSSupport / System / Library / Frameworks / FMWK . framework / Modules / FMWK . swiftmodule / x86_64 . swiftinterface - o { { . + } } / output / FMWK . swiftmodule / x86_64 - apple - ios - macabi . swiftmodule <nl> - CHECK - DAG : MacOSX . sdk / usr / lib / swift / Foo . swiftmodule / x86_64 . swiftinterface - o { { . + } } output / Foo . swiftmodule / x86_64 - apple - macos . swiftmodule <nl> - CHECK - DAG : - Fsystem SECRET_SEARCH_PATH - Fsystem { { . + } } MacOSX . sdk / System / iOSSupport / System / Library / Frameworks { { . + } } MacOSX . sdk / System / iOSSupport / usr / lib / swift / Foo . swiftmodule / x86_64 . swiftinterface - o { { . + } } output / Foo . swiftmodule / x86_64 - apple - ios - macabi . swiftmodule <nl> - CHECK - DAG : MacOSX . sdk / System / Library / Frameworks / Zippered . framework / Modules / Zippered . swiftmodule / x86_64 . swiftinterface - o { { . + } } / output / Zippered . swiftmodule / x86_64 - apple - macos . swiftmodule <nl> - CHECK - DAG : MacOSX . sdk / System / Library / Frameworks / Zippered . framework / Modules / Zippered . swiftmodule / x86_64 - apple - macos . swiftinterface - o { { . + } } / output / Zippered . swiftmodule / x86_64 - apple - macos . swiftmodule <nl> - CHECK - DAG : - Fsystem SECRET_SEARCH_PATH - Fsystem { { . + } } MacOSX . sdk / System / iOSSupport / System / Library / Frameworks { { . + } } MacOSX . sdk / System / Library / Frameworks / Zippered . framework / Modules / Zippered . swiftmodule / x86_64 - apple - ios - macabi . swiftinterface - o { { . + } } / output / Zippered . swiftmodule / x86_64 - apple - ios - macabi . swiftmodule <nl> + CHECK - DAG : MacOSX . sdk / System / Library / Frameworks { { \ \ | / } } FMWK . framework { { \ \ | / } } Modules { { \ \ | / } } FMWK . swiftmodule { { \ \ | / } } x86_64 . swiftinterface - o { { . + } } / output { { \ \ | / } } FMWK . swiftmodule { { \ \ | / } } x86_64 - apple - macos . swiftmodule <nl> + CHECK - DAG : - Fsystem SECRET_SEARCH_PATH - Fsystem { { . + } } MacOSX . sdk / System { { \ \ | / } } iOSSupport { { \ \ | / } } System { { \ \ | / } } Library { { \ \ | / } } Frameworks { { . + } } MacOSX . sdk / System / iOSSupport / System / Library / Frameworks { { \ \ | / } } FMWK . framework { { \ \ | / } } Modules { { \ \ | / } } FMWK . swiftmodule { { \ \ | / } } x86_64 . swiftinterface - o { { . + } } / output { { \ \ | / } } FMWK . swiftmodule { { \ \ | / } } x86_64 - apple - ios - macabi . swiftmodule <nl> + CHECK - DAG : MacOSX . sdk / usr / lib / swift { { \ \ | / } } Foo . swiftmodule { { \ \ | / } } x86_64 . swiftinterface - o { { . + } } output { { \ \ | / } } Foo . swiftmodule { { \ \ | / } } x86_64 - apple - macos . swiftmodule <nl> + CHECK - DAG : - Fsystem SECRET_SEARCH_PATH - Fsystem { { . + } } MacOSX . sdk / System { { \ \ | / } } iOSSupport { { \ \ | / } } System { { \ \ | / } } Library { { \ \ | / } } Frameworks { { . + } } MacOSX . sdk / System / iOSSupport / usr / lib / swift { { \ \ | / } } Foo . swiftmodule { { \ \ | / } } x86_64 . swiftinterface - o { { . + } } output { { \ \ | / } } Foo . swiftmodule { { \ \ | / } } x86_64 - apple - ios - macabi . swiftmodule <nl> + CHECK - DAG : MacOSX . sdk / System / Library / Frameworks { { \ \ | / } } Zippered . framework { { \ \ | / } } Modules { { \ \ | / } } Zippered . swiftmodule { { \ \ | / } } x86_64 . swiftinterface - o { { . + } } / output { { \ \ | / } } Zippered . swiftmodule { { \ \ | / } } x86_64 - apple - macos . swiftmodule <nl> + CHECK - DAG : MacOSX . sdk / System / Library / Frameworks { { \ \ | / } } Zippered . framework { { \ \ | / } } Modules { { \ \ | / } } Zippered . swiftmodule { { \ \ | / } } x86_64 - apple - macos . swiftinterface - o { { . + } } / output { { \ \ | / } } Zippered . swiftmodule { { \ \ | / } } x86_64 - apple - macos . swiftmodule <nl> + CHECK - DAG : - Fsystem SECRET_SEARCH_PATH - Fsystem { { . + } } MacOSX . sdk / System { { \ \ | / } } iOSSupport { { \ \ | / } } System { { \ \ | / } } Library { { \ \ | / } } Frameworks { { . + } } MacOSX . sdk / System / Library / Frameworks { { \ \ | / } } Zippered . framework { { \ \ | / } } Modules { { \ \ | / } } Zippered . swiftmodule { { \ \ | / } } x86_64 - apple - ios - macabi . swiftinterface - o { { . + } } / output { { \ \ | / } } Zippered . swiftmodule { { \ \ | / } } x86_64 - apple - ios - macabi . swiftmodule <nl> <nl> NEGATIVE - NOT : iOSSupport { { . + } } { { macos | x86_64 } } . swiftmodule <nl> NEGATIVE - NOT : SECRET_SEARCH_PATH { { . + } } { { macos | x86_64 } } . swiftmodule <nl> mmm a / test / ParseableInterface / swift_build_sdk_interfaces / xfail - logs . test - sh <nl> ppp b / test / ParseableInterface / swift_build_sdk_interfaces / xfail - logs . test - sh <nl> RUN : % empty - directory ( % t ) <nl> RUN : not % swift_build_sdk_interfaces - sdk % S / Inputs / xfails - sdk / - o % t / output - log - path % t / logs | % FileCheck % s <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / logs / Bad - Bad - err . txt <nl> <nl> - CHECK : # ( FAIL ) { { . + } } / Bad . swiftinterface <nl> + CHECK : # ( FAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> <nl> PRINTS - ERROR : unresolved identifier ' garbage ' <nl> <nl> RUN : echo ' [ " Good " ] ' > % t / xfails - good . json <nl> RUN : not % swift_build_sdk_interfaces - sdk % S / Inputs / xfails - sdk / - o % t / output - log - path % t / logs - xfails % t / xfails - good . json | % FileCheck - check - prefix = CHECK - XFAIL - GOOD % s <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / logs / Bad - Bad - err . txt <nl> <nl> - CHECK - XFAIL - GOOD - DAG : # ( FAIL ) { { . + } } / Bad . swiftinterface <nl> - CHECK - XFAIL - GOOD - DAG : # ( UPASS ) { { . + } } / Good . swiftinterface <nl> + CHECK - XFAIL - GOOD - DAG : # ( FAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> + CHECK - XFAIL - GOOD - DAG : # ( UPASS ) { { . + } } { { \ \ | / } } Good . swiftinterface <nl> <nl> RUN : % empty - directory ( % t ) <nl> RUN : echo ' [ " Good " , " Bad " ] ' > % t / xfails - good - and - bad . json <nl> RUN : % swift_build_sdk_interfaces - sdk % S / Inputs / xfails - sdk / - o % t / output - log - path % t / logs - xfails % t / xfails - good - and - bad . json | % FileCheck - check - prefix = CHECK - XFAIL - GOOD - AND - BAD % s <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / logs / Bad - Bad - err . txt <nl> <nl> - CHECK - XFAIL - GOOD - AND - BAD - DAG : # ( XFAIL ) { { . + } } / Bad . swiftinterface <nl> - CHECK - XFAIL - GOOD - AND - BAD - DAG : # ( UPASS ) { { . + } } / Good . swiftinterface <nl> + CHECK - XFAIL - GOOD - AND - BAD - DAG : # ( XFAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> + CHECK - XFAIL - GOOD - AND - BAD - DAG : # ( UPASS ) { { . + } } { { \ \ | / } } Good . swiftinterface <nl> <nl> RUN : % empty - directory ( % t ) <nl> RUN : echo ' [ " Bad " ] ' > % t / xfails - bad . json <nl> RUN : % swift_build_sdk_interfaces - sdk % S / Inputs / xfails - sdk / - o % t / output - log - path % t / logs - xfails % t / xfails - bad . json | % FileCheck - check - prefix = CHECK - XFAIL - BAD % s <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / logs / Bad - Bad - err . txt <nl> <nl> - CHECK - XFAIL - BAD : # ( XFAIL ) { { . + } } / Bad . swiftinterface <nl> + CHECK - XFAIL - BAD : # ( XFAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> <nl> RUN : % empty - directory ( % t ) <nl> RUN : not % swift_build_sdk_interfaces - sdk % t - o % t / output - log - path % t / logs % S / Inputs / xfail - logs - framework / | % FileCheck - check - prefix = CHECK - FRAMEWORK % s <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / logs / BadFMWK - x86_64 - apple - macos - err . txt <nl> <nl> - CHECK - FRAMEWORK : # ( FAIL ) { { . + } } / BadFMWK . swiftmodule / x86_64 - apple - macos . swiftinterface <nl> + CHECK - FRAMEWORK : # ( FAIL ) { { . + } } { { \ \ | / } } BadFMWK . swiftmodule { { \ \ | / } } x86_64 - apple - macos . swiftinterface <nl> mmm a / test / ParseableInterface / swift_build_sdk_interfaces / xfails . test - sh <nl> ppp b / test / ParseableInterface / swift_build_sdk_interfaces / xfails . test - sh <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / stderr . txt <nl> RUN : not % swift_build_sdk_interfaces - sdk % S / Inputs / xfails - sdk / - v - o % t / output 2 > % t / stderr . txt | % FileCheck - check - prefix CHECK - VERBOSE % s <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / stderr . txt <nl> <nl> - CHECK : # ( FAIL ) { { . + } } / Bad . swiftinterface <nl> - CHECK - VERBOSE - DAG : # ( FAIL ) { { . + } } / Bad . swiftinterface <nl> - CHECK - VERBOSE - DAG : # ( PASS ) { { . + } } / Good . swiftinterface <nl> + CHECK : # ( FAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> + CHECK - VERBOSE - DAG : # ( FAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> + CHECK - VERBOSE - DAG : # ( PASS ) { { . + } } { { \ \ | / } } Good . swiftinterface <nl> <nl> PRINTS - ERROR : unresolved identifier ' garbage ' <nl> HIDES - ERROR - NOT : unresolved identifier ' garbage ' <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / stderr . txt <nl> RUN : not % swift_build_sdk_interfaces - sdk % S / Inputs / xfails - sdk / - v - o % t / output - xfails % t / xfails - good . json 2 > % t / stderr . txt | % FileCheck - check - prefix = CHECK - XFAIL - GOOD % s <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / stderr . txt <nl> <nl> - CHECK - XFAIL - GOOD - DAG : # ( FAIL ) { { . + } } / Bad . swiftinterface <nl> - CHECK - XFAIL - GOOD - DAG : # ( UPASS ) { { . + } } / Good . swiftinterface <nl> + CHECK - XFAIL - GOOD - DAG : # ( FAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> + CHECK - XFAIL - GOOD - DAG : # ( UPASS ) { { . + } } { { \ \ | / } } Good . swiftinterface <nl> <nl> RUN : % empty - directory ( % t ) <nl> RUN : echo ' [ " Good " , " Bad " ] ' > % t / xfails - good - and - bad . json <nl> RUN : % FileCheck - check - prefix HIDES - ERROR - allow - empty % s < % t / stderr . txt <nl> RUN : % swift_build_sdk_interfaces - sdk % S / Inputs / xfails - sdk / - v - o % t / output - xfails % t / xfails - good - and - bad . json 2 > % t / stderr . txt | % FileCheck - check - prefix = CHECK - XFAIL - GOOD - AND - BAD % s <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / stderr . txt <nl> <nl> - CHECK - XFAIL - GOOD - AND - BAD - DAG : # ( XFAIL ) { { . + } } / Bad . swiftinterface <nl> - CHECK - XFAIL - GOOD - AND - BAD - DAG : # ( UPASS ) { { . + } } / Good . swiftinterface <nl> + CHECK - XFAIL - GOOD - AND - BAD - DAG : # ( XFAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> + CHECK - XFAIL - GOOD - AND - BAD - DAG : # ( UPASS ) { { . + } } { { \ \ | / } } Good . swiftinterface <nl> <nl> RUN : % empty - directory ( % t ) <nl> RUN : echo ' [ " Bad " ] ' > % t / xfails - bad . json <nl> RUN : % FileCheck - check - prefix HIDES - ERROR - allow - empty % s < % t / stderr . txt <nl> RUN : % swift_build_sdk_interfaces - sdk % S / Inputs / xfails - sdk / - v - o % t / output - xfails % t / xfails - bad . json 2 > % t / stderr . txt | % FileCheck - check - prefix = CHECK - XFAIL - BAD - VERBOSE % s <nl> RUN : % FileCheck - check - prefix PRINTS - ERROR % s < % t / stderr . txt <nl> <nl> - CHECK - XFAIL - BAD : # ( XFAIL ) { { . + } } / Bad . swiftinterface <nl> - CHECK - XFAIL - BAD - VERBOSE - DAG : # ( XFAIL ) { { . + } } / Bad . swiftinterface <nl> - CHECK - XFAIL - BAD - VERBOSE - DAG : # ( PASS ) { { . + } } / Good . swiftinterface <nl> + CHECK - XFAIL - BAD : # ( XFAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> + CHECK - XFAIL - BAD - VERBOSE - DAG : # ( XFAIL ) { { . + } } { { \ \ | / } } Bad . swiftinterface <nl> + CHECK - XFAIL - BAD - VERBOSE - DAG : # ( PASS ) { { . + } } { { \ \ | / } } Good . swiftinterface <nl> mmm a / utils / PathSanitizingFileCheck <nl> ppp b / utils / PathSanitizingFileCheck <nl> constants . " " " ) <nl> <nl> stdin = sys . stdin . read ( ) <nl> <nl> - if args . enable_windows_compatibility : <nl> - # Let ' s look for paths in the output , and try to transform them to use <nl> - # Unix directory separators to be automatically picked up by the tests . <nl> - # This only picks up absolute paths , but those should be the more <nl> - # common in the tools output and the easier to detect without false <nl> - # positives . <nl> - <nl> - def replace_slashes ( matchobj ) : <nl> - return re . sub ( r ' \ \ \ \ | \ \ ' , r ' / ' , matchobj . group ( 0 ) ) <nl> - <nl> - # The regex is composed of three parts : <nl> - # Matches a drive letter followed by a slash ( backward <nl> - # escaped , simple backward , or forward ) <nl> - stdin = re . sub ( r ' \ b [ a - zA - Z ] : ( ? : \ \ \ \ | \ \ | \ / ) ' + <nl> - # Matches the path part , it always ends up in a slash . <nl> - r ' ( ? : [ - a - zA - Z0 - 9_ . ] + ( ? : \ \ \ \ | \ \ | \ / ) ) * ' + <nl> - # Matches the last path component , which do not has a <nl> - # trailing slash , but it is optional . <nl> - r ' ( ? : [ - a - zA - Z0 - 9_ . ] + ) ? \ b ' , <nl> - replace_slashes , stdin ) <nl> - <nl> for s in args . sanitize_strings : <nl> replacement , pattern = s . split ( ' = ' , 1 ) <nl> # We are replacing the Unix path separators in the paths passed as <nl>
|
Merge remote - tracking branch ' origin / master ' into master - next
|
apple/swift
|
b12236f33fed2437ef7877baf587ffa26cc4cb28
|
2019-06-20T22:50:40Z
|
mmm a / src / heap / incremental - marking - inl . h <nl> ppp b / src / heap / incremental - marking - inl . h <nl> bool IncrementalMarking : : BaseRecordWrite ( HeapObject * obj , Object * * slot , <nl> Object * value ) { <nl> HeapObject * value_heap_obj = HeapObject : : cast ( value ) ; <nl> MarkBit value_bit = Marking : : MarkBitFrom ( value_heap_obj ) ; <nl> - / / Checking the obj marking state is not necessary , but reduces the marking <nl> - / / load . <nl> - MarkBit obj_bit = Marking : : MarkBitFrom ( obj ) ; <nl> - if ( Marking : : IsWhite ( value_bit ) & & Marking : : IsBlack ( obj_bit ) ) { <nl> - WhiteToGreyAndPush ( value_heap_obj , value_bit ) ; <nl> - RestartIfNotMarking ( ) ; <nl> + if ( Marking : : IsWhite ( value_bit ) ) { <nl> + MarkBit obj_bit = Marking : : MarkBitFrom ( obj ) ; <nl> + if ( Marking : : IsBlack ( obj_bit ) ) { <nl> + MemoryChunk * chunk = MemoryChunk : : FromAddress ( obj - > address ( ) ) ; <nl> + if ( chunk - > IsFlagSet ( MemoryChunk : : HAS_PROGRESS_BAR ) ) { <nl> + if ( chunk - > IsLeftOfProgressBar ( slot ) ) { <nl> + WhiteToGreyAndPush ( value_heap_obj , value_bit ) ; <nl> + RestartIfNotMarking ( ) ; <nl> + } else { <nl> + return false ; <nl> + } <nl> + } else { <nl> + BlackToGreyAndUnshift ( obj , obj_bit ) ; <nl> + RestartIfNotMarking ( ) ; <nl> + return false ; <nl> + } <nl> + } else { <nl> + return false ; <nl> + } <nl> } <nl> if ( ! is_compacting_ ) return false ; <nl> + MarkBit obj_bit = Marking : : MarkBitFrom ( obj ) ; <nl> return Marking : : IsBlack ( obj_bit ) ; <nl> } <nl> <nl> mmm a / src / heap / spaces . h <nl> ppp b / src / heap / spaces . h <nl> class MemoryChunk { <nl> } <nl> } <nl> <nl> + bool IsLeftOfProgressBar ( Object * * slot ) { <nl> + Address slot_address = reinterpret_cast < Address > ( slot ) ; <nl> + DCHECK ( slot_address > this - > address ( ) ) ; <nl> + return ( slot_address - ( this - > address ( ) + kObjectStartOffset ) ) < <nl> + progress_bar ( ) ; <nl> + } <nl> + <nl> static void IncrementLiveBytesFromGC ( Address address , int by ) { <nl> MemoryChunk : : FromAddress ( address ) - > IncrementLiveBytes ( by ) ; <nl> } <nl>
|
Revert of Re - land new insertion write barrier . ( patchset id : 40001 of https : / / codereview . chromium . org / 1153233003 / )
|
v8/v8
|
5f88fc60e20182f77427ca36f46c294c3cfd6728
|
2015-06-18T18:04:53Z
|
mmm a / cocos / scripting / lua - bindings / script / cocos2d / Cocos2d . lua <nl> ppp b / cocos / scripting / lua - bindings / script / cocos2d / Cocos2d . lua <nl> function cc . pIsSegmentIntersect ( pt1 , pt2 , pt3 , pt4 ) <nl> local s , t , ret = 0 , 0 , false <nl> ret , s , t = cc . pIsLineIntersect ( pt1 , pt2 , pt3 , pt4 , s , t ) <nl> <nl> - if ret and s > = 0 . 0 and s < = 1 . 0 and t > = 0 . 0 and t < = 0 . 0 then <nl> + if ret and s > = 0 . 0 and s < = 1 . 0 and t > = 0 . 0 and t < = 1 . 0 then <nl> return true <nl> end <nl> <nl>
|
Fixed : Correct ` cc . pIsSegmentIntersect ` for lua
|
cocos2d/cocos2d-x
|
2605865ca60dc3cbf28c552783d672e77c71addc
|
2015-08-19T08:21:31Z
|
mmm a / src / qt / forms / overviewpage . ui <nl> ppp b / src / qt / forms / overviewpage . ui <nl> <nl> < / item > <nl> < item row = " 1 " column = " 0 " > <nl> < widget class = " QLabel " name = " label_5 " > <nl> + < property name = " font " > <nl> + < font > <nl> + < pointsize > 11 < / pointsize > <nl> + < bold > true < / bold > <nl> + < / font > <nl> + < / property > <nl> < property name = " text " > <nl> - < string > & lt ; ! DOCTYPE HTML PUBLIC & quot ; - / / W3C / / DTD HTML 4 . 0 / / EN & quot ; & quot ; http : / / www . w3 . org / TR / REC - html40 / strict . dtd & quot ; & gt ; <nl> - & lt ; html & gt ; & lt ; head & gt ; & lt ; meta name = & quot ; qrichtext & quot ; content = & quot ; 1 & quot ; / & gt ; & lt ; style type = & quot ; text / css & quot ; & gt ; <nl> - p , li { white - space : pre - wrap ; } <nl> - & lt ; / style & gt ; & lt ; / head & gt ; & lt ; body style = & quot ; font - family : ' Ubuntu ' ; font - size : 11pt ; font - weight : 400 ; font - style : normal ; & quot ; & gt ; <nl> - & lt ; p style = & quot ; margin - top : 0px ; margin - bottom : 0px ; margin - left : 0px ; margin - right : 0px ; - qt - block - indent : 0 ; text - indent : 0px ; & quot ; & gt ; & lt ; span style = & quot ; font - weight : 600 ; & quot ; & gt ; Wallet & lt ; / span & gt ; & lt ; / p & gt ; & lt ; / body & gt ; & lt ; / html & gt ; < / string > <nl> + < string > Wallet < / string > <nl> < / property > <nl> < / widget > <nl> < / item > <nl>
|
Merge pull request from Diapolo / fix
|
bitcoin/bitcoin
|
3118d11d889acb7ce6e3d95b38c5f63429d2deb9
|
2012-05-05T06:58:46Z
|
mmm a / hphp / hack / src / procs / worker . ml <nl> ppp b / hphp / hack / src / procs / worker . ml <nl> let unix_worker_main restore state ( ic , oc ) = <nl> | 0 - > slave_main ic oc <nl> | pid - > <nl> ( * Wait for the slave termination . . . * ) <nl> - match snd ( Unix . waitpid [ ] pid ) with <nl> + match snd ( Sys_utils . waitpid_non_intr [ ] pid ) with <nl> | Unix . WEXITED 0 - > ( ) <nl> | Unix . WEXITED 1 - > <nl> raise End_of_file <nl> mmm a / hphp / hack / src / utils / sys_utils . ml <nl> ppp b / hphp / hack / src / utils / sys_utils . ml <nl> let rec select_non_intr read write exn timeout = <nl> then timeout <nl> else max 0 . 0 ( timeout - . ( Unix . gettimeofday ( ) - . start_time ) ) in <nl> select_non_intr read write exn timeout <nl> + <nl> + ( * Flow uses lwt , which installs a sigchld handler . So the old pattern of fork & waitpid will hit <nl> + * an EINTR when the forked process dies and the parent gets a sigchld signal . Note : this is only a <nl> + * problem if you ' re not using the WNOHANG flag , since EINTR isn ' t thrown for WNOHANG * ) <nl> + let rec waitpid_non_intr flags pid = <nl> + try Unix . waitpid flags pid <nl> + with Unix . Unix_error ( Unix . EINTR , _ , _ ) - > waitpid_non_intr flags pid <nl> mmm a / hphp / hack / src / utils / timeout . ml <nl> ppp b / hphp / hack / src / utils / timeout . ml <nl> module Alarm_timeout = struct <nl> | None - > invalid_arg " Timeout . close_process_in " <nl> | Some pid - > <nl> Pervasives . close_in ic ; <nl> - snd ( Unix . waitpid [ ] pid ) <nl> + snd ( Sys_utils . waitpid_non_intr [ ] pid ) <nl> <nl> let read_process ~ timeout ~ on_timeout ~ reader cmd args = <nl> let ( ic , oc ) = open_process cmd args in <nl> module Select_timeout = struct <nl> try Unix . close tic . fd <nl> with _ - > ( ) <nl> <nl> - let rec waitpid_non_intr pid = <nl> - try Unix . waitpid [ ] pid <nl> - with Unix . Unix_error ( Unix . EINTR , _ , _ ) - > waitpid_non_intr pid <nl> - <nl> let close_process_in tic = <nl> match tic . pid with <nl> | None - > invalid_arg " Timeout . close_process_in " <nl> | Some pid - > <nl> close_in tic ; <nl> - snd ( waitpid_non_intr pid ) <nl> + snd ( Sys_utils . waitpid_non_intr [ ] pid ) <nl> <nl> let do_read ? timeout tic = <nl> let timeout_duration = get_current_timeout timeout in <nl>
|
Add Sys_utils . waitpid_non_intr
|
facebook/hhvm
|
8caed9ac835af37b3e8ca5aab7db05a64469500b
|
2017-11-03T01:51:17Z
|
mmm a / templates / cocos2dx_files . json <nl> ppp b / templates / cocos2dx_files . json <nl> <nl> " cmake / Modules / PreventInSourceBuilds . cmake " , <nl> " cmake / Modules / iOSBundleInfo . plist . in " , <nl> " cmake / README . md " , <nl> - " cmake / ios . toolchain . cmake " , <nl> " cocos / 2d / CCAction . cpp " , <nl> " cocos / 2d / CCAction . h " , <nl> " cocos / 2d / CCActionCamera . cpp " , <nl>
|
[ ci skip ] [ AUTO ] : updating luabinding & cocos_file . json automatically ( )
|
cocos2d/cocos2d-x
|
6d8b1f5b9d3a7dd6ed677e346fa79cba5e20f7cc
|
2019-08-26T07:51:44Z
|
mmm a / tensorflow / core / kernels / aggregate_ops . cc <nl> ppp b / tensorflow / core / kernels / aggregate_ops . cc <nl> REGISTER_ADDN_CPU ( Variant ) ; <nl> <nl> # undef REGISTER_ADDN_CPU <nl> <nl> - # if GOOGLE_CUDA <nl> + # if GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl> # define REGISTER_ADDN_GPU ( type ) REGISTER_ADDN ( type , GPU ) <nl> TF_CALL_GPU_NUMBER_TYPES ( REGISTER_ADDN_GPU ) ; <nl> TF_CALL_int64 ( REGISTER_ADDN_GPU ) ; <nl> REGISTER_KERNEL_BUILDER ( Name ( " AddN " ) <nl> . HostMemory ( " sum " ) , <nl> AddNOp < CPUDevice , int32 > ) ; <nl> <nl> - # endif / / GOOGLE_CUDA <nl> + # endif / / GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl> <nl> # ifdef TENSORFLOW_USE_SYCL <nl> REGISTER_ADDN ( float , SYCL ) ; <nl> mmm a / tensorflow / core / kernels / aggregate_ops_gpu . cu . cc <nl> ppp b / tensorflow / core / kernels / aggregate_ops_gpu . cu . cc <nl> See the License for the specific language governing permissions and <nl> limitations under the License . <nl> = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = * / <nl> <nl> - # if GOOGLE_CUDA <nl> + # if GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl> <nl> # define EIGEN_USE_GPU <nl> <nl> TF_CALL_complex128 ( REGISTER_FUNCTORS ) ; <nl> <nl> } / / end namespace tensorflow <nl> <nl> - # endif / / GOOGLE_CUDA <nl> + # endif / / GOOGLE_CUDA | | TENSORFLOW_USE_ROCM <nl>
|
add ROCm support for AddN op
|
tensorflow/tensorflow
|
1e2932a70c6e8127417a40aa84936e4169ed2e11
|
2019-03-14T22:24:24Z
|
mmm a / src / library_sdl . js <nl> ppp b / src / library_sdl . js <nl> var LibrarySDL = { <nl> webAudioAvailable : function ( ) { return ! ! SDL . audioContext ; } , <nl> <nl> fillWebAudioBufferFromHeap : function ( heapPtr , sizeSamplesPerChannel , dstAudioBuffer ) { <nl> - / / The input audio data is interleaved across the channels , i . e . [ L , R , L , R , L , R , . . . ] and is either 8 - bit or 16 - bit as <nl> + / / The input audio data is interleaved across the channels , i . e . [ L , R , L , R , L , R , . . . ] and is either 8 - bit , 16 - bit or float as <nl> / / supported by the SDL API . The output audio wave data for Web Audio API must be in planar buffers of [ - 1 , 1 ] - normalized Float32 data , <nl> / / so perform a buffer conversion for the data . <nl> var numChannels = SDL . audio . channels ; <nl> var LibrarySDL = { <nl> var v = ( { { { makeGetValue ( ' heapPtr ' , ' j * numChannels + c ' , ' i8 ' , 0 , 0 ) } } } ) ; <nl> channelData [ j ] = ( ( v > = 0 ) ? v - 128 : v + 128 ) / 128 ; <nl> } <nl> + } else if ( SDL . audio . format = = 0x8120 / * AUDIO_F32 * / ) { <nl> + for ( var j = 0 ; j < sizeSamplesPerChannel ; + + j ) { <nl> + channelData [ j ] = ( { { { makeGetValue ( ' heapPtr ' , ' ( j * numChannels + c ) * 4 ' , ' float ' , 0 , 0 ) } } } ) ; <nl> + } <nl> + } else { <nl> + throw ' Invalid SDL audio format ' + SDL . audio . format + ' ! ' ; <nl> } <nl> } <nl> } , <nl> var LibrarySDL = { <nl> SDL . audio . silence = 128 ; / / Audio ranges in [ 0 , 255 ] , so silence is half - way in between . <nl> } else if ( SDL . audio . format = = 0x8010 / * AUDIO_S16LSB * / ) { <nl> SDL . audio . silence = 0 ; / / Signed data in range [ - 32768 , 32767 ] , silence is 0 . <nl> + } else if ( SDL . audio . format = = 0x8120 / * AUDIO_F32 * / ) { <nl> + SDL . audio . silence = 0 . 0 ; / / Float data in range [ - 1 . 0 , 1 . 0 ] , silence is 0 . 0 <nl> } else { <nl> throw ' Invalid SDL audio format ' + SDL . audio . format + ' ! ' ; <nl> } <nl> var LibrarySDL = { <nl> } <nl> <nl> var totalSamples = SDL . audio . samples * SDL . audio . channels ; <nl> - SDL . audio . bytesPerSample = ( SDL . audio . format = = 0x0008 / * AUDIO_U8 * / | | SDL . audio . format = = 0x8008 / * AUDIO_S8 * / ) ? 1 : 2 ; <nl> + if ( SDL . audio . format = = 0x0008 / * AUDIO_U8 * / ) { <nl> + SDL . audio . bytesPerSample = 1 ; <nl> + } else if ( SDL . audio . format = = 0x8010 / * AUDIO_S16LSB * / ) { <nl> + SDL . audio . bytesPerSample = 2 ; <nl> + } else if ( SDL . audio . format = = 0x8120 / * AUDIO_F32 * / ) { <nl> + SDL . audio . bytesPerSample = 4 ; <nl> + } else { <nl> + throw ' Invalid SDL audio format ' + SDL . audio . format + ' ! ' ; <nl> + } <nl> SDL . audio . bufferSize = totalSamples * SDL . audio . bytesPerSample ; <nl> SDL . audio . bufferDurationSecs = SDL . audio . bufferSize / SDL . audio . bytesPerSample / SDL . audio . channels / SDL . audio . freq ; / / Duration of a single queued buffer in seconds . <nl> SDL . audio . bufferingDelay = 50 / 1000 ; / / Audio samples are played with a constant delay of this many seconds to account for browser and jitter . <nl> mmm a / tests / sdl_audio_beep . cpp <nl> ppp b / tests / sdl_audio_beep . cpp <nl> Beeper : : ~ Beeper ( ) { <nl> <nl> template < typename T > <nl> void Beeper : : generateSamples ( T * stream , int length ) { <nl> - const int AMPLITUDE = ( sizeof ( T ) = = 2 ) ? 28000 : 120 ; <nl> - const int offset = ( sdlAudioFormat = = AUDIO_U8 ) ? 120 : 0 ; <nl> + T AMPLITUDE ; <nl> + if ( sdlAudioFormat = = AUDIO_F32 ) { <nl> + AMPLITUDE = ( T ) 0 . 8f ; <nl> + } <nl> + else { <nl> + AMPLITUDE = ( sizeof ( T ) = = 2 ) ? 28000 : 120 ; <nl> + } <nl> + const T offset = ( sdlAudioFormat = = AUDIO_U8 ) ? 120 : 0 ; <nl> <nl> int i = 0 ; <nl> length / = numChannels ; <nl> void Beeper : : generateSamples ( T * stream , int length ) { <nl> <nl> while ( i < samplesToDo ) { <nl> for ( int j = 0 ; j < numChannels ; + + j ) { <nl> - stream [ numChannels * i + j ] = ( T ) ( offset + ( int ) ( AMPLITUDE * std : : sin ( phase * 2 * M_PI / frequency ) ) ) ; <nl> + stream [ numChannels * i + j ] = ( T ) ( offset + ( AMPLITUDE * std : : sin ( phase * 2 * M_PI / frequency ) ) ) ; <nl> if ( numChannels > 1 & & j = = mutedChannel ) { <nl> stream [ numChannels * i + j ] = 0 ; <nl> } <nl> Beeper * beep = 0 ; <nl> / / test will report you which work . <nl> const int freqs [ ] = { 8000 , 11025 , 16000 , 22050 , 32000 , 44100 , 48000 , 96000 } ; <nl> const int channels [ ] = { 1 , 2 } ; <nl> - const int sdlAudioFormats [ ] = { AUDIO_U8 , AUDIO_S16LSB / * , AUDIO_S8 , AUDIO_U16LSB , AUDIO_U16MSB , AUDIO_S16MSB * / } ; <nl> + const int sdlAudioFormats [ ] = { AUDIO_U8 , AUDIO_S16LSB , AUDIO_F32 / * , AUDIO_S8 , AUDIO_U16LSB , AUDIO_U16MSB , AUDIO_S16MSB * / } ; <nl> <nl> const char * SdlAudioFormatToString ( int sdlAudioType ) { <nl> switch ( sdlAudioType ) { <nl> const char * SdlAudioFormatToString ( int sdlAudioType ) { <nl> case AUDIO_U16MSB : return " AUDIO_U16MSB " ; <nl> case AUDIO_S16LSB : return " AUDIO_S16LSB " ; <nl> case AUDIO_S16MSB : return " AUDIO_S16MSB " ; <nl> + case AUDIO_F32 : return " AUDIO_F32 " ; <nl> default : return " ( unknown ) " ; <nl> } <nl> } <nl> void audio_callback ( void * _beeper , Uint8 * _stream , int _length ) { <nl> Sint16 * stream = ( Sint16 * ) _stream ; <nl> int length = _length / 2 ; <nl> beeper - > generateSamples ( stream , length ) ; <nl> + } else if ( beeper - > sdlAudioFormat = = AUDIO_F32 ) { <nl> + float * stream = ( float * ) _stream ; <nl> + int length = _length / 4 ; <nl> + beeper - > generateSamples ( stream , length ) ; <nl> } else { <nl> assert ( false & & " Audio sample generation not implemented for current format ! \ n " ) ; <nl> } <nl>
|
library_sdl . js : Support AUDIO_F32 sample format in SDL_OpenAudio ( )
|
emscripten-core/emscripten
|
b8c3e2eca6c34602b68cde0a27a2f12cac1d8bd4
|
2018-04-09T22:31:13Z
|
mmm a / yarn . lock <nl> ppp b / yarn . lock <nl> bcrypt - pbkdf @ ^ 1 . 0 . 0 : <nl> tweetnacl " ^ 0 . 14 . 3 " <nl> <nl> beachball @ ^ 1 . 32 . 0 : <nl> - version " 1 . 32 . 2 " <nl> - resolved " https : / / registry . yarnpkg . com / beachball / - / beachball - 1 . 32 . 2 . tgz # 8c8501a20bc3d7f7cffcb5e7661dcffe2c00cfee " <nl> - integrity sha512 - 1rUhqockNXdAjCCzFLszHxnfsjf + / dTFo2YudpeQWyKUyQ1HeIiwdUVp / bM9uOc + VxG6sUrk5nnrBRAX7yI4aw = = <nl> + version " 1 . 35 . 0 " <nl> + resolved " https : / / registry . yarnpkg . com / beachball / - / beachball - 1 . 35 . 0 . tgz # 0bca3c87a9d64a2d92b08e9ec26dd8cd759d2c6f " <nl> + integrity sha512 - VtQP9dKhAWeqh5NDuWqtzci9bN / xJT / fr / + t0h3OjaNLDCefybU6F1Txv9zhoLiimaiiWOYXjh0dqoa8hrPz8w = = <nl> dependencies : <nl> cosmiconfig " ^ 6 . 0 . 0 " <nl> execa " ^ 4 . 0 . 3 " <nl>
|
Bump beachball from 1 . 32 . 2 to 1 . 35 . 0 ( )
|
microsoft/react-native-windows
|
9ec8b3e6a4be0ab0eb12a69d224fb4496243dc69
|
2020-08-07T16:15:12Z
|
mmm a / docs / api / native - image . md <nl> ppp b / docs / api / native - image . md <nl> <nl> # NativeImage <nl> <nl> - In Electron for the APIs that take images , you can pass either file paths or <nl> - ` NativeImage ` instances . When passing ` null ` , an empty image will be used . <nl> + In Electron , for the APIs that take images , you can pass either file paths or <nl> + ` NativeImage ` instances . An empty image will be used when ` null ` is passed . <nl> <nl> - For example , when creating a tray or setting a window ' s icon , you can pass an image <nl> - file path as a ` String ` : <nl> + For example , when creating a tray or setting a window ' s icon , you can pass an <nl> + image file path as a ` String ` : <nl> <nl> ` ` ` javascript <nl> var appIcon = new Tray ( ' / Users / somebody / images / icon . png ' ) ; <nl> var window = new BrowserWindow ( { icon : ' / Users / somebody / images / window . png ' } ) ; <nl> ` ` ` <nl> <nl> - Or read the image from the clipboard : <nl> + Or read the image from the clipboard which returns a ` NativeImage ` : <nl> <nl> ` ` ` javascript <nl> var clipboard = require ( ' clipboard ' ) ; <nl> On Windows , you can also load ` ICO ` icon from a file path . <nl> On platforms that have high - DPI support , you can append ` @ 2x ` after image ' s <nl> file name ' s base name to mark it as a high resolution image . <nl> <nl> - For example if ` icon . png ` is a normal image that has standard resolution , the <nl> + For example if ` icon . png ` is a normal image that has standard resolution , then <nl> ` icon @ 2x . png ` would be treated as a high resolution image that has double DPI <nl> density . <nl> <nl> Following suffixes as DPI denses are also supported : <nl> * ` @ 4x ` <nl> * ` @ 5x ` <nl> <nl> - # # Template image <nl> + # # Template Image <nl> <nl> Template images consist of black and clear colors ( and an alpha channel ) . <nl> Template images are not intended to be used as standalone images and are usually <nl> mixed with other content to create the desired final appearance . <nl> The most common case is to use template image for menu bar icon so it can adapt <nl> to both light and dark menu bars . <nl> <nl> - Template image is only supported on Mac . <nl> + Template image is only supported on OS X . <nl> <nl> - To mark an image as template image , its filename should end with the word <nl> + To mark an image as a template image , its filename should end with the word <nl> ` Template ` , examples are : <nl> <nl> * ` xxxTemplate . png ` <nl> * ` xxxTemplate @ 2x . png ` <nl> <nl> - # # nativeImage . createEmpty ( ) <nl> + # # Methods <nl> + <nl> + The ` NativeImage ` class has the following methods : <nl> + <nl> + # # # ` NativeImage . createEmpty ( ) ` <nl> <nl> Creates an empty ` NativeImage ` instance . <nl> <nl> - # # nativeImage . createFromPath ( path ) <nl> + # # # ` NativeImage . createFromPath ( path ) ` <nl> <nl> * ` path ` String <nl> <nl> Creates a new ` NativeImage ` instance from a file located at ` path ` . <nl> <nl> - # # nativeImage . createFromBuffer ( buffer [ , scaleFactor ] ) <nl> + # # # ` NativeImage . createFromBuffer ( buffer [ , scaleFactor ] ) ` <nl> <nl> * ` buffer ` [ Buffer ] [ buffer ] <nl> - * ` scaleFactor ` Double <nl> + * ` scaleFactor ` Double ( optional ) <nl> <nl> - Creates a new ` NativeImage ` instance from ` buffer ` . The ` scaleFactor ` is 1 . 0 by <nl> - default . <nl> + Creates a new ` NativeImage ` instance from ` buffer ` . The default ` scaleFactor ` is <nl> + 1 . 0 . <nl> <nl> - # # nativeImage . createFromDataUrl ( dataUrl ) <nl> + # # # ` NativeImage . createFromDataUrl ( dataUrl ) ` <nl> <nl> * ` dataUrl ` String <nl> <nl> Creates a new ` NativeImage ` instance from ` dataUrl ` . <nl> <nl> - # # Class : NativeImage <nl> + # # Instance Methods <nl> + <nl> + The following methods are available on instances of ` nativeImage ` <nl> <nl> - This class is used to represent an image . <nl> + ` ` ` javascript <nl> + var image = nativeImage . createFromPath ( ' / Users / somebody / images / icon . png ' ) <nl> + ` ` ` <nl> <nl> - # # # NativeImage . toPng ( ) <nl> + # # # ` image . toPng ( ) ` <nl> <nl> - Returns a [ Buffer ] [ buffer ] that contains image ' s ` PNG ` encoded data . <nl> + Returns a [ Buffer ] [ buffer ] that contains the image ' s ` PNG ` encoded data . <nl> <nl> - # # # NativeImage . toJpeg ( quality ) <nl> + # # # ` image . toJpeg ( quality ) ` <nl> <nl> - * ` quality ` Integer between 0 - 100 ( required ) <nl> + * ` quality ` Integer between 0 - 100 ( * * required * * ) <nl> <nl> - Returns a [ Buffer ] [ buffer ] that contains image ' s ` JPEG ` encoded data . <nl> + Returns a [ Buffer ] [ buffer ] that contains the image ' s ` JPEG ` encoded data . <nl> <nl> - # # # NativeImage . toDataUrl ( ) <nl> + # # # ` image . toDataUrl ( ) ` <nl> <nl> - Returns the data URL of image . <nl> + Returns the data URL of the image . <nl> <nl> - # # # NativeImage . isEmpty ( ) <nl> + # # # ` image . isEmpty ( ) ` <nl> <nl> - Returns whether the image is empty . <nl> + Returns a boolean whether the image is empty . <nl> <nl> - # # # NativeImage . getSize ( ) <nl> + # # # ` image . getSize ( ) ` <nl> <nl> Returns the size of the image . <nl> <nl> [ buffer ] : https : / / iojs . org / api / buffer . html # buffer_class_buffer <nl> <nl> - # # # NativeImage . setTemplateImage ( option ) <nl> + # # # ` image . setTemplateImage ( option ) ` <nl> <nl> * ` option ` Boolean <nl> <nl> Marks the image as template image . <nl> <nl> - # # # NativeImage . isTemplateImage ( ) <nl> + # # # ` image . isTemplateImage ( ) ` <nl> <nl> - Returns whether the image is a template image . <nl> + Returns a boolean whether the image is a template image . <nl>
|
Standardize native - image
|
electron/electron
|
a38d34d368aad6313acb28ee8f3f0edd9ffabea3
|
2015-08-29T04:33:45Z
|
mmm a / tensorflow / core / grappler / optimizers / constant_folding . cc <nl> ppp b / tensorflow / core / grappler / optimizers / constant_folding . cc <nl> Status ConstantFolding : : ReplaceOperationWithConstant ( <nl> Status ConstantFolding : : SimplifyGraph ( GraphDef * optimized_graph , <nl> GraphProperties * properties , <nl> bool use_shape_info ) { <nl> - const bool is_aggressive = opt_level_ = = RewriterConfig : : AGGRESSIVE ; <nl> for ( int i = 0 ; i < optimized_graph - > node_size ( ) ; + + i ) { <nl> - NodeDef * node = optimized_graph - > mutable_node ( i ) ; <nl> + TF_RETURN_IF_ERROR ( SimplifyNode ( optimized_graph - > mutable_node ( i ) , <nl> + optimized_graph , properties , <nl> + use_shape_info ) ) ; <nl> + } <nl> + return Status : : OK ( ) ; <nl> + } <nl> <nl> - if ( IsSplit ( * node ) & & node - > attr ( ) . at ( " num_split " ) . i ( ) = = 1 ) { <nl> - ReplaceOperationWithIdentity ( 1 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> - } <nl> + Status ConstantFolding : : SimplifyNode ( NodeDef * node , GraphDef * optimized_graph , <nl> + GraphProperties * properties , <nl> + bool use_shape_info ) { <nl> + const bool is_aggressive = opt_level_ = = RewriterConfig : : AGGRESSIVE ; <nl> + if ( IsSplit ( * node ) & & node - > attr ( ) . at ( " num_split " ) . i ( ) = = 1 ) { <nl> + ReplaceOperationWithIdentity ( 1 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> <nl> - if ( IsSplitV ( * node ) & & node - > attr ( ) . at ( " num_split " ) . i ( ) = = 1 ) { <nl> - ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> - } <nl> + if ( IsSplitV ( * node ) & & node - > attr ( ) . at ( " num_split " ) . i ( ) = = 1 ) { <nl> + ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> <nl> - / / Remove Shuffle or Transpose op over dimensions of size 1 . <nl> - if ( use_shape_info & & ( IsShuffle ( * node ) | | IsTranspose ( * node ) ) & & <nl> - properties - > GetInputProperties ( node - > name ( ) ) . size ( ) > = 2 ) { <nl> - const auto & shape = <nl> - properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> - if ( shape . unknown_rank ( ) ) { <nl> - / / Not optimizable . <nl> - continue ; <nl> - } <nl> - const auto & p = properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] ; <nl> - if ( TensorShape : : IsValid ( p . shape ( ) ) & & p . has_value ( ) ) { <nl> - Tensor perm ( p . dtype ( ) , p . shape ( ) ) ; <nl> - if ( ! perm . FromProto ( p . value ( ) ) ) { <nl> - return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> - p . value ( ) . DebugString ( ) ) ; <nl> - } <nl> - std : : vector < int > permutation ; <nl> - for ( int j = 0 ; j < perm . NumElements ( ) ; + + j ) { <nl> - if ( perm . dtype ( ) = = DT_INT64 ) { <nl> - permutation . push_back ( perm . vec < int64 > ( ) ( j ) ) ; <nl> - } else { <nl> - permutation . push_back ( perm . vec < int > ( ) ( j ) ) ; <nl> - } <nl> - } <nl> - if ( permutation . size ( ) ! = shape . dim_size ( ) ) { <nl> - / / Number of elements in perm should be same as dim_size . Skip if not . <nl> - continue ; <nl> - } <nl> - / / The node is replaceable iff <nl> - / / dim_size = = 0 | | all dims have size 1 | | <nl> - / / all dims with > 1 size are not permuted . <nl> - bool replaceable = true ; <nl> - for ( int j = 0 ; replaceable & & j < shape . dim_size ( ) ; + + j ) { <nl> - replaceable & = shape . dim ( j ) . size ( ) = = 1 | | j = = permutation [ j ] ; <nl> - } <nl> - if ( replaceable ) { <nl> - ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> + / / Remove Shuffle or Transpose op over dimensions of size 1 . <nl> + if ( use_shape_info & & ( IsShuffle ( * node ) | | IsTranspose ( * node ) ) & & <nl> + properties - > GetInputProperties ( node - > name ( ) ) . size ( ) > = 2 ) { <nl> + const auto & shape = properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> + if ( shape . unknown_rank ( ) ) { <nl> + / / Not optimizable . <nl> + return Status : : OK ( ) ; <nl> + } <nl> + const auto & p = properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] ; <nl> + if ( TensorShape : : IsValid ( p . shape ( ) ) & & p . has_value ( ) ) { <nl> + Tensor perm ( p . dtype ( ) , p . shape ( ) ) ; <nl> + if ( ! perm . FromProto ( p . value ( ) ) ) { <nl> + return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> + p . value ( ) . DebugString ( ) ) ; <nl> + } <nl> + std : : vector < int > permutation ; <nl> + for ( int j = 0 ; j < perm . NumElements ( ) ; + + j ) { <nl> + if ( perm . dtype ( ) = = DT_INT64 ) { <nl> + permutation . push_back ( perm . vec < int64 > ( ) ( j ) ) ; <nl> + } else { <nl> + permutation . push_back ( perm . vec < int > ( ) ( j ) ) ; <nl> } <nl> } <nl> - } <nl> - <nl> - / / Remove RandomShuffle op if it is scalar or first dimension is of size 1 . <nl> - if ( use_shape_info & & IsRandomShuffle ( * node ) & & <nl> - ! properties - > GetInputProperties ( node - > name ( ) ) . empty ( ) ) { <nl> - const auto & shape = <nl> - properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> + if ( permutation . size ( ) ! = shape . dim_size ( ) ) { <nl> + / / Number of elements in perm should be same as dim_size . Skip if not . <nl> + return Status : : OK ( ) ; <nl> + } <nl> / / The node is replaceable iff <nl> - / / unknown_rank = = false & & ( dim_size = = 0 | | first dim is of size 1 ) <nl> - if ( ! shape . unknown_rank ( ) & & <nl> - ( shape . dim_size ( ) = = 0 | | shape . dim ( 0 ) . size ( ) = = 1 ) ) { <nl> + / / dim_size = = 0 | | all dims have size 1 | | <nl> + / / all dims with > 1 size are not permuted . <nl> + bool replaceable = true ; <nl> + for ( int j = 0 ; replaceable & & j < shape . dim_size ( ) ; + + j ) { <nl> + replaceable & = shape . dim ( j ) . size ( ) = = 1 | | j = = permutation [ j ] ; <nl> + } <nl> + if ( replaceable ) { <nl> ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> + return Status : : OK ( ) ; <nl> } <nl> } <nl> + } <nl> <nl> - / / Remove Reverse op over dimensions with size 1 . <nl> - if ( use_shape_info & & node - > op ( ) = = " ReverseV2 " & & <nl> - properties - > GetInputProperties ( node - > name ( ) ) . size ( ) > = 2 ) { <nl> - const auto & shape = <nl> - properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> - if ( shape . unknown_rank ( ) ) { <nl> - / / Not optimizable . <nl> - continue ; <nl> - } <nl> - const auto & a = properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] ; <nl> - if ( TensorShape : : IsValid ( a . shape ( ) ) & & a . has_value ( ) ) { <nl> - Tensor axis ( a . dtype ( ) , a . shape ( ) ) ; <nl> - if ( ! axis . FromProto ( a . value ( ) ) ) { <nl> - return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> - a . value ( ) . DebugString ( ) ) ; <nl> - } <nl> - std : : set < int > target_axes ; <nl> - for ( int j = 0 ; j < axis . NumElements ( ) ; + + j ) { <nl> - / / value of axis can be negative . <nl> - if ( axis . dtype ( ) = = DT_INT64 ) { <nl> - target_axes . insert ( ( axis . vec < int64 > ( ) ( j ) + shape . dim_size ( ) ) % <nl> - shape . dim_size ( ) ) ; <nl> - } else { <nl> - target_axes . insert ( ( axis . vec < int > ( ) ( j ) + shape . dim_size ( ) ) % <nl> - shape . dim_size ( ) ) ; <nl> - } <nl> - } <nl> - <nl> - / / The node is replaceable iff <nl> - / / unknown_rank = = false & & <nl> - / / ( dim_size = = 0 | | all dims have size 1 | | <nl> - / / all dims with > 1 size are not in target_axes ) <nl> - bool replaceable = ! shape . unknown_rank ( ) ; <nl> - for ( int j = 0 ; replaceable & & j < shape . dim_size ( ) ; + + j ) { <nl> - replaceable & = shape . dim ( j ) . size ( ) = = 1 | | <nl> - target_axes . find ( j ) = = target_axes . end ( ) ; <nl> - } <nl> - if ( replaceable ) { <nl> - ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> - } <nl> - } <nl> + / / Remove RandomShuffle op if it is scalar or first dimension is of size 1 . <nl> + if ( use_shape_info & & IsRandomShuffle ( * node ) & & <nl> + ! properties - > GetInputProperties ( node - > name ( ) ) . empty ( ) ) { <nl> + const auto & shape = properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> + / / The node is replaceable iff <nl> + / / unknown_rank = = false & & ( dim_size = = 0 | | first dim is of size 1 ) <nl> + if ( ! shape . unknown_rank ( ) & & <nl> + ( shape . dim_size ( ) = = 0 | | shape . dim ( 0 ) . size ( ) = = 1 ) ) { <nl> + ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> } <nl> + } <nl> <nl> - if ( use_shape_info & & IsSlice ( * node ) & & <nl> - properties - > GetInputProperties ( node - > name ( ) ) . size ( ) = = 3 ) { <nl> - const auto & input = properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] ; <nl> - const auto & b = properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] ; <nl> - const auto & s = properties - > GetInputProperties ( node - > name ( ) ) [ 2 ] ; <nl> - if ( TensorShape : : IsValid ( b . shape ( ) ) & & b . has_value ( ) & & <nl> - TensorShape : : IsValid ( s . shape ( ) ) & & s . has_value ( ) ) { <nl> - Tensor begin ( b . dtype ( ) , b . shape ( ) ) ; <nl> - if ( ! begin . FromProto ( b . value ( ) ) ) { <nl> - return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> - b . value ( ) . DebugString ( ) ) ; <nl> - } <nl> - Tensor size ( s . dtype ( ) , s . shape ( ) ) ; <nl> - if ( ! size . FromProto ( s . value ( ) ) ) { <nl> - return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> - s . value ( ) . DebugString ( ) ) ; <nl> - } <nl> - / / The node is replaceable iff unknown_rank = = false & & <nl> - / / begin = = 0 & & ( size = = - 1 | | size = = input_shape ) for all dimensions <nl> - bool replaceable = ! input . shape ( ) . unknown_rank ( ) ; <nl> - for ( int j = 0 ; replaceable & & j < input . shape ( ) . dim_size ( ) ; + + j ) { <nl> - if ( begin . dtype ( ) = = DT_INT32 ) { <nl> - replaceable & = begin . vec < int > ( ) ( j ) = = 0 ; <nl> - } else { <nl> - replaceable & = begin . vec < int64 > ( ) ( j ) = = 0 ; <nl> - } <nl> - if ( size . dtype ( ) = = DT_INT32 ) { <nl> - replaceable & = ( size . vec < int > ( ) ( j ) = = - 1 | | <nl> - size . vec < int > ( ) ( j ) = = input . shape ( ) . dim ( j ) . size ( ) ) ; <nl> - } else { <nl> - replaceable & = <nl> - ( size . vec < int64 > ( ) ( j ) = = - 1 | | <nl> - size . vec < int64 > ( ) ( j ) = = input . shape ( ) . dim ( j ) . size ( ) ) ; <nl> - } <nl> - } <nl> - if ( replaceable ) { <nl> - ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> - } <nl> - } <nl> + / / Remove Reverse op over dimensions with size 1 . <nl> + if ( use_shape_info & & node - > op ( ) = = " ReverseV2 " & & <nl> + properties - > GetInputProperties ( node - > name ( ) ) . size ( ) > = 2 ) { <nl> + const auto & shape = properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> + if ( shape . unknown_rank ( ) ) { <nl> + / / Not optimizable . <nl> + return Status : : OK ( ) ; <nl> } <nl> - <nl> - if ( use_shape_info & & IsTile ( * node ) & & <nl> - properties - > GetInputProperties ( node - > name ( ) ) . size ( ) = = 2 ) { <nl> - const auto & m = properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] ; <nl> - if ( TensorShape : : IsValid ( m . shape ( ) ) & & m . has_value ( ) ) { <nl> - Tensor multiplies ( m . dtype ( ) , m . shape ( ) ) ; <nl> - if ( ! multiplies . FromProto ( m . value ( ) ) ) { <nl> - return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> - m . value ( ) . DebugString ( ) ) ; <nl> - } <nl> - / / The node is replaceable iff all values in multiplies are 1 . <nl> - bool replaceable = true ; <nl> - if ( multiplies . dtype ( ) = = DT_INT32 ) { <nl> - for ( int j = 0 ; replaceable & & j < multiplies . vec < int > ( ) . size ( ) ; <nl> - + + j ) { <nl> - replaceable & = multiplies . vec < int > ( ) ( j ) = = 1 ; <nl> - } <nl> + const auto & a = properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] ; <nl> + if ( TensorShape : : IsValid ( a . shape ( ) ) & & a . has_value ( ) ) { <nl> + Tensor axis ( a . dtype ( ) , a . shape ( ) ) ; <nl> + if ( ! axis . FromProto ( a . value ( ) ) ) { <nl> + return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> + a . value ( ) . DebugString ( ) ) ; <nl> + } <nl> + std : : set < int > target_axes ; <nl> + for ( int j = 0 ; j < axis . NumElements ( ) ; + + j ) { <nl> + / / value of axis can be negative . <nl> + if ( axis . dtype ( ) = = DT_INT64 ) { <nl> + target_axes . insert ( ( axis . vec < int64 > ( ) ( j ) + shape . dim_size ( ) ) % <nl> + shape . dim_size ( ) ) ; <nl> } else { <nl> - for ( int j = 0 ; replaceable & & j < multiplies . vec < int64 > ( ) . size ( ) ; <nl> - + + j ) { <nl> - replaceable & = multiplies . vec < int64 > ( ) ( j ) = = 1 ; <nl> - } <nl> - } <nl> - if ( replaceable ) { <nl> - ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> + target_axes . insert ( ( axis . vec < int > ( ) ( j ) + shape . dim_size ( ) ) % <nl> + shape . dim_size ( ) ) ; <nl> } <nl> } <nl> - } <nl> <nl> - if ( use_shape_info & & IsPad ( * node ) & & <nl> - properties - > GetInputProperties ( node - > name ( ) ) . size ( ) > = 2 ) { <nl> - const auto & p = properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] ; <nl> - if ( TensorShape : : IsValid ( p . shape ( ) ) & & p . has_value ( ) ) { <nl> - Tensor paddings ( p . dtype ( ) , p . shape ( ) ) ; <nl> - if ( ! paddings . FromProto ( p . value ( ) ) ) { <nl> - return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> - p . value ( ) . DebugString ( ) ) ; <nl> - } <nl> - / / The node is replaceable iff all values in paddings are 0 . <nl> - bool replaceable = true ; <nl> - / / The operation requires it to be int32 value so we don ' t check for <nl> - / / 1nt64 . <nl> - const auto flatten = paddings . flat < int32 > ( ) ; <nl> - for ( int j = 0 ; replaceable & & j < flatten . size ( ) ; + + j ) { <nl> - replaceable & = flatten ( j ) = = 0 ; <nl> - } <nl> - if ( replaceable ) { <nl> - ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> - } <nl> - } <nl> - } <nl> - <nl> - if ( use_shape_info & & IsSqueeze ( * node ) & & <nl> - ! properties - > GetInputProperties ( node - > name ( ) ) . empty ( ) ) { <nl> - / / https : / / www . tensorflow . org / api_docs / python / tf / squeeze mentions it ' s <nl> - / / error to squeeze a dimension that is not 1 , so we only need to check <nl> - / / whether the input has > 1 size for each dimension . <nl> - const auto & shape = <nl> - properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> / / The node is replaceable iff <nl> - / / unknown_rank = = false & & ( dim_size = = 0 | | all dims have size > 1 ) <nl> + / / unknown_rank = = false & & <nl> + / / ( dim_size = = 0 | | all dims have size 1 | | <nl> + / / all dims with > 1 size are not in target_axes ) <nl> bool replaceable = ! shape . unknown_rank ( ) ; <nl> for ( int j = 0 ; replaceable & & j < shape . dim_size ( ) ; + + j ) { <nl> - replaceable & = shape . dim ( j ) . size ( ) > 1 ; <nl> + replaceable & = shape . dim ( j ) . size ( ) = = 1 | | <nl> + target_axes . find ( j ) = = target_axes . end ( ) ; <nl> } <nl> if ( replaceable ) { <nl> ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> + return Status : : OK ( ) ; <nl> } <nl> } <nl> + } <nl> <nl> - if ( IsPack ( * node ) & & NumNonControlInputs ( * node ) = = 1 & & <nl> - ! OptimizedNodeExists ( * node , " _const_axis " ) ) { <nl> - / / Create constant axis node . <nl> - Tensor axis_t ( DT_INT32 , TensorShape ( { } ) ) ; <nl> - NodeDef * axis_node = optimized_graph - > add_node ( ) ; <nl> - axis_node - > set_name ( OptimizedNodeName ( * node , " _const_axis " ) ) ; <nl> - const int axis = node - > attr ( ) . at ( " axis " ) . i ( ) ; <nl> - if ( ! SetTensorValue ( DT_INT32 , axis , & axis_t ) . ok ( ) | | <nl> - ! CreateNodeDef ( axis_node - > name ( ) , TensorValue ( & axis_t ) , axis_node ) <nl> - . ok ( ) ) { <nl> - continue ; <nl> + if ( use_shape_info & & IsSlice ( * node ) & & <nl> + properties - > GetInputProperties ( node - > name ( ) ) . size ( ) = = 3 ) { <nl> + const auto & input = properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] ; <nl> + const auto & b = properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] ; <nl> + const auto & s = properties - > GetInputProperties ( node - > name ( ) ) [ 2 ] ; <nl> + if ( TensorShape : : IsValid ( b . shape ( ) ) & & b . has_value ( ) & & <nl> + TensorShape : : IsValid ( s . shape ( ) ) & & s . has_value ( ) ) { <nl> + Tensor begin ( b . dtype ( ) , b . shape ( ) ) ; <nl> + if ( ! begin . FromProto ( b . value ( ) ) ) { <nl> + return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> + b . value ( ) . DebugString ( ) ) ; <nl> } <nl> - / / Add a control dependency to make sure axis_node is in the right frame . <nl> - const string ctrl_dep = ConstantFolding : : AddControlDependency ( <nl> - node - > input ( 0 ) , graph_ , node_map_ . get ( ) ) ; <nl> - axis_node - > add_input ( ctrl_dep ) ; <nl> - axis_node - > set_device ( node - > device ( ) ) ; <nl> - node - > set_op ( " ExpandDims " ) ; <nl> - if ( node - > attr ( ) . count ( " axis " ) ! = 0 ) { <nl> - node - > mutable_attr ( ) - > erase ( " axis " ) ; <nl> + Tensor size ( s . dtype ( ) , s . shape ( ) ) ; <nl> + if ( ! size . FromProto ( s . value ( ) ) ) { <nl> + return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> + s . value ( ) . DebugString ( ) ) ; <nl> } <nl> - if ( node - > attr ( ) . count ( " N " ) ! = 0 ) { <nl> - node - > mutable_attr ( ) - > erase ( " N " ) ; <nl> + / / The node is replaceable iff unknown_rank = = false & & <nl> + / / begin = = 0 & & ( size = = - 1 | | size = = input_shape ) for all dimensions <nl> + bool replaceable = ! input . shape ( ) . unknown_rank ( ) ; <nl> + for ( int j = 0 ; replaceable & & j < input . shape ( ) . dim_size ( ) ; + + j ) { <nl> + if ( begin . dtype ( ) = = DT_INT32 ) { <nl> + replaceable & = begin . vec < int > ( ) ( j ) = = 0 ; <nl> + } else { <nl> + replaceable & = begin . vec < int64 > ( ) ( j ) = = 0 ; <nl> + } <nl> + if ( size . dtype ( ) = = DT_INT32 ) { <nl> + replaceable & = ( size . vec < int > ( ) ( j ) = = - 1 | | <nl> + size . vec < int > ( ) ( j ) = = input . shape ( ) . dim ( j ) . size ( ) ) ; <nl> + } else { <nl> + replaceable & = ( size . vec < int64 > ( ) ( j ) = = - 1 | | <nl> + size . vec < int64 > ( ) ( j ) = = input . shape ( ) . dim ( j ) . size ( ) ) ; <nl> + } <nl> } <nl> - ( * node - > mutable_attr ( ) ) [ " Tdim " ] . set_type ( DT_INT32 ) ; <nl> - node - > add_input ( axis_node - > name ( ) ) ; <nl> - if ( node - > input_size ( ) > 2 ) { <nl> - node - > mutable_input ( ) - > SwapElements ( 1 , node - > input_size ( ) - 1 ) ; <nl> + if ( replaceable ) { <nl> + ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> } <nl> - graph_modified_ = true ; <nl> - continue ; <nl> } <nl> + } <nl> <nl> - / / Move constants past Enter . <nl> - if ( IsEnter ( * node ) & & node - > input_size ( ) > 0 ) { <nl> - if ( node - > attr ( ) . count ( " is_constant " ) = = 0 | | <nl> - ! node - > attr ( ) . at ( " is_constant " ) . b ( ) ) { <nl> - continue ; <nl> + if ( use_shape_info & & IsTile ( * node ) & & <nl> + properties - > GetInputProperties ( node - > name ( ) ) . size ( ) = = 2 ) { <nl> + const auto & m = properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] ; <nl> + if ( TensorShape : : IsValid ( m . shape ( ) ) & & m . has_value ( ) ) { <nl> + Tensor multiplies ( m . dtype ( ) , m . shape ( ) ) ; <nl> + if ( ! multiplies . FromProto ( m . value ( ) ) ) { <nl> + return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> + m . value ( ) . DebugString ( ) ) ; <nl> } <nl> - const string & node_name = node - > name ( ) ; <nl> - const NodeDef * input = node_map_ - > GetNode ( node - > input ( 0 ) ) ; <nl> - if ( input ! = nullptr & & IsReallyConstant ( * input ) & & <nl> - ! OptimizedNodeExists ( * input , " _enter " ) ) { <nl> - auto fanouts = node_map_ - > GetOutputs ( node_name ) ; <nl> - / / Find non - constant nodes that consume the output of * node . <nl> - std : : vector < NodeDef * > consumers ; <nl> - for ( NodeDef * fanout : fanouts ) { <nl> - if ( ! IsConstant ( * fanout ) ) { <nl> - for ( int i = 0 ; i < fanout - > input_size ( ) ; + + i ) { <nl> - if ( fanout - > input ( i ) = = node_name ) { <nl> - consumers . push_back ( fanout ) ; <nl> - break ; <nl> - } <nl> - } <nl> - } <nl> + / / The node is replaceable iff all values in multiplies are 1 . <nl> + bool replaceable = true ; <nl> + if ( multiplies . dtype ( ) = = DT_INT32 ) { <nl> + for ( int j = 0 ; replaceable & & j < multiplies . vec < int > ( ) . size ( ) ; + + j ) { <nl> + replaceable & = multiplies . vec < int > ( ) ( j ) = = 1 ; <nl> } <nl> - if ( ! consumers . empty ( ) ) { <nl> - NodeDef * new_node = optimized_graph - > add_node ( ) ; <nl> - * new_node = * input ; <nl> - new_node - > set_name ( OptimizedNodeName ( * input , " _enter " ) ) ; <nl> - new_node - > set_device ( node - > device ( ) ) ; <nl> - new_node - > clear_input ( ) ; <nl> - new_node - > add_input ( AsControlDependency ( node_name ) ) ; <nl> - node_map_ - > AddNode ( new_node - > name ( ) , new_node ) ; <nl> - node_map_ - > AddOutput ( node_name , new_node - > name ( ) ) ; <nl> - for ( NodeDef * consumer : consumers ) { <nl> - for ( int i = 0 ; i < consumer - > input_size ( ) ; + + i ) { <nl> - if ( NodeName ( consumer - > input ( i ) ) = = node_name ) { <nl> - node_map_ - > UpdateInput ( consumer - > name ( ) , node_name , <nl> - new_node - > name ( ) ) ; <nl> - consumer - > set_input ( i , new_node - > name ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - graph_modified_ = true ; <nl> - continue ; <nl> + } else { <nl> + for ( int j = 0 ; replaceable & & j < multiplies . vec < int64 > ( ) . size ( ) ; <nl> + + + j ) { <nl> + replaceable & = multiplies . vec < int64 > ( ) ( j ) = = 1 ; <nl> } <nl> } <nl> + if ( replaceable ) { <nl> + ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> } <nl> + } <nl> <nl> - / / Switch ( x , x ) will always feed false to its false branch and true to <nl> - / / its true branch . By rewriting the graph a bit , we can propagate these <nl> - / / constants down the two output branches , and just use control dependencies <nl> - / / to trigger the selected one at runtime . For example , <nl> - / / <nl> - / / + mmmmmm + <nl> - / / x - - > | Switch | - - > a ( in practice there may be multiple consumers of each <nl> - / / x - - > | | - - > b output branch . ) <nl> - / / + mmmmmm + <nl> - / / <nl> - / / Is rewritten as <nl> - / / <nl> - / / + mmmmmm + <nl> - / / x - - > | Switch | - - > Identity - - ^ > Const ( false ) - - > a <nl> - / / x - - > | | - - > Identity - - ^ > Const ( true ) - - > b <nl> - / / + mmmmmm + <nl> - if ( node - > op ( ) = = " Switch " & & node - > input ( 0 ) = = node - > input ( 1 ) & & <nl> - ! OptimizedNodeExists ( * node , " _const_false " ) & & <nl> - ! OptimizedNodeExists ( * node , " _const_true " ) ) { <nl> - bool already_optimized = true ; <nl> - / / If the optimization was already applied , the switch would have exactly <nl> - / / one Identity node consuming each of its outputs , each without any <nl> - / / non - control outputs . <nl> - auto fanouts = node_map_ - > GetOutputs ( node - > name ( ) ) ; <nl> - if ( fanouts . size ( ) = = 2 ) { <nl> - for ( NodeDef * fanout : fanouts ) { <nl> - if ( ! IsIdentity ( * fanout ) | | <nl> - NumNonControlOutputs ( * fanout , * node_map_ ) > 0 ) { <nl> - already_optimized = false ; <nl> - break ; <nl> - } <nl> - } <nl> + if ( use_shape_info & & IsPad ( * node ) & & <nl> + properties - > GetInputProperties ( node - > name ( ) ) . size ( ) > = 2 ) { <nl> + const auto & p = properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] ; <nl> + if ( TensorShape : : IsValid ( p . shape ( ) ) & & p . has_value ( ) ) { <nl> + Tensor paddings ( p . dtype ( ) , p . shape ( ) ) ; <nl> + if ( ! paddings . FromProto ( p . value ( ) ) ) { <nl> + return errors : : InvalidArgument ( " Cannot parse tensor from proto : " , <nl> + p . value ( ) . DebugString ( ) ) ; <nl> } <nl> - Tensor false_t ( DT_BOOL , TensorShape ( { } ) ) ; <nl> - Tensor true_t ( DT_BOOL , TensorShape ( { } ) ) ; <nl> - / / Make sure we don ' t proceed if this switch node was already optimized . <nl> - if ( ! already_optimized & & SetTensorValue ( DT_BOOL , true , & true_t ) . ok ( ) & & <nl> - SetTensorValue ( DT_BOOL , false , & false_t ) . ok ( ) ) { <nl> - / / Copy the set of consumers of the switch as they will be manipulated <nl> - / / below . <nl> - const std : : set < NodeDef * > & consumer_set = <nl> - node_map_ - > GetOutputs ( node - > name ( ) ) ; <nl> - std : : vector < NodeDef * > consumers ( consumer_set . begin ( ) , <nl> - consumer_set . end ( ) ) ; <nl> - std : : sort ( consumers . begin ( ) , consumers . end ( ) , <nl> - [ ] ( const NodeDef * n1 , const NodeDef * n2 ) { <nl> - return n1 - > name ( ) < n2 - > name ( ) ; <nl> - } ) ; <nl> - / / Create constant false & true nodes . <nl> - NodeDef * false_node = optimized_graph - > add_node ( ) ; <nl> - false_node - > set_name ( OptimizedNodeName ( * node , " _const_false " ) ) ; <nl> - if ( ! CreateNodeDef ( false_node - > name ( ) , TensorValue ( & false_t ) , <nl> - false_node ) <nl> - . ok ( ) ) { <nl> - continue ; <nl> - } <nl> - false_node - > set_device ( node - > device ( ) ) ; <nl> + / / The node is replaceable iff all values in paddings are 0 . <nl> + bool replaceable = true ; <nl> + / / The operation requires it to be int32 value so we don ' t check for <nl> + / / 1nt64 . <nl> + const auto flatten = paddings . flat < int32 > ( ) ; <nl> + for ( int j = 0 ; replaceable & & j < flatten . size ( ) ; + + j ) { <nl> + replaceable & = flatten ( j ) = = 0 ; <nl> + } <nl> + if ( replaceable ) { <nl> + ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + } <nl> + } <nl> <nl> - NodeDef * true_node = optimized_graph - > add_node ( ) ; <nl> - true_node - > set_name ( OptimizedNodeName ( * node , " _const_true " ) ) ; <nl> - if ( ! CreateNodeDef ( true_node - > name ( ) , TensorValue ( & true_t ) , true_node ) <nl> - . ok ( ) ) { <nl> - continue ; <nl> - } <nl> - true_node - > set_device ( node - > device ( ) ) ; <nl> - <nl> - / / Add controls from the switch ports to the constants , and connect the <nl> - / / constants to the original switch outputs . <nl> - const string false_port = node - > name ( ) ; <nl> - const string true_port = strings : : StrCat ( node - > name ( ) , " : 1 " ) ; <nl> - const string false_ctrl_dep = <nl> - AddControlDependency ( false_port , optimized_graph , node_map_ . get ( ) ) ; <nl> - false_node - > add_input ( false_ctrl_dep ) ; <nl> - const string true_ctrl_dep = <nl> - AddControlDependency ( true_port , optimized_graph , node_map_ . get ( ) ) ; <nl> - true_node - > add_input ( true_ctrl_dep ) ; <nl> - <nl> - node_map_ - > AddNode ( false_node - > name ( ) , false_node ) ; <nl> - node_map_ - > AddNode ( true_node - > name ( ) , true_node ) ; <nl> - node_map_ - > AddOutput ( NodeName ( false_ctrl_dep ) , false_node - > name ( ) ) ; <nl> - node_map_ - > AddOutput ( NodeName ( true_ctrl_dep ) , true_node - > name ( ) ) ; <nl> + if ( use_shape_info & & IsSqueeze ( * node ) & & <nl> + ! properties - > GetInputProperties ( node - > name ( ) ) . empty ( ) ) { <nl> + / / https : / / www . tensorflow . org / api_docs / python / tf / squeeze mentions it ' s <nl> + / / error to squeeze a dimension that is not 1 , so we only need to check <nl> + / / whether the input has > 1 size for each dimension . <nl> + const auto & shape = properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> + / / The node is replaceable iff <nl> + / / unknown_rank = = false & & ( dim_size = = 0 | | all dims have size > 1 ) <nl> + bool replaceable = ! shape . unknown_rank ( ) ; <nl> + for ( int j = 0 ; replaceable & & j < shape . dim_size ( ) ; + + j ) { <nl> + replaceable & = shape . dim ( j ) . size ( ) > 1 ; <nl> + } <nl> + if ( replaceable ) { <nl> + ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + } <nl> + <nl> + if ( IsPack ( * node ) & & NumNonControlInputs ( * node ) = = 1 & & <nl> + ! OptimizedNodeExists ( * node , " _const_axis " ) ) { <nl> + / / Create constant axis node . <nl> + Tensor axis_t ( DT_INT32 , TensorShape ( { } ) ) ; <nl> + NodeDef * axis_node = optimized_graph - > add_node ( ) ; <nl> + axis_node - > set_name ( OptimizedNodeName ( * node , " _const_axis " ) ) ; <nl> + const int axis = node - > attr ( ) . at ( " axis " ) . i ( ) ; <nl> + if ( ! SetTensorValue ( DT_INT32 , axis , & axis_t ) . ok ( ) | | <nl> + ! CreateNodeDef ( axis_node - > name ( ) , TensorValue ( & axis_t ) , axis_node ) <nl> + . ok ( ) ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + / / Add a control dependency to make sure axis_node is in the right frame . <nl> + const string ctrl_dep = ConstantFolding : : AddControlDependency ( <nl> + node - > input ( 0 ) , graph_ , node_map_ . get ( ) ) ; <nl> + axis_node - > add_input ( ctrl_dep ) ; <nl> + axis_node - > set_device ( node - > device ( ) ) ; <nl> + node - > set_op ( " ExpandDims " ) ; <nl> + if ( node - > attr ( ) . count ( " axis " ) ! = 0 ) { <nl> + node - > mutable_attr ( ) - > erase ( " axis " ) ; <nl> + } <nl> + if ( node - > attr ( ) . count ( " N " ) ! = 0 ) { <nl> + node - > mutable_attr ( ) - > erase ( " N " ) ; <nl> + } <nl> + ( * node - > mutable_attr ( ) ) [ " Tdim " ] . set_type ( DT_INT32 ) ; <nl> + node - > add_input ( axis_node - > name ( ) ) ; <nl> + if ( node - > input_size ( ) > 2 ) { <nl> + node - > mutable_input ( ) - > SwapElements ( 1 , node - > input_size ( ) - 1 ) ; <nl> + } <nl> + graph_modified_ = true ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> <nl> + / / Move constants past Enter . <nl> + if ( IsEnter ( * node ) & & node - > input_size ( ) > 0 ) { <nl> + if ( node - > attr ( ) . count ( " is_constant " ) = = 0 | | <nl> + ! node - > attr ( ) . at ( " is_constant " ) . b ( ) ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + const string & node_name = node - > name ( ) ; <nl> + const NodeDef * input = node_map_ - > GetNode ( node - > input ( 0 ) ) ; <nl> + if ( input ! = nullptr & & IsReallyConstant ( * input ) & & <nl> + ! OptimizedNodeExists ( * input , " _enter " ) ) { <nl> + auto fanouts = node_map_ - > GetOutputs ( node_name ) ; <nl> + / / Find non - constant nodes that consume the output of * node . <nl> + std : : vector < NodeDef * > consumers ; <nl> + for ( NodeDef * fanout : fanouts ) { <nl> + if ( ! IsConstant ( * fanout ) ) { <nl> + for ( int i = 0 ; i < fanout - > input_size ( ) ; + + i ) { <nl> + if ( fanout - > input ( i ) = = node_name ) { <nl> + consumers . push_back ( fanout ) ; <nl> + break ; <nl> + } <nl> + } <nl> + } <nl> + } <nl> + if ( ! consumers . empty ( ) ) { <nl> + NodeDef * new_node = optimized_graph - > add_node ( ) ; <nl> + * new_node = * input ; <nl> + new_node - > set_name ( OptimizedNodeName ( * input , " _enter " ) ) ; <nl> + new_node - > set_device ( node - > device ( ) ) ; <nl> + new_node - > clear_input ( ) ; <nl> + new_node - > add_input ( AsControlDependency ( node_name ) ) ; <nl> + node_map_ - > AddNode ( new_node - > name ( ) , new_node ) ; <nl> + node_map_ - > AddOutput ( node_name , new_node - > name ( ) ) ; <nl> for ( NodeDef * consumer : consumers ) { <nl> for ( int i = 0 ; i < consumer - > input_size ( ) ; + + i ) { <nl> - const string & input = consumer - > input ( i ) ; <nl> - if ( input = = false_port ) { <nl> - consumer - > set_input ( i , false_node - > name ( ) ) ; <nl> - node_map_ - > UpdateInput ( consumer - > name ( ) , false_port , <nl> - false_node - > name ( ) ) ; <nl> - } else if ( input = = true_port ) { <nl> - consumer - > set_input ( i , true_node - > name ( ) ) ; <nl> - node_map_ - > UpdateInput ( consumer - > name ( ) , true_port , <nl> - true_node - > name ( ) ) ; <nl> + if ( NodeName ( consumer - > input ( i ) ) = = node_name ) { <nl> + node_map_ - > UpdateInput ( consumer - > name ( ) , node_name , <nl> + new_node - > name ( ) ) ; <nl> + consumer - > set_input ( i , new_node - > name ( ) ) ; <nl> } <nl> } <nl> } <nl> graph_modified_ = true ; <nl> - continue ; <nl> + return Status : : OK ( ) ; <nl> } <nl> } <nl> - if ( IsSimplifiableReduction ( * node ) ) { <nl> - / / Replace the reduction node with an identity node , that can be further <nl> - / / optimized by the model pruner . <nl> - DataType output_type ; <nl> - if ( node - > attr ( ) . count ( " T " ) > 0 ) { <nl> - output_type = node - > attr ( ) . at ( " T " ) . type ( ) ; <nl> - } else { <nl> - / / This is an ' any ' or ' all ' reduction . The output is always boolean . <nl> - output_type = DT_BOOL ; <nl> + } <nl> + <nl> + / / Switch ( x , x ) will always feed false to its false branch and true to <nl> + / / its true branch . By rewriting the graph a bit , we can propagate these <nl> + / / constants down the two output branches , and just use control dependencies <nl> + / / to trigger the selected one at runtime . For example , <nl> + / / <nl> + / / + mmmmmm + <nl> + / / x - - > | Switch | - - > a ( in practice there may be multiple consumers of each <nl> + / / x - - > | | - - > b output branch . ) <nl> + / / + mmmmmm + <nl> + / / <nl> + / / Is rewritten as <nl> + / / <nl> + / / + mmmmmm + <nl> + / / x - - > | Switch | - - > Identity - - ^ > Const ( false ) - - > a <nl> + / / x - - > | | - - > Identity - - ^ > Const ( true ) - - > b <nl> + / / + mmmmmm + <nl> + if ( node - > op ( ) = = " Switch " & & node - > input ( 0 ) = = node - > input ( 1 ) & & <nl> + ! OptimizedNodeExists ( * node , " _const_false " ) & & <nl> + ! OptimizedNodeExists ( * node , " _const_true " ) ) { <nl> + bool already_optimized = true ; <nl> + / / If the optimization was already applied , the switch would have exactly <nl> + / / one Identity node consuming each of its outputs , each without any <nl> + / / non - control outputs . <nl> + auto fanouts = node_map_ - > GetOutputs ( node - > name ( ) ) ; <nl> + if ( fanouts . size ( ) = = 2 ) { <nl> + for ( NodeDef * fanout : fanouts ) { <nl> + if ( ! IsIdentity ( * fanout ) | | <nl> + NumNonControlOutputs ( * fanout , * node_map_ ) > 0 ) { <nl> + already_optimized = false ; <nl> + break ; <nl> + } <nl> } <nl> - node - > set_op ( " Identity " ) ; <nl> - node - > clear_attr ( ) ; <nl> - ( * node - > mutable_attr ( ) ) [ " T " ] . set_type ( output_type ) ; <nl> - * node - > mutable_input ( 1 ) = AsControlDependency ( node - > input ( 1 ) ) ; <nl> - graph_modified_ = true ; <nl> - continue ; <nl> } <nl> - if ( use_shape_info & & IsSimplifiableReshape ( * node , * properties ) ) { <nl> - DataType output_type = node - > attr ( ) . at ( " T " ) . type ( ) ; <nl> - node - > set_op ( " Identity " ) ; <nl> - node - > clear_attr ( ) ; <nl> - ( * node - > mutable_attr ( ) ) [ " T " ] . set_type ( output_type ) ; <nl> - * node - > mutable_input ( 1 ) = AsControlDependency ( node - > input ( 1 ) ) ; <nl> - graph_modified_ = true ; <nl> - continue ; <nl> - } <nl> - <nl> - const bool is_mul = IsMul ( * node ) | | IsLogicalAnd ( * node ) ; <nl> - const bool is_matmul = IsMatMul ( * node ) ; <nl> - const bool is_add = IsAdd ( * node ) | | IsBiasAdd ( * node ) | | IsLogicalOr ( * node ) ; <nl> - const bool is_sub = IsSub ( * node ) ; <nl> - const bool is_any_div = IsAnyDiv ( * node ) ; <nl> - / / Simplify arithmetic operations with ones or zeros . <nl> - if ( use_shape_info & & <nl> - ( is_mul | | is_matmul | | is_add | | is_sub | | is_any_div ) & & <nl> - properties - > HasInputProperties ( node - > name ( ) ) & & <nl> - properties - > HasOutputProperties ( node - > name ( ) ) ) { <nl> - const NodeDef * x = node_map_ - > GetNode ( node - > input ( 0 ) ) ; <nl> - const NodeDef * y = node_map_ - > GetNode ( node - > input ( 1 ) ) ; <nl> - if ( x = = nullptr | | y = = nullptr ) { <nl> - return errors : : InvalidArgument ( " Invalid inputs to node : " , <nl> - node - > DebugString ( ) ) ; <nl> - } <nl> - const TensorShapeProto & output_shape = <nl> - properties - > GetOutputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> - <nl> - / / Simplify element - wise multiplication by ones or addition / subtraction <nl> - / / of zeros . <nl> - const TensorShapeProto & y_shape = <nl> - properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] . shape ( ) ; <nl> - const bool x_is_zero = IsZeros ( * x ) ; <nl> - const bool x_is_one = x_is_zero ? false : IsOnes ( * x ) ; <nl> - const bool y_matches_output_shape = ShapesEqual ( output_shape , y_shape ) ; <nl> - if ( y_matches_output_shape & & <nl> - ( ( is_mul & & x_is_one ) | | ( is_add & & x_is_zero ) ) ) { <nl> - / / 1 * y = y or 0 + y = y . <nl> - ReplaceOperationWithSnapshot ( 1 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> + Tensor false_t ( DT_BOOL , TensorShape ( { } ) ) ; <nl> + Tensor true_t ( DT_BOOL , TensorShape ( { } ) ) ; <nl> + / / Make sure we don ' t proceed if this switch node was already optimized . <nl> + if ( ! already_optimized & & SetTensorValue ( DT_BOOL , true , & true_t ) . ok ( ) & & <nl> + SetTensorValue ( DT_BOOL , false , & false_t ) . ok ( ) ) { <nl> + / / Copy the set of consumers of the switch as they will be manipulated <nl> + / / below . <nl> + const std : : set < NodeDef * > & consumer_set = <nl> + node_map_ - > GetOutputs ( node - > name ( ) ) ; <nl> + std : : vector < NodeDef * > consumers ( consumer_set . begin ( ) , consumer_set . end ( ) ) ; <nl> + std : : sort ( consumers . begin ( ) , consumers . end ( ) , <nl> + [ ] ( const NodeDef * n1 , const NodeDef * n2 ) { <nl> + return n1 - > name ( ) < n2 - > name ( ) ; <nl> + } ) ; <nl> + / / Create constant false & true nodes . <nl> + NodeDef * false_node = optimized_graph - > add_node ( ) ; <nl> + false_node - > set_name ( OptimizedNodeName ( * node , " _const_false " ) ) ; <nl> + if ( ! CreateNodeDef ( false_node - > name ( ) , TensorValue ( & false_t ) , false_node ) <nl> + . ok ( ) ) { <nl> + return Status : : OK ( ) ; <nl> } <nl> + false_node - > set_device ( node - > device ( ) ) ; <nl> <nl> - if ( y_matches_output_shape & & ( is_sub & & x_is_zero ) ) { <nl> - / / Replace 0 - y with Neg ( y ) . <nl> - ReplaceSubtractionFromZeroByNegation ( node , optimized_graph ) ; <nl> - continue ; <nl> + NodeDef * true_node = optimized_graph - > add_node ( ) ; <nl> + true_node - > set_name ( OptimizedNodeName ( * node , " _const_true " ) ) ; <nl> + if ( ! CreateNodeDef ( true_node - > name ( ) , TensorValue ( & true_t ) , true_node ) <nl> + . ok ( ) ) { <nl> + return Status : : OK ( ) ; <nl> } <nl> - <nl> - / / Replace 1 / y with Reciprocal op . <nl> - if ( y_matches_output_shape & & is_any_div & & x_is_one ) { <nl> - DataType type = node - > attr ( ) . at ( " T " ) . type ( ) ; <nl> - if ( DataTypeIsFloating ( type ) | | DataTypeIsComplex ( type ) ) { <nl> - ReplaceDivisionOfOnesByReciprocal ( node , optimized_graph ) ; <nl> - continue ; <nl> + true_node - > set_device ( node - > device ( ) ) ; <nl> + <nl> + / / Add controls from the switch ports to the constants , and connect the <nl> + / / constants to the original switch outputs . <nl> + const string false_port = node - > name ( ) ; <nl> + const string true_port = strings : : StrCat ( node - > name ( ) , " : 1 " ) ; <nl> + const string false_ctrl_dep = <nl> + AddControlDependency ( false_port , optimized_graph , node_map_ . get ( ) ) ; <nl> + false_node - > add_input ( false_ctrl_dep ) ; <nl> + const string true_ctrl_dep = <nl> + AddControlDependency ( true_port , optimized_graph , node_map_ . get ( ) ) ; <nl> + true_node - > add_input ( true_ctrl_dep ) ; <nl> + <nl> + node_map_ - > AddNode ( false_node - > name ( ) , false_node ) ; <nl> + node_map_ - > AddNode ( true_node - > name ( ) , true_node ) ; <nl> + node_map_ - > AddOutput ( NodeName ( false_ctrl_dep ) , false_node - > name ( ) ) ; <nl> + node_map_ - > AddOutput ( NodeName ( true_ctrl_dep ) , true_node - > name ( ) ) ; <nl> + <nl> + for ( NodeDef * consumer : consumers ) { <nl> + for ( int i = 0 ; i < consumer - > input_size ( ) ; + + i ) { <nl> + const string & input = consumer - > input ( i ) ; <nl> + if ( input = = false_port ) { <nl> + consumer - > set_input ( i , false_node - > name ( ) ) ; <nl> + node_map_ - > UpdateInput ( consumer - > name ( ) , false_port , <nl> + false_node - > name ( ) ) ; <nl> + } else if ( input = = true_port ) { <nl> + consumer - > set_input ( i , true_node - > name ( ) ) ; <nl> + node_map_ - > UpdateInput ( consumer - > name ( ) , true_port , <nl> + true_node - > name ( ) ) ; <nl> + } <nl> } <nl> } <nl> + graph_modified_ = true ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + } <nl> + if ( IsSimplifiableReduction ( * node ) ) { <nl> + / / Replace the reduction node with an identity node , that can be further <nl> + / / optimized by the model pruner . <nl> + DataType output_type ; <nl> + if ( node - > attr ( ) . count ( " T " ) > 0 ) { <nl> + output_type = node - > attr ( ) . at ( " T " ) . type ( ) ; <nl> + } else { <nl> + / / This is an ' any ' or ' all ' reduction . The output is always boolean . <nl> + output_type = DT_BOOL ; <nl> + } <nl> + node - > set_op ( " Identity " ) ; <nl> + node - > clear_attr ( ) ; <nl> + ( * node - > mutable_attr ( ) ) [ " T " ] . set_type ( output_type ) ; <nl> + * node - > mutable_input ( 1 ) = AsControlDependency ( node - > input ( 1 ) ) ; <nl> + graph_modified_ = true ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + if ( use_shape_info & & IsSimplifiableReshape ( * node , * properties ) ) { <nl> + DataType output_type = node - > attr ( ) . at ( " T " ) . type ( ) ; <nl> + node - > set_op ( " Identity " ) ; <nl> + node - > clear_attr ( ) ; <nl> + ( * node - > mutable_attr ( ) ) [ " T " ] . set_type ( output_type ) ; <nl> + * node - > mutable_input ( 1 ) = AsControlDependency ( node - > input ( 1 ) ) ; <nl> + graph_modified_ = true ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> <nl> - const TensorShapeProto & x_shape = <nl> - properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> - const bool y_is_zero = IsZeros ( * y ) ; <nl> - const bool y_is_one = y_is_zero ? false : IsOnes ( * y ) ; <nl> - const bool x_matches_output_shape = ShapesEqual ( output_shape , x_shape ) ; <nl> - if ( x_matches_output_shape & & ( ( ( is_mul | | is_any_div ) & & y_is_one ) | | <nl> - ( ( is_add | | is_sub ) & & y_is_zero ) ) ) { <nl> - / / x * 1 = x or x / 1 = x or x + / - 0 = x <nl> - ReplaceOperationWithSnapshot ( 0 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> - } <nl> + const bool is_mul = IsMul ( * node ) | | IsLogicalAnd ( * node ) ; <nl> + const bool is_matmul = IsMatMul ( * node ) ; <nl> + const bool is_add = IsAdd ( * node ) | | IsBiasAdd ( * node ) | | IsLogicalOr ( * node ) ; <nl> + const bool is_sub = IsSub ( * node ) ; <nl> + const bool is_any_div = IsAnyDiv ( * node ) ; <nl> + / / Simplify arithmetic operations with ones or zeros . <nl> + if ( use_shape_info & & <nl> + ( is_mul | | is_matmul | | is_add | | is_sub | | is_any_div ) & & <nl> + properties - > HasInputProperties ( node - > name ( ) ) & & <nl> + properties - > HasOutputProperties ( node - > name ( ) ) ) { <nl> + const NodeDef * x = node_map_ - > GetNode ( node - > input ( 0 ) ) ; <nl> + const NodeDef * y = node_map_ - > GetNode ( node - > input ( 1 ) ) ; <nl> + if ( x = = nullptr | | y = = nullptr ) { <nl> + return errors : : InvalidArgument ( " Invalid inputs to node : " , <nl> + node - > DebugString ( ) ) ; <nl> + } <nl> + const TensorShapeProto & output_shape = <nl> + properties - > GetOutputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> + <nl> + / / Simplify element - wise multiplication by ones or addition / subtraction <nl> + / / of zeros . <nl> + const TensorShapeProto & y_shape = <nl> + properties - > GetInputProperties ( node - > name ( ) ) [ 1 ] . shape ( ) ; <nl> + const bool x_is_zero = IsZeros ( * x ) ; <nl> + const bool x_is_one = x_is_zero ? false : IsOnes ( * x ) ; <nl> + const bool y_matches_output_shape = ShapesEqual ( output_shape , y_shape ) ; <nl> + if ( y_matches_output_shape & & <nl> + ( ( is_mul & & x_is_one ) | | ( is_add & & x_is_zero ) ) ) { <nl> + / / 1 * y = y or 0 + y = y . <nl> + ReplaceOperationWithSnapshot ( 1 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> <nl> - / / x OR true = true OR y = true . <nl> - const PartialTensorShape shp ( output_shape ) ; <nl> - if ( shp . IsFullyDefined ( ) & & IsLogicalOr ( * node ) & & <nl> - ( y_is_one | | x_is_one ) ) { <nl> - TF_RETURN_IF_ERROR ( ReplaceOperationWithConstant ( <nl> - 1 , * properties , output_shape , node , optimized_graph ) ) ; <nl> - } <nl> - <nl> - / / Simplify multiplication and matmul by zeros . <nl> - / / Also optimize zeros divided by a tensor , but only if we are in <nl> - / / aggressive mode , since we might get rid of divisions by zero . <nl> - bool optimize_zeros_divided_by_y = <nl> - is_any_div & & x_is_zero & & is_aggressive ; <nl> - if ( ( x_is_zero | | y_is_zero ) & & <nl> - ( is_mul | | is_matmul | | optimize_zeros_divided_by_y ) ) { <nl> - if ( shp . IsFullyDefined ( ) ) { <nl> - TF_RETURN_IF_ERROR ( ReplaceOperationWithConstant ( <nl> - 0 , * properties , output_shape , node , optimized_graph ) ) ; <nl> - continue ; <nl> - } <nl> - / / Even if an input shape is only partially known , we may known that it <nl> - / / matches the output shape and thus forward the corresponding zero <nl> - / / input . <nl> - if ( ( is_mul | | is_any_div ) & & x_is_zero & & x_matches_output_shape ) { <nl> - ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> - } else if ( is_mul & & y_is_zero & & y_matches_output_shape ) { <nl> - ReplaceOperationWithIdentity ( 1 , * properties , node , optimized_graph ) ; <nl> - continue ; <nl> - } <nl> - } <nl> + if ( y_matches_output_shape & & ( is_sub & & x_is_zero ) ) { <nl> + / / Replace 0 - y with Neg ( y ) . <nl> + ReplaceSubtractionFromZeroByNegation ( node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> } <nl> <nl> - / / Strength reduce floating point division by a constant Div ( x , const ) to <nl> - / / multiplication by the reciprocal Mul ( x , Reciprocal ( const ) ) . This in turn <nl> - / / will be constant folded to Mul ( x , 1 . 0 / const ) . <nl> - if ( node - > input_size ( ) > = 2 & & ( IsRealDiv ( * node ) | | IsDiv ( * node ) ) ) { <nl> - const string & const_input = node - > input ( 1 ) ; <nl> - const NodeDef * denom = node_map_ - > GetNode ( const_input ) ; <nl> - CHECK ( denom ! = nullptr ) ; <nl> - if ( ! IsReallyConstant ( * denom ) ) { <nl> - continue ; <nl> - } <nl> - if ( node - > attr ( ) . count ( " T " ) = = 0 ) { <nl> - continue ; <nl> - } <nl> + / / Replace 1 / y with Reciprocal op . <nl> + if ( y_matches_output_shape & & is_any_div & & x_is_one ) { <nl> DataType type = node - > attr ( ) . at ( " T " ) . type ( ) ; <nl> - if ( IsDiv ( * node ) & & <nl> - ! ( DataTypeIsFloating ( type ) | | DataTypeIsComplex ( type ) ) ) { <nl> - continue ; <nl> + if ( DataTypeIsFloating ( type ) | | DataTypeIsComplex ( type ) ) { <nl> + ReplaceDivisionOfOnesByReciprocal ( node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> } <nl> - / / Insert new reciprocal op and change node from Div to Mul . <nl> - NodeDef * reciprocal_node = optimized_graph - > add_node ( ) ; <nl> - reciprocal_node - > set_name ( OptimizedNodeName ( * node , " _recip " ) ) ; <nl> - reciprocal_node - > set_op ( " Reciprocal " ) ; <nl> - reciprocal_node - > set_device ( node - > device ( ) ) ; <nl> - node - > set_op ( " Mul " ) ; <nl> - / / Re - wire inputs and outputs . <nl> - reciprocal_node - > add_input ( const_input ) ; <nl> - ( * reciprocal_node - > mutable_attr ( ) ) [ " T " ] . set_type ( type ) ; <nl> - node - > set_input ( 1 , reciprocal_node - > name ( ) ) ; <nl> - node_map_ - > AddNode ( reciprocal_node - > name ( ) , reciprocal_node ) ; <nl> - node_map_ - > UpdateOutput ( node - > name ( ) , const_input , <nl> - reciprocal_node - > name ( ) ) ; <nl> - graph_modified_ = true ; <nl> - continue ; <nl> } <nl> <nl> - / / Consider the transformation <nl> - / / <nl> - / / + + = parent <nl> - / / / \ / \ <nl> - / / C + - - > X + = children <nl> - / / / \ / \ <nl> - / / X Y C Y = leaves <nl> - / / <nl> - / / where C is constant and X is non - constant , and ' + ' denotes an <nl> - / / associative and commutative operator like addition or multiplication . <nl> - / / This optimization pushes constants down in the tree to canonicalize it . <nl> - / / Moreoever , in cases where the child node has a second constant input Y <nl> - / / we will create a leaf node that can be folded , e . g . <nl> - / / <nl> - / / Add ( C1 , Add ( C2 , X ) ) - > Add ( X , Add ( C1 , C2 ) ) - > Add ( X , C1 + C2 ) <nl> - / / <nl> - / / TODO ( rmlarsen ) : Handle non - associative / non - commutative operators like <nl> - / / subtraction and division , as well as mixed subtraction / addition , <nl> - / / division / multiplication . <nl> - / / Don ' t touch BiasAdd since they can ' t handle vectors as their first <nl> - / / inputs . <nl> - if ( has_fetch_ & & ( IsAdd ( * node ) | | is_mul ) & & <nl> - NumNonControlInputs ( * node ) = = 2 ) { <nl> - NodeDef * left_child = node_map_ - > GetNode ( node - > input ( 0 ) ) ; <nl> - NodeDef * right_child = node_map_ - > GetNode ( node - > input ( 1 ) ) ; <nl> - / / One child must be constant , and the other the same op as the parent . <nl> - if ( node - > op ( ) ! = left_child - > op ( ) & & node - > op ( ) ! = right_child - > op ( ) ) { <nl> - continue ; <nl> - } <nl> - const bool left_child_is_constant = IsReallyConstant ( * left_child ) ; <nl> - const bool right_child_is_constant = IsReallyConstant ( * right_child ) ; <nl> - if ( ! left_child_is_constant & & ! right_child_is_constant ) { <nl> - continue ; <nl> - } <nl> - if ( node - > device ( ) ! = left_child - > device ( ) | | <nl> - node - > device ( ) ! = right_child - > device ( ) ) { <nl> - continue ; <nl> + const TensorShapeProto & x_shape = <nl> + properties - > GetInputProperties ( node - > name ( ) ) [ 0 ] . shape ( ) ; <nl> + const bool y_is_zero = IsZeros ( * y ) ; <nl> + const bool y_is_one = y_is_zero ? false : IsOnes ( * y ) ; <nl> + const bool x_matches_output_shape = ShapesEqual ( output_shape , x_shape ) ; <nl> + if ( x_matches_output_shape & & ( ( ( is_mul | | is_any_div ) & & y_is_one ) | | <nl> + ( ( is_add | | is_sub ) & & y_is_zero ) ) ) { <nl> + / / x * 1 = x or x / 1 = x or x + / - 0 = x <nl> + ReplaceOperationWithSnapshot ( 0 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + / / x OR true = true OR y = true . <nl> + const PartialTensorShape shp ( output_shape ) ; <nl> + if ( shp . IsFullyDefined ( ) & & IsLogicalOr ( * node ) & & ( y_is_one | | x_is_one ) ) { <nl> + TF_RETURN_IF_ERROR ( ReplaceOperationWithConstant ( <nl> + 1 , * properties , output_shape , node , optimized_graph ) ) ; <nl> + } <nl> + <nl> + / / Simplify multiplication and matmul by zeros . <nl> + / / Also optimize zeros divided by a tensor , but only if we are in <nl> + / / aggressive mode , since we might get rid of divisions by zero . <nl> + bool optimize_zeros_divided_by_y = is_any_div & & x_is_zero & & is_aggressive ; <nl> + if ( ( x_is_zero | | y_is_zero ) & & <nl> + ( is_mul | | is_matmul | | optimize_zeros_divided_by_y ) ) { <nl> + if ( shp . IsFullyDefined ( ) ) { <nl> + TF_RETURN_IF_ERROR ( ReplaceOperationWithConstant ( <nl> + 0 , * properties , output_shape , node , optimized_graph ) ) ; <nl> + return Status : : OK ( ) ; <nl> } <nl> - NodeDef * op_child_node = <nl> - left_child_is_constant ? right_child : left_child ; <nl> - NodeDef * const_child_node = <nl> - left_child_is_constant ? left_child : right_child ; <nl> - / / Make sure that it is safe to change the value of the child node - > <nl> - if ( op_child_node - > input_size ( ) < 2 | | <nl> - nodes_to_preserve_ . find ( op_child_node - > name ( ) ) ! = <nl> - nodes_to_preserve_ . end ( ) | | <nl> - NumNonControlOutputs ( * op_child_node , * node_map_ ) > 1 ) { <nl> - continue ; <nl> + / / Even if an input shape is only partially known , we may known that it <nl> + / / matches the output shape and thus forward the corresponding zero <nl> + / / input . <nl> + if ( ( is_mul | | is_any_div ) & & x_is_zero & & x_matches_output_shape ) { <nl> + ReplaceOperationWithIdentity ( 0 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> + } else if ( is_mul & & y_is_zero & & y_matches_output_shape ) { <nl> + ReplaceOperationWithIdentity ( 1 , * properties , node , optimized_graph ) ; <nl> + return Status : : OK ( ) ; <nl> } <nl> + } <nl> + } <nl> <nl> - / / Identify the nodes to swap . <nl> - NodeDef * left_leaf = node_map_ - > GetNode ( op_child_node - > input ( 0 ) ) ; <nl> - NodeDef * right_leaf = node_map_ - > GetNode ( op_child_node - > input ( 1 ) ) ; <nl> - const bool left_leaf_is_constant = IsReallyConstant ( * left_leaf ) ; <nl> - const bool right_leaf_is_constant = IsReallyConstant ( * right_leaf ) ; <nl> - if ( left_leaf_is_constant & & right_leaf_is_constant ) { <nl> - / / Child is already foldable , leave it alone . <nl> - continue ; <nl> - } <nl> - const int non_const_leaf_input = left_leaf_is_constant ? 1 : 0 ; <nl> - const int parent_const_input = left_child_is_constant ? 0 : 1 ; <nl> - const auto & child_output = node_map_ - > GetOutputs ( op_child_node - > name ( ) ) ; <nl> - if ( child_output . find ( const_child_node ) ! = child_output . end ( ) ) { <nl> - / / If there is a control edge from the child op to C , the transformation <nl> - / / would create a cycle in the graph . We know that it must be a control <nl> - / / edge . We can replace such a control edge with a control edge from A <nl> - / / to C . <nl> - CHECK ( MaybeRemoveControlInput ( op_child_node - > name ( ) , const_child_node , <nl> - graph_ , node_map_ . get ( ) ) ) ; <nl> - NodeDef * other_leaf = left_leaf_is_constant ? left_leaf : right_leaf ; <nl> - MaybeAddControlInput ( other_leaf - > name ( ) , const_child_node , graph_ , <nl> - node_map_ . get ( ) ) ; <nl> - } <nl> - <nl> - / / Swap the constant child with a non - constant leaf node . <nl> - node_map_ - > UpdateInput ( node - > name ( ) , node - > input ( parent_const_input ) , <nl> - op_child_node - > input ( non_const_leaf_input ) ) ; <nl> - node_map_ - > UpdateInput ( op_child_node - > name ( ) , <nl> - op_child_node - > input ( non_const_leaf_input ) , <nl> - node - > input ( parent_const_input ) ) ; <nl> - std : : swap ( * node - > mutable_input ( parent_const_input ) , <nl> - * op_child_node - > mutable_input ( non_const_leaf_input ) ) ; <nl> - graph_modified_ = true ; <nl> - continue ; <nl> + / / Strength reduce floating point division by a constant Div ( x , const ) to <nl> + / / multiplication by the reciprocal Mul ( x , Reciprocal ( const ) ) . This in turn <nl> + / / will be constant folded to Mul ( x , 1 . 0 / const ) . <nl> + if ( node - > input_size ( ) > = 2 & & ( IsRealDiv ( * node ) | | IsDiv ( * node ) ) ) { <nl> + const string & const_input = node - > input ( 1 ) ; <nl> + const NodeDef * denom = node_map_ - > GetNode ( const_input ) ; <nl> + CHECK ( denom ! = nullptr ) ; <nl> + if ( ! IsReallyConstant ( * denom ) ) { <nl> + return Status : : OK ( ) ; <nl> } <nl> + if ( node - > attr ( ) . count ( " T " ) = = 0 ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + DataType type = node - > attr ( ) . at ( " T " ) . type ( ) ; <nl> + if ( IsDiv ( * node ) & & <nl> + ! ( DataTypeIsFloating ( type ) | | DataTypeIsComplex ( type ) ) ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + / / Insert new reciprocal op and change node from Div to Mul . <nl> + NodeDef * reciprocal_node = optimized_graph - > add_node ( ) ; <nl> + reciprocal_node - > set_name ( OptimizedNodeName ( * node , " _recip " ) ) ; <nl> + reciprocal_node - > set_op ( " Reciprocal " ) ; <nl> + reciprocal_node - > set_device ( node - > device ( ) ) ; <nl> + node - > set_op ( " Mul " ) ; <nl> + / / Re - wire inputs and outputs . <nl> + reciprocal_node - > add_input ( const_input ) ; <nl> + ( * reciprocal_node - > mutable_attr ( ) ) [ " T " ] . set_type ( type ) ; <nl> + node - > set_input ( 1 , reciprocal_node - > name ( ) ) ; <nl> + node_map_ - > AddNode ( reciprocal_node - > name ( ) , reciprocal_node ) ; <nl> + node_map_ - > UpdateOutput ( node - > name ( ) , const_input , reciprocal_node - > name ( ) ) ; <nl> + graph_modified_ = true ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> <nl> - / / Partial constant propagation through IdentityN . <nl> - if ( IsIdentityN ( * node ) & & NumNonControlInputs ( * node ) > 0 ) { <nl> - const std : : set < NodeDef * > & tmp = node_map_ - > GetOutputs ( node - > name ( ) ) ; <nl> - const std : : vector < NodeDef * > consumers ( tmp . begin ( ) , tmp . end ( ) ) ; <nl> - bool updated_graph = false ; <nl> - for ( int input_idx = 0 ; input_idx < node - > input_size ( ) ; + + input_idx ) { <nl> - const string & input = node - > input ( input_idx ) ; <nl> - if ( IsControlInput ( input ) ) { <nl> - break ; <nl> - } <nl> - const NodeDef * input_node = node_map_ - > GetNode ( NodeName ( input ) ) ; <nl> - if ( input_node = = nullptr ) { <nl> - LOG ( ERROR ) < < " Bad input : " < < input ; <nl> - break ; <nl> - } <nl> - / / Forward constant inputs to outputs and add a control dependency on <nl> - / / the IdentityN node . <nl> - if ( IsReallyConstant ( * input_node ) ) { <nl> - / / Update each consumer . <nl> - for ( NodeDef * consumer : consumers ) { <nl> - bool add_dep = false ; <nl> - for ( int consumer_input_idx = 0 ; <nl> - consumer_input_idx < consumer - > input_size ( ) ; <nl> - + + consumer_input_idx ) { <nl> - const string & consumer_input = <nl> - consumer - > input ( consumer_input_idx ) ; <nl> - if ( IsControlInput ( consumer_input ) ) { <nl> - break ; <nl> - } <nl> - int output_idx ; <nl> - const string input_node_name = <nl> - ParseNodeName ( consumer_input , & output_idx ) ; <nl> - if ( input_node_name = = node - > name ( ) & & output_idx = = input_idx ) { <nl> - consumer - > set_input ( consumer_input_idx , input ) ; <nl> - / / We will keep the input from IdentityN through a control <nl> - / / dependency , so we only need to add the consumer as an output <nl> - / / for the constant input node . <nl> - node_map_ - > AddOutput ( NodeName ( input ) , consumer - > name ( ) ) ; <nl> - add_dep = true ; <nl> - } <nl> + / / Consider the transformation <nl> + / / <nl> + / / + + = parent <nl> + / / / \ / \ <nl> + / / C + - - > X + = children <nl> + / / / \ / \ <nl> + / / X Y C Y = leaves <nl> + / / <nl> + / / where C is constant and X is non - constant , and ' + ' denotes an <nl> + / / associative and commutative operator like addition or multiplication . <nl> + / / This optimization pushes constants down in the tree to canonicalize it . <nl> + / / Moreoever , in cases where the child node has a second constant input Y <nl> + / / we will create a leaf node that can be folded , e . g . <nl> + / / <nl> + / / Add ( C1 , Add ( C2 , X ) ) - > Add ( X , Add ( C1 , C2 ) ) - > Add ( X , C1 + C2 ) <nl> + / / <nl> + / / TODO ( rmlarsen ) : Handle non - associative / non - commutative operators like <nl> + / / subtraction and division , as well as mixed subtraction / addition , <nl> + / / division / multiplication . <nl> + / / Don ' t touch BiasAdd since they can ' t handle vectors as their first <nl> + / / inputs . <nl> + if ( has_fetch_ & & ( IsAdd ( * node ) | | is_mul ) & & <nl> + NumNonControlInputs ( * node ) = = 2 ) { <nl> + NodeDef * left_child = node_map_ - > GetNode ( node - > input ( 0 ) ) ; <nl> + NodeDef * right_child = node_map_ - > GetNode ( node - > input ( 1 ) ) ; <nl> + / / One child must be constant , and the other the same op as the parent . <nl> + if ( node - > op ( ) ! = left_child - > op ( ) & & node - > op ( ) ! = right_child - > op ( ) ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + const bool left_child_is_constant = IsReallyConstant ( * left_child ) ; <nl> + const bool right_child_is_constant = IsReallyConstant ( * right_child ) ; <nl> + if ( ! left_child_is_constant & & ! right_child_is_constant ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + if ( node - > device ( ) ! = left_child - > device ( ) | | <nl> + node - > device ( ) ! = right_child - > device ( ) ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + NodeDef * op_child_node = left_child_is_constant ? right_child : left_child ; <nl> + NodeDef * const_child_node = <nl> + left_child_is_constant ? left_child : right_child ; <nl> + / / Make sure that it is safe to change the value of the child node - > <nl> + if ( op_child_node - > input_size ( ) < 2 | | <nl> + nodes_to_preserve_ . find ( op_child_node - > name ( ) ) ! = <nl> + nodes_to_preserve_ . end ( ) | | <nl> + NumNonControlOutputs ( * op_child_node , * node_map_ ) > 1 ) { <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + / / Identify the nodes to swap . <nl> + NodeDef * left_leaf = node_map_ - > GetNode ( op_child_node - > input ( 0 ) ) ; <nl> + NodeDef * right_leaf = node_map_ - > GetNode ( op_child_node - > input ( 1 ) ) ; <nl> + const bool left_leaf_is_constant = IsReallyConstant ( * left_leaf ) ; <nl> + const bool right_leaf_is_constant = IsReallyConstant ( * right_leaf ) ; <nl> + if ( left_leaf_is_constant & & right_leaf_is_constant ) { <nl> + / / Child is already foldable , leave it alone . <nl> + return Status : : OK ( ) ; <nl> + } <nl> + const int non_const_leaf_input = left_leaf_is_constant ? 1 : 0 ; <nl> + const int parent_const_input = left_child_is_constant ? 0 : 1 ; <nl> + const auto & child_output = node_map_ - > GetOutputs ( op_child_node - > name ( ) ) ; <nl> + if ( child_output . find ( const_child_node ) ! = child_output . end ( ) ) { <nl> + / / If there is a control edge from the child op to C , the transformation <nl> + / / would create a cycle in the graph . We know that it must be a control <nl> + / / edge . We can replace such a control edge with a control edge from A <nl> + / / to C . <nl> + CHECK ( MaybeRemoveControlInput ( op_child_node - > name ( ) , const_child_node , <nl> + graph_ , node_map_ . get ( ) ) ) ; <nl> + NodeDef * other_leaf = left_leaf_is_constant ? left_leaf : right_leaf ; <nl> + MaybeAddControlInput ( other_leaf - > name ( ) , const_child_node , graph_ , <nl> + node_map_ . get ( ) ) ; <nl> + } <nl> + <nl> + / / Swap the constant child with a non - constant leaf node . <nl> + node_map_ - > UpdateInput ( node - > name ( ) , node - > input ( parent_const_input ) , <nl> + op_child_node - > input ( non_const_leaf_input ) ) ; <nl> + node_map_ - > UpdateInput ( op_child_node - > name ( ) , <nl> + op_child_node - > input ( non_const_leaf_input ) , <nl> + node - > input ( parent_const_input ) ) ; <nl> + std : : swap ( * node - > mutable_input ( parent_const_input ) , <nl> + * op_child_node - > mutable_input ( non_const_leaf_input ) ) ; <nl> + graph_modified_ = true ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + / / Partial constant propagation through IdentityN . <nl> + if ( IsIdentityN ( * node ) & & NumNonControlInputs ( * node ) > 0 ) { <nl> + const std : : set < NodeDef * > & tmp = node_map_ - > GetOutputs ( node - > name ( ) ) ; <nl> + const std : : vector < NodeDef * > consumers ( tmp . begin ( ) , tmp . end ( ) ) ; <nl> + bool updated_graph = false ; <nl> + for ( int input_idx = 0 ; input_idx < node - > input_size ( ) ; + + input_idx ) { <nl> + const string & input = node - > input ( input_idx ) ; <nl> + if ( IsControlInput ( input ) ) { <nl> + break ; <nl> + } <nl> + const NodeDef * input_node = node_map_ - > GetNode ( NodeName ( input ) ) ; <nl> + if ( input_node = = nullptr ) { <nl> + LOG ( ERROR ) < < " Bad input : " < < input ; <nl> + break ; <nl> + } <nl> + / / Forward constant inputs to outputs and add a control dependency on <nl> + / / the IdentityN node . <nl> + if ( IsReallyConstant ( * input_node ) ) { <nl> + / / Update each consumer . <nl> + for ( NodeDef * consumer : consumers ) { <nl> + bool add_dep = false ; <nl> + for ( int consumer_input_idx = 0 ; <nl> + consumer_input_idx < consumer - > input_size ( ) ; <nl> + + + consumer_input_idx ) { <nl> + const string & consumer_input = consumer - > input ( consumer_input_idx ) ; <nl> + if ( IsControlInput ( consumer_input ) ) { <nl> + break ; <nl> } <nl> - if ( add_dep ) { <nl> - consumer - > add_input ( AsControlDependency ( node - > name ( ) ) ) ; <nl> - updated_graph = true ; <nl> + int output_idx ; <nl> + const string input_node_name = <nl> + ParseNodeName ( consumer_input , & output_idx ) ; <nl> + if ( input_node_name = = node - > name ( ) & & output_idx = = input_idx ) { <nl> + consumer - > set_input ( consumer_input_idx , input ) ; <nl> + / / We will keep the input from IdentityN through a control <nl> + / / dependency , so we only need to add the consumer as an output <nl> + / / for the constant input node . <nl> + node_map_ - > AddOutput ( NodeName ( input ) , consumer - > name ( ) ) ; <nl> + add_dep = true ; <nl> } <nl> } <nl> + if ( add_dep ) { <nl> + consumer - > add_input ( AsControlDependency ( node - > name ( ) ) ) ; <nl> + updated_graph = true ; <nl> + } <nl> } <nl> } <nl> - <nl> - if ( updated_graph ) { <nl> - for ( NodeDef * consumer : consumers ) { <nl> - DedupControlInputs ( consumer ) ; <nl> - } <nl> - graph_modified_ = true ; <nl> - continue ; <nl> - } <nl> } <nl> <nl> - if ( PartialAssocOpConstFolding ( optimized_graph , properties , node ) ) { <nl> + if ( updated_graph ) { <nl> + for ( NodeDef * consumer : consumers ) { <nl> + DedupControlInputs ( consumer ) ; <nl> + } <nl> graph_modified_ = true ; <nl> - continue ; <nl> + return Status : : OK ( ) ; <nl> } <nl> + } <nl> <nl> - if ( PartialConcatConstFolding ( optimized_graph , properties , node ) ) { <nl> - graph_modified_ = true ; <nl> - continue ; <nl> - } <nl> + if ( PartialAssocOpConstFolding ( optimized_graph , properties , node ) ) { <nl> + graph_modified_ = true ; <nl> + return Status : : OK ( ) ; <nl> + } <nl> + <nl> + if ( PartialConcatConstFolding ( optimized_graph , properties , node ) ) { <nl> + graph_modified_ = true ; <nl> + return Status : : OK ( ) ; <nl> } <nl> <nl> return Status : : OK ( ) ; <nl> mmm a / tensorflow / core / grappler / optimizers / constant_folding . h <nl> ppp b / tensorflow / core / grappler / optimizers / constant_folding . h <nl> class ConstantFolding : public GraphOptimizer { <nl> const GraphProperties & properties ) const ; <nl> Status SimplifyGraph ( GraphDef * output , GraphProperties * properties , <nl> bool use_shape_info ) ; <nl> + Status SimplifyNode ( NodeDef * node , GraphDef * optimized_graph , <nl> + GraphProperties * properties , bool use_shape_info ) ; <nl> <nl> Status RunOptimizationPass ( Cluster * cluster , const GrapplerItem & item , <nl> GraphDef * output ) ; <nl>
|
Break out node loop from ConstantFolding : : SimplifyGraph .
|
tensorflow/tensorflow
|
0172ce3504dc455198b67d9cdda19bce012af1a9
|
2018-05-10T19:30:59Z
|
mmm a / vnext / CopyHeaders . inc <nl> ppp b / vnext / CopyHeaders . inc <nl> COPYFILES_PASS0 = \ <nl> ReactCommon \ jsi \ jsi . h , jsi ; \ <nl> ReactCommon \ jsi \ jsi - inl . h , jsi ; \ <nl> ReactCommon \ jsi \ V8Runtime . h , jsi ; \ <nl> - ReactWindows \ Chakra \ ChakraRuntime . h , jsi ; \ <nl> mmm a / vnext / make . inc <nl> ppp b / vnext / make . inc <nl> INCLUDES = $ ( INCLUDES ) ; \ <nl> $ ( OPENSOURCE_REACTNATIVE ) \ OfficeISS \ ReactWindows \ include \ ReactWindowsCore ; \ <nl> $ ( OPENSOURCE_REACTNATIVE ) \ OfficeISS \ ReactWindows \ Desktop ; \ <nl> $ ( OPENSOURCE_REACTNATIVE ) \ OfficeISS \ ReactWindows \ ReactWindowsCore ; \ <nl> + $ ( PKGMICROSOFT_CHAKRACORE_VC140 ) \ build \ native \ include ; \ <nl> $ ( OPENSOURCE_OPENSSL ) ; \ <nl> <nl> + ! LISTFILES - recursive CHAKRACORE_HEADERS = $ ( PKGMICROSOFT_CHAKRACORE_VC140 ) * . h <nl> ! LISTFILES - recursive JAVASCRIPTCORE_TEMP_HEADERS = $ ( PKGJAVASCRIPTCORE_TEMP ) * . h <nl> ! LISTFILES - recursive BOOST_HEADERS = $ ( PKGBOOST ) * <nl> <nl> HEADERS = $ ( HEADERS ) \ <nl> + $ ( CHAKRACORE_HEADERS ) \ <nl> $ ( JAVASCRIPTCORE_TEMP_HEADERS ) \ <nl> $ ( BOOST_HEADERS ) \ <nl> <nl>
|
Internal build fixes ( )
|
microsoft/react-native-windows
|
718572fff46ca5d9d26f6ce8853155e150e4890a
|
2019-05-09T20:51:38Z
|
mmm a / arangod / V8Server / v8 - wrapshapedjson . cpp <nl> ppp b / arangod / V8Server / v8 - wrapshapedjson . cpp <nl> static int32_t const WRP_SHAPED_JSON_TYPE = 4 ; <nl> static int const SLOT_BARRIER = 2 ; <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> - / / / @ brief add basic attributes ( _key , _rev , _from , _to ) to a document object <nl> + / / / @ brief get basic attributes ( _id , _key , _rev , _from , _to ) for a JavaScript <nl> + / / / document object <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> <nl> - static v8 : : Handle < v8 : : Object > AddBasicDocumentAttributes ( CollectionNameResolver const * resolver , <nl> - TRI_v8_global_t * v8g , <nl> - TRI_voc_cid_t cid , <nl> - TRI_df_marker_t const * marker , <nl> - v8 : : Handle < v8 : : Object > result ) { <nl> + static v8 : : Handle < v8 : : Object > SetBasicDocumentAttributesJs ( CollectionNameResolver const * resolver , <nl> + TRI_v8_global_t * v8g , <nl> + TRI_voc_cid_t cid , <nl> + TRI_df_marker_t const * marker ) { <nl> v8 : : HandleScope scope ; <nl> TRI_ASSERT ( marker ! = nullptr ) ; <nl> <nl> + v8 : : Handle < v8 : : Object > result = v8 : : Object : : New ( ) ; <nl> + <nl> / / buffer that we ' ll use for generating _id , _key , _rev , _from and _to values <nl> / / using a single buffer will avoid several memory allocation <nl> char buffer [ TRI_COL_NAME_LENGTH + TRI_VOC_KEY_MAX_LENGTH + 2 ] ; <nl> static v8 : : Handle < v8 : : Object > AddBasicDocumentAttributes ( CollectionNameResolver <nl> return scope . Close ( result ) ; <nl> } <nl> <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + / / / @ brief add basic attributes ( _id , _key , _rev , _from , _to ) to a ShapedJson <nl> + / / / object <nl> + / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> + <nl> + static v8 : : Handle < v8 : : Object > SetBasicDocumentAttributesShaped ( CollectionNameResolver const * resolver , <nl> + TRI_v8_global_t * v8g , <nl> + TRI_voc_cid_t cid , <nl> + TRI_df_marker_t const * marker , <nl> + v8 : : Handle < v8 : : Object > & result ) { <nl> + v8 : : HandleScope scope ; <nl> + TRI_ASSERT ( marker ! = nullptr ) ; <nl> + <nl> + / / buffer that we ' ll use for generating _id , _key , _rev , _from and _to values <nl> + / / using a single buffer will avoid several memory allocation <nl> + char buffer [ TRI_COL_NAME_LENGTH + TRI_VOC_KEY_MAX_LENGTH + 2 ] ; <nl> + <nl> + / / _id <nl> + size_t len = resolver - > getCollectionName ( buffer , cid ) ; <nl> + char const * docKey = TRI_EXTRACT_MARKER_KEY ( marker ) ; <nl> + TRI_ASSERT ( docKey ! = nullptr ) ; <nl> + size_t keyLength = strlen ( docKey ) ; <nl> + buffer [ len ] = ' / ' ; <nl> + memcpy ( buffer + len + 1 , docKey , keyLength ) ; <nl> + result - > ForceSet ( v8g - > _IdKey , v8 : : String : : New ( buffer , ( int ) ( len + keyLength + 1 ) ) ) ; <nl> + <nl> + TRI_df_marker_type_t type = marker - > _type ; <nl> + char const * base = reinterpret_cast < char const * > ( marker ) ; <nl> + <nl> + if ( type = = TRI_DOC_MARKER_KEY_EDGE ) { <nl> + TRI_doc_edge_key_marker_t const * m = reinterpret_cast < TRI_doc_edge_key_marker_t const * > ( marker ) ; <nl> + <nl> + / / _from <nl> + len = resolver - > getCollectionNameCluster ( buffer , m - > _fromCid ) ; <nl> + keyLength = strlen ( base + m - > _offsetFromKey ) ; <nl> + buffer [ len ] = ' / ' ; <nl> + memcpy ( buffer + len + 1 , base + m - > _offsetFromKey , keyLength ) ; <nl> + result - > ForceSet ( v8g - > _FromKey , v8 : : String : : New ( buffer , ( int ) ( len + keyLength + 1 ) ) ) ; <nl> + <nl> + / / _to <nl> + if ( m - > _fromCid ! = m - > _toCid ) { <nl> + / / only lookup collection name if we haven ' t done it yet <nl> + len = resolver - > getCollectionNameCluster ( buffer , m - > _toCid ) ; <nl> + } <nl> + keyLength = strlen ( base + m - > _offsetToKey ) ; <nl> + buffer [ len ] = ' / ' ; <nl> + memcpy ( buffer + len + 1 , base + m - > _offsetToKey , keyLength ) ; <nl> + result - > ForceSet ( v8g - > _ToKey , v8 : : String : : New ( buffer , ( int ) ( len + keyLength + 1 ) ) ) ; <nl> + } <nl> + else if ( type = = TRI_WAL_MARKER_EDGE ) { <nl> + triagens : : wal : : edge_marker_t const * m = reinterpret_cast < triagens : : wal : : edge_marker_t const * > ( marker ) ; <nl> + <nl> + / / _from <nl> + len = resolver - > getCollectionNameCluster ( buffer , m - > _fromCid ) ; <nl> + keyLength = strlen ( base + m - > _offsetFromKey ) ; <nl> + buffer [ len ] = ' / ' ; <nl> + memcpy ( buffer + len + 1 , base + m - > _offsetFromKey , keyLength ) ; <nl> + result - > ForceSet ( v8g - > _FromKey , v8 : : String : : New ( buffer , ( int ) ( len + keyLength + 1 ) ) ) ; <nl> + <nl> + / / _to <nl> + if ( m - > _fromCid ! = m - > _toCid ) { <nl> + / / only lookup collection name if we haven ' t done it yet <nl> + len = resolver - > getCollectionNameCluster ( buffer , m - > _toCid ) ; <nl> + } <nl> + keyLength = strlen ( base + m - > _offsetToKey ) ; <nl> + buffer [ len ] = ' / ' ; <nl> + memcpy ( buffer + len + 1 , base + m - > _offsetToKey , keyLength ) ; <nl> + result - > ForceSet ( v8g - > _ToKey , v8 : : String : : New ( buffer , ( int ) ( len + keyLength + 1 ) ) ) ; <nl> + } <nl> + <nl> + return scope . Close ( result ) ; <nl> + } <nl> + <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> / / / @ brief weak reference callback for a barrier <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> v8 : : Handle < v8 : : Value > TRI_WrapShapedJson ( triagens : : arango : : CollectionNameResolv <nl> return v8 : : Object : : New ( ) ; <nl> } <nl> <nl> - v8 : : Handle < v8 : : Object > result = v8 : : Object : : New ( ) ; <nl> - result = AddBasicDocumentAttributes ( resolver , v8g , cid , marker , result ) ; <nl> + v8 : : Handle < v8 : : Object > result = SetBasicDocumentAttributesJs ( resolver , v8g , cid , marker ) ; <nl> <nl> - return TRI_JsonShapeData ( result , shaper , shape , json . _data . data , json . _data . length ) ; <nl> + return scope . Close ( TRI_JsonShapeData ( result , shaper , shape , json . _data . data , json . _data . length ) ) ; <nl> } <nl> <nl> / / we ' ll create a document stub , with a pointer into the datafile <nl> v8 : : Handle < v8 : : Value > TRI_WrapShapedJson ( triagens : : arango : : CollectionNameResolv <nl> result - > SetInternalField ( SLOT_BARRIER , ( * it ) . second ) ; <nl> } <nl> <nl> - return scope . Close ( AddBasicDocumentAttributes ( resolver , v8g , cid , marker , result ) ) ; <nl> + return scope . Close ( SetBasicDocumentAttributesShaped ( resolver , v8g , cid , marker , result ) ) ; <nl> } <nl> <nl> / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / <nl> static v8 : : Handle < v8 : : Value > MapGetNamedShapedJson ( v8 : : Local < v8 : : String > name , <nl> } <nl> <nl> if ( key [ 0 ] = = ' _ ' ) { <nl> - if ( key = = TRI_VOC_ATTRIBUTE_KEY | | <nl> - key = = TRI_VOC_ATTRIBUTE_REV | | <nl> - key = = TRI_VOC_ATTRIBUTE_ID | | <nl> + char buffer [ TRI_VOC_KEY_MAX_LENGTH + 1 ] ; <nl> + <nl> + if ( key = = TRI_VOC_ATTRIBUTE_KEY ) { <nl> + char const * docKey = TRI_EXTRACT_MARKER_KEY ( static_cast < TRI_df_marker_t const * > ( marker ) ) ; <nl> + TRI_ASSERT ( docKey ! = nullptr ) ; <nl> + size_t keyLength = strlen ( docKey ) ; <nl> + memcpy ( buffer , docKey , keyLength ) ; <nl> + return scope . Close ( v8 : : String : : New ( buffer , ( int ) keyLength ) ) ; <nl> + } <nl> + else if ( key = = TRI_VOC_ATTRIBUTE_REV ) { <nl> + TRI_voc_rid_t rid = TRI_EXTRACT_MARKER_RID ( static_cast < TRI_df_marker_t const * > ( marker ) ) ; <nl> + TRI_ASSERT ( rid > 0 ) ; <nl> + size_t len = TRI_StringUInt64InPlace ( ( uint64_t ) rid , ( char * ) & buffer ) ; <nl> + return scope . Close ( v8 : : String : : New ( ( char const * ) buffer , ( int ) len ) ) ; <nl> + } <nl> + <nl> + if ( key = = TRI_VOC_ATTRIBUTE_ID | | <nl> key = = TRI_VOC_ATTRIBUTE_FROM | | <nl> key = = TRI_VOC_ATTRIBUTE_TO ) { <nl> / / strip reserved attributes <nl>
|
less memory usage for ShapedJson documents
|
arangodb/arangodb
|
79c584d3623d2fccb63811e1c1d848664a2d7730
|
2014-09-22T14:43:31Z
|
mmm a / xbmc / windowing / windows / WinEventsWin32 . cpp <nl> ppp b / xbmc / windowing / windows / WinEventsWin32 . cpp <nl> static int XBMC_MapVirtualKey ( int scancode , WPARAM vkey ) <nl> case VK_LAUNCH_MEDIA_SELECT : <nl> case VK_LAUNCH_APP1 : <nl> case VK_LAUNCH_APP2 : <nl> - return vkey ; <nl> + return static_cast < int > ( vkey ) ; <nl> default : ; <nl> } <nl> switch ( mvke ) <nl> static int XBMC_MapVirtualKey ( int scancode , WPARAM vkey ) <nl> case VK_PRIOR : return EXTKEYPAD ( VK_NUMPAD9 ) ; <nl> default : ; <nl> } <nl> - return mvke ? mvke : vkey ; <nl> + return mvke ? mvke : static_cast < int > ( vkey ) ; <nl> } <nl> <nl> <nl> static XBMC_keysym * TranslateKey ( WPARAM vkey , UINT scancode , XBMC_keysym * keysym <nl> * so we handle it as a special case here * / <nl> if ( ( keystate [ VK_NUMLOCK ] & 1 ) & & vkey > = VK_NUMPAD0 & & vkey < = VK_NUMPAD9 ) <nl> { <nl> - keysym - > unicode = vkey - VK_NUMPAD0 + ' 0 ' ; <nl> + keysym - > unicode = static_cast < uint16_t > ( vkey - VK_NUMPAD0 + ' 0 ' ) ; <nl> } <nl> else if ( ToUnicode ( static_cast < UINT > ( vkey ) , scancode , keystate , reinterpret_cast < LPWSTR > ( wchars ) , ARRAY_SIZE ( wchars ) , 0 ) > 0 ) <nl> { <nl> mmm a / xbmc / windowing / windows / WinSystemWin32 . cpp <nl> ppp b / xbmc / windowing / windows / WinSystemWin32 . cpp <nl> bool CWinSystemWin32 : : CreateNewWindow ( const std : : string & name , bool fullScreen , <nl> <nl> m_inFocus = true ; <nl> <nl> - const DWORD dwHwndTabletProperty = <nl> + DWORD dwHwndTabletProperty = <nl> TABLET_DISABLE_PENBARRELFEEDBACK | / / disables UI feedback on pen button down ( circle ) <nl> TABLET_DISABLE_FLICKS ; / / disables pen flicks ( back , forward , drag down , drag up ) <nl> <nl> - SetProp ( hWnd , MICROSOFT_TABLETPENSERVICE_PROPERTY , reinterpret_cast < HANDLE > ( dwHwndTabletProperty ) ) ; <nl> + SetProp ( hWnd , MICROSOFT_TABLETPENSERVICE_PROPERTY , & dwHwndTabletProperty ) ; <nl> <nl> m_hWnd = hWnd ; <nl> m_bWindowCreated = true ; <nl> bool CWinSystemWin32 : : CreateBlankWindows ( ) <nl> } <nl> <nl> / / We need as many blank windows as there are screens ( minus 1 ) <nl> - int BlankWindowsCount = m_MonitorsInfo . size ( ) - 1 ; <nl> + size_t BlankWindowsCount = m_MonitorsInfo . size ( ) - 1 ; <nl> <nl> - for ( int i = 0 ; i < BlankWindowsCount ; i + + ) <nl> + for ( size_t i = 0 ; i < BlankWindowsCount ; i + + ) <nl> { <nl> HWND hBlankWindow = CreateWindowEx ( WS_EX_TOPMOST , L " BlankWindowClass " , L " " , WS_POPUP | WS_DISABLED , <nl> CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , nullptr , nullptr , nullptr , nullptr ) ; <nl> bool CWinSystemWin32 : : UpdateResolutionsInternal ( ) <nl> <nl> / / Careful , some adapters don ' t end up in the vector ( mirroring , no active output , etc . ) <nl> if ( ddAdapter . StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE ) <nl> - m_nPrimary = m_MonitorsInfo . size ( ) - 1 ; <nl> + m_nPrimary = static_cast < int > ( m_MonitorsInfo . size ( ) ) - 1 ; <nl> <nl> } <nl> } <nl> void CWinSystemWin32 : : SetForegroundWindowInternal ( HWND hWnd ) <nl> <nl> if ( dwThisTID ! = dwCurrTID ) <nl> { <nl> - SystemParametersInfo ( SPI_SETFOREGROUNDLOCKTIMEOUT , 0 , reinterpret_cast < PVOID > ( lockTimeOut ) , SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE ) ; <nl> + SystemParametersInfo ( SPI_SETFOREGROUNDLOCKTIMEOUT , 0 , & lockTimeOut , SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE ) ; <nl> AttachThreadInput ( dwThisTID , dwCurrTID , FALSE ) ; <nl> } <nl> } <nl> mmm a / xbmc / windowing / windows / WinSystemWin32 . h <nl> ppp b / xbmc / windowing / windows / WinSystemWin32 . h <nl> DECLARE_HANDLE ( HGESTUREINFO ) ; <nl> <nl> # endif <nl> <nl> + # ifdef IsMinimized <nl> + # undef IsMinimized <nl> + # endif <nl> + <nl> class CWinSystemWin32 : public CWinSystemBase <nl> { <nl> public : <nl> class CWinSystemWin32 : public CWinSystemBase <nl> void UpdateResolutions ( ) override ; <nl> bool CenterWindow ( ) override ; <nl> virtual void NotifyAppFocusChange ( bool bGaining ) override ; <nl> - int GetNumScreens ( ) override { return m_MonitorsInfo . size ( ) ; } ; <nl> + int GetNumScreens ( ) override { return static_cast < int > ( m_MonitorsInfo . size ( ) ) ; } ; <nl> int GetCurrentScreen ( ) override ; <nl> void ShowOSMouse ( bool show ) override ; <nl> bool HasInertialGestures ( ) override { return true ; } / / if win32 has touchscreen - it uses the win32 gesture api for inertial scrolling <nl> mmm a / xbmc / windowing / windows / WinSystemWin32DX . cpp <nl> ppp b / xbmc / windowing / windows / WinSystemWin32DX . cpp <nl> void CWinSystemWin32DX : : OnResize ( int width , int height ) <nl> if ( ! m_IsAlteringWindow ) <nl> ReleaseBackBuffer ( ) ; <nl> <nl> - m_deviceResources - > SetLogicalSize ( width , height ) ; <nl> + m_deviceResources - > SetLogicalSize ( static_cast < float > ( width ) , static_cast < float > ( height ) ) ; <nl> <nl> if ( ! m_IsAlteringWindow ) <nl> CreateBackBuffer ( ) ; <nl> void CWinSystemWin32DX : : FixRefreshRateIfNecessary ( const D3D10DDIARG_CREATERESOUR <nl> refreshRate / = 2 ; <nl> <nl> uint32_t refreshNum , refreshDen ; <nl> - DX : : GetRefreshRatio ( floor ( m_fRefreshRate ) , & refreshNum , & refreshDen ) ; <nl> + DX : : GetRefreshRatio ( static_cast < uint32_t > ( floor ( m_fRefreshRate ) ) , & refreshNum , & refreshDen ) ; <nl> float diff = fabs ( refreshRate - static_cast < float > ( refreshNum ) / static_cast < float > ( refreshDen ) ) / refreshRate ; <nl> CLog : : LogF ( LOGDEBUG , " refreshRate : % 0 . 4f , desired : % 0 . 4f , deviation : % . 5f , fixRequired : % s , % d " , <nl> refreshRate , m_fRefreshRate , diff , ( diff > 0 . 0005 & & diff < 0 . 1 ) ? " yes " : " no " , pResource - > pPrimaryDesc - > Flags ) ; <nl>
|
[ win32 ] windowing : fix some warnings .
|
xbmc/xbmc
|
ae26c35f55577a2836b7dff5952f98cbb36ce5f2
|
2018-04-03T08:17:32Z
|
mmm a / cmake / modules / AddSwift . cmake <nl> ppp b / cmake / modules / AddSwift . cmake <nl> function ( _add_swift_library_single target name ) <nl> LINK_FLAGS " $ { link_flags } - L $ { SWIFTLIB_DIR } / $ { SWIFTLIB_SINGLE_SUBDIR } - L $ { SWIFT_NATIVE_SWIFT_TOOLS_PATH } / . . / lib / swift / $ { SWIFTLIB_SINGLE_SUBDIR } - L $ { SWIFT_NATIVE_SWIFT_TOOLS_PATH } / . . / lib / swift / $ { SWIFT_SDK_ $ { SWIFTLIB_SINGLE_SDK } _LIB_SUBDIR } " ) <nl> target_link_libraries ( " $ { target } " PRIVATE <nl> $ { SWIFTLIB_SINGLE_PRIVATE_LINK_LIBRARIES } ) <nl> - if ( $ { SWIFTLIB_SINGLE_INTERFACE_LINK_LIBRARIES } ) <nl> - message ( FATAL_ERROR " $ { SWIFTLIB_SINGLE_INTERFACE_LINK_LIBRARIES } " ) <nl> - endif ( ) <nl> target_link_libraries ( " $ { target } " INTERFACE <nl> $ { SWIFTLIB_SINGLE_INTERFACE_LINK_LIBRARIES } ) <nl> set_property ( TARGET " $ { target } " PROPERTY <nl>
|
[ cmake ] Remove debug statement that snuck in .
|
apple/swift
|
b901341bb56697b616037d175e1373e0b56e1574
|
2016-05-19T00:22:00Z
|
mmm a / scene / gui / base_button . cpp <nl> ppp b / scene / gui / base_button . cpp <nl> void BaseButton : : _notification ( int p_what ) { <nl> group - > _remove_button ( this ) ; <nl> } <nl> <nl> + if ( p_what = = NOTIFICATION_VISIBILITY_CHANGED & & ! is_visible ( ) ) { <nl> + <nl> + if ( ! toggle_mode ) { <nl> + status . pressed = false ; <nl> + } <nl> + status . hovering = false ; <nl> + status . press_attempt = false ; <nl> + status . pressing_inside = false ; <nl> + status . pressing_button = 0 ; <nl> + } <nl> } <nl> <nl> void BaseButton : : pressed ( ) { <nl>
|
Fix BaseButtons remaining pressed when hiding them while pressing them down
|
godotengine/godot
|
ce2faae2c512b03a575db1cca0696cbec0469bfa
|
2015-09-26T01:06:42Z
|
deleted file mode 100644 <nl> index ddf72204ec . . 0000000000 <nl> mmm a / change / react - native - windows - 2019 - 12 - 05 - 16 - 02 - 42 - savespace . json <nl> ppp / dev / null <nl> <nl> - { <nl> - " type " : " none " , <nl> - " comment " : " Avoid duplicate V8JSI and Hermes " , <nl> - " packageName " : " react - native - windows " , <nl> - " email " : " licanhua @ live . com " , <nl> - " commit " : " 186e002485ef3ade1036df59e3273c191c063622 " , <nl> - " date " : " 2019 - 12 - 06T00 : 02 : 42 . 705Z " <nl> - } <nl> \ No newline at end of file <nl> mmm a / packages / E2ETest / package . json <nl> ppp b / packages / E2ETest / package . json <nl> <nl> { <nl> " name " : " e2etest " , <nl> - " version " : " 0 . 0 . 22 " , <nl> + " version " : " 0 . 0 . 23 " , <nl> " private " : true , <nl> " scripts " : { <nl> " build " : " just - scripts build " , <nl> <nl> " react " : " 16 . 8 . 6 " , <nl> " react - native " : " https : / / github . com / microsoft / react - native / archive / v0 . 60 . 0 - microsoft . 28 . tar . gz " , <nl> " react - native - windows " : " 0 . 60 . 0 - vnext . 91 " , <nl> - " react - native - windows - extended " : " 0 . 60 . 39 " , <nl> + " react - native - windows - extended " : " 0 . 60 . 40 " , <nl> " rnpm - plugin - windows " : " ^ 0 . 3 . 8 " <nl> } , <nl> " devDependencies " : { <nl> mmm a / packages / microsoft - reactnative - sampleapps / package . json <nl> ppp b / packages / microsoft - reactnative - sampleapps / package . json <nl> <nl> { <nl> " name " : " microsoft - reactnative - sampleapps " , <nl> - " version " : " 0 . 0 . 22 " , <nl> + " version " : " 0 . 0 . 23 " , <nl> " private " : true , <nl> " scripts " : { <nl> " build " : " just - scripts build " , <nl> <nl> " react " : " 16 . 8 . 6 " , <nl> " react - native " : " https : / / github . com / microsoft / react - native / archive / v0 . 60 . 0 - microsoft . 28 . tar . gz " , <nl> " react - native - windows " : " 0 . 60 . 0 - vnext . 91 " , <nl> - " react - native - windows - extended " : " 0 . 60 . 39 " , <nl> + " react - native - windows - extended " : " 0 . 60 . 40 " , <nl> " rnpm - plugin - windows " : " ^ 0 . 3 . 8 " <nl> } , <nl> " devDependencies " : { <nl> mmm a / packages / playground / package . json <nl> ppp b / packages / playground / package . json <nl> <nl> { <nl> " name " : " playground " , <nl> - " version " : " 0 . 0 . 22 " , <nl> + " version " : " 0 . 0 . 23 " , <nl> " private " : true , <nl> " scripts " : { <nl> " build " : " just - scripts build " , <nl> <nl> " react " : " 16 . 8 . 6 " , <nl> " react - native " : " https : / / github . com / microsoft / react - native / archive / v0 . 60 . 0 - microsoft . 28 . tar . gz " , <nl> " react - native - windows " : " 0 . 60 . 0 - vnext . 91 " , <nl> - " react - native - windows - extended " : " 0 . 60 . 39 " , <nl> + " react - native - windows - extended " : " 0 . 60 . 40 " , <nl> " rnpm - plugin - windows " : " ^ 0 . 3 . 8 " <nl> } , <nl> " devDependencies " : { <nl> mmm a / packages / react - native - windows - extended / package . json <nl> ppp b / packages / react - native - windows - extended / package . json <nl> <nl> { <nl> " name " : " react - native - windows - extended " , <nl> - " version " : " 0 . 60 . 39 " , <nl> + " version " : " 0 . 60 . 40 " , <nl> " description " : " Additional react - native - windows components that are not part of RN lean - core . " , <nl> " main " : " lib / index . js " , <nl> " repository " : { <nl>
|
applying package updates * * * NO_CI * * *
|
microsoft/react-native-windows
|
916ac28ed860673d174585b1cc3cf428bfa83bcd
|
2019-12-10T21:38:39Z
|
new file mode 100644 <nl> index 00000000000 . . 6ec6246ebb9 <nl> mmm / dev / null <nl> ppp b / ports / libosip2 / CONTROL <nl> <nl> + Source : libosip2 <nl> + Version : 5 . 1 . 0 <nl> + Homepage : https : / / www . gnu . org / software / osip / <nl> + Description : oSIP is an LGPL implementation of SIP . It ' s stable , portable , flexible and compliant ! - may be more - ! It is used mostly with eXosip2 stack ( GPL ) which provides simpler API for User - Agent implementation . <nl> \ No newline at end of file <nl> new file mode 100644 <nl> index 00000000000 . . 145c771d52a <nl> mmm / dev / null <nl> ppp b / ports / libosip2 / portfile . cmake <nl> <nl> + include ( vcpkg_common_functions ) <nl> + <nl> + set ( LIBOSIP2_VER " 5 . 1 . 0 " ) <nl> + <nl> + if ( VCPKG_TARGET_IS_WINDOWS ) <nl> + message ( FATAL_ERROR " libosio2 only support unix currently . " ) <nl> + endif ( ) <nl> + <nl> + vcpkg_download_distfile ( ARCHIVE <nl> + URLS " http : / / ftp . gnu . org / gnu / osip / libosip2 - $ { LIBOSIP2_VER } . tar . gz " <nl> + FILENAME " libosip2 - $ { LIBOSIP2_VER } . tar . gz " <nl> + SHA512 391c9a0ea399f789d7061b0216d327eecba5bbf0429659f4f167604b9e703e1678ba6f58079aa4f84b3636a937064ecfb92e985368164fcb679e95654e43d65b <nl> + ) <nl> + <nl> + vcpkg_extract_source_archive_ex ( <nl> + ARCHIVE $ { ARCHIVE } <nl> + OUT_SOURCE_PATH SOURCE_PATH <nl> + ) <nl> + <nl> + find_program ( autoreconf autoreconf ) <nl> + if ( NOT autoreconf ) <nl> + message ( FATAL_ERROR " autoreconf must be installed before libx11 can build . Install them with \ " apt - get dh - autoreconf \ " . " ) <nl> + endif ( ) <nl> + <nl> + find_program ( MAKE make ) <nl> + if ( NOT MAKE ) <nl> + message ( FATAL_ERROR " MAKE not found " ) <nl> + endif ( ) <nl> + <nl> + vcpkg_execute_required_process ( <nl> + COMMAND " . / autogen . sh " <nl> + WORKING_DIRECTORY $ { SOURCE_PATH } <nl> + LOGNAME autoreconf - $ { TARGET_TRIPLET } <nl> + ) <nl> + <nl> + message ( STATUS " Configuring $ { TARGET_TRIPLET } " ) <nl> + set ( OUT_PATH $ { CURRENT_BUILDTREES_DIR } / make - build - $ { TARGET_TRIPLET } ) <nl> + <nl> + file ( REMOVE_RECURSE $ { OUT_PATH } ) <nl> + file ( MAKE_DIRECTORY $ { OUT_PATH } ) <nl> + <nl> + vcpkg_execute_required_process ( <nl> + COMMAND " . / configure " - - prefix = $ { OUT_PATH } <nl> + WORKING_DIRECTORY $ { SOURCE_PATH } <nl> + LOGNAME config - $ { TARGET_TRIPLET } <nl> + ) <nl> + <nl> + message ( STATUS " Building $ { TARGET_TRIPLET } " ) <nl> + vcpkg_execute_required_process ( <nl> + COMMAND make <nl> + WORKING_DIRECTORY $ { SOURCE_PATH } <nl> + LOGNAME build - $ { TARGET_TRIPLET } - release <nl> + ) <nl> + <nl> + message ( STATUS " Installing $ { TARGET_TRIPLET } " ) <nl> + vcpkg_execute_required_process ( <nl> + COMMAND make install <nl> + WORKING_DIRECTORY $ { SOURCE_PATH } <nl> + LOGNAME install - $ { TARGET_TRIPLET } - release <nl> + ) <nl> + file ( COPY $ { OUT_PATH } / include DESTINATION $ { CURRENT_PACKAGES_DIR } ) <nl> + file ( COPY $ { OUT_PATH } / lib DESTINATION $ { CURRENT_PACKAGES_DIR } ) <nl> + <nl> + file ( GLOB_RECURSE LIBOSIP2_BINARIES $ { CURRENT_PACKAGES_DIR } / lib * . so ) <nl> + foreach ( LIBOSIP2_BINARY LIBOSIP2_BINARIES ) <nl> + if ( VCPKG_LIBRARY_LINKAGE STREQUAL dynamic ) <nl> + file ( COPY $ { LIBOSIP2_BINARY } DESTINATION $ { CURRENT_PACKAGES_DIR } / bin ) <nl> + endif ( ) <nl> + file ( REMOVE $ { LIBOSIP2_BINARY } ) <nl> + endforeach ( ) <nl> + <nl> + # Handle copyright <nl> + file ( INSTALL $ { SOURCE_PATH } / COPYING DESTINATION $ { CURRENT_PACKAGES_DIR } / share / $ { PORT } RENAME copyright ) <nl> \ No newline at end of file <nl>
|
[ libosip2 ] Add new port . ( )
|
microsoft/vcpkg
|
2419d391602f6cfbcf88cfb29b3709690086639a
|
2019-09-25T19:19:45Z
|
mmm a / src / mips / full - codegen - mips . cc <nl> ppp b / src / mips / full - codegen - mips . cc <nl> void FullCodeGenerator : : VisitYield ( Yield * expr ) { <nl> } <nl> <nl> <nl> + void FullCodeGenerator : : EmitGeneratorResume ( Expression * generator , <nl> + Expression * value , <nl> + JSGeneratorObject : : ResumeMode resume_mode ) { <nl> + / / The value stays in a0 , and is ultimately read by the resumed generator , as <nl> + / / if the CallRuntime ( Runtime : : kSuspendJSGeneratorObject ) returned it . a1 <nl> + / / will hold the generator object until the activation has been resumed . <nl> + VisitForStackValue ( generator ) ; <nl> + VisitForAccumulatorValue ( value ) ; <nl> + __ pop ( a1 ) ; <nl> + <nl> + / / Check generator state . <nl> + Label wrong_state , done ; <nl> + __ lw ( a3 , FieldMemOperand ( a1 , JSGeneratorObject : : kContinuationOffset ) ) ; <nl> + STATIC_ASSERT ( JSGeneratorObject : : kGeneratorExecuting < = 0 ) ; <nl> + STATIC_ASSERT ( JSGeneratorObject : : kGeneratorClosed < = 0 ) ; <nl> + __ Branch ( & wrong_state , le , a3 , Operand ( zero_reg ) ) ; <nl> + <nl> + / / Load suspended function and context . <nl> + __ lw ( cp , FieldMemOperand ( a1 , JSGeneratorObject : : kContextOffset ) ) ; <nl> + __ lw ( t0 , FieldMemOperand ( a1 , JSGeneratorObject : : kFunctionOffset ) ) ; <nl> + <nl> + / / Push holes for arguments to generator function . <nl> + __ lw ( a3 , FieldMemOperand ( t0 , JSFunction : : kSharedFunctionInfoOffset ) ) ; <nl> + __ lw ( a3 , <nl> + FieldMemOperand ( a3 , SharedFunctionInfo : : kFormalParameterCountOffset ) ) ; <nl> + __ LoadRoot ( a2 , Heap : : kTheHoleValueRootIndex ) ; <nl> + Label push_argument_holes ; <nl> + __ bind ( & push_argument_holes ) ; <nl> + __ push ( a2 ) ; <nl> + __ Subu ( a3 , a3 , Operand ( 1 ) ) ; <nl> + __ Branch ( & push_argument_holes , ge , a3 , Operand ( zero_reg ) ) ; <nl> + <nl> + / / Enter a new JavaScript frame , and initialize its slots as they were when <nl> + / / the generator was suspended . <nl> + Label push_frame , resume_frame ; <nl> + __ bind ( & push_frame ) ; <nl> + __ Call ( & resume_frame ) ; <nl> + __ jmp ( & done ) ; <nl> + __ bind ( & resume_frame ) ; <nl> + __ push ( ra ) ; / / Return address . <nl> + __ push ( fp ) ; / / Caller ' s frame pointer . <nl> + __ mov ( fp , sp ) ; <nl> + __ push ( cp ) ; / / Callee ' s context . <nl> + __ push ( t0 ) ; / / Callee ' s JS Function . <nl> + <nl> + / / Load the operand stack size . <nl> + __ lw ( a3 , FieldMemOperand ( a1 , JSGeneratorObject : : kOperandStackOffset ) ) ; <nl> + __ lw ( a3 , FieldMemOperand ( a3 , FixedArray : : kLengthOffset ) ) ; <nl> + __ SmiUntag ( a3 ) ; <nl> + <nl> + / / If we are sending a value and there is no operand stack , we can jump back <nl> + / / in directly . <nl> + if ( resume_mode = = JSGeneratorObject : : SEND ) { <nl> + Label slow_resume ; <nl> + __ Branch ( & slow_resume , ne , a3 , Operand ( zero_reg ) ) ; <nl> + __ lw ( a3 , FieldMemOperand ( t0 , JSFunction : : kCodeEntryOffset ) ) ; <nl> + __ lw ( a2 , FieldMemOperand ( a1 , JSGeneratorObject : : kContinuationOffset ) ) ; <nl> + __ SmiUntag ( a2 ) ; <nl> + __ Addu ( a3 , a3 , Operand ( a2 ) ) ; <nl> + __ li ( a2 , Operand ( Smi : : FromInt ( JSGeneratorObject : : kGeneratorExecuting ) ) ) ; <nl> + __ sw ( a2 , FieldMemOperand ( a1 , JSGeneratorObject : : kContinuationOffset ) ) ; <nl> + __ Jump ( a3 ) ; <nl> + __ bind ( & slow_resume ) ; <nl> + } <nl> + <nl> + / / Otherwise , we push holes for the operand stack and call the runtime to fix <nl> + / / up the stack and the handlers . <nl> + Label push_operand_holes , call_resume ; <nl> + __ bind ( & push_operand_holes ) ; <nl> + __ Subu ( a3 , a3 , Operand ( 1 ) ) ; <nl> + __ Branch ( & call_resume , lt , a3 , Operand ( zero_reg ) ) ; <nl> + __ push ( a2 ) ; <nl> + __ b ( & push_operand_holes ) ; <nl> + __ bind ( & call_resume ) ; <nl> + __ push ( a1 ) ; <nl> + __ push ( result_register ( ) ) ; <nl> + __ Push ( Smi : : FromInt ( resume_mode ) ) ; <nl> + __ CallRuntime ( Runtime : : kResumeJSGeneratorObject , 3 ) ; <nl> + / / Not reached : the runtime call returns elsewhere . <nl> + __ stop ( " not - reached " ) ; <nl> + <nl> + / / Throw error if we attempt to operate on a running generator . <nl> + __ bind ( & wrong_state ) ; <nl> + __ push ( a1 ) ; <nl> + __ CallRuntime ( Runtime : : kThrowGeneratorStateError , 1 ) ; <nl> + <nl> + __ bind ( & done ) ; <nl> + context ( ) - > Plug ( result_register ( ) ) ; <nl> + } <nl> + <nl> + <nl> void FullCodeGenerator : : EmitNamedPropertyLoad ( Property * prop ) { <nl> SetSourcePosition ( prop - > position ( ) ) ; <nl> Literal * key = prop - > key ( ) - > AsLiteral ( ) ; <nl>
|
MIPS : Generators can resume
|
v8/v8
|
8ddaa0c1a598666ecb53cb2f7c060006c8c119f1
|
2013-04-24T23:11:48Z
|
mmm a / Makefile <nl> ppp b / Makefile <nl> update_doxygen_online : <nl> git checkout gh - pages <nl> rm - fr html <nl> mv / tmp / github - html html <nl> + cd html ; git rm $ ( git ls - files - - deleted ) <nl> git commit - m " Doxygen update " <nl> git checkout master <nl> <nl>
|
clean up
|
nlohmann/json
|
332b10998a45e2b0a4884eff4f1df453e13eb9e0
|
2015-06-21T11:12:17Z
|
mmm a / validation - test / compiler_crashers_2 / 0207 - sr7371 . swift <nl> ppp b / validation - test / compiler_crashers_2 / 0207 - sr7371 . swift <nl> <nl> / / RUN : not - - crash % target - swift - frontend - emit - ir % s <nl> + / / rdar : / / problem / 65571199 <nl> + / / UNSUPPORTED : asan <nl> <nl> public protocol TypedParserResultTransferType { <nl> / / Remove type constraint <nl> mmm a / validation - test / compiler_crashers_2 / 0208 - sr8751 . swift <nl> ppp b / validation - test / compiler_crashers_2 / 0208 - sr8751 . swift <nl> <nl> / / RUN : not - - crash % target - swift - frontend - emit - ir % s <nl> + / / rdar : / / problem / 65571199 <nl> + / / UNSUPPORTED : asan <nl> <nl> protocol TreeProtocol { <nl> <nl>
|
Merge pull request from nate - chandler / disable - long - running - tests
|
apple/swift
|
12b6b759537b5325257107ef02c217c77432d239
|
2020-07-14T23:24:10Z
|
mmm a / README . md <nl> ppp b / README . md <nl> You can download previous versions of Karabiner - Elements from here : <nl> <nl> # # System requirements <nl> <nl> - * macOS Sierra ( 10 . 12 ) <nl> - * macOS High Sierra ( 10 . 13 ) <nl> - * macOS Mojave ( 10 . 14 ) <nl> + - macOS Sierra ( 10 . 12 ) <nl> + - macOS High Sierra ( 10 . 13 ) <nl> + - macOS Mojave ( 10 . 14 ) <nl> <nl> # Usage <nl> <nl> You can download previous versions of Karabiner - Elements from here : <nl> <nl> System requirements to build Karabiner - Elements : <nl> <nl> - * macOS 10 . 14 + <nl> - * Xcode 10 + <nl> - * Command Line Tools for Xcode <nl> - * CMake ( ` brew install cmake ` ) <nl> + - macOS 10 . 14 + <nl> + - Xcode 10 + <nl> + - Command Line Tools for Xcode <nl> + - CMake ( ` brew install cmake ` ) <nl> <nl> # # # Step 1 : Getting source code <nl> <nl> make package <nl> <nl> The ` make ` script will create a redistributable * * Karabiner - Elements - VERSION . dmg * * in the current directory . <nl> <nl> + # # # About pre - built binaries in the source tree <nl> + <nl> + Karabiner - Elements uses some pre - built binaries in the source tree . <nl> + <nl> + - ` src / vendor / Karabiner - VirtualHIDDevice / dist / * . kext ` <nl> + - ` src / vendor / Sparkle / Sparkle . framework ` <nl> + <nl> + Above ` make package ` command does not build these binaries . < br / > <nl> + ( These binaries will be copied in the distributed package . ) <nl> + <nl> + If you want to rebuild these binaries , you have to build them manually . <nl> + <nl> + # # # # About rebuilding kext in Karabiner - VirtualHIDDevice <nl> + <nl> + If you want to build kext in Karabiner - VirtualHIDDevice , macOS requires a valid certificate which be able to sign the built kext . < br / > <nl> + Please read a documentation about [ System Integrity Protection Guide ] ( https : / / developer . apple . com / library / archive / documentation / Security / Conceptual / System_Integrity_Protection_Guide / KernelExtensions / KernelExtensions . html ) for more details . <nl> + <nl> + ( We are including the pre - built kext binary to avoid the restriction that macOS requires a uncommon certificate . ) <nl> + <nl> # Donations <nl> <nl> If you would like to contribute financially to the development of Karabiner Elements , donations can be made via < https : / / pqrs . org / osx / karabiner / pricing . html > <nl>
|
Add About pre - built binaries in the source tree
|
pqrs-org/Karabiner-Elements
|
be56ff997942120892df1e243083a37ee39a4d25
|
2019-03-15T17:47:52Z
|
mmm a / Telegram / Resources / lang . strings <nl> ppp b / Telegram / Resources / lang . strings <nl> Copyright ( c ) 2014 - 2015 John Preston , https : / / desktop . telegram . org <nl> " lng_send_image_compressed " = " Send compressed image " ; <nl> " lng_send_image_empty " = " Could not send an empty file : ( " ; <nl> " lng_send_image_too_large " = " Could not send a file , because it is larger than 1 . 5 GB : ( " ; <nl> + " lng_send_folder " = " Could not send « { name } » because it is a directory : ( " ; <nl> <nl> " lng_forward_choose " = " Choose recipient . . " ; <nl> " lng_forward_cant " = " Sorry , no way to forward here : ( " ; <nl>
|
langs updated for 0 . 9 . 9 . dev
|
telegramdesktop/tdesktop
|
29befef3ea1846d153eed0f5edc2e8cb90b7d3ac
|
2015-11-02T22:51:21Z
|
mmm a / Telegram / Resources / basic . style <nl> ppp b / Telegram / Resources / basic . style <nl> toastPadding : margins ( 19px , 13px , 19px , 12px ) ; <nl> toastFadeInDuration : 200 ; <nl> toastFadeOutDuration : 1000 ; <nl> <nl> - / / forward declaration for single " title_back " usage . <nl> - profileTopBarBackIconFg : # 0290d7 ; <nl> - profileTopBarBackIcon : icon { { " title_back " , profileTopBarBackIconFg } } ; <nl> - <nl> historyReplyCancelIcon : icon { { " box_button_close " , historyReplyCancelFg } } ; <nl> historyReplyCancelIconOver : icon { { " box_button_close " , historyReplyCancelFgOver } } ; <nl> boxSearchCancelIcon : icon { { " box_button_close " , boxSearchCancelIconFg } } ; <nl> new file mode 100644 <nl> index 00000000000 . . 9db1870f6b3 <nl> Binary files / dev / null and b / Telegram / Resources / icons / box_button_back . png differ <nl> new file mode 100644 <nl> index 00000000000 . . b729fc2796d <nl> Binary files / dev / null and b / Telegram / Resources / icons / box_button_back @ 2x . png differ <nl> mmm a / Telegram / SourceFiles / boxes / boxes . style <nl> ppp b / Telegram / SourceFiles / boxes / boxes . style <nl> boxLabel : FlatLabel ( defaultFlatLabel ) { <nl> align : align ( topleft ) ; <nl> } <nl> <nl> - boxScroll : FlatScroll ( defaultSolidScroll ) { <nl> - round : 3px ; <nl> - width : 18px ; <nl> - deltax : 6px ; <nl> - } <nl> + boxScroll : defaultSolidScroll ; <nl> boxScrollSkip : 6px ; <nl> boxScrollShadowBg : # 00000012 ; <nl> <nl> notificationSampleSize : size ( 64px , 16px ) ; <nl> <nl> membersAboutLimitPadding : margins ( 0px , 12px , 0px , 12px ) ; <nl> <nl> - sessionsScroll : FlatScroll ( boxScroll ) { <nl> - round : 2px ; <nl> - deltax : 5px ; <nl> - width : 14px ; <nl> - } <nl> + sessionsScroll : boxScroll ; <nl> sessionsHeight : 440px ; <nl> sessionHeight : 70px ; <nl> sessionCurrentPadding : margins ( 0px , 7px , 0px , 4px ) ; <nl> langsButton : Radiobutton ( defaultRadiobutton ) { <nl> backgroundPadding : 10px ; <nl> backgroundSize : size ( 108px , 193px ) ; <nl> backgroundScroll : FlatScroll ( boxScroll ) { <nl> - round : 2px ; <nl> - width : 10px ; <nl> - deltax : 3px ; <nl> deltat : 10px ; <nl> deltab : 0px ; <nl> } <nl> mmm a / Telegram / SourceFiles / history / history . style <nl> ppp b / Telegram / SourceFiles / history / history . style <nl> botKbTinyButton : BotKeyboardButton { <nl> textTop : 2px ; <nl> ripple : defaultRippleAnimation ; <nl> } <nl> - botKbScroll : FlatScroll ( defaultSolidScroll ) { <nl> - deltax : 3px ; <nl> - width : 10px ; <nl> - } <nl> + botKbScroll : defaultSolidScroll ; <nl> <nl> mentionHeight : 40px ; <nl> mentionScroll : FlatScroll ( defaultFlatScroll ) { <nl> mmm a / Telegram / SourceFiles / historywidget . cpp <nl> ppp b / Telegram / SourceFiles / historywidget . cpp <nl> void HistoryWidget : : onForwardHere ( ) { <nl> App : : forward ( _peer - > id , ForwardContextMessage ) ; <nl> } <nl> <nl> - bool HistoryWidget : : paintTopBar ( Painter & p , float64 over , int32 decreaseWidth ) { <nl> + bool HistoryWidget : : paintTopBar ( Painter & p , int decreaseWidth ) { <nl> if ( _a_show . animating ( ) ) { <nl> int retina = cIntRetinaFactor ( ) ; <nl> if ( a_coordOver . current ( ) > 0 ) { <nl> bool HistoryWidget : : paintTopBar ( Painter & p , float64 over , int32 decreaseWidth ) { <nl> _peer - > dialogName ( ) . drawElided ( p , rectForName . left ( ) , rectForName . top ( ) , rectForName . width ( ) ) ; <nl> <nl> if ( Adaptive : : OneColumn ( ) | | ! App : : main ( ) - > stackIsEmpty ( ) ) { <nl> - p . setOpacity ( st : : topBarForwardAlpha + ( 1 - st : : topBarForwardAlpha ) * over ) ; <nl> st : : topBarBackward . paint ( p , ( st : : topBarArrowPadding . left ( ) - st : : topBarBackward . width ( ) ) / 2 , ( st : : topBarHeight - st : : topBarBackward . height ( ) ) / 2 , width ( ) ) ; <nl> - p . setOpacity ( 1 . ) ; <nl> } <nl> return true ; <nl> } <nl> mmm a / Telegram / SourceFiles / historywidget . h <nl> ppp b / Telegram / SourceFiles / historywidget . h <nl> class HistoryWidget : public TWidget , public RPCSender , private base : : Subscriber <nl> <nl> void updateTopBarSelection ( ) ; <nl> <nl> - bool paintTopBar ( Painter & p , float64 over , int32 decreaseWidth ) ; <nl> + bool paintTopBar ( Painter & p , int decreaseWidth ) ; <nl> QRect getMembersShowAreaGeometry ( ) const ; <nl> void setMembersShowAreaActive ( bool active ) ; <nl> void topBarClick ( ) ; <nl> mmm a / Telegram / SourceFiles / mainwidget . cpp <nl> ppp b / Telegram / SourceFiles / mainwidget . cpp <nl> bool MainWidget : : needBackButton ( ) { <nl> return _overview | | _wideSection | | _history - > peer ( ) ; <nl> } <nl> <nl> - bool MainWidget : : paintTopBar ( Painter & p , float64 over , int32 decreaseWidth ) { <nl> + bool MainWidget : : paintTopBar ( Painter & p , int decreaseWidth ) { <nl> if ( _overview ) { <nl> - return _overview - > paintTopBar ( p , over , decreaseWidth ) ; <nl> + return _overview - > paintTopBar ( p , decreaseWidth ) ; <nl> } else if ( ! _wideSection ) { <nl> - return _history - > paintTopBar ( p , over , decreaseWidth ) ; <nl> + return _history - > paintTopBar ( p , decreaseWidth ) ; <nl> } <nl> return false ; <nl> } <nl> mmm a / Telegram / SourceFiles / mainwidget . h <nl> ppp b / Telegram / SourceFiles / mainwidget . h <nl> class MainWidget : public TWidget , public RPCSender , private base : : Subscriber { <nl> bool needBackButton ( ) ; <nl> <nl> / / Temporary methods , while top bar was not done inside HistoryWidget / OverviewWidget . <nl> - bool paintTopBar ( Painter & p , float64 over , int32 decreaseWidth ) ; <nl> + bool paintTopBar ( Painter & , int decreaseWidth ) ; <nl> QRect getMembersShowAreaGeometry ( ) const ; <nl> void setMembersShowAreaActive ( bool active ) ; <nl> Window : : TopBarWidget * topBar ( ) ; <nl> mmm a / Telegram / SourceFiles / overviewwidget . cpp <nl> ppp b / Telegram / SourceFiles / overviewwidget . cpp <nl> void OverviewWidget : : scrollReset ( ) { <nl> _scroll - > scrollToY ( ( type ( ) = = OverviewMusicFiles | | type ( ) = = OverviewVoiceFiles ) ? _scroll - > scrollTopMax ( ) : 0 ) ; <nl> } <nl> <nl> - bool OverviewWidget : : paintTopBar ( Painter & p , float64 over , int32 decreaseWidth ) { <nl> + bool OverviewWidget : : paintTopBar ( Painter & p , int decreaseWidth ) { <nl> if ( _a_show . animating ( ) ) { <nl> int retina = cIntRetinaFactor ( ) ; <nl> if ( a_coordOver . current ( ) > 0 ) { <nl> bool OverviewWidget : : paintTopBar ( Painter & p , float64 over , int32 decreaseWidth ) <nl> st : : slideShadow . fill ( p , QRect ( a_coordOver . current ( ) - st : : slideShadow . width ( ) , 0 , st : : slideShadow . width ( ) , st : : topBarHeight ) ) ; <nl> return false ; <nl> } <nl> - p . setOpacity ( st : : topBarBackAlpha + ( 1 - st : : topBarBackAlpha ) * over ) ; <nl> st : : topBarBack . paint ( p , ( st : : topBarArrowPadding . left ( ) - st : : topBarBack . width ( ) ) / 2 , ( st : : topBarHeight - st : : topBarBack . height ( ) ) / 2 , width ( ) ) ; <nl> - p . setFont ( st : : topBarBackFont ) ; <nl> - p . setPen ( st : : topBarBackColor ) ; <nl> - p . drawText ( st : : topBarArrowPadding . left ( ) , ( st : : topBarHeight - st : : topBarBackFont - > height ) / 2 + st : : topBarBackFont - > ascent , _header ) ; <nl> - p . setOpacity ( 1 . ) ; <nl> + p . setFont ( st : : defaultLightButton . font ) ; <nl> + p . setPen ( st : : defaultLightButton . textFg ) ; <nl> + p . drawTextLeft ( st : : topBarArrowPadding . left ( ) , st : : topBarButton . padding . top ( ) + st : : topBarButton . textTop , width ( ) , _header ) ; <nl> return true ; <nl> } <nl> <nl> void OverviewWidget : : switchType ( MediaOverviewType type ) { <nl> case OverviewVoiceFiles : _header = lang ( lng_profile_audios_header ) ; break ; <nl> case OverviewLinks : _header = lang ( lng_profile_shared_links_header ) ; break ; <nl> } <nl> + _header = _header . toUpper ( ) ; <nl> + <nl> noSelectingScroll ( ) ; <nl> App : : main ( ) - > topBar ( ) - > showSelected ( 0 ) ; <nl> updateTopBarSelection ( ) ; <nl> mmm a / Telegram / SourceFiles / overviewwidget . h <nl> ppp b / Telegram / SourceFiles / overviewwidget . h <nl> class OverviewWidget : public TWidget , public RPCSender { <nl> void scrollBy ( int32 add ) ; <nl> void scrollReset ( ) ; <nl> <nl> - bool paintTopBar ( Painter & p , float64 over , int32 decreaseWidth ) ; <nl> + bool paintTopBar ( Painter & p , int decreaseWidth ) ; <nl> void topBarClick ( ) ; <nl> <nl> PeerData * peer ( ) const ; <nl> mmm a / Telegram / SourceFiles / profile / profile . style <nl> ppp b / Telegram / SourceFiles / profile / profile . style <nl> using " window / window . style " ; <nl> profileBg : windowBg ; <nl> <nl> profileTopBarHeight : topBarHeight ; <nl> - profileTopBarBackIconPosition : point ( 12px , 20px ) ; <nl> - profileTopBarBackFont : font ( 14px ) ; <nl> - profileTopBarBackFg : # 1485c2 ; <nl> - profileTopBarBackPosition : point ( 39px , 17px ) ; <nl> profileFixedBarButton : topBarButton ; <nl> <nl> profileMarginTop : 13px ; <nl> mmm a / Telegram / SourceFiles / profile / profile_fixed_bar . cpp <nl> ppp b / Telegram / SourceFiles / profile / profile_fixed_bar . cpp <nl> namespace Profile { <nl> <nl> class BackButton final : public Ui : : AbstractButton , private base : : Subscriber { <nl> public : <nl> - BackButton ( QWidget * parent ) : Ui : : AbstractButton ( parent ) { <nl> + BackButton ( QWidget * parent ) : Ui : : AbstractButton ( parent ) <nl> + , _text ( lang ( lng_menu_back ) . toUpper ( ) ) { <nl> setCursor ( style : : cur_pointer ) ; <nl> <nl> subscribe ( Adaptive : : Changed ( ) , [ this ] { updateAdaptiveLayout ( ) ; } ) ; <nl> class BackButton final : public Ui : : AbstractButton , private base : : Subscriber { <nl> Painter p ( this ) ; <nl> <nl> p . fillRect ( e - > rect ( ) , st : : profileBg ) ; <nl> - st : : profileTopBarBackIcon . paint ( p , st : : profileTopBarBackIconPosition , width ( ) ) ; <nl> + st : : topBarBack . paint ( p , ( st : : topBarArrowPadding . left ( ) - st : : topBarBack . width ( ) ) / 2 , ( st : : topBarHeight - st : : topBarBack . height ( ) ) / 2 , width ( ) ) ; <nl> <nl> - p . setFont ( st : : profileTopBarBackFont ) ; <nl> - p . setPen ( st : : profileTopBarBackFg ) ; <nl> - p . drawTextLeft ( st : : profileTopBarBackPosition . x ( ) , st : : profileTopBarBackPosition . y ( ) , width ( ) , lang ( lng_menu_back ) ) ; <nl> + p . setFont ( st : : topBarButton . font ) ; <nl> + p . setPen ( st : : topBarButton . textFg ) ; <nl> + p . drawTextLeft ( st : : topBarArrowPadding . left ( ) , st : : topBarButton . padding . top ( ) + st : : topBarButton . textTop , width ( ) , _text ) ; <nl> <nl> Window : : TopBarWidget : : paintUnreadCounter ( p , width ( ) ) ; <nl> } <nl> class BackButton final : public Ui : : AbstractButton , private base : : Subscriber { <nl> } <nl> <nl> int _unreadCounterSubscription = 0 ; <nl> + QString _text ; <nl> <nl> } ; <nl> <nl> void FixedBar : : addRightAction ( RightActionType type , const QString & text , const c <nl> _rightActions [ _currentAction ] . type = type ; <nl> delete _rightActions [ _currentAction ] . button ; <nl> _rightActions [ _currentAction ] . button = new Ui : : RoundButton ( this , text , st : : profileFixedBarButton ) ; <nl> - _rightActions [ _currentAction ] . button - > setTextTransform ( Ui : : RoundButton : : TextTransform : : NoTransform ) ; <nl> connect ( _rightActions [ _currentAction ] . button , SIGNAL ( clicked ( ) ) , this , slot ) ; <nl> bool showButton = ! _animatingMode & & ( type ! = RightActionType : : ShareContact | | ! _hideShareContactButton ) ; <nl> _rightActions [ _currentAction ] . button - > setVisible ( showButton ) ; <nl> mmm a / Telegram / SourceFiles / stickers / emoji_pan . cpp <nl> ppp b / Telegram / SourceFiles / stickers / emoji_pan . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> namespace internal { <nl> <nl> EmojiColorPicker : : EmojiColorPicker ( ) : TWidget ( ) <nl> - , _a_selected ( animation ( this , & EmojiColorPicker : : step_selected ) ) <nl> , a_opacity ( 0 ) <nl> , _a_appearance ( animation ( this , & EmojiColorPicker : : step_appearance ) ) <nl> , _shadow ( st : : defaultDropdownShadow ) { <nl> memset ( _variants , 0 , sizeof ( _variants ) ) ; <nl> - memset ( _hovers , 0 , sizeof ( _hovers ) ) ; <nl> <nl> setMouseTracking ( true ) ; <nl> <nl> void EmojiColorPicker : : mousePressEvent ( QMouseEvent * e ) { <nl> } <nl> <nl> void EmojiColorPicker : : mouseReleaseEvent ( QMouseEvent * e ) { <nl> - _lastMousePos = e ? e - > globalPos ( ) : QCursor : : pos ( ) ; <nl> + handleMouseRelease ( e - > globalPos ( ) ) ; <nl> + } <nl> + <nl> + void EmojiColorPicker : : handleMouseRelease ( QPoint globalPos ) { <nl> + _lastMousePos = globalPos ; <nl> int32 pressed = _pressedSel ; <nl> _pressedSel = - 1 ; <nl> <nl> void EmojiColorPicker : : mouseReleaseEvent ( QMouseEvent * e ) { <nl> hideAnimated ( ) ; <nl> } <nl> <nl> - void EmojiColorPicker : : mouseMoveEvent ( QMouseEvent * e ) { <nl> - _lastMousePos = e ? e - > globalPos ( ) : QCursor : : pos ( ) ; <nl> + void EmojiColorPicker : : handleMouseMove ( QPoint globalPos ) { <nl> + _lastMousePos = globalPos ; <nl> updateSelected ( ) ; <nl> } <nl> <nl> + void EmojiColorPicker : : mouseMoveEvent ( QMouseEvent * e ) { <nl> + handleMouseMove ( e - > globalPos ( ) ) ; <nl> + } <nl> + <nl> void EmojiColorPicker : : step_appearance ( float64 ms , bool timer ) { <nl> if ( _cache . isNull ( ) ) { <nl> _a_appearance . stop ( ) ; <nl> void EmojiColorPicker : : step_appearance ( float64 ms , bool timer ) { <nl> if ( timer ) update ( ) ; <nl> } <nl> <nl> - void EmojiColorPicker : : step_selected ( uint64 ms , bool timer ) { <nl> - QRegion toUpdate ; <nl> - for ( EmojiAnimations : : iterator i = _emojiAnimations . begin ( ) ; i ! = _emojiAnimations . end ( ) ; ) { <nl> - int index = qAbs ( i . key ( ) ) - 1 ; <nl> - float64 dt = float64 ( ms - i . value ( ) ) / st : : emojiPanDuration ; <nl> - if ( dt > = 1 ) { <nl> - _hovers [ index ] = ( i . key ( ) > 0 ) ? 1 : 0 ; <nl> - i = _emojiAnimations . erase ( i ) ; <nl> - } else { <nl> - _hovers [ index ] = ( i . key ( ) > 0 ) ? dt : ( 1 - dt ) ; <nl> - + + i ; <nl> - } <nl> - toUpdate + = QRect ( st : : defaultDropdownShadow . width ( ) + st : : emojiColorsPadding + index * st : : emojiPanSize . width ( ) + ( index ? 2 * st : : emojiColorsPadding + st : : emojiColorsSep : 0 ) , st : : defaultDropdownShadow . height ( ) + st : : emojiColorsPadding , st : : emojiPanSize . width ( ) , st : : emojiPanSize . height ( ) ) ; <nl> - } <nl> - if ( timer ) rtlupdate ( toUpdate . boundingRect ( ) ) ; <nl> - if ( _emojiAnimations . isEmpty ( ) ) _a_selected . stop ( ) ; <nl> - } <nl> - <nl> void EmojiColorPicker : : hideFast ( ) { <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> if ( _a_appearance . animating ( ) ) _a_appearance . stop ( ) ; <nl> - if ( _a_selected . animating ( ) ) _a_selected . stop ( ) ; <nl> a_opacity = anim : : fvalue ( 0 ) ; <nl> _cache = QPixmap ( ) ; <nl> hide ( ) ; <nl> void EmojiColorPicker : : hideFast ( ) { <nl> <nl> void EmojiColorPicker : : hideAnimated ( ) { <nl> if ( _cache . isNull ( ) ) { <nl> - int32 w = st : : defaultDropdownShadow . width ( ) , h = st : : defaultDropdownShadow . height ( ) ; <nl> + auto w = st : : defaultDropdownShadow . width ( ) , h = st : : defaultDropdownShadow . height ( ) ; <nl> _cache = myGrab ( this , QRect ( w , h , width ( ) - 2 * w , height ( ) - 2 * h ) ) ; <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> } <nl> _hiding = true ; <nl> a_opacity . start ( 0 ) ; <nl> void EmojiColorPicker : : showAnimated ( ) { <nl> return ; <nl> } <nl> if ( _cache . isNull ( ) ) { <nl> - int32 w = st : : defaultDropdownShadow . width ( ) , h = st : : defaultDropdownShadow . height ( ) ; <nl> + auto w = st : : defaultDropdownShadow . width ( ) , h = st : : defaultDropdownShadow . height ( ) ; <nl> _cache = myGrab ( this , QRect ( w , h , width ( ) - 2 * w , height ( ) - 2 * h ) ) ; <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> } <nl> show ( ) ; <nl> a_opacity . start ( 1 ) ; <nl> _a_appearance . start ( ) ; <nl> } <nl> <nl> - void EmojiColorPicker : : clearSelection ( bool fast ) { <nl> + void EmojiColorPicker : : clearSelection ( ) { <nl> _pressedSel = - 1 ; <nl> + setSelected ( - 1 ) ; <nl> _lastMousePos = mapToGlobal ( QPoint ( - 10 , - 10 ) ) ; <nl> - if ( fast ) { <nl> - _selected = - 1 ; <nl> - memset ( _hovers , 0 , sizeof ( _hovers ) ) ; <nl> - _emojiAnimations . clear ( ) ; <nl> - } else { <nl> - updateSelected ( ) ; <nl> - } <nl> } <nl> <nl> void EmojiColorPicker : : updateSelected ( ) { <nl> - int32 selIndex = - 1 ; <nl> - QPoint p ( mapFromGlobal ( _lastMousePos ) ) ; <nl> + auto newSelected = - 1 ; <nl> + auto p = mapFromGlobal ( _lastMousePos ) ; <nl> int32 sx = rtl ( ) ? ( width ( ) - p . x ( ) ) : p . x ( ) , y = p . y ( ) - st : : defaultDropdownShadow . height ( ) - st : : emojiColorsPadding ; <nl> if ( y > = 0 & & y < st : : emojiPanSize . height ( ) ) { <nl> int32 x = sx - st : : defaultDropdownShadow . width ( ) - st : : emojiColorsPadding ; <nl> if ( x > = 0 & & x < st : : emojiPanSize . width ( ) ) { <nl> - selIndex = 0 ; <nl> + newSelected = 0 ; <nl> } else { <nl> x - = st : : emojiPanSize . width ( ) + 2 * st : : emojiColorsPadding + st : : emojiColorsSep ; <nl> if ( x > = 0 & & x < st : : emojiPanSize . width ( ) * EmojiColorsCount ) { <nl> - selIndex = ( x / st : : emojiPanSize . width ( ) ) + 1 ; <nl> + newSelected = ( x / st : : emojiPanSize . width ( ) ) + 1 ; <nl> } <nl> } <nl> } <nl> <nl> - bool startanim = false ; <nl> - if ( selIndex ! = _selected ) { <nl> - if ( _selected > = 0 ) { <nl> - _emojiAnimations . remove ( _selected + 1 ) ; <nl> - if ( _emojiAnimations . find ( - _selected - 1 ) = = _emojiAnimations . end ( ) ) { <nl> - if ( _emojiAnimations . isEmpty ( ) ) startanim = true ; <nl> - _emojiAnimations . insert ( - _selected - 1 , getms ( ) ) ; <nl> - } <nl> - } <nl> - _selected = selIndex ; <nl> - if ( _selected > = 0 ) { <nl> - _emojiAnimations . remove ( - _selected - 1 ) ; <nl> - if ( _emojiAnimations . find ( _selected + 1 ) = = _emojiAnimations . end ( ) ) { <nl> - if ( _emojiAnimations . isEmpty ( ) ) startanim = true ; <nl> - _emojiAnimations . insert ( _selected + 1 , getms ( ) ) ; <nl> - } <nl> - } <nl> - setCursor ( ( _selected > = 0 ) ? style : : cur_pointer : style : : cur_default ) ; <nl> + setSelected ( newSelected ) ; <nl> + } <nl> + <nl> + void EmojiColorPicker : : setSelected ( int newSelected ) { <nl> + if ( _selected = = newSelected ) { <nl> + return ; <nl> } <nl> - if ( startanim & & ! _a_selected . animating ( ) ) _a_selected . start ( ) ; <nl> + auto updateSelectedRect = [ this ] { <nl> + if ( _selected < 0 ) return ; <nl> + rtlupdate ( st : : defaultDropdownShadow . width ( ) + st : : emojiColorsPadding + _selected * st : : emojiPanSize . width ( ) + ( _selected ? 2 * st : : emojiColorsPadding + st : : emojiColorsSep : 0 ) , st : : defaultDropdownShadow . height ( ) + st : : emojiColorsPadding , st : : emojiPanSize . width ( ) , st : : emojiPanSize . height ( ) ) ; <nl> + } ; <nl> + updateSelectedRect ( ) ; <nl> + _selected = newSelected ; <nl> + updateSelectedRect ( ) ; <nl> + setCursor ( ( _selected > = 0 ) ? style : : cur_pointer : style : : cur_default ) ; <nl> } <nl> <nl> void EmojiColorPicker : : drawVariant ( Painter & p , int variant ) { <nl> - float64 hover = _hovers [ variant ] ; <nl> - <nl> QPoint w ( st : : defaultDropdownShadow . width ( ) + st : : emojiColorsPadding + variant * st : : emojiPanSize . width ( ) + ( variant ? 2 * st : : emojiColorsPadding + st : : emojiColorsSep : 0 ) , st : : defaultDropdownShadow . height ( ) + st : : emojiColorsPadding ) ; <nl> - if ( hover > 0 ) { <nl> - p . setOpacity ( hover ) ; <nl> + if ( variant = = _selected ) { <nl> QPoint tl ( w ) ; <nl> if ( rtl ( ) ) tl . setX ( width ( ) - tl . x ( ) - st : : emojiPanSize . width ( ) ) ; <nl> App : : roundRect ( p , QRect ( tl , st : : emojiPanSize ) , st : : emojiPanHover , StickerHoverCorners ) ; <nl> - p . setOpacity ( 1 . ) ; <nl> } <nl> int esize = EmojiSizes [ EIndex + 1 ] ; <nl> p . drawPixmapLeft ( w . x ( ) + ( st : : emojiPanSize . width ( ) - ( esize / cIntRetinaFactor ( ) ) ) / 2 , w . y ( ) + ( st : : emojiPanSize . height ( ) - ( esize / cIntRetinaFactor ( ) ) ) / 2 , width ( ) , App : : emojiLarge ( ) , QRect ( _variants [ variant ] - > x * esize , _variants [ variant ] - > y * esize , esize , esize ) ) ; <nl> } <nl> <nl> EmojiPanInner : : EmojiPanInner ( QWidget * parent ) : TWidget ( parent ) <nl> - , _maxHeight ( int ( st : : emojiPanMaxHeight ) - st : : emojiCategory . height ) <nl> - , _a_selected ( animation ( this , & EmojiPanInner : : step_selected ) ) { <nl> + , _maxHeight ( int ( st : : emojiPanMaxHeight ) - st : : emojiCategory . height ) { <nl> resize ( st : : emojiPanWidth - st : : emojiScroll . width - st : : buttonRadius , countHeight ( ) ) ; <nl> <nl> setMouseTracking ( true ) ; <nl> EmojiPanInner : : EmojiPanInner ( QWidget * parent ) : TWidget ( parent ) <nl> <nl> _esize = EmojiSizes [ EIndex + 1 ] ; <nl> <nl> - for ( int32 i = 0 ; i < emojiTabCount ; + + i ) { <nl> + for ( auto i = 0 ; i ! = emojiTabCount ; + + i ) { <nl> _counts [ i ] = emojiPackCount ( emojiTabAtIndex ( i ) ) ; <nl> - _hovers [ i ] = QVector < float64 > ( _counts [ i ] , 0 ) ; <nl> } <nl> <nl> _showPickerTimer . setSingleShot ( true ) ; <nl> void EmojiPanInner : : paintEvent ( QPaintEvent * e ) { <nl> int32 index = i * EmojiPanPerRow + j ; <nl> if ( index > = size ) break ; <nl> <nl> - float64 hover = ( ! _picker . isHidden ( ) & & c * MatrixRowShift + index = = _pickerSel ) ? 1 : _hovers [ c ] [ index ] ; <nl> + auto selected = ( ! _picker . isHidden ( ) & & c * MatrixRowShift + index = = _pickerSel ) | | ( c * MatrixRowShift + index = = _selected ) ; <nl> <nl> QPoint w ( st : : emojiPanPadding + j * st : : emojiPanSize . width ( ) , y + i * st : : emojiPanSize . height ( ) ) ; <nl> - if ( hover > 0 ) { <nl> - p . setOpacity ( hover ) ; <nl> + if ( selected ) { <nl> QPoint tl ( w ) ; <nl> if ( rtl ( ) ) tl . setX ( width ( ) - tl . x ( ) - st : : emojiPanSize . width ( ) ) ; <nl> App : : roundRect ( p , QRect ( tl , st : : emojiPanSize ) , st : : emojiPanHover , StickerHoverCorners ) ; <nl> - p . setOpacity ( 1 . ) ; <nl> } <nl> p . drawPixmapLeft ( w . x ( ) + ( st : : emojiPanSize . width ( ) - ( _esize / cIntRetinaFactor ( ) ) ) / 2 , w . y ( ) + ( st : : emojiPanSize . height ( ) - ( _esize / cIntRetinaFactor ( ) ) ) / 2 , width ( ) , App : : emojiLarge ( ) , QRect ( _emojis [ c ] [ index ] - > x * _esize , _emojis [ c ] [ index ] - > y * _esize , _esize , _esize ) ) ; <nl> } <nl> void EmojiPanInner : : paintEvent ( QPaintEvent * e ) { <nl> } <nl> <nl> bool EmojiPanInner : : checkPickerHide ( ) { <nl> - if ( ! _picker . isHidden ( ) & & _selected = = _pickerSel ) { <nl> + if ( ! _picker . isHidden ( ) & & _pickerSel > = 0 ) { <nl> _picker . hideAnimated ( ) ; <nl> _pickerSel = - 1 ; <nl> updateSelected ( ) ; <nl> void EmojiPanInner : : mouseReleaseEvent ( QMouseEvent * e ) { <nl> _lastMousePos = e - > globalPos ( ) ; <nl> if ( ! _picker . isHidden ( ) ) { <nl> if ( _picker . rect ( ) . contains ( _picker . mapFromGlobal ( _lastMousePos ) ) ) { <nl> - return _picker . mouseReleaseEvent ( 0 ) ; <nl> + return _picker . handleMouseRelease ( QCursor : : pos ( ) ) ; <nl> } else if ( _pickerSel > = 0 ) { <nl> int tab = ( _pickerSel / MatrixRowShift ) , sel = _pickerSel % MatrixRowShift ; <nl> if ( tab < emojiTabCount & & sel < _emojis [ tab ] . size ( ) & & _emojis [ tab ] [ sel ] - > color ) { <nl> void EmojiPanInner : : mouseMoveEvent ( QMouseEvent * e ) { <nl> _lastMousePos = e - > globalPos ( ) ; <nl> if ( ! _picker . isHidden ( ) ) { <nl> if ( _picker . rect ( ) . contains ( _picker . mapFromGlobal ( _lastMousePos ) ) ) { <nl> - return _picker . mouseMoveEvent ( 0 ) ; <nl> + return _picker . handleMouseMove ( QCursor : : pos ( ) ) ; <nl> } else { <nl> _picker . clearSelection ( ) ; <nl> } <nl> void EmojiPanInner : : enterFromChildEvent ( QEvent * e , QWidget * child ) { <nl> updateSelected ( ) ; <nl> } <nl> <nl> - void EmojiPanInner : : clearSelection ( bool fast ) { <nl> + void EmojiPanInner : : clearSelection ( ) { <nl> _lastMousePos = mapToGlobal ( QPoint ( - 10 , - 10 ) ) ; <nl> - if ( fast ) { <nl> - for ( Animations : : const_iterator i = _animations . cbegin ( ) ; i ! = _animations . cend ( ) ; + + i ) { <nl> - int index = qAbs ( i . key ( ) ) - 1 , tab = ( index / MatrixRowShift ) , sel = index % MatrixRowShift ; <nl> - _hovers [ tab ] [ sel ] = 0 ; <nl> - } <nl> - _animations . clear ( ) ; <nl> - if ( _selected > = 0 ) { <nl> - int index = qAbs ( _selected ) , tab = ( index / MatrixRowShift ) , sel = index % MatrixRowShift ; <nl> - _hovers [ tab ] [ sel ] = 0 ; <nl> - } <nl> - if ( _pressedSel > = 0 ) { <nl> - int index = qAbs ( _pressedSel ) , tab = ( index / MatrixRowShift ) , sel = index % MatrixRowShift ; <nl> - _hovers [ tab ] [ sel ] = 0 ; <nl> - } <nl> - _selected = _pressedSel = - 1 ; <nl> - _a_selected . stop ( ) ; <nl> - } else { <nl> - updateSelected ( ) ; <nl> - } <nl> + _pressedSel = - 1 ; <nl> + setSelected ( - 1 ) ; <nl> } <nl> <nl> DBIEmojiTab EmojiPanInner : : currentTab ( int yOffset ) const { <nl> void EmojiPanInner : : hideFinish ( ) { <nl> if ( ! _picker . isHidden ( ) ) { <nl> _picker . hideFast ( ) ; <nl> _pickerSel = - 1 ; <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> } <nl> } <nl> <nl> void EmojiPanInner : : refreshRecent ( ) { <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> _counts [ 0 ] = emojiPackCount ( dbietRecent ) ; <nl> - if ( _hovers [ 0 ] . size ( ) ! = _counts [ 0 ] ) _hovers [ 0 ] = QVector < float64 > ( _counts [ 0 ] , 0 ) ; <nl> _emojis [ 0 ] = emojiPack ( dbietRecent ) ; <nl> int32 h = countHeight ( ) ; <nl> if ( h ! = height ( ) ) { <nl> void EmojiPanInner : : refreshPanels ( QVector < EmojiPanel * > & panels ) { <nl> void EmojiPanInner : : updateSelected ( ) { <nl> if ( _pressedSel > = 0 | | _pickerSel > = 0 ) return ; <nl> <nl> - int32 selIndex = - 1 ; <nl> - QPoint p ( mapFromGlobal ( _lastMousePos ) ) ; <nl> + auto newSelected = - 1 ; <nl> + auto p = mapFromGlobal ( _lastMousePos ) ; <nl> int y , ytill = 0 , sx = ( rtl ( ) ? width ( ) - p . x ( ) : p . x ( ) ) - st : : emojiPanPadding ; <nl> for ( int c = 0 ; c < emojiTabCount ; + + c ) { <nl> int cnt = _counts [ c ] ; <nl> void EmojiPanInner : : updateSelected ( ) { <nl> if ( p . y ( ) > = y & & p . y ( ) < ytill ) { <nl> y + = st : : emojiPanHeader ; <nl> if ( p . y ( ) > = y & & sx > = 0 & & sx < EmojiPanPerRow * st : : emojiPanSize . width ( ) ) { <nl> - selIndex = qFloor ( ( p . y ( ) - y ) / st : : emojiPanSize . height ( ) ) * EmojiPanPerRow + qFloor ( sx / st : : emojiPanSize . width ( ) ) ; <nl> - if ( selIndex > = _emojis [ c ] . size ( ) ) { <nl> - selIndex = - 1 ; <nl> + newSelected = qFloor ( ( p . y ( ) - y ) / st : : emojiPanSize . height ( ) ) * EmojiPanPerRow + qFloor ( sx / st : : emojiPanSize . width ( ) ) ; <nl> + if ( newSelected > = _emojis [ c ] . size ( ) ) { <nl> + newSelected = - 1 ; <nl> } else { <nl> - selIndex + = c * MatrixRowShift ; <nl> + newSelected + = c * MatrixRowShift ; <nl> } <nl> } <nl> break ; <nl> } <nl> } <nl> <nl> - bool startanim = false ; <nl> - int oldSel = _selected , newSel = selIndex ; <nl> + setSelected ( newSelected ) ; <nl> + } <nl> <nl> - if ( newSel ! = oldSel ) { <nl> - if ( oldSel > = 0 ) { <nl> - _animations . remove ( oldSel + 1 ) ; <nl> - if ( _animations . find ( - oldSel - 1 ) = = _animations . end ( ) ) { <nl> - if ( _animations . isEmpty ( ) ) startanim = true ; <nl> - _animations . insert ( - oldSel - 1 , getms ( ) ) ; <nl> - } <nl> - } <nl> - if ( newSel > = 0 ) { <nl> - _animations . remove ( - newSel - 1 ) ; <nl> - if ( _animations . find ( newSel + 1 ) = = _animations . end ( ) ) { <nl> - if ( _animations . isEmpty ( ) ) startanim = true ; <nl> - _animations . insert ( newSel + 1 , getms ( ) ) ; <nl> - } <nl> - } <nl> - setCursor ( ( newSel > = 0 ) ? style : : cur_pointer : style : : cur_default ) ; <nl> - if ( newSel > = 0 & & ! _picker . isHidden ( ) ) { <nl> - if ( newSel ! = _pickerSel ) { <nl> - _picker . hideAnimated ( ) ; <nl> - } else { <nl> - _picker . showAnimated ( ) ; <nl> - } <nl> - } <nl> + void EmojiPanInner : : setSelected ( int newSelected ) { <nl> + if ( _selected = = newSelected ) { <nl> + return ; <nl> } <nl> + auto updateSelected = [ this ] ( ) { <nl> + if ( _selected < 0 ) return ; <nl> + rtlupdate ( emojiRect ( _selected / MatrixRowShift , _selected % MatrixRowShift ) ) ; <nl> + } ; <nl> + updateSelected ( ) ; <nl> + _selected = newSelected ; <nl> + updateSelected ( ) ; <nl> <nl> - _selected = selIndex ; <nl> - if ( startanim & & ! _a_selected . animating ( ) ) _a_selected . start ( ) ; <nl> - } <nl> - <nl> - void EmojiPanInner : : step_selected ( uint64 ms , bool timer ) { <nl> - QRegion toUpdate ; <nl> - for ( Animations : : iterator i = _animations . begin ( ) ; i ! = _animations . end ( ) ; ) { <nl> - int index = qAbs ( i . key ( ) ) - 1 , tab = ( index / MatrixRowShift ) , sel = index % MatrixRowShift ; <nl> - float64 dt = float64 ( ms - i . value ( ) ) / st : : emojiPanDuration ; <nl> - if ( dt > = 1 ) { <nl> - _hovers [ tab ] [ sel ] = ( i . key ( ) > 0 ) ? 1 : 0 ; <nl> - i = _animations . erase ( i ) ; <nl> + setCursor ( ( _selected > = 0 ) ? style : : cur_pointer : style : : cur_default ) ; <nl> + if ( _selected > = 0 & & ! _picker . isHidden ( ) ) { <nl> + if ( _selected ! = _pickerSel ) { <nl> + _picker . hideAnimated ( ) ; <nl> } else { <nl> - _hovers [ tab ] [ sel ] = ( i . key ( ) > 0 ) ? dt : ( 1 - dt ) ; <nl> - + + i ; <nl> + _picker . showAnimated ( ) ; <nl> } <nl> - toUpdate + = emojiRect ( tab , sel ) ; <nl> } <nl> - if ( timer ) rtlupdate ( toUpdate . boundingRect ( ) ) ; <nl> - if ( _animations . isEmpty ( ) ) _a_selected . stop ( ) ; <nl> } <nl> <nl> void InlineCacheEntry : : clearResults ( ) { <nl> void InlineCacheEntry : : clearResults ( ) { <nl> } <nl> <nl> void EmojiPanInner : : showEmojiPack ( DBIEmojiTab packIndex ) { <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> <nl> refreshRecent ( ) ; <nl> <nl> void EmojiPanInner : : showEmojiPack ( DBIEmojiTab packIndex ) { <nl> } <nl> <nl> StickerPanInner : : StickerPanInner ( QWidget * parent ) : TWidget ( parent ) <nl> - , _a_selected ( animation ( this , & StickerPanInner : : step_selected ) ) <nl> , _section ( cShowingSavedGifs ( ) ? Section : : Gifs : Section : : Stickers ) <nl> , _addText ( lang ( lng_stickers_featured_add ) . toUpper ( ) ) <nl> , _addWidth ( st : : stickersTrendingAdd . font - > width ( _addText ) ) <nl> void StickerPanInner : : paintStickers ( Painter & p , const QRect & r ) { <nl> tocol = StickerPanPerRow - tocol ; <nl> } <nl> <nl> + auto & sets = shownSets ( ) ; <nl> + auto seltab = ( _selected > = 0 ) ? ( _selected / MatrixRowShift ) : - 1 ; <nl> + auto selindex = ( seltab > = 0 ) ? ( _selected % MatrixRowShift ) : - 1 ; <nl> + auto seldelete = false ; <nl> + if ( seltab > = sets . size ( ) ) { <nl> + seltab = - 1 ; <nl> + } else if ( seltab > = 0 & & selindex > = sets [ seltab ] . pack . size ( ) ) { <nl> + selindex - = sets [ seltab ] . pack . size ( ) ; <nl> + seldelete = true ; <nl> + } <nl> + <nl> auto tilly = 0 ; <nl> auto ms = getms ( ) ; <nl> - auto & sets = shownSets ( ) ; <nl> if ( _section = = Section : : Featured ) { <nl> tilly + = st : : emojiPanHeader ; <nl> for ( int c = 0 , l = sets . size ( ) ; c < l ; + + c ) { <nl> void StickerPanInner : : paintStickers ( Painter & p , const QRect & r ) { <nl> int index = j ; <nl> if ( index > = size ) break ; <nl> <nl> - paintSticker ( p , set , y , index ) ; <nl> + auto selected = ( seltab = = c & & selindex = = index ) ; <nl> + auto deleteSelected = selected & & seldelete ; <nl> + paintSticker ( p , set , y , index , selected , deleteSelected ) ; <nl> } <nl> } <nl> } else { <nl> void StickerPanInner : : paintStickers ( Painter & p , const QRect & r ) { <nl> int index = i * StickerPanPerRow + j ; <nl> if ( index > = size ) break ; <nl> <nl> - paintSticker ( p , set , y , index ) ; <nl> + auto selected = ( seltab = = c & & selindex = = index ) ; <nl> + auto deleteSelected = selected & & seldelete ; <nl> + paintSticker ( p , set , y , index , selected , deleteSelected ) ; <nl> } <nl> } <nl> } <nl> } <nl> } <nl> <nl> - void StickerPanInner : : paintSticker ( Painter & p , Set & set , int y , int index ) { <nl> - float64 hover = set . hovers [ index ] ; <nl> - <nl> + void StickerPanInner : : paintSticker ( Painter & p , Set & set , int y , int index , bool selected , bool deleteSelected ) { <nl> auto sticker = set . pack [ index ] ; <nl> if ( ! sticker - > sticker ( ) ) return ; <nl> <nl> int row = ( index / StickerPanPerRow ) , col = ( index % StickerPanPerRow ) ; <nl> <nl> QPoint pos ( stickersLeft ( ) + col * st : : stickerPanSize . width ( ) , y + row * st : : stickerPanSize . height ( ) ) ; <nl> - if ( hover > 0 ) { <nl> - p . setOpacity ( hover ) ; <nl> + if ( selected ) { <nl> QPoint tl ( pos ) ; <nl> if ( rtl ( ) ) tl . setX ( width ( ) - tl . x ( ) - st : : stickerPanSize . width ( ) ) ; <nl> App : : roundRect ( p , QRect ( tl , st : : stickerPanSize ) , st : : emojiPanHover , StickerHoverCorners ) ; <nl> - p . setOpacity ( 1 . ) ; <nl> } <nl> <nl> bool goodThumb = ! sticker - > thumb - > isNull ( ) & & ( ( sticker - > thumb - > width ( ) > = 128 ) | | ( sticker - > thumb - > height ( ) > = 128 ) ) ; <nl> void StickerPanInner : : paintSticker ( Painter & p , Set & set , int y , int index ) { <nl> p . drawPixmapLeft ( ppos , width ( ) , sticker - > sticker ( ) - > img - > pix ( w , h ) ) ; <nl> } <nl> <nl> - if ( hover > 0 & & set . id = = Stickers : : RecentSetId & & _custom . at ( index ) ) { <nl> - float64 xHover = set . hovers [ set . pack . size ( ) + index ] ; <nl> - <nl> + if ( selected & & set . id = = Stickers : : RecentSetId & & _custom . at ( index ) ) { <nl> QPoint xPos = pos + QPoint ( st : : stickerPanSize . width ( ) - st : : stickerPanDelete . width ( ) , 0 ) ; <nl> - p . setOpacity ( hover * ( xHover + ( 1 - xHover ) * st : : stickerPanDeleteOpacity ) ) ; <nl> + if ( ! deleteSelected ) p . setOpacity ( st : : stickerPanDeleteOpacity ) ; <nl> st : : stickerPanDelete . paint ( p , xPos , width ( ) ) ; <nl> - p . setOpacity ( 1 . ) ; <nl> + if ( ! deleteSelected ) p . setOpacity ( 1 . ) ; <nl> } <nl> } <nl> <nl> void StickerPanInner : : removeRecentSticker ( int tab , int index ) { <nl> return ; <nl> } <nl> <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> bool refresh = false ; <nl> auto sticker = _mySets [ tab ] . pack [ index ] ; <nl> auto & recent = cGetRecentStickers ( ) ; <nl> bool StickerPanInner : : showSectionIcons ( ) const { <nl> return ! inlineResultsShown ( ) ; <nl> } <nl> <nl> - void StickerPanInner : : clearSelection ( bool fast ) { <nl> - if ( fast ) { <nl> - if ( showingInlineItems ( ) ) { <nl> - if ( _selected > = 0 ) { <nl> - int srow = _selected / MatrixRowShift , scol = _selected % MatrixRowShift ; <nl> - t_assert ( srow > = 0 & & srow < _inlineRows . size ( ) & & scol > = 0 & & scol < _inlineRows . at ( srow ) . items . size ( ) ) ; <nl> - ClickHandler : : clearActive ( _inlineRows . at ( srow ) . items . at ( scol ) ) ; <nl> - setCursor ( style : : cur_default ) ; <nl> - } <nl> - _selected = _pressed = - 1 ; <nl> - return ; <nl> - } <nl> - <nl> - auto & sets = shownSets ( ) ; <nl> - for ( auto i = _animations . cbegin ( ) ; i ! = _animations . cend ( ) ; + + i ) { <nl> - int index = qAbs ( i . key ( ) ) - 1 , tab = ( index / MatrixRowShift ) , sel = index % MatrixRowShift ; <nl> - sets [ tab ] . hovers [ sel ] = 0 ; <nl> - } <nl> - _animations . clear ( ) ; <nl> + void StickerPanInner : : clearSelection ( ) { <nl> + if ( showingInlineItems ( ) ) { <nl> if ( _selected > = 0 ) { <nl> - int index = qAbs ( _selected ) , tab = ( index / MatrixRowShift ) , sel = index % MatrixRowShift ; <nl> - if ( index > = 0 & & tab < sets . size ( ) & & sets [ tab ] . id = = Stickers : : RecentSetId & & sel > = tab * MatrixRowShift + sets [ tab ] . pack . size ( ) ) { <nl> - sets [ tab ] . hovers [ sel ] = 0 ; <nl> - sel - = sets [ tab ] . pack . size ( ) ; <nl> - } <nl> - sets [ tab ] . hovers [ sel ] = 0 ; <nl> - } <nl> - if ( _pressed > = 0 ) { <nl> - int index = qAbs ( _pressed ) , tab = ( index / MatrixRowShift ) , sel = index % MatrixRowShift ; <nl> - if ( index > = 0 & & tab < sets . size ( ) & & sets [ tab ] . id = = Stickers : : RecentSetId & & sel > = tab * MatrixRowShift + sets [ tab ] . pack . size ( ) ) { <nl> - sets [ tab ] . hovers [ sel ] = 0 ; <nl> - sel - = sets [ tab ] . pack . size ( ) ; <nl> - } <nl> - sets [ tab ] . hovers [ sel ] = 0 ; <nl> + int srow = _selected / MatrixRowShift , scol = _selected % MatrixRowShift ; <nl> + t_assert ( srow > = 0 & & srow < _inlineRows . size ( ) & & scol > = 0 & & scol < _inlineRows . at ( srow ) . items . size ( ) ) ; <nl> + ClickHandler : : clearActive ( _inlineRows . at ( srow ) . items . at ( scol ) ) ; <nl> + setCursor ( style : : cur_default ) ; <nl> } <nl> _selected = _pressed = - 1 ; <nl> - _selectedFeaturedSet = _pressedFeaturedSet = - 1 ; <nl> - _selectedFeaturedSetAdd = - 1 ; <nl> - setPressedFeaturedSetAdd ( - 1 ) ; <nl> - _a_selected . stop ( ) ; <nl> - update ( ) ; <nl> } else { <nl> - auto pos = _lastMousePos ; <nl> - _lastMousePos = mapToGlobal ( QPoint ( - 10 , - 10 ) ) ; <nl> - updateSelected ( ) ; <nl> - _lastMousePos = pos ; <nl> + _pressed = - 1 ; <nl> + _pressedFeaturedSet = - 1 ; <nl> + setSelected ( - 1 , - 1 , - 1 ) ; <nl> + setPressedFeaturedSetAdd ( - 1 ) ; <nl> } <nl> + update ( ) ; <nl> } <nl> <nl> void StickerPanInner : : hideFinish ( bool completely ) { <nl> void StickerPanInner : : hideFinish ( bool completely ) { <nl> void StickerPanInner : : refreshStickers ( ) { <nl> auto stickersShown = ( _section = = Section : : Stickers | | _section = = Section : : Featured ) ; <nl> if ( stickersShown ) { <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> } <nl> <nl> _mySets . clear ( ) ; <nl> void StickerPanInner : : refreshStickers ( ) { <nl> <nl> emit refreshIcons ( kRefreshIconsNoAnimation ) ; <nl> <nl> - / / Hack : skip over animations to the very end , <nl> - / / so that currently selected sticker won ' t get <nl> - / / blinking background when refreshing stickers . <nl> - if ( stickersShown ) { <nl> - updateSelected ( ) ; <nl> - int sel = _selected , tab = sel / MatrixRowShift , xsel = - 1 ; <nl> - if ( sel > = 0 ) { <nl> - auto & sets = shownSets ( ) ; <nl> - if ( tab < sets . size ( ) & & sets [ tab ] . id = = Stickers : : RecentSetId & & sel > = tab * MatrixRowShift + sets [ tab ] . pack . size ( ) ) { <nl> - xsel = sel ; <nl> - sel - = sets [ tab ] . pack . size ( ) ; <nl> - } <nl> - auto i = _animations . find ( sel + 1 ) ; <nl> - if ( i ! = _animations . cend ( ) ) { <nl> - i . value ( ) = ( i . value ( ) > = static_cast < uint32 > ( st : : emojiPanDuration ) ) ? ( i . value ( ) - st : : emojiPanDuration ) : 0 ; <nl> - } <nl> - if ( xsel > = 0 ) { <nl> - auto j = _animations . find ( xsel + 1 ) ; <nl> - if ( j ! = _animations . cend ( ) ) { <nl> - j . value ( ) = ( j . value ( ) > = static_cast < uint32 > ( st : : emojiPanDuration ) ) ? ( j . value ( ) - st : : emojiPanDuration ) : 0 ; <nl> - } <nl> - } <nl> - step_selected ( getms ( ) , true ) ; <nl> - } <nl> - } <nl> + if ( stickersShown ) updateSelected ( ) ; <nl> } <nl> <nl> bool StickerPanInner : : inlineRowsAddItem ( DocumentData * savedGif , InlineResult * result , InlineRow & row , int32 & sumWidth ) { <nl> void StickerPanInner : : clearInlineRows ( bool resultsDeleted ) { <nl> } <nl> } else { <nl> if ( showingInlineItems ( ) ) { <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> } <nl> for_const ( auto & row , _inlineRows ) { <nl> for_const ( auto & item , row . items ) { <nl> int StickerPanInner : : refreshInlineRows ( UserData * bot , const InlineCacheEntry * en <nl> return 0 ; <nl> } <nl> <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> <nl> t_assert ( _inlineBot ! = 0 ) ; <nl> _inlineBotTitle = lng_inline_bot_results ( lt_inline_bot , _inlineBot - > username . isEmpty ( ) ? _inlineBot - > name : ( ' @ ' + _inlineBot - > username ) ) ; <nl> void StickerPanInner : : refreshRecent ( ) { <nl> <nl> void StickerPanInner : : refreshRecentStickers ( bool performResize ) { <nl> _custom . clear ( ) ; <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> auto & sets = Global : : StickerSets ( ) ; <nl> auto & recent = cGetRecentStickers ( ) ; <nl> auto customIt = sets . constFind ( Stickers : : CustomSetId ) ; <nl> void StickerPanInner : : refreshRecentStickers ( bool performResize ) { <nl> _mySets . push_back ( Set ( Stickers : : RecentSetId , MTPDstickerSet : : Flag : : f_official | MTPDstickerSet_ClientFlag : : f_special , lang ( lng_recent_stickers ) , recentPack . size ( ) * 2 , recentPack ) ) ; <nl> } else { <nl> _mySets [ 0 ] . pack = recentPack ; <nl> - _mySets [ 0 ] . hovers . resize ( recentPack . size ( ) * 2 ) ; <nl> } <nl> } <nl> <nl> void StickerPanInner : : updateSelected ( ) { <nl> return ; <nl> } <nl> <nl> - int selIndex = - 1 ; <nl> + auto newSelected = - 1 ; <nl> auto p = mapFromGlobal ( _lastMousePos ) ; <nl> <nl> if ( showingInlineItems ( ) ) { <nl> void StickerPanInner : : updateSelected ( ) { <nl> return ; <nl> } <nl> <nl> - int selectedFeaturedSet = - 1 ; <nl> - int selectedFeaturedSetAdd = - 1 ; <nl> + auto newSelectedFeaturedSet = - 1 ; <nl> + auto newSelectedFeaturedSetAdd = - 1 ; <nl> auto featured = ( _section = = Section : : Featured ) ; <nl> auto & sets = shownSets ( ) ; <nl> int y , ytill = 0 , sx = ( rtl ( ) ? width ( ) - p . x ( ) : p . x ( ) ) - stickersLeft ( ) ; <nl> void StickerPanInner : : updateSelected ( ) { <nl> if ( featured ) { <nl> if ( p . y ( ) < y + st : : stickersTrendingHeader ) { <nl> if ( featuredHasAddButton ( c ) & & myrtlrect ( featuredAddRect ( c ) ) . contains ( p . x ( ) , p . y ( ) ) ) { <nl> - selectedFeaturedSetAdd = c ; <nl> + newSelectedFeaturedSetAdd = c ; <nl> } else { <nl> - selectedFeaturedSet = c ; <nl> + newSelectedFeaturedSet = c ; <nl> } <nl> break ; <nl> } <nl> void StickerPanInner : : updateSelected ( ) { <nl> if ( p . y ( ) > = y & & sx > = 0 & & sx < StickerPanPerRow * st : : stickerPanSize . width ( ) ) { <nl> auto rowIndex = qFloor ( ( p . y ( ) - y ) / st : : stickerPanSize . height ( ) ) ; <nl> if ( ! featured | | ! rowIndex ) { <nl> - selIndex = rowIndex * StickerPanPerRow + qFloor ( sx / st : : stickerPanSize . width ( ) ) ; <nl> - if ( selIndex > = set . pack . size ( ) ) { <nl> - selIndex = - 1 ; <nl> + newSelected = rowIndex * StickerPanPerRow + qFloor ( sx / st : : stickerPanSize . width ( ) ) ; <nl> + if ( newSelected > = set . pack . size ( ) ) { <nl> + newSelected = - 1 ; <nl> } else { <nl> - if ( set . id = = Stickers : : RecentSetId & & _custom [ selIndex ] ) { <nl> - int inx = sx - ( selIndex % StickerPanPerRow ) * st : : stickerPanSize . width ( ) , iny = p . y ( ) - y - ( ( selIndex / StickerPanPerRow ) * st : : stickerPanSize . height ( ) ) ; <nl> + if ( set . id = = Stickers : : RecentSetId & & _custom [ newSelected ] ) { <nl> + auto inx = sx - ( newSelected % StickerPanPerRow ) * st : : stickerPanSize . width ( ) ; <nl> + auto iny = p . y ( ) - y - ( ( newSelected / StickerPanPerRow ) * st : : stickerPanSize . height ( ) ) ; <nl> if ( inx > = st : : stickerPanSize . width ( ) - st : : stickerPanDelete . width ( ) & & iny < st : : stickerPanDelete . height ( ) ) { <nl> - selIndex + = set . pack . size ( ) ; <nl> + newSelected + = set . pack . size ( ) ; <nl> } <nl> } <nl> - selIndex + = c * MatrixRowShift ; <nl> + newSelected + = c * MatrixRowShift ; <nl> } <nl> } <nl> } <nl> void StickerPanInner : : updateSelected ( ) { <nl> } <nl> } <nl> <nl> - bool startanim = false ; <nl> - int oldSel = _selected , oldSelTab = oldSel / MatrixRowShift , xOldSel = - 1 , newSel = selIndex , newSelTab = newSel / MatrixRowShift , xNewSel = - 1 ; <nl> - if ( oldSel > = 0 & & oldSelTab < sets . size ( ) & & sets [ oldSelTab ] . id = = Stickers : : RecentSetId & & oldSel > = oldSelTab * MatrixRowShift + sets [ oldSelTab ] . pack . size ( ) ) { <nl> - xOldSel = oldSel ; <nl> - oldSel - = sets [ oldSelTab ] . pack . size ( ) ; <nl> - } <nl> - if ( newSel > = 0 & & newSelTab < sets . size ( ) & & sets [ newSelTab ] . id = = Stickers : : RecentSetId & & newSel > = newSelTab * MatrixRowShift + sets [ newSelTab ] . pack . size ( ) ) { <nl> - xNewSel = newSel ; <nl> - newSel - = sets [ newSelTab ] . pack . size ( ) ; <nl> - } <nl> - if ( newSel ! = oldSel | | selectedFeaturedSet ! = _selectedFeaturedSet | | selectedFeaturedSetAdd ! = _selectedFeaturedSetAdd ) { <nl> - setCursor ( ( newSel > = 0 | | selectedFeaturedSet > = 0 | | selectedFeaturedSetAdd > = 0 ) ? style : : cur_pointer : style : : cur_default ) ; <nl> + setSelected ( newSelected , newSelectedFeaturedSet , newSelectedFeaturedSetAdd ) ; <nl> + } <nl> + <nl> + void StickerPanInner : : setSelected ( int newSelected , int newSelectedFeaturedSet , int newSelectedFeaturedSetAdd ) { <nl> + if ( _selected ! = newSelected | | _selectedFeaturedSet ! = newSelectedFeaturedSet | | _selectedFeaturedSetAdd ! = newSelectedFeaturedSetAdd ) { <nl> + setCursor ( ( newSelected > = 0 | | newSelectedFeaturedSet > = 0 | | newSelectedFeaturedSetAdd > = 0 ) ? style : : cur_pointer : style : : cur_default ) ; <nl> } <nl> - if ( newSel ! = oldSel ) { <nl> - if ( oldSel > = 0 ) { <nl> - _animations . remove ( oldSel + 1 ) ; <nl> - if ( _animations . find ( - oldSel - 1 ) = = _animations . end ( ) ) { <nl> - if ( _animations . isEmpty ( ) ) startanim = true ; <nl> - _animations . insert ( - oldSel - 1 , getms ( ) ) ; <nl> + if ( _selected ! = newSelected ) { <nl> + auto & sets = shownSets ( ) ; <nl> + auto updateSelected = [ this , & sets ] ( ) { <nl> + if ( _selected < 0 ) return ; <nl> + auto tab = _selected / MatrixRowShift , sel = _selected % MatrixRowShift ; <nl> + if ( tab < sets . size ( ) & & sel > = sets [ tab ] . pack . size ( ) ) { <nl> + sel - = sets [ tab ] . pack . size ( ) ; <nl> } <nl> - } <nl> - if ( newSel > = 0 ) { <nl> - _animations . remove ( - newSel - 1 ) ; <nl> - if ( _animations . find ( newSel + 1 ) = = _animations . end ( ) ) { <nl> - if ( _animations . isEmpty ( ) ) startanim = true ; <nl> - _animations . insert ( newSel + 1 , getms ( ) ) ; <nl> + rtlupdate ( stickerRect ( tab , sel ) ) ; <nl> + } ; <nl> + updateSelected ( ) ; <nl> + _selected = newSelected ; <nl> + updateSelected ( ) ; <nl> + <nl> + if ( _previewShown & & _selected > = 0 & & _pressed ! = _selected ) { <nl> + _pressed = _selected ; <nl> + auto tab = _selected / MatrixRowShift , sel = _selected % MatrixRowShift ; <nl> + if ( tab < sets . size ( ) & & sel < sets [ tab ] . pack . size ( ) ) { <nl> + Ui : : showMediaPreview ( sets [ tab ] . pack [ sel ] ) ; <nl> } <nl> } <nl> } <nl> - if ( selectedFeaturedSet ! = _selectedFeaturedSet ) { <nl> - _selectedFeaturedSet = selectedFeaturedSet ; <nl> + if ( _selectedFeaturedSet ! = newSelectedFeaturedSet ) { <nl> + _selectedFeaturedSet = newSelectedFeaturedSet ; <nl> } <nl> - if ( selectedFeaturedSetAdd ! = _selectedFeaturedSetAdd ) { <nl> - _selectedFeaturedSetAdd = selectedFeaturedSetAdd ; <nl> + if ( _selectedFeaturedSetAdd ! = newSelectedFeaturedSetAdd ) { <nl> + _selectedFeaturedSetAdd = newSelectedFeaturedSetAdd ; <nl> update ( ) ; <nl> } <nl> - if ( xNewSel ! = xOldSel ) { <nl> - if ( xOldSel > = 0 ) { <nl> - _animations . remove ( xOldSel + 1 ) ; <nl> - if ( _animations . find ( - xOldSel - 1 ) = = _animations . end ( ) ) { <nl> - if ( _animations . isEmpty ( ) ) startanim = true ; <nl> - _animations . insert ( - xOldSel - 1 , getms ( ) ) ; <nl> - } <nl> - } <nl> - if ( xNewSel > = 0 ) { <nl> - _animations . remove ( - xNewSel - 1 ) ; <nl> - if ( _animations . find ( xNewSel + 1 ) = = _animations . end ( ) ) { <nl> - if ( _animations . isEmpty ( ) ) startanim = true ; <nl> - _animations . insert ( xNewSel + 1 , getms ( ) ) ; <nl> - } <nl> - } <nl> - } <nl> - _selected = selIndex ; <nl> - if ( _previewShown & & _selected > = 0 & & _pressed ! = _selected ) { <nl> - _pressed = _selected ; <nl> - if ( newSel > = 0 & & xNewSel < 0 ) { <nl> - Ui : : showMediaPreview ( sets . at ( newSelTab ) . pack . at ( newSel % MatrixRowShift ) ) ; <nl> - } <nl> - } <nl> - if ( startanim & & ! _a_selected . animating ( ) ) _a_selected . start ( ) ; <nl> } <nl> <nl> void StickerPanInner : : onSettings ( ) { <nl> void StickerPanInner : : onSwitchPm ( ) { <nl> } <nl> } <nl> <nl> - void StickerPanInner : : step_selected ( uint64 ms , bool timer ) { <nl> - QRegion toUpdate ; <nl> - auto & sets = shownSets ( ) ; <nl> - for ( auto i = _animations . begin ( ) ; i ! = _animations . end ( ) ; ) { <nl> - int index = qAbs ( i . key ( ) ) - 1 , tab = ( index / MatrixRowShift ) , sel = index % MatrixRowShift ; <nl> - float64 dt = float64 ( ms - i . value ( ) ) / st : : emojiPanDuration ; <nl> - if ( dt > = 1 ) { <nl> - sets [ tab ] . hovers [ sel ] = ( i . key ( ) > 0 ) ? 1 : 0 ; <nl> - i = _animations . erase ( i ) ; <nl> - } else { <nl> - sets [ tab ] . hovers [ sel ] = ( i . key ( ) > 0 ) ? dt : ( 1 - dt ) ; <nl> - + + i ; <nl> - } <nl> - toUpdate + = stickerRect ( tab , sel ) ; <nl> - } <nl> - if ( timer ) rtlupdate ( toUpdate . boundingRect ( ) ) ; <nl> - if ( _animations . isEmpty ( ) ) _a_selected . stop ( ) ; <nl> - } <nl> - <nl> void StickerPanInner : : showStickerSet ( uint64 setId ) { <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> <nl> if ( setId = = Stickers : : NoneSetId ) { <nl> if ( ! showingInlineItems ( ) ) { <nl> void StickerPanInner : : showStickerSet ( uint64 setId ) { <nl> void StickerPanInner : : updateShowingSavedGifs ( ) { <nl> if ( cShowingSavedGifs ( ) ) { <nl> if ( ! showingInlineItems ( ) ) { <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> _section = Section : : Gifs ; <nl> if ( _inlineRows . isEmpty ( ) ) refreshSavedGifs ( ) ; <nl> } <nl> } else if ( ! showingInlineItems ( ) ) { <nl> - clearSelection ( true ) ; <nl> + clearSelection ( ) ; <nl> } <nl> } <nl> <nl> void EmojiPan : : hideAll ( ) { <nl> _symbols - > hide ( ) ; <nl> e_scroll - > hide ( ) ; <nl> s_scroll - > hide ( ) ; <nl> - e_inner - > clearSelection ( true ) ; <nl> - s_inner - > clearSelection ( true ) ; <nl> + e_inner - > clearSelection ( ) ; <nl> + s_inner - > clearSelection ( ) ; <nl> } <nl> <nl> void EmojiPan : : setActiveTab ( DBIEmojiTab tab ) { <nl> mmm a / Telegram / SourceFiles / stickers / emoji_pan . h <nl> ppp b / Telegram / SourceFiles / stickers / emoji_pan . h <nl> class EmojiColorPicker : public TWidget { <nl> <nl> void showEmoji ( uint32 code ) ; <nl> <nl> - void paintEvent ( QPaintEvent * e ) ; <nl> - void enterEvent ( QEvent * e ) ; <nl> - void leaveEvent ( QEvent * e ) ; <nl> - void mousePressEvent ( QMouseEvent * e ) ; <nl> - void mouseReleaseEvent ( QMouseEvent * e ) ; <nl> - void mouseMoveEvent ( QMouseEvent * e ) ; <nl> - <nl> - void step_appearance ( float64 ms , bool timer ) ; <nl> - void step_selected ( uint64 ms , bool timer ) ; <nl> - <nl> - void clearSelection ( bool fast = false ) ; <nl> + void clearSelection ( ) ; <nl> + void handleMouseMove ( QPoint globalPos ) ; <nl> + void handleMouseRelease ( QPoint globalPos ) ; <nl> <nl> void hideFast ( ) ; <nl> <nl> public slots : <nl> void emojiSelected ( EmojiPtr emoji ) ; <nl> void hidden ( ) ; <nl> <nl> + protected : <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> + void enterEvent ( QEvent * e ) override ; <nl> + void leaveEvent ( QEvent * e ) override ; <nl> + void mousePressEvent ( QMouseEvent * e ) override ; <nl> + void mouseReleaseEvent ( QMouseEvent * e ) override ; <nl> + void mouseMoveEvent ( QMouseEvent * e ) override ; <nl> + <nl> private : <nl> + void step_appearance ( float64 ms , bool timer ) ; <nl> + <nl> void drawVariant ( Painter & p , int variant ) ; <nl> <nl> void updateSelected ( ) ; <nl> + void setSelected ( int newSelected ) ; <nl> <nl> bool _ignoreShow = false ; <nl> <nl> EmojiPtr _variants [ EmojiColorsCount + 1 ] ; <nl> <nl> - typedef QMap < int32 , uint64 > EmojiAnimations ; / / index - showing , - index - hiding <nl> - EmojiAnimations _emojiAnimations ; <nl> - Animation _a_selected ; <nl> - <nl> - float64 _hovers [ EmojiColorsCount + 1 ] ; <nl> - <nl> int _selected = - 1 ; <nl> int _pressedSel = - 1 ; <nl> QPoint _lastMousePos ; <nl> class EmojiPanInner : public TWidget { <nl> EmojiPanInner ( QWidget * parent ) ; <nl> <nl> void setMaxHeight ( int32 h ) ; <nl> - void paintEvent ( QPaintEvent * e ) override ; <nl> <nl> - void step_selected ( uint64 ms , bool timer ) ; <nl> void hideFinish ( ) ; <nl> <nl> void showEmojiPack ( DBIEmojiTab packIndex ) ; <nl> <nl> - void clearSelection ( bool fast = false ) ; <nl> + void clearSelection ( ) ; <nl> <nl> DBIEmojiTab currentTab ( int yOffset ) const ; <nl> <nl> class EmojiPanInner : public TWidget { <nl> void mousePressEvent ( QMouseEvent * e ) override ; <nl> void mouseReleaseEvent ( QMouseEvent * e ) override ; <nl> void mouseMoveEvent ( QMouseEvent * e ) override ; <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> void leaveEvent ( QEvent * e ) override ; <nl> void leaveToChildEvent ( QEvent * e , QWidget * child ) override ; <nl> void enterFromChildEvent ( QEvent * e , QWidget * child ) override ; <nl> <nl> public slots : <nl> - void updateSelected ( ) ; <nl> - <nl> void onShowPicker ( ) ; <nl> void onPickerHidden ( ) ; <nl> void onColorSelected ( EmojiPtr emoji ) ; <nl> public slots : <nl> void saveConfigDelayed ( int32 delay ) ; <nl> <nl> private : <nl> + void updateSelected ( ) ; <nl> + void setSelected ( int newSelected ) ; <nl> + <nl> int32 _maxHeight ; <nl> <nl> int countHeight ( ) ; <nl> public slots : <nl> <nl> QRect emojiRect ( int tab , int sel ) ; <nl> <nl> - typedef QMap < int32 , uint64 > Animations ; / / index - showing , - index - hiding <nl> - Animations _animations ; <nl> - Animation _a_selected ; <nl> - <nl> int _visibleTop = 0 ; <nl> int _visibleBottom = 0 ; <nl> int _counts [ emojiTabCount ] ; <nl> <nl> QVector < EmojiPtr > _emojis [ emojiTabCount ] ; <nl> - QVector < float64 > _hovers [ emojiTabCount ] ; <nl> <nl> int32 _esize ; <nl> <nl> class StickerPanInner : public TWidget , private base : : Subscriber { <nl> StickerPanInner ( QWidget * parent ) ; <nl> <nl> void setMaxHeight ( int32 h ) ; <nl> - void paintEvent ( QPaintEvent * e ) override ; <nl> - <nl> - void step_selected ( uint64 ms , bool timer ) ; <nl> <nl> void hideFinish ( bool completely ) ; <nl> void showFinish ( ) ; <nl> class StickerPanInner : public TWidget , private base : : Subscriber { <nl> void updateShowingSavedGifs ( ) ; <nl> <nl> bool showSectionIcons ( ) const ; <nl> - void clearSelection ( bool fast = false ) ; <nl> + void clearSelection ( ) ; <nl> <nl> void refreshStickers ( ) ; <nl> void refreshRecentStickers ( bool resize = true ) ; <nl> class StickerPanInner : public TWidget , private base : : Subscriber { <nl> void mousePressEvent ( QMouseEvent * e ) override ; <nl> void mouseReleaseEvent ( QMouseEvent * e ) override ; <nl> void mouseMoveEvent ( QMouseEvent * e ) override ; <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> void leaveEvent ( QEvent * e ) override ; <nl> void leaveToChildEvent ( QEvent * e , QWidget * child ) override ; <nl> void enterFromChildEvent ( QEvent * e , QWidget * child ) override ; <nl> <nl> private slots : <nl> - void updateSelected ( ) ; <nl> void onSettings ( ) ; <nl> void onPreview ( ) ; <nl> void onUpdateInlineItems ( ) ; <nl> private slots : <nl> static constexpr bool kRefreshIconsScrollAnimation = true ; <nl> static constexpr bool kRefreshIconsNoAnimation = false ; <nl> <nl> + void updateSelected ( ) ; <nl> + void setSelected ( int newSelected , int newSelectedFeaturedSet , int newSelectedFeaturedSetAdd ) ; <nl> + <nl> void setPressedFeaturedSetAdd ( int newPressedFeaturedSetAdd ) ; <nl> <nl> struct Set { <nl> - Set ( uint64 id , MTPDstickerSet : : Flags flags , const QString & title , int32 hoversSize , const StickerPack & pack = StickerPack ( ) ) : id ( id ) , flags ( flags ) , title ( title ) , hovers ( hoversSize , 0 ) , pack ( pack ) { <nl> + Set ( uint64 id , MTPDstickerSet : : Flags flags , const QString & title , int32 hoversSize , const StickerPack & pack = StickerPack ( ) ) : id ( id ) , flags ( flags ) , title ( title ) , pack ( pack ) { <nl> } <nl> uint64 id ; <nl> MTPDstickerSet : : Flags flags ; <nl> QString title ; <nl> - QVector < float64 > hovers ; <nl> StickerPack pack ; <nl> QSharedPointer < Ui : : RippleAnimation > ripple ; <nl> } ; <nl> private slots : <nl> <nl> void paintInlineItems ( Painter & p , const QRect & r ) ; <nl> void paintStickers ( Painter & p , const QRect & r ) ; <nl> - void paintSticker ( Painter & p , Set & set , int y , int index ) ; <nl> + void paintSticker ( Painter & p , Set & set , int y , int index , bool selected , bool deleteSelected ) ; <nl> bool featuredHasAddButton ( int index ) const ; <nl> int featuredContentWidth ( ) const ; <nl> QRect featuredAddRect ( int y ) const ; <nl> private slots : <nl> <nl> int32 _maxHeight ; <nl> <nl> - typedef QMap < int32 , uint64 > Animations ; / / index - showing , - index - hiding <nl> - Animations _animations ; <nl> - Animation _a_selected ; <nl> - <nl> int _visibleTop = 0 ; <nl> int _visibleBottom = 0 ; <nl> <nl> class EmojiPanel : public TWidget { <nl> Q_OBJECT <nl> <nl> public : <nl> - <nl> EmojiPanel ( QWidget * parent , const QString & text , uint64 setId , bool special , int32 wantedY ) ; / / Stickers : : NoneSetId if in emoji <nl> void setText ( const QString & text ) ; <nl> void setDeleteVisible ( bool isVisible ) ; <nl> <nl> - void paintEvent ( QPaintEvent * e ) ; <nl> - void mousePressEvent ( QMouseEvent * e ) ; <nl> - <nl> - int32 wantedY ( ) const { <nl> + int wantedY ( ) const { <nl> return _wantedY ; <nl> } <nl> void setWantedY ( int32 y ) { <nl> class EmojiPanel : public TWidget { <nl> } <nl> <nl> signals : <nl> - <nl> void deleteClicked ( quint64 setId ) ; <nl> void mousePressed ( ) ; <nl> <nl> public slots : <nl> - <nl> void onDelete ( ) ; <nl> <nl> - private : <nl> + protected : <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> + void mousePressEvent ( QMouseEvent * e ) override ; <nl> <nl> + private : <nl> void updateText ( ) ; <nl> <nl> int32 _wantedY ; <nl> QString _text , _fullText ; <nl> uint64 _setId ; <nl> bool _special , _deleteVisible ; <nl> - Ui : : IconButton * _delete ; <nl> + Ui : : IconButton * _delete = nullptr ; <nl> <nl> } ; <nl> <nl> class EmojiSwitchButton : public Ui : : AbstractButton { <nl> public : <nl> - <nl> EmojiSwitchButton ( QWidget * parent , bool toStickers ) ; / / otherwise toEmoji <nl> - void paintEvent ( QPaintEvent * e ) ; <nl> void updateText ( const QString & inlineBotUsername = QString ( ) ) ; <nl> <nl> protected : <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> <nl> - bool _toStickers ; <nl> + private : <nl> + bool _toStickers = false ; <nl> QString _text ; <nl> - int32 _textWidth ; <nl> + int _textWidth = 0 ; <nl> <nl> } ; <nl> <nl> class EmojiPan : public TWidget , public RPCSender { <nl> EmojiPan ( QWidget * parent ) ; <nl> <nl> void setMaxHeight ( int32 h ) ; <nl> - void paintEvent ( QPaintEvent * e ) ; <nl> <nl> void moveBottom ( int32 bottom , bool force = false ) ; <nl> <nl> - void enterEvent ( QEvent * e ) ; <nl> - void leaveEvent ( QEvent * e ) ; <nl> - void otherEnter ( ) ; <nl> - void otherLeave ( ) ; <nl> - <nl> - void mousePressEvent ( QMouseEvent * e ) ; <nl> - void mouseMoveEvent ( QMouseEvent * e ) ; <nl> - void mouseReleaseEvent ( QMouseEvent * e ) ; <nl> - <nl> - bool event ( QEvent * e ) ; <nl> - <nl> void hideFast ( ) ; <nl> bool hiding ( ) const { <nl> return _hiding | | _hideTimer . isActive ( ) ; <nl> class EmojiPan : public TWidget , public RPCSender { <nl> <nl> void step_icons ( uint64 ms , bool timer ) ; <nl> <nl> - bool eventFilter ( QObject * obj , QEvent * e ) ; <nl> void stickersInstalled ( uint64 setId ) ; <nl> <nl> void queryInlineBot ( UserData * bot , PeerData * peer , QString query ) ; <nl> class EmojiPan : public TWidget , public RPCSender { <nl> <nl> ~ EmojiPan ( ) ; <nl> <nl> + protected : <nl> + void enterEvent ( QEvent * e ) override ; <nl> + void leaveEvent ( QEvent * e ) override ; <nl> + void otherEnter ( ) ; <nl> + void otherLeave ( ) ; <nl> + <nl> + void mousePressEvent ( QMouseEvent * e ) override ; <nl> + void mouseMoveEvent ( QMouseEvent * e ) override ; <nl> + void mouseReleaseEvent ( QMouseEvent * e ) override ; <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> + <nl> + bool event ( QEvent * e ) override ; <nl> + bool eventFilter ( QObject * obj , QEvent * e ) override ; <nl> + <nl> public slots : <nl> void refreshStickers ( ) ; <nl> <nl> mmm a / Telegram / SourceFiles / stickers / stickers . style <nl> ppp b / Telegram / SourceFiles / stickers / stickers . style <nl> stickersMaxHeight : 440px ; <nl> stickersPadding : margins ( 19px , 17px , 19px , 17px ) ; <nl> stickersSize : size ( 64px , 64px ) ; <nl> stickersScroll : FlatScroll ( boxScroll ) { <nl> - round : 2px ; <nl> - deltax : 7px ; <nl> deltat : 23px ; <nl> deltab : 9px ; <nl> } <nl> emojiPanWidth : 345px ; <nl> emojiPanMaxHeight : 366px ; <nl> emojiPanShowDuration : 200 ; <nl> emojiPanDuration : 200 ; <nl> - emojiPanHover : # f0f4f7 ; <nl> + emojiPanHover : windowBgOver ; <nl> emojiPanSlideDuration : 200 ; <nl> emojiPanSlideDelta : 0 ; / / between hide start and show start <nl> <nl> mmm a / Telegram / SourceFiles / ui / widgets / widgets . style <nl> ppp b / Telegram / SourceFiles / ui / widgets / widgets . style <nl> defaultFlatScroll : FlatScroll { <nl> hiding : 1000 ; <nl> } <nl> <nl> - defaultSolidScroll : FlatScroll { <nl> - barColor : # 3f729734 ; <nl> - bgColor : # 214f751a ; <nl> - barOverColor : # 3f729734 ; <nl> - bgOverColor : # 214f751a ; <nl> - <nl> - minHeight : 20px ; <nl> - <nl> - round : 2px ; <nl> + defaultSolidScroll : FlatScroll ( defaultFlatScroll ) { <nl> deltax : 5px ; <nl> width : 14px ; <nl> deltat : 6px ; <nl> defaultSolidScroll : FlatScroll { <nl> <nl> topsh : 0px ; <nl> bottomsh : 0px ; <nl> - shColor : # 00000012 ; <nl> <nl> - duration : 150 ; <nl> hiding : 0 ; <nl> } <nl> <nl> mmm a / Telegram / SourceFiles / window / top_bar_widget . cpp <nl> ppp b / Telegram / SourceFiles / window / top_bar_widget . cpp <nl> Copyright ( c ) 2014 - 2016 John Preston , https : / / desktop . telegram . org <nl> namespace Window { <nl> <nl> TopBarWidget : : TopBarWidget ( MainWidget * w ) : TWidget ( w ) <nl> - , _a_appearance ( animation ( this , & TopBarWidget : : step_appearance ) ) <nl> , _clearSelection ( this , lang ( lng_selected_clear ) , st : : topBarClearButton ) <nl> , _forward ( this , lang ( lng_selected_forward ) , st : : defaultActiveButton ) <nl> , _delete ( this , lang ( lng_selected_delete ) , st : : defaultActiveButton ) <nl> TopBarWidget : : TopBarWidget ( MainWidget * w ) : TWidget ( w ) <nl> , _mediaType ( this , lang ( lng_media_type ) , st : : topBarButton ) <nl> , _search ( this , st : : topBarSearch ) <nl> , _menuToggle ( this , st : : topBarMenuToggle ) { <nl> - _mediaType - > setTextTransform ( Ui : : RoundButton : : TextTransform : : NoTransform ) ; <nl> - <nl> _forward - > setClickedCallback ( [ this ] { onForwardSelection ( ) ; } ) ; <nl> _delete - > setClickedCallback ( [ this ] { onDeleteSelection ( ) ; } ) ; <nl> _clearSelection - > setClickedCallback ( [ this ] { onClearSelection ( ) ; } ) ; <nl> void TopBarWidget : : showMenu ( ) { <nl> } <nl> } <nl> <nl> - void TopBarWidget : : enterEvent ( QEvent * e ) { <nl> - a_over . start ( 1 ) ; <nl> - _a_appearance . start ( ) ; <nl> - } <nl> - <nl> - void TopBarWidget : : enterFromChildEvent ( QEvent * e , QWidget * child ) { <nl> - if ( child ! = _membersShowArea ) { <nl> - a_over . start ( 1 ) ; <nl> - _a_appearance . start ( ) ; <nl> - } <nl> - } <nl> - <nl> - void TopBarWidget : : leaveEvent ( QEvent * e ) { <nl> - a_over . start ( 0 ) ; <nl> - _a_appearance . start ( ) ; <nl> - } <nl> - <nl> - void TopBarWidget : : leaveToChildEvent ( QEvent * e , QWidget * child ) { <nl> - if ( child ! = _membersShowArea ) { <nl> - a_over . start ( 0 ) ; <nl> - _a_appearance . start ( ) ; <nl> - } <nl> - } <nl> - <nl> - void TopBarWidget : : step_appearance ( float64 ms , bool timer ) { <nl> - float64 dt = ms / st : : topBarDuration ; <nl> - if ( dt > = 1 ) { <nl> - _a_appearance . stop ( ) ; <nl> - a_over . finish ( ) ; <nl> - } else { <nl> - a_over . update ( dt , anim : : linear ) ; <nl> - } <nl> - if ( timer ) update ( ) ; <nl> - } <nl> - <nl> bool TopBarWidget : : eventFilter ( QObject * obj , QEvent * e ) { <nl> if ( obj = = _membersShowArea ) { <nl> switch ( e - > type ( ) ) { <nl> void TopBarWidget : : paintEvent ( QPaintEvent * e ) { <nl> if ( ! _search - > isHidden ( ) ) { <nl> decreaseWidth + = _search - > width ( ) ; <nl> } <nl> - auto paintCounter = main ( ) - > paintTopBar ( p , a_over . current ( ) , decreaseWidth ) ; <nl> + auto paintCounter = main ( ) - > paintTopBar ( p , decreaseWidth ) ; <nl> p . restore ( ) ; <nl> <nl> if ( paintCounter ) { <nl> mmm a / Telegram / SourceFiles / window / top_bar_widget . h <nl> ppp b / Telegram / SourceFiles / window / top_bar_widget . h <nl> class TopBarWidget : public TWidget , private base : : Subscriber { <nl> public : <nl> TopBarWidget ( MainWidget * w ) ; <nl> <nl> - void enterEvent ( QEvent * e ) override ; <nl> - void enterFromChildEvent ( QEvent * e , QWidget * child ) override ; <nl> - void leaveEvent ( QEvent * e ) override ; <nl> - void leaveToChildEvent ( QEvent * e , QWidget * child ) override ; <nl> - void paintEvent ( QPaintEvent * e ) override ; <nl> - void mousePressEvent ( QMouseEvent * e ) override ; <nl> - void resizeEvent ( QResizeEvent * e ) override ; <nl> - <nl> - void step_appearance ( float64 ms , bool timer ) ; <nl> - <nl> void startAnim ( ) ; <nl> void stopAnim ( ) ; <nl> void showAll ( ) ; <nl> class TopBarWidget : public TWidget , private base : : Subscriber { <nl> static void paintUnreadCounter ( Painter & p , int outerWidth ) ; <nl> <nl> protected : <nl> + void paintEvent ( QPaintEvent * e ) override ; <nl> + void mousePressEvent ( QMouseEvent * e ) override ; <nl> + void resizeEvent ( QResizeEvent * e ) override ; <nl> bool eventFilter ( QObject * obj , QEvent * e ) override ; <nl> <nl> signals : <nl> class TopBarWidget : public TWidget , private base : : Subscriber { <nl> void updateAdaptiveLayout ( ) ; <nl> <nl> MainWidget * main ( ) ; <nl> - anim : : fvalue a_over = { 0 . } ; <nl> - Animation _a_appearance ; <nl> <nl> PeerData * _searchInPeer = nullptr ; <nl> PeerData * _selPeer = nullptr ; <nl> mmm a / Telegram / SourceFiles / window / window . style <nl> ppp b / Telegram / SourceFiles / window / window . style <nl> topBarMenuPosition : point ( - 2px , 35px ) ; <nl> topBarDuration : 200 ; <nl> topBarBackward : icon { { " title_back " , # a3a3a3 } } ; <nl> topBarForwardAlpha : 0 . 6 ; <nl> - topBarBack : icon { { " title_back " , # 259fd8 } } ; <nl> - topBarBackAlpha : 0 . 8 ; <nl> - topBarBackColor : # 005faf ; <nl> - topBarBackFont : font ( 16px ) ; <nl> + topBarBack : icon { { " title_back " , lightButtonFg } } ; <nl> topBarArrowPadding : margins ( 39px , 8px , 17px , 8px ) ; <nl> topBarMinPadding : 5px ; <nl> - topBarButton : RoundButton { <nl> - textFg : btnYesColor ; <nl> - textFgOver : btnYesColor ; <nl> - secondaryTextFg : btnYesColor ; <nl> - secondaryTextFgOver : btnYesColor ; <nl> - textBg : windowBg ; <nl> - textBgOver : # edf4f7 ; <nl> - <nl> - width : - 22px ; <nl> - height : 28px ; <nl> - padding : margins ( 0px , 14px , 12px , 12px ) ; <nl> - <nl> - textTop : 6px ; <nl> - <nl> - font : font ( fsize ) ; <nl> - <nl> - ripple : RippleAnimation ( defaultRippleAnimation ) { <nl> - color : lightButtonBgRipple ; <nl> - } <nl> + topBarButton : RoundButton ( defaultLightButton ) { <nl> + width : - 18px ; <nl> + padding : margins ( 0px , 10px , 12px , 10px ) ; <nl> } <nl> topBarClearButton : RoundButton ( defaultLightButton ) { <nl> width : - 18px ; <nl>
|
Top bar buttons design improved , emoji pan animations removed .
|
telegramdesktop/tdesktop
|
2ada4d841fe033dccd17f9dae67886a3bc15482e
|
2016-12-30T13:52:18Z
|
mmm a / src / mongo / db / op_observer_impl . cpp <nl> ppp b / src / mongo / db / op_observer_impl . cpp <nl> const OperationContext : : Decoration < boost : : optional < OpObserverImpl : : DocumentKey > > <nl> documentKeyDecoration = <nl> OperationContext : : declareDecoration < boost : : optional < OpObserverImpl : : DocumentKey > > ( ) ; <nl> <nl> + const OperationContext : : Decoration < boost : : optional < ShardId > > destinedRecipientDecoration = <nl> + OperationContext : : declareDecoration < boost : : optional < ShardId > > ( ) ; <nl> + <nl> namespace { <nl> <nl> MONGO_FAIL_POINT_DEFINE ( failCollectionUpdates ) ; <nl> OpTimeBundle replLogDelete ( OperationContext * opCtx , <nl> MutableOplogEntry oplogEntry ; <nl> oplogEntry . setNss ( nss ) ; <nl> oplogEntry . setUuid ( uuid ) ; <nl> + oplogEntry . setDestinedRecipient ( destinedRecipientDecoration ( opCtx ) ) ; <nl> <nl> repl : : OplogLink oplogLink ; <nl> repl : : appendOplogEntryChainInfo ( opCtx , & oplogEntry , & oplogLink , stmtId ) ; <nl> void OpObserverImpl : : aboutToDelete ( OperationContext * opCtx , <nl> BSONObj const & doc ) { <nl> documentKeyDecoration ( opCtx ) . emplace ( getDocumentKey ( opCtx , nss , doc ) ) ; <nl> <nl> + repl : : DurableReplOperation op ; <nl> + shardAnnotateOplogEntry ( opCtx , nss , doc , op ) ; <nl> + destinedRecipientDecoration ( opCtx ) = op . getDestinedRecipient ( ) ; <nl> + <nl> shardObserveAboutToDelete ( opCtx , nss , doc ) ; <nl> } <nl> <nl> void OpObserverImpl : : onDelete ( OperationContext * opCtx , <nl> operation . setPreImage ( deletedDoc - > getOwned ( ) ) ; <nl> } <nl> <nl> + operation . setDestinedRecipient ( destinedRecipientDecoration ( opCtx ) ) ; <nl> + <nl> txnParticipant . addTransactionOperation ( opCtx , operation ) ; <nl> } else { <nl> opTime = replLogDelete ( opCtx , nss , uuid , stmtId , fromMigrate , deletedDoc ) ; <nl> mmm a / src / mongo / db / s / resharding_destined_recipient_test . cpp <nl> ppp b / src / mongo / db / s / resharding_destined_recipient_test . cpp <nl> class DestinedRecipientTest : public ShardServerTestFixture { <nl> Helpers : : update ( opCtx , nss . toString ( ) , filter , update ) ; <nl> } <nl> <nl> + void deleteDoc ( OperationContext * opCtx , <nl> + const NamespaceString & nss , <nl> + const BSONObj & query , <nl> + const ReshardingEnv & env ) { <nl> + AutoGetCollection coll ( opCtx , nss , MODE_IX ) ; <nl> + <nl> + / / TODO ( SERVER - 50027 ) : This is to temporarily make this test pass until getOwnershipFilter <nl> + / / has been updated to detect frozen migrations . <nl> + if ( ! OperationShardingState : : isOperationVersioned ( opCtx ) ) { <nl> + OperationShardingState : : get ( opCtx ) . initializeClientRoutingVersions ( <nl> + kNss , env . version , env . dbVersion ) ; <nl> + } <nl> + <nl> + RecordId rid = Helpers : : findOne ( opCtx , coll . getCollection ( ) , query , false ) ; <nl> + ASSERT ( ! rid . isNull ( ) ) ; <nl> + <nl> + WriteUnitOfWork wuow ( opCtx ) ; <nl> + OpDebug opDebug ; <nl> + coll - > deleteDocument ( opCtx , kUninitializedStmtId , rid , & opDebug ) ; <nl> + wuow . commit ( ) ; <nl> + } <nl> + <nl> repl : : OplogEntry getLastOplogEntry ( OperationContext * opCtx ) { <nl> repl : : OplogInterfaceLocal oplogInterface ( opCtx ) ; <nl> auto oplogIter = oplogInterface . makeIterator ( ) ; <nl> TEST_F ( DestinedRecipientTest , TestOpObserverSetsDestinedRecipientOnUpdatesInTran <nl> ASSERT_EQ ( * recipShard , env . destShard ) ; <nl> } <nl> <nl> + TEST_F ( DestinedRecipientTest , TestOpObserverSetsDestinedRecipientOnDeletes ) { <nl> + auto opCtx = operationContext ( ) ; <nl> + <nl> + DBDirectClient client ( opCtx ) ; <nl> + client . insert ( kNss . toString ( ) , BSON ( " _id " < < 0 < < " x " < < 2 < < " y " < < 10 < < " z " < < 4 ) ) ; <nl> + <nl> + auto env = setupReshardingEnv ( opCtx , true ) ; <nl> + <nl> + deleteDoc ( opCtx , kNss , BSON ( " _id " < < 0 ) , env ) ; <nl> + <nl> + auto entry = getLastOplogEntry ( opCtx ) ; <nl> + auto recipShard = entry . getDestinedRecipient ( ) ; <nl> + <nl> + ASSERT ( recipShard ) ; <nl> + ASSERT_EQ ( * recipShard , env . destShard ) ; <nl> + } <nl> + <nl> + TEST_F ( DestinedRecipientTest , TestOpObserverSetsDestinedRecipientOnDeletesInTransaction ) { <nl> + auto opCtx = operationContext ( ) ; <nl> + <nl> + DBDirectClient client ( opCtx ) ; <nl> + client . insert ( kNss . toString ( ) , BSON ( " _id " < < 0 < < " x " < < 2 < < " y " < < 10 ) ) ; <nl> + <nl> + auto env = setupReshardingEnv ( opCtx , true ) ; <nl> + <nl> + runInTransaction ( opCtx , [ & ] ( ) { deleteDoc ( opCtx , kNss , BSON ( " _id " < < 0 ) , env ) ; } ) ; <nl> + <nl> + / / Look for destined recipient in latest oplog entry . Since this write was done in a <nl> + / / transaction , the write operation will be embedded in an applyOps entry and needs to be <nl> + / / extracted . <nl> + auto entry = getLastOplogEntry ( opCtx ) ; <nl> + auto info = repl : : ApplyOpsCommandInfo : : parse ( entry . getOperationToApply ( ) ) ; <nl> + <nl> + auto ops = info . getOperations ( ) ; <nl> + auto replOp = repl : : ReplOperation : : parse ( IDLParserErrorContext ( " deleteOp " ) , ops [ 0 ] ) ; <nl> + ASSERT_EQ ( replOp . getNss ( ) , kNss ) ; <nl> + <nl> + auto recipShard = replOp . getDestinedRecipient ( ) ; <nl> + ASSERT ( recipShard ) ; <nl> + ASSERT_EQ ( * recipShard , env . destShard ) ; <nl> + } <nl> + <nl> } / / namespace <nl> } / / namespace mongo <nl>
|
SERVER - 49824 Add destined recipient to oplog entries from deletes
|
mongodb/mongo
|
ea5c903938ad3f54bd1364644e5a93ee94e7404b
|
2020-10-12T15:35:53Z
|
mmm a / modules / core / src / copy . cpp <nl> ppp b / modules / core / src / copy . cpp <nl> void Mat : : copyTo ( OutputArray _dst , InputArray _mask ) const <nl> copymask ( ptrs [ 0 ] , 0 , ptrs [ 2 ] , 0 , ptrs [ 1 ] , 0 , sz , & esz ) ; <nl> } <nl> <nl> + <nl> + static bool can_apply_memset ( const Mat & mat , const Scalar & s , int & fill_value ) <nl> + { <nl> + / / check if depth is 1 byte . <nl> + switch ( mat . depth ( ) ) <nl> + { <nl> + case CV_8U : fill_value = saturate_cast < uchar > ( s . val [ 0 ] ) ; break ; <nl> + case CV_8S : fill_value = saturate_cast < schar > ( s . val [ 0 ] ) ; break ; <nl> + default : return false ; <nl> + } <nl> + <nl> + / / check if all element is same . <nl> + const int64 * is = ( const int64 * ) & s . val [ 0 ] ; <nl> + switch ( mat . channels ( ) ) <nl> + { <nl> + case 1 : return true ; <nl> + case 2 : return ( is [ 0 ] = = is [ 1 ] ) ; <nl> + case 3 : return ( is [ 0 ] = = is [ 1 ] & & is [ 1 ] = = is [ 2 ] ) ; <nl> + case 4 : return ( is [ 0 ] = = is [ 1 ] & & is [ 1 ] = = is [ 2 ] & & is [ 2 ] = = is [ 3 ] ) ; <nl> + default : return false ; <nl> + } <nl> + } <nl> + <nl> Mat & Mat : : operator = ( const Scalar & s ) <nl> { <nl> CV_INSTRUMENT_REGION ( ) ; <nl> Mat & Mat : : operator = ( const Scalar & s ) <nl> } <nl> else <nl> { <nl> + int fill_value = 0 ; <nl> + if ( can_apply_memset ( * this , s , fill_value ) ) <nl> + { <nl> + for ( size_t i = 0 ; i < it . nplanes ; i + + , + + it ) <nl> + memset ( dptr , fill_value , elsize ) ; <nl> + return * this ; <nl> + } <nl> + <nl> if ( it . nplanes > 0 ) <nl> { <nl> double scalar [ 12 ] ; <nl> mmm a / modules / core / src / cuda / gpu_mat . cu <nl> ppp b / modules / core / src / cuda / gpu_mat . cu <nl> void cv : : cuda : : GpuMat : : convertTo ( OutputArray _dst , int rtype , Stream & stream ) co <nl> { convertToNoScale < double , uchar > , convertToNoScale < double , schar > , convertToNoScale < double , ushort > , convertToNoScale < double , short > , convertToNoScale < double , int > , convertToNoScale < double , float > , 0 } <nl> } ; <nl> <nl> - funcs [ sdepth ] [ ddepth ] ( reshape ( 1 ) , dst . reshape ( 1 ) , stream ) ; <nl> + funcs [ sdepth ] [ ddepth ] ( src . reshape ( 1 ) , dst . reshape ( 1 ) , stream ) ; <nl> } <nl> <nl> void cv : : cuda : : GpuMat : : convertTo ( OutputArray _dst , int rtype , double alpha , double beta , Stream & stream ) const <nl> void cv : : cuda : : GpuMat : : convertTo ( OutputArray _dst , int rtype , double alpha , doub <nl> { convertToScale < double , uchar > , convertToScale < double , schar > , convertToScale < double , ushort > , convertToScale < double , short > , convertToScale < double , int > , convertToScale < double , float > , convertToScale < double , double > } <nl> } ; <nl> <nl> - funcs [ sdepth ] [ ddepth ] ( reshape ( 1 ) , dst . reshape ( 1 ) , alpha , beta , stream ) ; <nl> + funcs [ sdepth ] [ ddepth ] ( src . reshape ( 1 ) , dst . reshape ( 1 ) , alpha , beta , stream ) ; <nl> } <nl> <nl> void cv : : cuda : : convertFp16 ( InputArray _src , OutputArray _dst , Stream & stream ) <nl> mmm a / modules / core / src / ocl . cpp <nl> ppp b / modules / core / src / ocl . cpp <nl> struct Image2D : : Impl <nl> CV_Error ( Error : : OpenCLApiCallError , " OpenCL runtime not found ! " ) ; <nl> <nl> cl_context context = ( cl_context ) Context : : getDefault ( ) . ptr ( ) ; <nl> + if ( ! context ) <nl> + return false ; <nl> + <nl> / / Figure out how many formats are supported by this context . <nl> cl_uint numFormats = 0 ; <nl> cl_int err = clGetSupportedImageFormats ( context , CL_MEM_READ_WRITE , <nl> mmm a / modules / dnn / src / layers / fully_connected_layer . cpp <nl> ppp b / modules / dnn / src / layers / fully_connected_layer . cpp <nl> class FullyConnectedLayerImpl CV_FINAL : public InnerProductLayer <nl> CV_CheckEQ ( inputs . size ( ) , ( size_t ) 2 , " " ) ; <nl> numOutput = inputs [ 1 ] . back ( ) ; <nl> cAxis = inputs [ 0 ] . size ( ) - 1 ; <nl> - CV_CheckEQ ( numOutput , inputs [ 0 ] [ cAxis - 1 ] , " " ) ; <nl> int dims = inputs [ 0 ] . size ( ) ; <nl> CV_CheckEQ ( inputs [ 1 ] . size ( ) , ( size_t ) dims , " " ) ; <nl> CV_CheckGE ( dims , 2 , " " ) ; <nl> mmm a / modules / dnn / src / layers / pooling_layer . cpp <nl> ppp b / modules / dnn / src / layers / pooling_layer . cpp <nl> class PoolingLayerImpl CV_FINAL : public PoolingLayer <nl> type = AVE ; <nl> else if ( pool = = " stochastic " ) <nl> type = STOCHASTIC ; <nl> + else if ( pool = = " sum " ) <nl> + type = SUM ; <nl> else <nl> CV_Error ( Error : : StsBadArg , " Unknown pooling type \ " " + pool + " \ " " ) ; <nl> <nl> class PoolingLayerImpl CV_FINAL : public PoolingLayer <nl> return type = = MAX | | type = = AVE ; <nl> } <nl> else <nl> - return type ! = STOCHASTIC ; <nl> + return type ! = STOCHASTIC & & type ! = SUM ; <nl> } <nl> # endif <nl> if ( backendId = = DNN_BACKEND_INFERENCE_ENGINE_NGRAPH ) <nl> class PoolingLayerImpl CV_FINAL : public PoolingLayer <nl> maxPooling ( inputs [ 0 ] , outputs [ 0 ] , mask ) ; <nl> break ; <nl> } <nl> - case AVE : <nl> + case AVE : case SUM : <nl> CV_Assert_N ( inputs . size ( ) = = 1 , outputs . size ( ) = = 1 ) ; <nl> avePooling ( inputs [ 0 ] , outputs [ 0 ] ) ; <nl> break ; <nl> class PoolingLayerImpl CV_FINAL : public PoolingLayer <nl> virtual Ptr < BackendNode > initNgraph ( const std : : vector < Ptr < BackendWrapper > > & inputs , <nl> const std : : vector < Ptr < BackendNode > > & nodes ) CV_OVERRIDE <nl> { <nl> - CV_Assert_N ( ( inputs . size ( ) = = 1 & & ( type = = MAX | | type = = AVE ) ) | | inputs . size ( ) = = 2 , nodes . size ( ) = = inputs . size ( ) ) ; <nl> + CV_Assert_N ( ( inputs . size ( ) = = 1 & & ( type = = MAX | | type = = AVE | | type = = SUM ) ) | | inputs . size ( ) = = 2 , nodes . size ( ) = = inputs . size ( ) ) ; <nl> auto & ieInpNode = nodes [ 0 ] . dynamicCast < InfEngineNgraphNode > ( ) - > node ; <nl> <nl> ngraph : : op : : PadType pad_type = ngraph : : op : : PadType : : EXPLICIT ; <nl> class PoolingLayerImpl CV_FINAL : public PoolingLayer <nl> exclude_pad , rounding_type , pad_type ) ; <nl> return Ptr < BackendNode > ( new InfEngineNgraphNode ( ave_pool ) ) ; <nl> } <nl> + else if ( type = = SUM ) { <nl> + ngraph : : Shape inpShape = ieInpNode - > get_shape ( ) ; <nl> + CV_Assert ( inpShape . size ( ) = = 2 + kernel_size . size ( ) ) ; <nl> + std : : vector < int64_t > axes ; <nl> + for ( size_t i = 0 ; i < kernel_size . size ( ) ; i + + ) <nl> + { <nl> + if ( inpShape [ 2 + i ] = = kernel_size [ i ] ) <nl> + axes . push_back ( 2 + i ) ; <nl> + } <nl> + auto reduction_axes = std : : make_shared < ngraph : : op : : Constant > ( ngraph : : element : : i64 , ngraph : : Shape { axes . size ( ) } , axes ) ; <nl> + auto reduce_sum = std : : make_shared < ngraph : : op : : v1 : : ReduceSum > ( ieInpNode , reduction_axes , true ) ; <nl> + return Ptr < BackendNode > ( new InfEngineNgraphNode ( reduce_sum ) ) ; <nl> + } <nl> else if ( type = = MAX ) { <nl> auto max_pool = std : : make_shared < ngraph : : op : : v1 : : MaxPool > ( ieInpNode , ngraph : : Strides ( strides ) , <nl> ngraph : : Shape ( pads_begin ) , ngraph : : Shape ( pads_end ) , ngraph : : Shape ( kernel_size ) , <nl> class PoolingLayerImpl CV_FINAL : public PoolingLayer <nl> } <nl> } <nl> } <nl> - else if ( poolingType = = AVE ) <nl> + else if ( poolingType = = AVE | | poolingType = = SUM ) <nl> { <nl> for ( ; x0 < x1 ; + + x0 ) <nl> { <nl> class PoolingLayerImpl CV_FINAL : public PoolingLayer <nl> xend = min ( xend , inp_width ) ; <nl> float inv_kernel_area = avePoolPaddedArea ? xdelta * ydelta * ddelta : <nl> ( ( dend - dstart ) * ( yend - ystart ) * ( xend - xstart ) ) ; <nl> - inv_kernel_area = 1 . 0 / inv_kernel_area ; <nl> + inv_kernel_area = poolingType = = AVE ? 1 . 0 / inv_kernel_area : 1 . 0 ; <nl> # if CV_SIMD128 <nl> if ( isPool2D & & xstart > 0 & & x0 + 7 < x1 & & ( x0 + 7 ) * stride_w - pad_l + kernel_w < inp_width ) <nl> { <nl> class PoolingLayerImpl CV_FINAL : public PoolingLayer <nl> MAX , <nl> AVE , <nl> STOCHASTIC , <nl> + SUM , <nl> ROI , / / RoI pooling , https : / / arxiv . org / pdf / 1504 . 08083 . pdf <nl> PSROI / / Position - sensitive RoI pooling , https : / / arxiv . org / pdf / 1605 . 06409 . pdf <nl> } ; <nl> mmm a / modules / dnn / src / onnx / onnx_graph_simplifier . cpp <nl> ppp b / modules / dnn / src / onnx / onnx_graph_simplifier . cpp <nl> class GatherCastSubgraph : public Subgraph <nl> } <nl> } ; <nl> <nl> + class ExpandSubgraph : public Subgraph <nl> + { <nl> + public : <nl> + ExpandSubgraph ( ) <nl> + { <nl> + int input = addNodeToMatch ( " " ) ; <nl> + int values = addNodeToMatch ( " " ) ; <nl> + int init = addNodeToMatch ( " ConstantOfShape " , values ) ; <nl> + int coeff = addNodeToMatch ( " Constant " ) ; <nl> + int mul = addNodeToMatch ( " Mul " , init , coeff ) ; <nl> + int shape = addNodeToMatch ( " Constant " ) ; <nl> + int condition = addNodeToMatch ( " Equal " , shape , mul ) ; <nl> + int where = addNodeToMatch ( " Where " , condition , init , addNodeToMatch ( " Constant " ) ) ; <nl> + addNodeToMatch ( " Expand " , input , where ) ; <nl> + setFusedNode ( " Expand " , input , shape ) ; <nl> + } <nl> + } ; <nl> + <nl> class MulCastSubgraph : public Subgraph <nl> { <nl> public : <nl> void simplifySubgraphs ( opencv_onnx : : GraphProto & net ) <nl> subgraphs . push_back ( makePtr < NormalizeSubgraph3 > ( ) ) ; <nl> subgraphs . push_back ( makePtr < BatchNormalizationSubgraph1 > ( ) ) ; <nl> subgraphs . push_back ( makePtr < BatchNormalizationSubgraph2 > ( ) ) ; <nl> + subgraphs . push_back ( makePtr < ExpandSubgraph > ( ) ) ; <nl> <nl> simplifySubgraphs ( Ptr < ImportGraphWrapper > ( new ONNXGraphWrapper ( net ) ) , subgraphs ) ; <nl> } <nl> mmm a / modules / dnn / src / onnx / onnx_importer . cpp <nl> ppp b / modules / dnn / src / onnx / onnx_importer . cpp <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> layerParams . set ( " ceil_mode " , layerParams . has ( " pad_mode " ) ) ; <nl> layerParams . set ( " ave_pool_padded_area " , framework_name = = " pytorch " ) ; <nl> } <nl> - else if ( layer_type = = " GlobalAveragePool " | | layer_type = = " GlobalMaxPool " | | layer_type = = " ReduceMean " ) <nl> + else if ( layer_type = = " GlobalAveragePool " | | layer_type = = " GlobalMaxPool " | | <nl> + layer_type = = " ReduceMean " | | layer_type = = " ReduceSum " ) <nl> { <nl> CV_Assert ( node_proto . input_size ( ) = = 1 ) ; <nl> layerParams . type = " Pooling " ; <nl> - layerParams . set ( " pool " , layer_type = = " GlobalMaxPool " ? " MAX " : " AVE " ) ; <nl> + String pool ; <nl> + if ( layer_type = = " GlobalMaxPool " ) <nl> + pool = " MAX " ; <nl> + else if ( layer_type = = " ReduceSum " ) <nl> + pool = " SUM " ; <nl> + else <nl> + pool = " AVE " ; <nl> + layerParams . set ( " pool " , pool ) ; <nl> layerParams . set ( " global_pooling " , layer_type = = " GlobalAveragePool " | | layer_type = = " GlobalMaxPool " ) ; <nl> - <nl> - if ( layer_type = = " ReduceMean " ) <nl> + if ( layer_type = = " ReduceMean " | | layer_type = = " ReduceSum " ) <nl> { <nl> - if ( layerParams . get < int > ( " keepdims " ) = = 0 | | ! layerParams . has ( " axes " ) ) <nl> - CV_Error ( Error : : StsNotImplemented , " Unsupported mode of ReduceMean operation . " ) ; <nl> + if ( ! layerParams . has ( " axes " ) ) <nl> + CV_Error ( Error : : StsNotImplemented , " Unsupported mode of " + layer_type + " operation . " ) ; <nl> <nl> MatShape inpShape = outShapes [ node_proto . input ( 0 ) ] ; <nl> DictValue axes = layerParams . get ( " axes " ) ; <nl> + bool keepdims = layerParams . get < int > ( " keepdims " ) ; <nl> + MatShape targetShape = inpShape ; <nl> + for ( int i = 0 ; i < axes . size ( ) ; i + + ) { <nl> + int axis = clamp ( axes . get < int > ( i ) , inpShape . size ( ) ) ; <nl> + if ( keepdims ) { <nl> + targetShape [ axis ] = 1 ; <nl> + } else { <nl> + targetShape . erase ( targetShape . begin ( ) + axis ) ; <nl> + } <nl> + } <nl> + <nl> if ( inpShape . size ( ) = = 3 & & axes . size ( ) < = 2 ) <nl> { <nl> - int axis = axes . get < int > ( 0 ) ; <nl> + int axis = clamp ( axes . get < int > ( 0 ) , inpShape . size ( ) ) ; <nl> CV_CheckNE ( axis , 0 , " " ) ; <nl> - outShapes [ layerParams . name ] = inpShape ; <nl> - outShapes [ layerParams . name ] [ axis ] = 1 ; <nl> <nl> LayerParams reshapeLp ; <nl> reshapeLp . name = layerParams . name + " / reshape " ; <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> avgLp . name = layerParams . name + " / avg " ; <nl> avgLp . type = " Pooling " ; <nl> CV_Assert ( layer_id . find ( avgLp . name ) = = layer_id . end ( ) ) ; <nl> - avgLp . set ( " pool " , " ave " ) ; <nl> + avgLp . set ( " pool " , pool ) ; <nl> if ( axes . size ( ) = = 2 ) <nl> { <nl> - CV_CheckEQ ( axes . get < int > ( 0 ) , 1 , " Unsupported ReduceMean mode " ) ; <nl> - CV_CheckEQ ( axes . get < int > ( 1 ) , 2 , " Unsupported ReduceMean mode " ) ; <nl> + CV_CheckEQ ( clamp ( axes . get < int > ( 0 ) , inpShape . size ( ) ) , 1 , ( " Unsupported " + layer_type + " mode " ) . c_str ( ) ) ; <nl> + CV_CheckEQ ( clamp ( axes . get < int > ( 1 ) , inpShape . size ( ) ) , 2 , ( " Unsupported " + layer_type + " mode " ) . c_str ( ) ) ; <nl> avgLp . set ( " global_pooling " , true ) ; <nl> - outShapes [ layerParams . name ] [ axes . get < int > ( 1 ) ] = 1 ; <nl> } <nl> else <nl> { <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> node_proto . set_input ( 0 , reshapeLp . name ) ; <nl> node_proto . set_output ( 0 , avgLp . name ) ; <nl> addLayer ( dstNet , avgLp , node_proto , layer_id , outShapes ) ; <nl> - <nl> - layerParams . type = " Flatten " ; <nl> - layerParams . set ( " axis " , 0 ) ; <nl> - layerParams . set ( " end_axis " , 1 ) ; <nl> - <nl> - node_proto . set_input ( 0 , avgLp . name ) ; <nl> - node_proto . set_output ( 0 , layerParams . name ) ; <nl> } <nl> else <nl> { <nl> if ( inpShape . size ( ) ! = 4 & & inpShape . size ( ) ! = 5 ) <nl> - CV_Error ( Error : : StsNotImplemented , " Unsupported input shape of reduce_mean operation . " ) ; <nl> + CV_Error ( Error : : StsNotImplemented , " Unsupported input shape of " + layer_type + " operation . " ) ; <nl> <nl> CV_Assert ( axes . size ( ) < = inpShape . size ( ) - 2 ) ; <nl> std : : vector < int > kernel_size ( inpShape . size ( ) - 2 , 1 ) ; <nl> for ( int i = 0 ; i < axes . size ( ) ; i + + ) { <nl> - int axis = axes . get < int > ( i ) ; <nl> + int axis = clamp ( axes . get < int > ( i ) , inpShape . size ( ) ) ; <nl> CV_Assert_N ( axis > = 2 + i , axis < inpShape . size ( ) ) ; <nl> kernel_size [ axis - 2 ] = inpShape [ axis ] ; <nl> } <nl> - layerParams . set ( " kernel_size " , DictValue : : arrayInt ( & kernel_size [ 0 ] , kernel_size . size ( ) ) ) ; <nl> + LayerParams poolLp = layerParams ; <nl> + poolLp . name = layerParams . name + " / avg " ; <nl> + CV_Assert ( layer_id . find ( poolLp . name ) = = layer_id . end ( ) ) ; <nl> + poolLp . set ( " kernel_size " , DictValue : : arrayInt ( & kernel_size [ 0 ] , kernel_size . size ( ) ) ) ; <nl> + <nl> + node_proto . set_output ( 0 , poolLp . name ) ; <nl> + addLayer ( dstNet , poolLp , node_proto , layer_id , outShapes ) ; <nl> } <nl> + <nl> + layerParams . type = " Reshape " ; <nl> + layerParams . set ( " dim " , DictValue : : arrayInt ( & targetShape [ 0 ] , targetShape . size ( ) ) ) ; <nl> + <nl> + node_proto . set_input ( 0 , node_proto . output ( 0 ) ) ; <nl> + node_proto . set_output ( 0 , layerParams . name ) ; <nl> } <nl> } <nl> else if ( layer_type = = " Slice " ) <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> { <nl> layerParams . type = " Scale " ; <nl> layerParams . set ( " bias_term " , true ) ; <nl> + int axis = 1 ; <nl> + for ( int i = 0 ; i < graph_proto . initializer_size ( ) ; i + + ) <nl> + { <nl> + opencv_onnx : : TensorProto tensor_proto = graph_proto . initializer ( i ) ; <nl> + if ( tensor_proto . name ( ) = = node_proto . input ( const_blob_id ) ) <nl> + { <nl> + axis = inpShape . size ( ) - tensor_proto . dims_size ( ) ; <nl> + break ; <nl> + } <nl> + } <nl> + layerParams . set ( " axis " , axis ) ; <nl> blob = blob . reshape ( 1 , 1 ) ; <nl> layerParams . blobs . push_back ( ( isSub ? - 1 : 1 ) * blob ) ; <nl> } <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> CV_Assert ( node_proto . input_size ( ) = = 2 ) ; <nl> layerParams . type = " InnerProduct " ; <nl> layerParams . set ( " bias_term " , false ) ; <nl> + CV_Assert ( constBlobs . find ( node_proto . input ( 0 ) ) = = constBlobs . end ( ) ) ; <nl> + int firstInpDims = outShapes [ node_proto . input ( 0 ) ] . size ( ) ; <nl> + int secondInpDims ; <nl> <nl> if ( constBlobs . find ( node_proto . input ( 1 ) ) ! = constBlobs . end ( ) ) <nl> { <nl> Mat blob = getBlob ( node_proto , constBlobs , 1 ) ; <nl> + secondInpDims = blob . dims ; <nl> layerParams . blobs . push_back ( blob . t ( ) ) ; <nl> layerParams . set ( " num_output " , layerParams . blobs [ 0 ] . size [ 0 ] ) ; <nl> + } else { <nl> + secondInpDims = outShapes [ node_proto . input ( 1 ) ] . size ( ) ; <nl> } <nl> + layerParams . set ( " axis " , firstInpDims - secondInpDims + 1 ) ; <nl> } <nl> else if ( layer_type = = " Mul " | | layer_type = = " Div " ) <nl> { <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> { <nl> Mat inp0 = getBlob ( node_proto , constBlobs , 0 ) ; <nl> Mat inp1 = getBlob ( node_proto , constBlobs , 1 ) ; <nl> - if ( inp0 . size ! = inp1 . size ) <nl> + if ( inp0 . size ! = inp1 . size & & inp1 . total ( ) ! = 1 ) <nl> CV_Error ( Error : : StsNotImplemented , " Constant multiply with different shapes " ) ; <nl> <nl> - Mat out ; <nl> - if ( isDiv ) <nl> - divide ( inp0 , inp1 , out ) ; <nl> - else <nl> - multiply ( inp0 , inp1 , out ) ; <nl> - <nl> + Mat out = isDiv ? inp0 / inp1 : inp0 . mul ( inp1 ) ; <nl> out = out . reshape ( 1 , inp0 . dims , inp0 . size ) ; <nl> out . dims = inp0 . dims ; / / to workaround dims = = 1 <nl> addConstant ( layerParams . name , out , constBlobs , outShapes ) ; <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> Mat newShapeMat = getBlob ( node_proto , constBlobs , 1 ) ; <nl> MatShape targetShape ( newShapeMat . ptr < int > ( ) , newShapeMat . ptr < int > ( ) + newShapeMat . total ( ) ) ; <nl> <nl> - shapeIt = outShapes . find ( node_proto . input ( 0 ) ) ; <nl> - CV_Assert ( shapeIt ! = outShapes . end ( ) ) ; <nl> - MatShape inpShape = shapeIt - > second ; <nl> + MatShape inpShape ; <nl> + bool haveVariables = constBlobs . find ( node_proto . input ( 0 ) ) = = constBlobs . end ( ) ; <nl> + if ( haveVariables ) <nl> + { <nl> + shapeIt = outShapes . find ( node_proto . input ( 0 ) ) ; <nl> + CV_Assert ( shapeIt ! = outShapes . end ( ) ) ; <nl> + inpShape = shapeIt - > second ; <nl> + } <nl> + else <nl> + { <nl> + inpShape = shape ( getBlob ( node_proto , constBlobs , 0 ) ) ; <nl> + } <nl> + <nl> + String srcName = node_proto . input ( 0 ) ; <nl> + / / Unsqueeze and repeat along new axis <nl> + if ( targetShape . size ( ) = = inpShape . size ( ) + 1 ) <nl> + { <nl> + for ( int i = 0 ; i < targetShape . size ( ) ; i + + ) <nl> + { <nl> + if ( targetShape [ i ] = = - 1 & & i < inpShape . size ( ) ) <nl> + targetShape [ i ] = inpShape [ i ] ; <nl> + else if ( i < inpShape . size ( ) & & targetShape [ i ] ! = inpShape [ i ] ) <nl> + inpShape . insert ( inpShape . begin ( ) + i , 1 ) ; <nl> + } <nl> + if ( haveVariables ) <nl> + { <nl> + LayerParams reshapeLp ; <nl> + reshapeLp . name = layerParams . name + " / reshape " ; <nl> + reshapeLp . type = " Reshape " ; <nl> + CV_Assert ( layer_id . find ( reshapeLp . name ) = = layer_id . end ( ) ) ; <nl> + reshapeLp . set ( " dim " , DictValue : : arrayInt ( & inpShape [ 0 ] , inpShape . size ( ) ) ) ; <nl> + <nl> + opencv_onnx : : NodeProto proto ; <nl> + proto . add_input ( node_proto . input ( 0 ) ) ; <nl> + proto . add_output ( reshapeLp . name ) ; <nl> + addLayer ( dstNet , reshapeLp , proto , layer_id , outShapes ) ; <nl> + srcName = reshapeLp . name ; <nl> + } <nl> + } <nl> CV_CheckEQ ( inpShape . size ( ) , targetShape . size ( ) , " Unsupported Expand op with different dims " ) ; <nl> <nl> std : : vector < int > broadcast_axes ; <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> } <nl> } <nl> <nl> + if ( ! haveVariables ) <nl> + { <nl> + if ( broadcast_axes . size ( ) ! = 1 ) <nl> + CV_Error ( Error : : StsNotImplemented , " Expand op doesn ' t support multiple axes for constant input " ) ; <nl> + <nl> + Mat input = getBlob ( node_proto , constBlobs , 0 ) ; <nl> + input = input . reshape ( 0 , total ( inpShape , 0 , broadcast_axes [ 0 ] ) ) ; <nl> + Mat output = cv : : repeat ( input , 1 , targetShape [ broadcast_axes [ 0 ] ] ) ; <nl> + output = output . reshape ( 0 , targetShape ) ; <nl> + addConstant ( layerParams . name , output , constBlobs , outShapes ) ; <nl> + continue ; <nl> + } <nl> + <nl> if ( broadcast_axes . size ( ) = = 2 & & <nl> broadcast_axes [ 0 ] = = broadcast_axes [ 1 ] - 1 & & broadcast_axes [ 1 ] = = inpShape . size ( ) - 1 ) <nl> { <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> CV_Assert ( layer_id . find ( copyLP . name ) = = layer_id . end ( ) ) ; <nl> input_names . push_back ( copyLP . name ) ; <nl> <nl> + node_proto . set_input ( 0 , srcName ) ; <nl> node_proto . set_output ( 0 , copyLP . name ) ; <nl> addLayer ( dstNet , copyLP , node_proto , layer_id , outShapes ) ; <nl> } <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> } <nl> layerParams . set ( " axis " , broadcast_axes [ 0 ] ) ; <nl> layerParams . type = " Concat " ; <nl> + node_proto . set_output ( 0 , layerParams . name ) ; <nl> } <nl> else <nl> CV_Error ( Error : : StsNotImplemented , " Unsupported Expand op " ) ; <nl> void ONNXImporter : : populateNet ( Net dstNet ) <nl> <nl> inpShape . erase ( inpShape . begin ( ) + axis ) ; <nl> layerParams . type = " Reshape " ; <nl> + layerParams . set ( " axis " , 0 ) ; <nl> layerParams . set ( " dim " , DictValue : : arrayInt ( & inpShape [ 0 ] , inpShape . size ( ) ) ) ; <nl> node_proto . set_input ( 0 , sliceLp . name ) ; <nl> } <nl> mmm a / modules / dnn / src / tensorflow / tf_importer . cpp <nl> ppp b / modules / dnn / src / tensorflow / tf_importer . cpp <nl> void TFImporter : : populateNet ( Net dstNet ) <nl> connect ( layer_id , dstNet , parsePin ( layer . input ( 0 ) ) , id , 0 ) ; <nl> connect ( layer_id , dstNet , parsePin ( layer . input ( 1 ) ) , id , 1 ) ; <nl> } <nl> - else if ( type = = " Mean " ) <nl> + else if ( type = = " Mean " | | type = = " Sum " ) <nl> { <nl> / / Computes the mean of elements across dimensions of a tensor . <nl> / / If keepdims is false ( default ) reduces input_tensor along the dimensions given in axis , <nl> void TFImporter : : populateNet ( Net dstNet ) <nl> LayerParams avgLp ; <nl> std : : string avgName = name + " / avg " ; <nl> CV_Assert ( layer_id . find ( avgName ) = = layer_id . end ( ) ) ; <nl> - avgLp . set ( " pool " , " ave " ) ; <nl> + avgLp . set ( " pool " , type = = " Mean " ? " ave " : " sum " ) ; <nl> / / pooling kernel H x 1 <nl> avgLp . set ( " global_pooling_h " , true ) ; <nl> avgLp . set ( " kernel_w " , 1 ) ; <nl> void TFImporter : : populateNet ( Net dstNet ) <nl> layer_id [ name ] = id ; <nl> connect ( layer_id , dstNet , Pin ( avgName ) , id , 0 ) ; <nl> connect ( layer_id , dstNet , Pin ( layerShapeName ) , id , 1 ) ; <nl> + } else if ( indices . total ( ) = = 1 ) { <nl> + int axis = toNCHW ( indices . at < int > ( 0 ) ) ; <nl> + if ( axis = = 2 | | axis = = 3 ) <nl> + { <nl> + layerParams . set ( " pool " , type = = " Mean " ? " ave " : " sum " ) ; <nl> + layerParams . set ( axis = = 2 ? " kernel_w " : " kernel_h " , 1 ) ; <nl> + layerParams . set ( axis = = 2 ? " global_pooling_h " : " global_pooling_w " , true ) ; <nl> + int id = dstNet . addLayer ( name , " Pooling " , layerParams ) ; <nl> + layer_id [ name ] = id ; <nl> + connect ( layer_id , dstNet , parsePin ( layer . input ( 0 ) ) , id , 0 ) ; <nl> + <nl> + if ( ! keepDims ) <nl> + { <nl> + / / To keep correct order after squeeze dims we first need to change layout from NCHW to NHWC <nl> + LayerParams permLP ; <nl> + int order [ ] = { 0 , 2 , 3 , 1 } ; / / From OpenCV ' s NCHW to NHWC . <nl> + permLP . set ( " order " , DictValue : : arrayInt < int * > ( order , 4 ) ) ; <nl> + std : : string permName = name + " / nchw " ; <nl> + CV_Assert ( layer_id . find ( permName ) = = layer_id . end ( ) ) ; <nl> + int permId = dstNet . addLayer ( permName , " Permute " , permLP ) ; <nl> + layer_id [ permName ] = permId ; <nl> + connect ( layer_id , dstNet , Pin ( name ) , permId , 0 ) ; <nl> + <nl> + LayerParams squeezeLp ; <nl> + std : : string squeezeName = name + " / squeeze " ; <nl> + CV_Assert ( layer_id . find ( squeezeName ) = = layer_id . end ( ) ) ; <nl> + squeezeLp . set ( " axis " , indices . at < int > ( 0 ) ) ; <nl> + squeezeLp . set ( " end_axis " , indices . at < int > ( 0 ) + 1 ) ; <nl> + int squeezeId = dstNet . addLayer ( squeezeName , " Flatten " , squeezeLp ) ; <nl> + layer_id [ squeezeName ] = squeezeId ; <nl> + connect ( layer_id , dstNet , Pin ( permName ) , squeezeId , 0 ) ; <nl> + } <nl> + } <nl> } else { <nl> if ( indices . total ( ) ! = 2 | | indices . at < int > ( 0 ) ! = 1 | | indices . at < int > ( 1 ) ! = 2 ) <nl> - CV_Error ( Error : : StsNotImplemented , " Unsupported mode of reduce_mean operation . " ) ; <nl> + CV_Error ( Error : : StsNotImplemented , " Unsupported mode of reduce_mean or reduce_sum operation . " ) ; <nl> <nl> - layerParams . set ( " pool " , " ave " ) ; <nl> + layerParams . set ( " pool " , type = = " Mean " ? " ave " : " sum " ) ; <nl> layerParams . set ( " global_pooling " , true ) ; <nl> int id = dstNet . addLayer ( name , " Pooling " , layerParams ) ; <nl> layer_id [ name ] = id ; <nl> mmm a / modules / dnn / test / test_darknet_importer . cpp <nl> ppp b / modules / dnn / test / test_darknet_importer . cpp <nl> TEST_P ( Test_Darknet_layers , connected ) <nl> <nl> TEST_P ( Test_Darknet_layers , relu ) <nl> { <nl> + if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 & & target = = DNN_TARGET_MYRIAD ) <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_MYRIAD ) ; <nl> testDarknetLayer ( " relu " ) ; <nl> } <nl> <nl> mmm a / modules / dnn / test / test_layers . cpp <nl> ppp b / modules / dnn / test / test_layers . cpp <nl> TEST_P ( Layer_Test_BatchNorm , fusion ) <nl> <nl> INSTANTIATE_TEST_CASE_P ( / * * / , Layer_Test_BatchNorm , dnnBackendsAndTargets ( ) ) ; <nl> <nl> + class TestLayerFusion : public DNNTestLayer { <nl> + public : <nl> + static void makeDefaultTestConvolutionLayer ( LayerParams & convParams , int in_channels , int num_filters , bool bias_term ) <nl> + { <nl> + const int kernel_h = 3 , kernel_w = 3 ; <nl> + const int pad_h = kernel_h / 2 , pad_w = kernel_w / 2 ; <nl> + <nl> + convParams . set ( " kernel_h " , kernel_h ) ; <nl> + convParams . set ( " kernel_w " , kernel_w ) ; <nl> + convParams . set ( " pad_h " , pad_h ) ; <nl> + convParams . set ( " pad_w " , pad_w ) ; <nl> + convParams . set ( " num_output " , num_filters ) ; <nl> + convParams . set ( " bias_term " , bias_term ) ; <nl> + convParams . type = " Convolution " ; <nl> + convParams . name = " convolution " ; <nl> + <nl> + float conv_init_magnitude = 1 . 0f / in_channels / kernel_h / kernel_w ; <nl> + int weightsShape [ ] = { num_filters , in_channels , kernel_h , kernel_w } ; <nl> + Mat weights ( 4 , & weightsShape [ 0 ] , CV_32F ) ; <nl> + randu ( weights , - conv_init_magnitude , conv_init_magnitude ) ; <nl> + convParams . blobs . push_back ( weights ) ; <nl> + if ( bias_term ) <nl> + { <nl> + Mat bias ( 1 , num_filters , CV_32F ) ; <nl> + randu ( bias , - 1 . 0f , 1 . 0f ) ; <nl> + convParams . blobs . push_back ( bias ) ; <nl> + } <nl> + } <nl> + <nl> + static void makeDefaultTestActivationLayer ( LayerParams & activationParams , const std : : string & type , int in_channels ) <nl> + { <nl> + activationParams . type = type ; <nl> + activationParams . name = " activation " ; <nl> + if ( activationParams . type = = " ReLU " ) <nl> + activationParams . set ( " negative_slope " , 0 . 1f ) ; <nl> + else if ( activationParams . type = = " Power " ) <nl> + { <nl> + activationParams . set ( " power " , 2 . 0f ) ; <nl> + activationParams . set ( " scale " , 0 . 5f ) ; <nl> + activationParams . set ( " shift " , 0 . 3f ) ; <nl> + } <nl> + else if ( activationParams . type = = " ReLU6 " ) <nl> + { <nl> + activationParams . set ( " min_value " , - 1 . 0f ) ; <nl> + activationParams . set ( " max_value " , 1 . 0f ) ; <nl> + } <nl> + else if ( activationParams . type = = " ChannelsPReLU " ) <nl> + { <nl> + Mat scales ( 1 , in_channels , CV_32F ) ; <nl> + randu ( scales , - 1 . 0f , 1 . 0f ) ; <nl> + activationParams . blobs . push_back ( scales ) ; <nl> + } <nl> + } <nl> + <nl> + static void makeDefaultTestEltwiseLayer ( LayerParams & eltwiseParams , const std : : string & op , bool withCoefficients ) <nl> + { <nl> + eltwiseParams . type = " Eltwise " ; <nl> + eltwiseParams . name = " eltwise " ; <nl> + eltwiseParams . set ( " operation " , op ) ; <nl> + if ( withCoefficients ) <nl> + { <nl> + float coeff [ ] = { 0 . 3f , 0 . 5f } ; <nl> + eltwiseParams . set ( " coeff " , DictValue : : arrayReal < float * > ( coeff , 2 ) ) ; <nl> + } <nl> + } <nl> + <nl> + static void test ( Mat & input , Net & net , Backend backendId , Target targetId , std : : vector < int > expectedFusedLayers = std : : vector < int > ( ) , double l1 = 0 . 0 , double lInf = 0 . 0 ) <nl> + { <nl> + DNNTestLayer : : checkBackend ( backendId , targetId ) ; <nl> + <nl> + net . enableFusion ( false ) ; <nl> + net . setPreferableBackend ( DNN_BACKEND_OPENCV ) ; <nl> + net . setPreferableTarget ( DNN_TARGET_CPU ) ; <nl> + net . setInput ( input ) ; <nl> + Mat outputReference = net . forward ( ) . clone ( ) ; <nl> + std : : vector < double > refTimings ; <nl> + net . getPerfProfile ( refTimings ) ; <nl> + for ( int i = 0 ; i < refTimings . size ( ) ; i + + ) <nl> + { <nl> + CV_Assert ( refTimings [ i ] ! = 0 . 0 ) ; <nl> + } <nl> + <nl> + net . enableFusion ( true ) ; <nl> + net . setPreferableBackend ( backendId ) ; <nl> + net . setPreferableTarget ( targetId ) ; <nl> + net . setInput ( input ) ; <nl> + Mat outputTest = net . forward ( ) . clone ( ) ; <nl> + std : : vector < double > testTimings ; <nl> + net . getPerfProfile ( testTimings ) ; <nl> + for ( int i = 0 ; i < testTimings . size ( ) ; i + + ) <nl> + { <nl> + if ( std : : find ( expectedFusedLayers . begin ( ) , expectedFusedLayers . end ( ) , i + 1 ) ! = expectedFusedLayers . end ( ) ) <nl> + { <nl> + EXPECT_EQ ( testTimings [ i ] , 0 . 0 ) ; <nl> + } <nl> + else <nl> + { <nl> + EXPECT_NE ( testTimings [ i ] , 0 . 0 ) ; <nl> + } <nl> + } <nl> + <nl> + / / double ref_max_value , ref_min_value ; <nl> + / / minMaxLoc ( outputReference . reshape ( 1 , 1 ) , & ref_min_value , & ref_max_value ) ; <nl> + / / std : : cout < < " reference range : " < < ref_min_value < < ' ' < < ref_max_value < < std : : endl ; <nl> + <nl> + double default_l1 , default_lInf ; <nl> + DNNTestLayer : : getDefaultThresholds ( backendId , targetId , & default_l1 , & default_lInf ) ; <nl> + if ( l1 = = 0 . 0 ) <nl> + l1 = default_l1 ; <nl> + if ( lInf = = 0 . 0 ) <nl> + lInf = default_lInf ; <nl> + normAssert ( outputReference , outputTest , " " , l1 , lInf ) ; <nl> + } <nl> + <nl> + static testing : : internal : : ParamGenerator < std : : string > eltwiseOpList ( ) <nl> + { <nl> + / / TODO : automate list generation <nl> + return Values ( " sum " , " max " , " prod " , " div " ) ; <nl> + } <nl> + <nl> + static testing : : internal : : ParamGenerator < std : : string > activationLayersList ( ) <nl> + { <nl> + / / TODO : automate list generation <nl> + return Values ( " ReLU " , " ReLU6 " , " ChannelsPReLU " , " TanH " , " Swish " , " Mish " , " Sigmoid " , " ELU " , " AbsVal " , " BNLL " , " Power " ) ; <nl> + } <nl> + <nl> + static testing : : internal : : ParamGenerator < tuple < Backend , Target > > dnnBackendsAndTargetsForFusionTests ( ) <nl> + { <nl> + return dnnBackendsAndTargets ( false , false , true , false , false , false ) ; / / OCV OpenCL + OCV CPU <nl> + } <nl> + } ; <nl> + <nl> + typedef TestWithParam < tuple < bool , std : : string , tuple < Backend , Target > > > ConvolutionActivationFusion ; <nl> + TEST_P ( ConvolutionActivationFusion , Accuracy ) <nl> + { <nl> + / / input <nl> + / / | <nl> + / / mmmmmmmmmmmmmmmmmmmmm - - <nl> + / / | convolution | <nl> + / / mmmmmmmmmmmmmmmmmmmmm - - <nl> + / / | <nl> + / / mmmmmmmmmmmmmmmmmmmmm - - <nl> + / / | activation | <nl> + / / mmmmmmmmmmmmmmmmmmmmm - - <nl> + / / | <nl> + / / output <nl> + <nl> + const int batch_size = 2 , in_channels = 16 ; <nl> + const int in_height = 16 , in_width = 16 ; <nl> + int inputShape [ ] = { batch_size , in_channels , in_height , in_width } ; <nl> + Mat input ( 4 , & inputShape [ 0 ] , CV_32F ) ; <nl> + randu ( input , 1 . 0f , 2 . 0f ) ; <nl> + <nl> + bool bias_term = get < 0 > ( GetParam ( ) ) ; <nl> + LayerParams convParams ; <nl> + TestLayerFusion : : makeDefaultTestConvolutionLayer ( convParams , in_channels , in_channels , bias_term ) ; <nl> + <nl> + std : : string actType = get < 1 > ( GetParam ( ) ) ; <nl> + LayerParams activationParams ; <nl> + TestLayerFusion : : makeDefaultTestActivationLayer ( activationParams , actType , in_channels ) ; <nl> + <nl> + Backend backendId = get < 0 > ( get < 2 > ( GetParam ( ) ) ) ; <nl> + Target targetId = get < 1 > ( get < 2 > ( GetParam ( ) ) ) ; <nl> + <nl> + / / bug : https : / / github . com / opencv / opencv / issues / 17964 <nl> + if ( actType = = " Power " & & backendId = = DNN_BACKEND_OPENCV & & ( targetId = = DNN_TARGET_OPENCL | | targetId = = DNN_TARGET_OPENCL_FP16 ) ) <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL ) ; <nl> + <nl> + / / bug : https : / / github . com / opencv / opencv / issues / 17953 <nl> + if ( actType = = " ChannelsPReLU " & & bias_term = = false & & <nl> + backendId = = DNN_BACKEND_OPENCV & & ( targetId = = DNN_TARGET_OPENCL | | targetId = = DNN_TARGET_OPENCL_FP16 ) ) <nl> + { <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL ) ; <nl> + } <nl> + <nl> + Net net ; <nl> + int convId = net . addLayer ( convParams . name , convParams . type , convParams ) ; <nl> + int activId = net . addLayerToPrev ( activationParams . name , activationParams . type , activationParams ) ; <nl> + net . connect ( 0 , 0 , convId , 0 ) ; <nl> + <nl> + std : : vector < int > expectedFusedLayers ; <nl> + if ( backendId = = DNN_BACKEND_OPENCV ) <nl> + { <nl> + if ( targetId = = DNN_TARGET_CPU ) <nl> + expectedFusedLayers . push_back ( activId ) ; / / all activations are fused <nl> + else if ( targetId = = DNN_TARGET_OPENCL | | targetId = = DNN_TARGET_OPENCL_FP16 ) <nl> + { <nl> + if ( actType = = " ReLU " | | actType = = " ChannelsPReLU " | | actType = = " ReLU6 " | | actType = = " TanH " | | actType = = " Power " ) <nl> + expectedFusedLayers . push_back ( activId ) ; <nl> + } <nl> + } <nl> + <nl> + TestLayerFusion : : test ( input , net , backendId , targetId , expectedFusedLayers ) ; <nl> + } <nl> + INSTANTIATE_TEST_CASE_P ( TestLayerFusion , ConvolutionActivationFusion , Combine ( <nl> + / * bias * / testing : : Bool ( ) , <nl> + / * activation * / TestLayerFusion : : activationLayersList ( ) , <nl> + TestLayerFusion : : dnnBackendsAndTargetsForFusionTests ( ) <nl> + ) ) ; <nl> + <nl> + typedef TestWithParam < tuple < bool , std : : string , bool , tuple < Backend , Target > > > ConvolutionEltwiseFusion ; <nl> + TEST_P ( ConvolutionEltwiseFusion , Accuracy ) <nl> + { <nl> + / / input <nl> + / / | <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + / / | | <nl> + / / | mmmmmmmmmmmmmmm <nl> + / / | | convolution | <nl> + / / | mmmmmmmmmmmmmmm <nl> + / / | | <nl> + / / | mmmmmmmmmmmmmmm - | <nl> + / / mmmmmm - - | eltwise op | mmmmmm - <nl> + / / mmmmmmmmmmmmmmm - <nl> + / / | <nl> + / / output <nl> + <nl> + const int batch_size = 2 , in_channels = 16 ; <nl> + const int in_height = 16 , in_width = 16 ; <nl> + int inputShape [ ] = { batch_size , in_channels , in_height , in_width } ; <nl> + Mat input ( 4 , & inputShape [ 0 ] , CV_32F ) ; <nl> + randu ( input , 1 . 0f , 2 . 0f ) ; / / avoid small values to test eltwise div <nl> + <nl> + bool bias_term = get < 0 > ( GetParam ( ) ) ; <nl> + LayerParams convParams ; <nl> + TestLayerFusion : : makeDefaultTestConvolutionLayer ( convParams , in_channels , in_channels , bias_term ) ; <nl> + <nl> + std : : string eltwiseOp = get < 1 > ( GetParam ( ) ) ; <nl> + bool weightedEltwise = get < 2 > ( GetParam ( ) ) ; <nl> + if ( eltwiseOp ! = " sum " & & weightedEltwise ) <nl> + throw SkipTestException ( " weighted eltwise not supported " ) ; <nl> + LayerParams eltwiseParams ; <nl> + TestLayerFusion : : makeDefaultTestEltwiseLayer ( eltwiseParams , eltwiseOp , weightedEltwise ) ; <nl> + <nl> + Net net ; <nl> + int convId = net . addLayer ( convParams . name , convParams . type , convParams ) ; <nl> + int eltwiseId = net . addLayer ( eltwiseParams . name , eltwiseParams . type , eltwiseParams ) ; <nl> + net . connect ( 0 , 0 , convId , 0 ) ; <nl> + net . connect ( convId , 0 , eltwiseId , 0 ) ; <nl> + net . connect ( 0 , 0 , eltwiseId , 1 ) ; <nl> + <nl> + Backend backendId = get < 0 > ( get < 3 > ( GetParam ( ) ) ) ; <nl> + Target targetId = get < 1 > ( get < 3 > ( GetParam ( ) ) ) ; <nl> + TestLayerFusion : : test ( input , net , backendId , targetId ) ; <nl> + } <nl> + INSTANTIATE_TEST_CASE_P ( TestLayerFusion , ConvolutionEltwiseFusion , Combine ( <nl> + / * bias * / testing : : Bool ( ) , <nl> + / * eltwise op * / TestLayerFusion : : eltwiseOpList ( ) , <nl> + / * eltwise weighted * / testing : : Bool ( ) , <nl> + TestLayerFusion : : dnnBackendsAndTargetsForFusionTests ( ) <nl> + ) ) ; <nl> + <nl> + typedef TestWithParam < tuple < bool , std : : string , bool , std : : string , tuple < Backend , Target > > > ConvolutionEltwiseActivationFusion ; <nl> + TEST_P ( ConvolutionEltwiseActivationFusion , Accuracy ) <nl> + { <nl> + / / input <nl> + / / | <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + / / | | <nl> + / / | mmmmmmmmmmmmmmm <nl> + / / | | convolution | <nl> + / / | mmmmmmmmmmmmmmm <nl> + / / | | <nl> + / / | mmmmmmmmmmmmmmm - | <nl> + / / mmmmmm - - | eltwise op | mmmmmm - <nl> + / / mmmmmmmmmmmmmmm - <nl> + / / | <nl> + / / mmmmmmmmmmmmmmm - <nl> + / / | activation | <nl> + / / mmmmmmmmmmmmmmm - <nl> + / / | <nl> + / / output <nl> + <nl> + const int batch_size = 2 , in_channels = 16 ; <nl> + const int in_height = 16 , in_width = 16 ; <nl> + int inputShape [ ] = { batch_size , in_channels , in_height , in_width } ; <nl> + Mat input ( 4 , & inputShape [ 0 ] , CV_32F ) ; <nl> + randu ( input , 1 . 0f , 2 . 0f ) ; / / avoid small values to test eltwise div <nl> + <nl> + bool bias_term = get < 0 > ( GetParam ( ) ) ; <nl> + LayerParams convParams ; <nl> + TestLayerFusion : : makeDefaultTestConvolutionLayer ( convParams , in_channels , in_channels , bias_term ) ; <nl> + <nl> + std : : string eltwiseOp = get < 1 > ( GetParam ( ) ) ; <nl> + bool weightedEltwise = get < 2 > ( GetParam ( ) ) ; <nl> + if ( eltwiseOp ! = " sum " & & weightedEltwise ) <nl> + throw SkipTestException ( " weighted eltwise not supported " ) ; <nl> + LayerParams eltwiseParams ; <nl> + TestLayerFusion : : makeDefaultTestEltwiseLayer ( eltwiseParams , eltwiseOp , false ) ; <nl> + <nl> + std : : string actType = get < 3 > ( GetParam ( ) ) ; <nl> + LayerParams activationParams ; <nl> + TestLayerFusion : : makeDefaultTestActivationLayer ( activationParams , actType , in_channels ) ; <nl> + <nl> + Backend backendId = get < 0 > ( get < 4 > ( GetParam ( ) ) ) ; <nl> + Target targetId = get < 1 > ( get < 4 > ( GetParam ( ) ) ) ; <nl> + <nl> + / / bug : https : / / github . com / opencv / opencv / issues / 17945 <nl> + if ( eltwiseOp ! = " sum " & & backendId = = DNN_BACKEND_OPENCV & & ( targetId = = DNN_TARGET_OPENCL | | targetId = = DNN_TARGET_OPENCL_FP16 ) ) <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL ) ; <nl> + <nl> + / / bug : https : / / github . com / opencv / opencv / issues / 17953 <nl> + if ( eltwiseOp = = " sum " & & actType = = " ChannelsPReLU " & & bias_term = = false & & <nl> + backendId = = DNN_BACKEND_OPENCV & & ( targetId = = DNN_TARGET_OPENCL | | targetId = = DNN_TARGET_OPENCL_FP16 ) ) <nl> + { <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL ) ; <nl> + } <nl> + <nl> + / / bug : https : / / github . com / opencv / opencv / issues / 17964 <nl> + if ( actType = = " Power " & & backendId = = DNN_BACKEND_OPENCV & & ( targetId = = DNN_TARGET_OPENCL | | targetId = = DNN_TARGET_OPENCL_FP16 ) ) <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL ) ; <nl> + <nl> + Net net ; <nl> + int convId = net . addLayer ( convParams . name , convParams . type , convParams ) ; <nl> + int eltwiseId = net . addLayer ( eltwiseParams . name , eltwiseParams . type , eltwiseParams ) ; <nl> + int activId = net . addLayer ( activationParams . name , activationParams . type , activationParams ) ; <nl> + net . connect ( 0 , 0 , convId , 0 ) ; <nl> + net . connect ( convId , 0 , eltwiseId , 0 ) ; <nl> + net . connect ( 0 , 0 , eltwiseId , 1 ) ; <nl> + net . connect ( eltwiseId , 0 , activId , 0 ) ; <nl> + <nl> + std : : vector < int > expectedFusedLayers ; <nl> + if ( backendId = = DNN_BACKEND_OPENCV ) <nl> + { <nl> + if ( targetId = = DNN_TARGET_CPU ) <nl> + expectedFusedLayers . push_back ( activId ) ; / / activation is fused with eltwise layer <nl> + else if ( targetId = = DNN_TARGET_OPENCL | | targetId = = DNN_TARGET_OPENCL_FP16 ) <nl> + { <nl> + if ( actType = = " ReLU " | | actType = = " ChannelsPReLU " | | actType = = " Power " ) <nl> + { <nl> + expectedFusedLayers . push_back ( eltwiseId ) ; <nl> + expectedFusedLayers . push_back ( activId ) ; <nl> + } <nl> + } <nl> + } <nl> + <nl> + TestLayerFusion : : test ( input , net , backendId , targetId , expectedFusedLayers ) ; <nl> + } <nl> + INSTANTIATE_TEST_CASE_P ( TestLayerFusion , ConvolutionEltwiseActivationFusion , Combine ( <nl> + / * bias * / testing : : Bool ( ) , <nl> + / * eltwise op * / TestLayerFusion : : eltwiseOpList ( ) , <nl> + / * eltwise weighted * / testing : : Bool ( ) , <nl> + / * activation * / TestLayerFusion : : activationLayersList ( ) , <nl> + TestLayerFusion : : dnnBackendsAndTargetsForFusionTests ( ) <nl> + ) ) ; <nl> + <nl> + typedef TestWithParam < tuple < bool , std : : string , std : : string , bool , tuple < Backend , Target > > > ConvolutionActivationEltwiseFusion ; <nl> + TEST_P ( ConvolutionActivationEltwiseFusion , Accuracy ) <nl> + { <nl> + / / input <nl> + / / | <nl> + / / mmmmmmmmmmmmmmmmmmmmmmmmmmmmmm - <nl> + / / | | <nl> + / / | mmmmmmmmmmmmmmm - <nl> + / / | | convolution | <nl> + / / | mmmmmmmmmmmmmmm - <nl> + / / | | <nl> + / / | mmmmmmmmmmmmmmm - <nl> + / / | | activation | <nl> + / / | mmmmmmmmmmmmmmm - <nl> + / / | | <nl> + / / | mmmmmmmmmmmmmmm - | <nl> + / / mmmmmm - - | eltwise sum | mmmmmm - <nl> + / / mmmmmmmmmmmmmmm - <nl> + / / | <nl> + <nl> + const int batch_size = 2 , in_channels = 16 ; <nl> + const int in_height = 16 , in_width = 16 ; <nl> + int inputShape [ ] = { batch_size , in_channels , in_height , in_width } ; <nl> + Mat input ( 4 , & inputShape [ 0 ] , CV_32F ) ; <nl> + randu ( input , 1 . 0f , 2 . 0f ) ; / / avoid small values to test eltwise div <nl> + <nl> + bool bias_term = get < 0 > ( GetParam ( ) ) ; <nl> + LayerParams convParams ; <nl> + TestLayerFusion : : makeDefaultTestConvolutionLayer ( convParams , in_channels , in_channels , bias_term ) ; <nl> + <nl> + std : : string actType = get < 1 > ( GetParam ( ) ) ; <nl> + LayerParams activationParams ; <nl> + TestLayerFusion : : makeDefaultTestActivationLayer ( activationParams , actType , in_channels ) ; <nl> + <nl> + std : : string eltwiseOp = get < 2 > ( GetParam ( ) ) ; <nl> + bool weightedEltwise = get < 3 > ( GetParam ( ) ) ; <nl> + if ( eltwiseOp ! = " sum " & & weightedEltwise ) <nl> + throw SkipTestException ( " weighted eltwise not supported " ) ; <nl> + LayerParams eltwiseParams ; <nl> + TestLayerFusion : : makeDefaultTestEltwiseLayer ( eltwiseParams , eltwiseOp , false ) ; <nl> + <nl> + Backend backendId = get < 0 > ( get < 4 > ( GetParam ( ) ) ) ; <nl> + Target targetId = get < 1 > ( get < 4 > ( GetParam ( ) ) ) ; <nl> + <nl> + / / bug : https : / / github . com / opencv / opencv / issues / 17964 <nl> + if ( actType = = " Power " & & backendId = = DNN_BACKEND_OPENCV & & ( targetId = = DNN_TARGET_OPENCL | | targetId = = DNN_TARGET_OPENCL_FP16 ) ) <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL ) ; <nl> + <nl> + / / bug : https : / / github . com / opencv / opencv / issues / 17953 <nl> + if ( actType = = " ChannelsPReLU " & & bias_term = = false & & <nl> + backendId = = DNN_BACKEND_OPENCV & & ( targetId = = DNN_TARGET_OPENCL | | targetId = = DNN_TARGET_OPENCL_FP16 ) ) <nl> + { <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL ) ; <nl> + } <nl> + <nl> + Net net ; <nl> + int convId = net . addLayer ( convParams . name , convParams . type , convParams ) ; <nl> + int activId = net . addLayer ( activationParams . name , activationParams . type , activationParams ) ; <nl> + int eltwiseId = net . addLayer ( eltwiseParams . name , eltwiseParams . type , eltwiseParams ) ; <nl> + net . connect ( 0 , 0 , convId , 0 ) ; <nl> + net . connect ( convId , 0 , activId , 0 ) ; <nl> + net . connect ( activId , 0 , eltwiseId , 0 ) ; <nl> + net . connect ( 0 , 0 , eltwiseId , 1 ) ; <nl> + <nl> + std : : vector < int > expectedFusedLayers ; <nl> + if ( backendId = = DNN_BACKEND_OPENCV ) <nl> + { <nl> + if ( targetId = = DNN_TARGET_CPU ) <nl> + expectedFusedLayers . push_back ( activId ) ; / / activation fused with convolution <nl> + else if ( targetId = = DNN_TARGET_OPENCL | | targetId = = DNN_TARGET_OPENCL_FP16 ) <nl> + { <nl> + if ( actType = = " ReLU " | | actType = = " ChannelsPReLU " | | actType = = " ReLU6 " | | actType = = " TanH " | | actType = = " Power " ) <nl> + expectedFusedLayers . push_back ( activId ) ; / / activation fused with convolution <nl> + } <nl> + } <nl> + <nl> + TestLayerFusion : : test ( input , net , backendId , targetId , expectedFusedLayers ) ; <nl> + } <nl> + INSTANTIATE_TEST_CASE_P ( TestLayerFusion , ConvolutionActivationEltwiseFusion , Combine ( <nl> + / * bias * / testing : : Bool ( ) , <nl> + / * activation * / TestLayerFusion : : activationLayersList ( ) , <nl> + / * eltwise op * / TestLayerFusion : : eltwiseOpList ( ) , <nl> + / * eltwise weighted * / testing : : Bool ( ) , <nl> + TestLayerFusion : : dnnBackendsAndTargetsForFusionTests ( ) <nl> + ) ) ; <nl> + <nl> } } / / namespace <nl> mmm a / modules / dnn / test / test_onnx_importer . cpp <nl> ppp b / modules / dnn / test / test_onnx_importer . cpp <nl> TEST_P ( Test_ONNX_layers , ReduceMean ) <nl> testONNXModels ( " reduce_mean_axis2 " ) ; <nl> } <nl> <nl> + TEST_P ( Test_ONNX_layers , ReduceSum ) <nl> + { <nl> + testONNXModels ( " reduce_sum " ) ; <nl> + } <nl> + <nl> TEST_P ( Test_ONNX_layers , ReduceMean3D ) <nl> { <nl> if ( backend = = DNN_BACKEND_CUDA ) <nl> TEST_P ( Test_ONNX_layers , MatMul ) <nl> testONNXModels ( " matmul_4d " ) ; <nl> } <nl> <nl> + TEST_P ( Test_ONNX_layers , MatMulAdd ) <nl> + { <nl> + if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ) <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER ) ; <nl> + if ( backend = = DNN_BACKEND_OPENCV & & target = = DNN_TARGET_OPENCL_FP16 ) <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_OPENCL_FP16 ) ; <nl> + testONNXModels ( " matmul_add " ) ; <nl> + } <nl> + <nl> TEST_P ( Test_ONNX_layers , Expand ) <nl> { <nl> testONNXModels ( " expand_batch " ) ; <nl> testONNXModels ( " expand_channels " ) ; <nl> + testONNXModels ( " expand_neg_batch " ) ; <nl> } <nl> <nl> TEST_P ( Test_ONNX_layers , ExpandHW ) <nl> mmm a / modules / dnn / test / test_tf_importer . cpp <nl> ppp b / modules / dnn / test / test_tf_importer . cpp <nl> TEST_P ( Test_TensorFlow_layers , reduce_mean ) <nl> runTensorFlowNet ( " global_pool_by_axis " ) ; <nl> } <nl> <nl> + TEST_P ( Test_TensorFlow_layers , reduce_sum ) <nl> + { <nl> + if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ) <nl> + applyTestTag ( CV_TEST_TAG_DNN_SKIP_IE_NN_BUILDER ) ; <nl> + runTensorFlowNet ( " sum_pool_by_axis " ) ; <nl> + } <nl> + <nl> TEST_P ( Test_TensorFlow_layers , conv_single_conv ) <nl> { <nl> runTensorFlowNet ( " single_conv " ) ; <nl> TEST_P ( Test_TensorFlow_layers , pooling_reduce_mean ) <nl> runTensorFlowNet ( " reduce_mean " ) ; / / an average pooling over all spatial dimensions . <nl> } <nl> <nl> + TEST_P ( Test_TensorFlow_layers , pooling_reduce_sum ) <nl> + { <nl> + runTensorFlowNet ( " reduce_sum " ) ; / / a SUM pooling over all spatial dimensions . <nl> + } <nl> + <nl> TEST_P ( Test_TensorFlow_layers , max_pool_grad ) <nl> { <nl> if ( backend = = DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 ) <nl> mmm a / modules / flann / include / opencv2 / flann / kmeans_index . h <nl> ppp b / modules / flann / include / opencv2 / flann / kmeans_index . h <nl> class KMeansIndex : public NNIndex < Distance > <nl> root_ [ i ] = pool_ . allocate < KMeansNode > ( ) ; <nl> std : : memset ( root_ [ i ] , 0 , sizeof ( KMeansNode ) ) ; <nl> <nl> - if ( is_kdtree_distance : : val | | is_vector_space_distance : : val ) { <nl> - computeNodeStatistics ( root_ [ i ] , indices_ [ i ] , ( unsigned int ) size_ ) ; <nl> - computeClustering ( root_ [ i ] , indices_ [ i ] , ( int ) size_ , branching_ , 0 ) ; <nl> - } <nl> - else { <nl> - computeBitfieldNodeStatistics ( root_ [ i ] , indices_ [ i ] , ( unsigned int ) size_ ) ; <nl> - computeBitfieldClustering ( root_ [ i ] , indices_ [ i ] , ( int ) size_ , branching_ , 0 ) ; <nl> - } <nl> + Distance * dummy = NULL ; <nl> + computeNodeStatistics ( root_ [ i ] , indices_ [ i ] , ( unsigned int ) size_ , dummy ) ; <nl> + <nl> + computeClustering ( root_ [ i ] , indices_ [ i ] , ( int ) size_ , branching_ , 0 ) ; <nl> } <nl> } <nl> <nl> class KMeansIndex : public NNIndex < Distance > <nl> } <nl> <nl> <nl> - <nl> - / * * <nl> - * The method responsible with actually doing the recursive hierarchical <nl> - * clustering <nl> - * <nl> - * Params : <nl> - * node = the node to cluster <nl> - * indices = indices of the points belonging to the current node <nl> - * branching = the branching factor to use in the clustering <nl> - * <nl> - * TODO : for 1 - sized clusters don ' t store a cluster center ( it ' s the same as the single cluster point ) <nl> - * / <nl> - void computeClustering ( KMeansNodePtr node , int * indices , int indices_length , int branching , int level ) <nl> + template < typename DistType > <nl> + void computeNodeStatistics ( KMeansNodePtr node , int * indices , <nl> + unsigned int indices_length , <nl> + const DistType * identifier ) <nl> { <nl> - node - > size = indices_length ; <nl> - node - > level = level ; <nl> - <nl> - if ( indices_length < branching ) { <nl> - node - > indices = indices ; <nl> - std : : sort ( node - > indices , node - > indices + indices_length ) ; <nl> - node - > childs = NULL ; <nl> - return ; <nl> - } <nl> - <nl> - cv : : AutoBuffer < int > centers_idx_buf ( branching ) ; <nl> - int * centers_idx = centers_idx_buf . data ( ) ; <nl> - int centers_length ; <nl> - ( this - > * chooseCenters ) ( branching , indices , indices_length , centers_idx , centers_length ) ; <nl> + ( void ) identifier ; <nl> + computeNodeStatistics ( node , indices , indices_length ) ; <nl> + } <nl> <nl> - if ( centers_length < branching ) { <nl> - node - > indices = indices ; <nl> - std : : sort ( node - > indices , node - > indices + indices_length ) ; <nl> - node - > childs = NULL ; <nl> - return ; <nl> - } <nl> + void computeNodeStatistics ( KMeansNodePtr node , int * indices , <nl> + unsigned int indices_length , <nl> + const cvflann : : HammingLUT * identifier ) <nl> + { <nl> + ( void ) identifier ; <nl> + computeBitfieldNodeStatistics ( node , indices , indices_length ) ; <nl> + } <nl> <nl> + void computeNodeStatistics ( KMeansNodePtr node , int * indices , <nl> + unsigned int indices_length , <nl> + const cvflann : : Hamming < unsigned char > * identifier ) <nl> + { <nl> + ( void ) identifier ; <nl> + computeBitfieldNodeStatistics ( node , indices , indices_length ) ; <nl> + } <nl> <nl> - std : : vector < DistanceType > radiuses ( branching ) ; <nl> - cv : : AutoBuffer < int > count_buf ( branching ) ; <nl> - int * count = count_buf . data ( ) ; <nl> - for ( int i = 0 ; i < branching ; + + i ) { <nl> - radiuses [ i ] = 0 ; <nl> - count [ i ] = 0 ; <nl> - } <nl> + void computeNodeStatistics ( KMeansNodePtr node , int * indices , <nl> + unsigned int indices_length , <nl> + const cvflann : : Hamming2 < unsigned char > * identifier ) <nl> + { <nl> + ( void ) identifier ; <nl> + computeBitfieldNodeStatistics ( node , indices , indices_length ) ; <nl> + } <nl> <nl> - / / assign points to clusters <nl> - cv : : AutoBuffer < int > belongs_to_buf ( indices_length ) ; <nl> - int * belongs_to = belongs_to_buf . data ( ) ; <nl> - for ( int i = 0 ; i < indices_length ; + + i ) { <nl> - DistanceType sq_dist = distance_ ( dataset_ [ indices [ i ] ] , dataset_ [ centers_idx [ 0 ] ] , veclen_ ) ; <nl> - belongs_to [ i ] = 0 ; <nl> - for ( int j = 1 ; j < branching ; + + j ) { <nl> - DistanceType new_sq_dist = distance_ ( dataset_ [ indices [ i ] ] , dataset_ [ centers_idx [ j ] ] , veclen_ ) ; <nl> - if ( sq_dist > new_sq_dist ) { <nl> - belongs_to [ i ] = j ; <nl> - sq_dist = new_sq_dist ; <nl> - } <nl> - } <nl> - if ( sq_dist > radiuses [ belongs_to [ i ] ] ) { <nl> - radiuses [ belongs_to [ i ] ] = sq_dist ; <nl> - } <nl> - count [ belongs_to [ i ] ] + + ; <nl> - } <nl> <nl> + void refineClustering ( int * indices , int indices_length , int branching , CentersType * * centers , <nl> + std : : vector < DistanceType > & radiuses , int * belongs_to , int * count ) <nl> + { <nl> cv : : AutoBuffer < double > dcenters_buf ( branching * veclen_ ) ; <nl> Matrix < double > dcenters ( dcenters_buf . data ( ) , branching , veclen_ ) ; <nl> - for ( int i = 0 ; i < centers_length ; + + i ) { <nl> - ElementType * vec = dataset_ [ centers_idx [ i ] ] ; <nl> - for ( size_t k = 0 ; k < veclen_ ; + + k ) { <nl> - dcenters [ i ] [ k ] = double ( vec [ k ] ) ; <nl> - } <nl> - } <nl> <nl> bool converged = false ; <nl> int iteration = 0 ; <nl> class KMeansIndex : public NNIndex < Distance > <nl> std : : vector < DistanceType > sq_dists ( indices_length ) ; <nl> <nl> / / reassign points to clusters <nl> - KMeansDistanceComputer < Matrix < double > > invoker ( distance_ , dataset_ , branching , indices , dcenters , veclen_ , new_centroids , sq_dists ) ; <nl> + KMeansDistanceComputer < Matrix < double > > invoker ( <nl> + distance_ , dataset_ , branching , indices , dcenters , veclen_ , new_centroids , sq_dists ) ; <nl> parallel_for_ ( cv : : Range ( 0 , ( int ) indices_length ) , invoker ) ; <nl> <nl> for ( int i = 0 ; i < ( int ) indices_length ; + + i ) { <nl> class KMeansIndex : public NNIndex < Distance > <nl> converged = false ; <nl> } <nl> } <nl> - <nl> - } <nl> - <nl> - CentersType * * centers = new CentersType * [ branching ] ; <nl> - <nl> - for ( int i = 0 ; i < branching ; + + i ) { <nl> - centers [ i ] = new CentersType [ veclen_ ] ; <nl> - memoryCounter_ + = ( int ) ( veclen_ * sizeof ( CentersType ) ) ; <nl> - for ( size_t k = 0 ; k < veclen_ ; + + k ) { <nl> - centers [ i ] [ k ] = ( CentersType ) dcenters [ i ] [ k ] ; <nl> - } <nl> - } <nl> - <nl> - <nl> - / / compute kmeans clustering for each of the resulting clusters <nl> - node - > childs = pool_ . allocate < KMeansNodePtr > ( branching ) ; <nl> - int start = 0 ; <nl> - int end = start ; <nl> - for ( int c = 0 ; c < branching ; + + c ) { <nl> - int s = count [ c ] ; <nl> - <nl> - DistanceType variance = 0 ; <nl> - DistanceType mean_radius = 0 ; <nl> - for ( int i = 0 ; i < indices_length ; + + i ) { <nl> - if ( belongs_to [ i ] = = c ) { <nl> - DistanceType d = distance_ ( dataset_ [ indices [ i ] ] , ZeroIterator < ElementType > ( ) , veclen_ ) ; <nl> - variance + = d ; <nl> - mean_radius + = static_cast < DistanceType > ( sqrt ( d ) ) ; <nl> - std : : swap ( indices [ i ] , indices [ end ] ) ; <nl> - std : : swap ( belongs_to [ i ] , belongs_to [ end ] ) ; <nl> - end + + ; <nl> - } <nl> - } <nl> - variance / = s ; <nl> - mean_radius / = s ; <nl> - variance - = distance_ ( centers [ c ] , ZeroIterator < ElementType > ( ) , veclen_ ) ; <nl> - <nl> - node - > childs [ c ] = pool_ . allocate < KMeansNode > ( ) ; <nl> - std : : memset ( node - > childs [ c ] , 0 , sizeof ( KMeansNode ) ) ; <nl> - node - > childs [ c ] - > radius = radiuses [ c ] ; <nl> - node - > childs [ c ] - > pivot = centers [ c ] ; <nl> - node - > childs [ c ] - > variance = variance ; <nl> - node - > childs [ c ] - > mean_radius = mean_radius ; <nl> - computeClustering ( node - > childs [ c ] , indices + start , end - start , branching , level + 1 ) ; <nl> - start = end ; <nl> } <nl> <nl> - delete [ ] centers ; <nl> + for ( int i = 0 ; i < branching ; + + i ) { <nl> + centers [ i ] = new CentersType [ veclen_ ] ; <nl> + memoryCounter_ + = ( int ) ( veclen_ * sizeof ( CentersType ) ) ; <nl> + for ( size_t k = 0 ; k < veclen_ ; + + k ) { <nl> + centers [ i ] [ k ] = ( CentersType ) dcenters [ i ] [ k ] ; <nl> + } <nl> + } <nl> } <nl> <nl> <nl> - / * * <nl> - * The method responsible with doing the recursive hierarchical clustering on <nl> - * binary vectors . <nl> - * As some might have heared that KMeans on binary data doesn ' t make sense , <nl> - * it ' s worth a little explanation why it actually fairly works . As <nl> - * with the Hierarchical Clustering algortihm , we seed several centers for the <nl> - * current node by picking some of its points . Then in a first pass each point <nl> - * of the node is then related to its closest center . Now let ' s have a look at <nl> - * the 5 central dimensions of the 9 following points : <nl> - * <nl> - * xxxxxx11100xxxxx ( 1 ) <nl> - * xxxxxx11010xxxxx ( 2 ) <nl> - * xxxxxx11001xxxxx ( 3 ) <nl> - * xxxxxx10110xxxxx ( 4 ) <nl> - * xxxxxx10101xxxxx ( 5 ) <nl> - * xxxxxx10011xxxxx ( 6 ) <nl> - * xxxxxx01110xxxxx ( 7 ) <nl> - * xxxxxx01101xxxxx ( 8 ) <nl> - * xxxxxx01011xxxxx ( 9 ) <nl> - * sum _____ <nl> - * of 1 : 66555 <nl> - * <nl> - * Even if the barycenter notion doesn ' t apply , we can set a center <nl> - * xxxxxx11111xxxxx that will better fit the five dimensions we are focusing <nl> - * on for these points . <nl> - * <nl> - * Note that convergence isn ' t ensured anymore . In practice , using Gonzales <nl> - * as seeding algorithm should be fine for getting convergence ( " iterations " <nl> - * value can be set to - 1 ) . But with KMeans + + seeding you should definitely <nl> - * set a maximum number of iterations ( but make it higher than the " iterations " <nl> - * default value of 11 ) . <nl> - * <nl> - * Params : <nl> - * node = the node to cluster <nl> - * indices = indices of the points belonging to the current node <nl> - * indices_length = number of points in the current node <nl> - * branching = the branching factor to use in the clustering <nl> - * level = 0 for the root node , it increases with the subdivision levels <nl> - * / <nl> - void computeBitfieldClustering ( KMeansNodePtr node , int * indices , <nl> - int indices_length , int branching , int level ) <nl> + void refineBitfieldClustering ( int * indices , int indices_length , int branching , CentersType * * centers , <nl> + std : : vector < DistanceType > & radiuses , int * belongs_to , int * count ) <nl> { <nl> - node - > size = indices_length ; <nl> - node - > level = level ; <nl> - <nl> - if ( indices_length < branching ) { <nl> - node - > indices = indices ; <nl> - std : : sort ( node - > indices , node - > indices + indices_length ) ; <nl> - node - > childs = NULL ; <nl> - return ; <nl> - } <nl> - <nl> - cv : : AutoBuffer < int > centers_idx_buf ( branching ) ; <nl> - int * centers_idx = centers_idx_buf . data ( ) ; <nl> - int centers_length ; <nl> - ( this - > * chooseCenters ) ( branching , indices , indices_length , centers_idx , centers_length ) ; <nl> - <nl> - if ( centers_length < branching ) { <nl> - node - > indices = indices ; <nl> - std : : sort ( node - > indices , node - > indices + indices_length ) ; <nl> - node - > childs = NULL ; <nl> - return ; <nl> + for ( int i = 0 ; i < branching ; + + i ) { <nl> + centers [ i ] = new CentersType [ veclen_ ] ; <nl> + memoryCounter_ + = ( int ) ( veclen_ * sizeof ( CentersType ) ) ; <nl> } <nl> <nl> const unsigned int accumulator_veclen = static_cast < unsigned int > ( <nl> class KMeansIndex : public NNIndex < Distance > <nl> cv : : AutoBuffer < unsigned int > dcenters_buf ( branching * accumulator_veclen ) ; <nl> Matrix < unsigned int > dcenters ( dcenters_buf . data ( ) , branching , accumulator_veclen ) ; <nl> <nl> - CentersType * * centers = new CentersType * [ branching ] ; <nl> - <nl> - for ( int i = 0 ; i < branching ; + + i ) { <nl> - centers [ i ] = new CentersType [ veclen_ ] ; <nl> - memoryCounter_ + = ( int ) ( veclen_ * sizeof ( CentersType ) ) ; <nl> - } <nl> - <nl> - std : : vector < DistanceType > radiuses ( branching ) ; <nl> - cv : : AutoBuffer < int > count_buf ( branching ) ; <nl> - int * count = count_buf . data ( ) ; <nl> - for ( int i = 0 ; i < branching ; + + i ) { <nl> - radiuses [ i ] = 0 ; <nl> - count [ i ] = 0 ; <nl> - } <nl> - <nl> - / / assign points to clusters <nl> - cv : : AutoBuffer < int > belongs_to_buf ( indices_length ) ; <nl> - int * belongs_to = belongs_to_buf . data ( ) ; <nl> - for ( int i = 0 ; i < indices_length ; + + i ) { <nl> - <nl> - DistanceType dist = distance_ ( dataset_ [ indices [ i ] ] , dataset_ [ centers_idx [ 0 ] ] , veclen_ ) ; <nl> - belongs_to [ i ] = 0 ; <nl> - for ( int j = 1 ; j < branching ; + + j ) { <nl> - DistanceType new_dist = distance_ ( dataset_ [ indices [ i ] ] , dataset_ [ centers_idx [ j ] ] , veclen_ ) ; <nl> - if ( dist > new_dist ) { <nl> - belongs_to [ i ] = j ; <nl> - dist = new_dist ; <nl> - } <nl> - } <nl> - if ( dist > radiuses [ belongs_to [ i ] ] ) { <nl> - radiuses [ belongs_to [ i ] ] = dist ; <nl> - } <nl> - count [ belongs_to [ i ] ] + + ; <nl> - } <nl> - <nl> bool converged = false ; <nl> int iteration = 0 ; <nl> while ( ! converged & & iteration < iterations_ ) { <nl> class KMeansIndex : public NNIndex < Distance > <nl> std : : vector < DistanceType > dists ( indices_length ) ; <nl> <nl> / / reassign points to clusters <nl> - KMeansDistanceComputer < ElementType * * > invoker ( distance_ , dataset_ , branching , indices , centers , veclen_ , new_centroids , dists ) ; <nl> + KMeansDistanceComputer < ElementType * * > invoker ( <nl> + distance_ , dataset_ , branching , indices , centers , veclen_ , new_centroids , dists ) ; <nl> parallel_for_ ( cv : : Range ( 0 , ( int ) indices_length ) , invoker ) ; <nl> <nl> for ( int i = 0 ; i < indices_length ; + + i ) { <nl> class KMeansIndex : public NNIndex < Distance > <nl> converged = false ; <nl> } <nl> } <nl> + } <nl> + } <nl> <nl> + <nl> + void computeSubClustering ( KMeansNodePtr node , int * indices , int indices_length , <nl> + int branching , int level , CentersType * * centers , <nl> + std : : vector < DistanceType > & radiuses , int * belongs_to , int * count ) <nl> + { <nl> + / / compute kmeans clustering for each of the resulting clusters <nl> + node - > childs = pool_ . allocate < KMeansNodePtr > ( branching ) ; <nl> + int start = 0 ; <nl> + int end = start ; <nl> + for ( int c = 0 ; c < branching ; + + c ) { <nl> + int s = count [ c ] ; <nl> + <nl> + DistanceType variance = 0 ; <nl> + DistanceType mean_radius = 0 ; <nl> + for ( int i = 0 ; i < indices_length ; + + i ) { <nl> + if ( belongs_to [ i ] = = c ) { <nl> + DistanceType d = distance_ ( dataset_ [ indices [ i ] ] , ZeroIterator < ElementType > ( ) , veclen_ ) ; <nl> + variance + = d ; <nl> + mean_radius + = static_cast < DistanceType > ( sqrt ( d ) ) ; <nl> + std : : swap ( indices [ i ] , indices [ end ] ) ; <nl> + std : : swap ( belongs_to [ i ] , belongs_to [ end ] ) ; <nl> + end + + ; <nl> + } <nl> + } <nl> + variance / = s ; <nl> + mean_radius / = s ; <nl> + variance - = distance_ ( centers [ c ] , ZeroIterator < ElementType > ( ) , veclen_ ) ; <nl> + <nl> + node - > childs [ c ] = pool_ . allocate < KMeansNode > ( ) ; <nl> + std : : memset ( node - > childs [ c ] , 0 , sizeof ( KMeansNode ) ) ; <nl> + node - > childs [ c ] - > radius = radiuses [ c ] ; <nl> + node - > childs [ c ] - > pivot = centers [ c ] ; <nl> + node - > childs [ c ] - > variance = variance ; <nl> + node - > childs [ c ] - > mean_radius = mean_radius ; <nl> + computeClustering ( node - > childs [ c ] , indices + start , end - start , branching , level + 1 ) ; <nl> + start = end ; <nl> } <nl> + } <nl> <nl> <nl> + void computeAnyBitfieldSubClustering ( KMeansNodePtr node , int * indices , int indices_length , <nl> + int branching , int level , CentersType * * centers , <nl> + std : : vector < DistanceType > & radiuses , int * belongs_to , int * count ) <nl> + { <nl> / / compute kmeans clustering for each of the resulting clusters <nl> node - > childs = pool_ . allocate < KMeansNodePtr > ( branching ) ; <nl> int start = 0 ; <nl> class KMeansIndex : public NNIndex < Distance > <nl> node - > childs [ c ] - > pivot = centers [ c ] ; <nl> node - > childs [ c ] - > variance = static_cast < DistanceType > ( variance ) ; <nl> node - > childs [ c ] - > mean_radius = mean_radius ; <nl> - computeBitfieldClustering ( node - > childs [ c ] , indices + start , end - start , branching , level + 1 ) ; <nl> + computeClustering ( node - > childs [ c ] , indices + start , end - start , branching , level + 1 ) ; <nl> start = end ; <nl> } <nl> + } <nl> <nl> - delete [ ] centers ; <nl> + <nl> + template < typename DistType > <nl> + void refineAndSplitClustering ( <nl> + KMeansNodePtr node , int * indices , int indices_length , int branching , <nl> + int level , CentersType * * centers , std : : vector < DistanceType > & radiuses , <nl> + int * belongs_to , int * count , const DistType * identifier ) <nl> + { <nl> + ( void ) identifier ; <nl> + refineClustering ( indices , indices_length , branching , centers , radiuses , belongs_to , count ) ; <nl> + <nl> + computeSubClustering ( node , indices , indices_length , branching , <nl> + level , centers , radiuses , belongs_to , count ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * The methods responsible with doing the recursive hierarchical clustering on <nl> + * binary vectors . <nl> + * As some might have heared that KMeans on binary data doesn ' t make sense , <nl> + * it ' s worth a little explanation why it actually fairly works . As <nl> + * with the Hierarchical Clustering algortihm , we seed several centers for the <nl> + * current node by picking some of its points . Then in a first pass each point <nl> + * of the node is then related to its closest center . Now let ' s have a look at <nl> + * the 5 central dimensions of the 9 following points : <nl> + * <nl> + * xxxxxx11100xxxxx ( 1 ) <nl> + * xxxxxx11010xxxxx ( 2 ) <nl> + * xxxxxx11001xxxxx ( 3 ) <nl> + * xxxxxx10110xxxxx ( 4 ) <nl> + * xxxxxx10101xxxxx ( 5 ) <nl> + * xxxxxx10011xxxxx ( 6 ) <nl> + * xxxxxx01110xxxxx ( 7 ) <nl> + * xxxxxx01101xxxxx ( 8 ) <nl> + * xxxxxx01011xxxxx ( 9 ) <nl> + * sum _____ <nl> + * of 1 : 66555 <nl> + * <nl> + * Even if the barycenter notion doesn ' t apply , we can set a center <nl> + * xxxxxx11111xxxxx that will better fit the five dimensions we are focusing <nl> + * on for these points . <nl> + * <nl> + * Note that convergence isn ' t ensured anymore . In practice , using Gonzales <nl> + * as seeding algorithm should be fine for getting convergence ( " iterations " <nl> + * value can be set to - 1 ) . But with KMeans + + seeding you should definitely <nl> + * set a maximum number of iterations ( but make it higher than the " iterations " <nl> + * default value of 11 ) . <nl> + * <nl> + * Params : <nl> + * node = the node to cluster <nl> + * indices = indices of the points belonging to the current node <nl> + * indices_length = number of points in the current node <nl> + * branching = the branching factor to use in the clustering <nl> + * level = 0 for the root node , it increases with the subdivision levels <nl> + * centers = clusters centers to compute <nl> + * radiuses = radiuses of clusters <nl> + * belongs_to = LookUp Table returning , for a given indice id , the center id it belongs to <nl> + * count = array storing the number of indices for a given center id <nl> + * identifier = dummy pointer on an instance of Distance ( use to branch correctly among templates ) <nl> + * / <nl> + void refineAndSplitClustering ( <nl> + KMeansNodePtr node , int * indices , int indices_length , int branching , <nl> + int level , CentersType * * centers , std : : vector < DistanceType > & radiuses , <nl> + int * belongs_to , int * count , const cvflann : : HammingLUT * identifier ) <nl> + { <nl> + ( void ) identifier ; <nl> + refineBitfieldClustering ( <nl> + indices , indices_length , branching , centers , radiuses , belongs_to , count ) ; <nl> + <nl> + computeAnyBitfieldSubClustering ( node , indices , indices_length , branching , <nl> + level , centers , radiuses , belongs_to , count ) ; <nl> + } <nl> + <nl> + <nl> + void refineAndSplitClustering ( <nl> + KMeansNodePtr node , int * indices , int indices_length , int branching , <nl> + int level , CentersType * * centers , std : : vector < DistanceType > & radiuses , <nl> + int * belongs_to , int * count , const cvflann : : Hamming < unsigned char > * identifier ) <nl> + { <nl> + ( void ) identifier ; <nl> + refineBitfieldClustering ( <nl> + indices , indices_length , branching , centers , radiuses , belongs_to , count ) ; <nl> + <nl> + computeAnyBitfieldSubClustering ( node , indices , indices_length , branching , <nl> + level , centers , radiuses , belongs_to , count ) ; <nl> } <nl> <nl> <nl> + void refineAndSplitClustering ( <nl> + KMeansNodePtr node , int * indices , int indices_length , int branching , <nl> + int level , CentersType * * centers , std : : vector < DistanceType > & radiuses , <nl> + int * belongs_to , int * count , const cvflann : : Hamming2 < unsigned char > * identifier ) <nl> + { <nl> + ( void ) identifier ; <nl> + refineBitfieldClustering ( <nl> + indices , indices_length , branching , centers , radiuses , belongs_to , count ) ; <nl> + <nl> + computeAnyBitfieldSubClustering ( node , indices , indices_length , branching , <nl> + level , centers , radiuses , belongs_to , count ) ; <nl> + } <nl> + <nl> + <nl> + / * * <nl> + * The method responsible with actually doing the recursive hierarchical <nl> + * clustering <nl> + * <nl> + * Params : <nl> + * node = the node to cluster <nl> + * indices = indices of the points belonging to the current node <nl> + * branching = the branching factor to use in the clustering <nl> + * <nl> + * TODO : for 1 - sized clusters don ' t store a cluster center ( it ' s the same as the single cluster point ) <nl> + * / <nl> + void computeClustering ( KMeansNodePtr node , int * indices , int indices_length , int branching , int level ) <nl> + { <nl> + node - > size = indices_length ; <nl> + node - > level = level ; <nl> + <nl> + if ( indices_length < branching ) { <nl> + node - > indices = indices ; <nl> + std : : sort ( node - > indices , node - > indices + indices_length ) ; <nl> + node - > childs = NULL ; <nl> + return ; <nl> + } <nl> + <nl> + cv : : AutoBuffer < int > centers_idx_buf ( branching ) ; <nl> + int * centers_idx = centers_idx_buf . data ( ) ; <nl> + int centers_length ; <nl> + ( this - > * chooseCenters ) ( branching , indices , indices_length , centers_idx , centers_length ) ; <nl> + <nl> + if ( centers_length < branching ) { <nl> + node - > indices = indices ; <nl> + std : : sort ( node - > indices , node - > indices + indices_length ) ; <nl> + node - > childs = NULL ; <nl> + return ; <nl> + } <nl> + <nl> + <nl> + std : : vector < DistanceType > radiuses ( branching ) ; <nl> + cv : : AutoBuffer < int > count_buf ( branching ) ; <nl> + int * count = count_buf . data ( ) ; <nl> + for ( int i = 0 ; i < branching ; + + i ) { <nl> + radiuses [ i ] = 0 ; <nl> + count [ i ] = 0 ; <nl> + } <nl> + <nl> + / / assign points to clusters <nl> + cv : : AutoBuffer < int > belongs_to_buf ( indices_length ) ; <nl> + int * belongs_to = belongs_to_buf . data ( ) ; <nl> + for ( int i = 0 ; i < indices_length ; + + i ) { <nl> + DistanceType sq_dist = distance_ ( dataset_ [ indices [ i ] ] , dataset_ [ centers_idx [ 0 ] ] , veclen_ ) ; <nl> + belongs_to [ i ] = 0 ; <nl> + for ( int j = 1 ; j < branching ; + + j ) { <nl> + DistanceType new_sq_dist = distance_ ( dataset_ [ indices [ i ] ] , dataset_ [ centers_idx [ j ] ] , veclen_ ) ; <nl> + if ( sq_dist > new_sq_dist ) { <nl> + belongs_to [ i ] = j ; <nl> + sq_dist = new_sq_dist ; <nl> + } <nl> + } <nl> + if ( sq_dist > radiuses [ belongs_to [ i ] ] ) { <nl> + radiuses [ belongs_to [ i ] ] = sq_dist ; <nl> + } <nl> + count [ belongs_to [ i ] ] + + ; <nl> + } <nl> + <nl> + CentersType * * centers = new CentersType * [ branching ] ; <nl> + <nl> + Distance * dummy = NULL ; <nl> + refineAndSplitClustering ( node , indices , indices_length , branching , level , <nl> + centers , radiuses , belongs_to , count , dummy ) ; <nl> + <nl> + delete [ ] centers ; <nl> + } <nl> <nl> <nl> / * * <nl> new file mode 100644 <nl> index 00000000000 . . 01ef93f8211 <nl> mmm / dev / null <nl> ppp b / samples / cpp / flann_search_dataset . cpp <nl> <nl> + / / flann_search_dataset . cpp <nl> + / / Naive program to search a query picture in a dataset illustrating usage of FLANN <nl> + <nl> + # include < iostream > <nl> + # include < vector > <nl> + # include " opencv2 / core . hpp " <nl> + # include " opencv2 / core / utils / filesystem . hpp " <nl> + # include " opencv2 / highgui . hpp " <nl> + # include " opencv2 / features2d . hpp " <nl> + # include " opencv2 / flann . hpp " <nl> + <nl> + using namespace cv ; <nl> + using std : : cout ; <nl> + using std : : endl ; <nl> + <nl> + # define _ORB_ <nl> + <nl> + const char * keys = <nl> + " { help h | | Print help message . } " <nl> + " { dataset | | Path to the images folder used as dataset . } " <nl> + " { image | | Path to the image to search for in the dataset . } " <nl> + " { save | | Path and filename where to save the flann structure to . } " <nl> + " { load | | Path and filename where to load the flann structure from . } " ; <nl> + <nl> + struct img_info { <nl> + int img_index ; <nl> + unsigned int nbr_of_matches ; <nl> + <nl> + img_info ( int _img_index , unsigned int _nbr_of_matches ) <nl> + : img_index ( _img_index ) <nl> + , nbr_of_matches ( _nbr_of_matches ) <nl> + { } <nl> + } ; <nl> + <nl> + <nl> + int main ( int argc , char * argv [ ] ) <nl> + { <nl> + / / - - Test the program options <nl> + CommandLineParser parser ( argc , argv , keys ) ; <nl> + if ( parser . has ( " help " ) ) <nl> + { <nl> + parser . printMessage ( ) ; <nl> + return - 1 ; <nl> + } <nl> + <nl> + const cv : : String img_path = parser . get < String > ( " image " ) ; <nl> + Mat img = imread ( samples : : findFile ( img_path ) , IMREAD_GRAYSCALE ) ; <nl> + if ( img . empty ( ) ) <nl> + { <nl> + cout < < " Could not open the image " < < img_path < < endl ; <nl> + return - 1 ; <nl> + } <nl> + <nl> + const cv : : String db_path = parser . get < String > ( " dataset " ) ; <nl> + if ( ! utils : : fs : : isDirectory ( db_path ) ) <nl> + { <nl> + cout < < " Dataset folder " < < db_path . c_str ( ) < < " doesn ' t exist ! " < < endl ; <nl> + return - 1 ; <nl> + } <nl> + <nl> + const cv : : String load_db_path = parser . get < String > ( " load " ) ; <nl> + if ( ( load_db_path ! = String ( ) ) & & ( ! utils : : fs : : exists ( load_db_path ) ) ) <nl> + { <nl> + cout < < " File " < < load_db_path . c_str ( ) <nl> + < < " where to load the flann structure from doesn ' t exist ! " < < endl ; <nl> + return - 1 ; <nl> + } <nl> + <nl> + const cv : : String save_db_path = parser . get < String > ( " save " ) ; <nl> + <nl> + / / - - Step 1 : Detect the keypoints using a detector , compute the descriptors <nl> + / / in the folder containing the images of the dataset <nl> + # ifdef _SIFT_ <nl> + int minHessian = 400 ; <nl> + Ptr < Feature2D > detector = SIFT : : create ( minHessian ) ; <nl> + # elif defined ( _ORB_ ) <nl> + Ptr < Feature2D > detector = ORB : : create ( ) ; <nl> + # else <nl> + cout < < " Missing or unknown defined descriptor . " <nl> + " Only SIFT and ORB are currently interfaced here " < < endl ; <nl> + return - 1 ; <nl> + # endif <nl> + <nl> + std : : vector < KeyPoint > db_keypoints ; <nl> + Mat db_descriptors ; <nl> + std : : vector < unsigned int > db_images_indice_range ; / / store the range of indices per image <nl> + std : : vector < int > db_indice_2_image_lut ; / / match descriptor indice to its image <nl> + <nl> + db_images_indice_range . push_back ( 0 ) ; <nl> + std : : vector < cv : : String > files ; <nl> + utils : : fs : : glob ( db_path , cv : : String ( ) , files ) ; <nl> + for ( std : : vector < cv : : String > : : iterator itr = files . begin ( ) ; itr ! = files . end ( ) ; + + itr ) <nl> + { <nl> + Mat tmp_img = imread ( * itr , IMREAD_GRAYSCALE ) ; <nl> + if ( ! tmp_img . empty ( ) ) <nl> + { <nl> + std : : vector < KeyPoint > kpts ; <nl> + Mat descriptors ; <nl> + detector - > detectAndCompute ( tmp_img , noArray ( ) , kpts , descriptors ) ; <nl> + <nl> + db_keypoints . insert ( db_keypoints . end ( ) , kpts . begin ( ) , kpts . end ( ) ) ; <nl> + db_descriptors . push_back ( descriptors ) ; <nl> + db_images_indice_range . push_back ( db_images_indice_range . back ( ) <nl> + + static_cast < unsigned int > ( kpts . size ( ) ) ) ; <nl> + } <nl> + } <nl> + <nl> + / / - - Set the LUT <nl> + db_indice_2_image_lut . resize ( db_images_indice_range . back ( ) ) ; <nl> + const int nbr_of_imgs = static_cast < int > ( db_images_indice_range . size ( ) - 1 ) ; <nl> + for ( int i = 0 ; i < nbr_of_imgs ; + + i ) <nl> + { <nl> + const unsigned int first_indice = db_images_indice_range [ i ] ; <nl> + const unsigned int last_indice = db_images_indice_range [ i + 1 ] ; <nl> + std : : fill ( db_indice_2_image_lut . begin ( ) + first_indice , <nl> + db_indice_2_image_lut . begin ( ) + last_indice , <nl> + i ) ; <nl> + } <nl> + <nl> + / / - - Step 2 : build the structure storing the descriptors <nl> + # if defined ( _SIFT_ ) <nl> + cv : : Ptr < flann : : GenericIndex < cvflann : : L2 < float > > > index ; <nl> + if ( load_db_path ! = String ( ) ) <nl> + index = cv : : makePtr < flann : : GenericIndex < cvflann : : L2 < float > > > ( db_descriptors , <nl> + cvflann : : SavedIndexParams ( load_db_path ) ) ; <nl> + else <nl> + index = cv : : makePtr < flann : : GenericIndex < cvflann : : L2 < float > > > ( db_descriptors , <nl> + cvflann : : KDTreeIndexParams ( 4 ) ) ; <nl> + <nl> + # elif defined ( _ORB_ ) <nl> + cv : : Ptr < flann : : GenericIndex < cvflann : : Hamming < unsigned char > > > index ; <nl> + if ( load_db_path ! = String ( ) ) <nl> + index = cv : : makePtr < flann : : GenericIndex < cvflann : : Hamming < unsigned char > > > <nl> + ( db_descriptors , cvflann : : SavedIndexParams ( load_db_path ) ) ; <nl> + else <nl> + index = cv : : makePtr < flann : : GenericIndex < cvflann : : Hamming < unsigned char > > > <nl> + ( db_descriptors , cvflann : : LshIndexParams ( ) ) ; <nl> + # else <nl> + cout < < " Descriptor not listed . Set the proper FLANN distance for this descriptor " < < endl ; <nl> + return - 1 ; <nl> + # endif <nl> + if ( save_db_path ! = String ( ) ) <nl> + index - > save ( save_db_path ) ; <nl> + <nl> + <nl> + / / Return if no query image was set <nl> + if ( img_path = = String ( ) ) <nl> + return 0 ; <nl> + <nl> + / / - - Detect the keypoints and compute the descriptors for the query image <nl> + std : : vector < KeyPoint > img_keypoints ; <nl> + Mat img_descriptors ; <nl> + detector - > detectAndCompute ( img , noArray ( ) , img_keypoints , img_descriptors ) ; <nl> + <nl> + <nl> + / / - - Step 3 : retrieve the descriptors in the dataset matching the ones of the query image <nl> + / / / ! \ knnSearch doesn ' t follow OpenCV standards by not initialising empty Mat properties <nl> + const int knn = 2 ; <nl> + Mat indices ( img_descriptors . rows , knn , CV_32S ) ; <nl> + # if defined ( _SIFT_ ) <nl> + # define DIST_TYPE float <nl> + Mat dists ( img_descriptors . rows , knn , CV_32F ) ; <nl> + # elif defined ( _ORB_ ) <nl> + # define DIST_TYPE int <nl> + Mat dists ( img_descriptors . rows , knn , CV_32S ) ; <nl> + # endif <nl> + index - > knnSearch ( img_descriptors , indices , dists , knn , cvflann : : SearchParams ( 32 ) ) ; <nl> + <nl> + / / - - Filter matches using the Lowe ' s ratio test <nl> + const float ratio_thresh = 0 . 7f ; <nl> + std : : vector < DMatch > good_matches ; / / contains <nl> + std : : vector < unsigned int > matches_per_img_histogram ( nbr_of_imgs , 0 ) ; <nl> + for ( int i = 0 ; i < dists . rows ; + + i ) <nl> + { <nl> + if ( dists . at < DIST_TYPE > ( i , 0 ) < ratio_thresh * dists . at < DIST_TYPE > ( i , 1 ) ) <nl> + { <nl> + const int indice_in_db = indices . at < int > ( i , 0 ) ; <nl> + DMatch dmatch ( i , indice_in_db , db_indice_2_image_lut [ indice_in_db ] , <nl> + static_cast < float > ( dists . at < DIST_TYPE > ( i , 0 ) ) ) ; <nl> + good_matches . push_back ( dmatch ) ; <nl> + matches_per_img_histogram [ db_indice_2_image_lut [ indice_in_db ] ] + + ; <nl> + } <nl> + } <nl> + <nl> + <nl> + / / - - Step 4 : find the dataset image with the highest proportion of matches <nl> + std : : multimap < float , img_info > images_infos ; <nl> + for ( int i = 0 ; i < nbr_of_imgs ; + + i ) <nl> + { <nl> + const unsigned int nbr_of_matches = matches_per_img_histogram [ i ] ; <nl> + if ( nbr_of_matches < 4 ) / / we need at leat 4 points for a homography <nl> + continue ; <nl> + <nl> + const unsigned int nbr_of_kpts = db_images_indice_range [ i + 1 ] - db_images_indice_range [ i ] ; <nl> + const float inverse_proportion_of_retrieved_kpts = <nl> + static_cast < float > ( nbr_of_kpts ) / static_cast < float > ( nbr_of_matches ) ; <nl> + <nl> + img_info info ( i , nbr_of_matches ) ; <nl> + images_infos . insert ( std : : pair < float , img_info > ( inverse_proportion_of_retrieved_kpts , <nl> + info ) ) ; <nl> + } <nl> + <nl> + if ( images_infos . begin ( ) = = images_infos . end ( ) ) <nl> + { <nl> + cout < < " No good match could be found . " < < endl ; <nl> + return 0 ; <nl> + } <nl> + <nl> + / / - - if there are several images with a similar proportion of matches , <nl> + / / select the one with the highest number of matches weighted by the <nl> + / / squared ratio of proportions <nl> + const float best_matches_proportion = images_infos . begin ( ) - > first ; <nl> + float new_matches_proportion = best_matches_proportion ; <nl> + img_info best_img = images_infos . begin ( ) - > second ; <nl> + <nl> + std : : multimap < float , img_info > : : iterator it = images_infos . begin ( ) ; <nl> + + + it ; <nl> + while ( ( it ! = images_infos . end ( ) ) & & ( it - > first < 1 . 1 * best_matches_proportion ) ) <nl> + { <nl> + const float ratio = new_matches_proportion / it - > first ; <nl> + if ( it - > second . nbr_of_matches * ( ratio * ratio ) > best_img . nbr_of_matches ) <nl> + { <nl> + new_matches_proportion = it - > first ; <nl> + best_img = it - > second ; <nl> + } <nl> + + + it ; <nl> + } <nl> + <nl> + / / - - Step 5 : filter goodmatches that belong to the best image match of the dataset <nl> + std : : vector < DMatch > filtered_good_matches ; <nl> + for ( std : : vector < DMatch > : : iterator itr ( good_matches . begin ( ) ) ; itr ! = good_matches . end ( ) ; + + itr ) <nl> + { <nl> + if ( itr - > imgIdx = = best_img . img_index ) <nl> + filtered_good_matches . push_back ( * itr ) ; <nl> + } <nl> + <nl> + / / - - Retrieve the best image match from the dataset <nl> + Mat db_img = imread ( files [ best_img . img_index ] , IMREAD_GRAYSCALE ) ; <nl> + <nl> + / / - - Draw matches <nl> + Mat img_matches ; <nl> + drawMatches ( img , img_keypoints , db_img , db_keypoints , filtered_good_matches , img_matches , Scalar : : all ( - 1 ) , <nl> + Scalar : : all ( - 1 ) , std : : vector < char > ( ) , DrawMatchesFlags : : NOT_DRAW_SINGLE_POINTS ) ; <nl> + <nl> + / / - - Show detected matches <nl> + imshow ( " Good Matches " , img_matches ) ; <nl> + waitKey ( ) ; <nl> + <nl> + return 0 ; <nl> + } <nl> mmm a / samples / dnn / dasiamrpn_tracker . py <nl> ppp b / samples / dnn / dasiamrpn_tracker . py <nl> <nl> import sys <nl> <nl> class DaSiamRPNTracker : <nl> - # initialization of used values , initial bounding box , used network <nl> - def __init__ ( self , im , target_pos , target_sz , net , kernel_r1 , kernel_cls1 ) : <nl> + # Initialization of used values , initial bounding box , used network <nl> + def __init__ ( self , net = " dasiamrpn_model . onnx " , kernel_r1 = " dasiamrpn_kernel_r1 . onnx " , kernel_cls1 = " dasiamrpn_kernel_cls1 . onnx " ) : <nl> self . windowing = " cosine " <nl> self . exemplar_size = 127 <nl> self . instance_size = 271 <nl> def __init__ ( self , im , target_pos , target_sz , net , kernel_r1 , kernel_cls1 ) : <nl> self . penalty_k = 0 . 055 <nl> self . window_influence = 0 . 42 <nl> self . lr = 0 . 295 <nl> + self . score = [ ] <nl> + if self . windowing = = " cosine " : <nl> + self . window = np . outer ( np . hanning ( self . score_size ) , np . hanning ( self . score_size ) ) <nl> + elif self . windowing = = " uniform " : <nl> + self . window = np . ones ( ( self . score_size , self . score_size ) ) <nl> + self . window = np . tile ( self . window . flatten ( ) , self . anchor_num ) <nl> + # Loading network ` s and kernel ` s models <nl> + self . net = cv . dnn . readNet ( net ) <nl> + self . kernel_r1 = cv . dnn . readNet ( kernel_r1 ) <nl> + self . kernel_cls1 = cv . dnn . readNet ( kernel_cls1 ) <nl> + <nl> + def init ( self , im , init_bb ) : <nl> + target_pos , target_sz = np . array ( [ init_bb [ 0 ] , init_bb [ 1 ] ] ) , np . array ( [ init_bb [ 2 ] , init_bb [ 3 ] ] ) <nl> self . im_h = im . shape [ 0 ] <nl> self . im_w = im . shape [ 1 ] <nl> self . target_pos = target_pos <nl> self . target_sz = target_sz <nl> self . avg_chans = np . mean ( im , axis = ( 0 , 1 ) ) <nl> - self . net = net <nl> - self . score = [ ] <nl> <nl> + # When we trying to generate ONNX model from the pre - trained . pth model <nl> + # we are using only one state of the network . In our case used state <nl> + # with big bounding box , so we were forced to add assertion for <nl> + # too small bounding boxes - current state of the network can not <nl> + # work properly with such small bounding boxes <nl> if ( ( self . target_sz [ 0 ] * self . target_sz [ 1 ] ) / float ( self . im_h * self . im_w ) ) < 0 . 004 : <nl> - raise AssertionError ( " Initializing BB is too small - try to restart tracker with larger BB " ) <nl> + raise AssertionError ( <nl> + " Initializing BB is too small - try to restart tracker with larger BB " ) <nl> <nl> self . anchor = self . __generate_anchor ( ) <nl> wc_z = self . target_sz [ 0 ] + self . context_amount * sum ( self . target_sz ) <nl> hc_z = self . target_sz [ 1 ] + self . context_amount * sum ( self . target_sz ) <nl> s_z = round ( np . sqrt ( wc_z * hc_z ) ) <nl> - <nl> z_crop = self . __get_subwindow_tracking ( im , self . exemplar_size , s_z ) <nl> z_crop = z_crop . transpose ( 2 , 0 , 1 ) . reshape ( 1 , 3 , 127 , 127 ) . astype ( np . float32 ) <nl> self . net . setInput ( z_crop ) <nl> z_f = self . net . forward ( ' 63 ' ) <nl> - kernel_r1 . setInput ( z_f ) <nl> - r1 = kernel_r1 . forward ( ) <nl> - kernel_cls1 . setInput ( z_f ) <nl> - cls1 = kernel_cls1 . forward ( ) <nl> + self . kernel_r1 . setInput ( z_f ) <nl> + r1 = self . kernel_r1 . forward ( ) <nl> + self . kernel_cls1 . setInput ( z_f ) <nl> + cls1 = self . kernel_cls1 . forward ( ) <nl> r1 = r1 . reshape ( 20 , 256 , 4 , 4 ) <nl> cls1 = cls1 . reshape ( 10 , 256 , 4 , 4 ) <nl> self . net . setParam ( self . net . getLayerId ( ' 65 ' ) , 0 , r1 ) <nl> self . net . setParam ( self . net . getLayerId ( ' 68 ' ) , 0 , cls1 ) <nl> <nl> - if self . windowing = = " cosine " : <nl> - self . window = np . outer ( np . hanning ( self . score_size ) , np . hanning ( self . score_size ) ) <nl> - elif self . windowing = = " uniform " : <nl> - self . window = np . ones ( ( self . score_size , self . score_size ) ) <nl> - self . window = np . tile ( self . window . flatten ( ) , self . anchor_num ) <nl> - <nl> - # creating anchor for tracking bounding box <nl> + # Сreating anchor for tracking bounding box <nl> def __generate_anchor ( self ) : <nl> self . anchor = np . zeros ( ( self . anchor_num , 4 ) , dtype = np . float32 ) <nl> size = self . total_stride * self . total_stride <nl> def __generate_anchor ( self ) : <nl> self . anchor [ : , 0 ] , self . anchor [ : , 1 ] = xx . astype ( np . float32 ) , yy . astype ( np . float32 ) <nl> return self . anchor <nl> <nl> - # track function <nl> - def track ( self , im ) : <nl> + # Function for updating tracker state <nl> + def update ( self , im ) : <nl> wc_z = self . target_sz [ 1 ] + self . context_amount * sum ( self . target_sz ) <nl> hc_z = self . target_sz [ 0 ] + self . context_amount * sum ( self . target_sz ) <nl> s_z = np . sqrt ( wc_z * hc_z ) <nl> def track ( self , im ) : <nl> pad = d_search / scale_z <nl> s_x = round ( s_z + 2 * pad ) <nl> <nl> - # region preprocessing <nl> + # Region preprocessing part <nl> x_crop = self . __get_subwindow_tracking ( im , self . instance_size , s_x ) <nl> x_crop = x_crop . transpose ( 2 , 0 , 1 ) . reshape ( 1 , 3 , 271 , 271 ) . astype ( np . float32 ) <nl> self . score = self . __tracker_eval ( x_crop , scale_z ) <nl> def track ( self , im ) : <nl> self . target_sz [ 0 ] = max ( 10 , min ( self . im_w , self . target_sz [ 0 ] ) ) <nl> self . target_sz [ 1 ] = max ( 10 , min ( self . im_h , self . target_sz [ 1 ] ) ) <nl> <nl> - # update bounding box position <nl> + cx , cy = self . target_pos <nl> + w , h = self . target_sz <nl> + updated_bb = ( cx , cy , w , h ) <nl> + return True , updated_bb <nl> + <nl> + # Function for updating position of the bounding box <nl> def __tracker_eval ( self , x_crop , scale_z ) : <nl> target_size = self . target_sz * scale_z <nl> self . net . setInput ( x_crop ) <nl> def __softmax ( self , x ) : <nl> y = e_x / e_x . sum ( axis = 0 ) <nl> return y <nl> <nl> - # evaluations with cropped image <nl> + # Reshaping cropped image for using in the model <nl> def __get_subwindow_tracking ( self , im , model_size , original_sz ) : <nl> im_sz = im . shape <nl> c = ( original_sz + 1 ) / 2 <nl> def __get_subwindow_tracking ( self , im , model_size , original_sz ) : <nl> left_pad = int ( max ( 0 . , - context_xmin ) ) <nl> top_pad = int ( max ( 0 . , - context_ymin ) ) <nl> right_pad = int ( max ( 0 . , context_xmax - im_sz [ 1 ] + 1 ) ) <nl> - bottom_pad = int ( max ( 0 . , context_ymax - im_sz [ 0 ] + 1 ) ) <nl> + bot_pad = int ( max ( 0 . , context_ymax - im_sz [ 0 ] + 1 ) ) <nl> context_xmin + = left_pad <nl> context_xmax + = left_pad <nl> context_ymin + = top_pad <nl> context_ymax + = top_pad <nl> r , c , k = im . shape <nl> <nl> - if any ( [ top_pad , bottom_pad , left_pad , right_pad ] ) : <nl> - te_im = np . zeros ( ( r + top_pad + bottom_pad , c + left_pad + right_pad , k ) , np . uint8 ) <nl> + if any ( [ top_pad , bot_pad , left_pad , right_pad ] ) : <nl> + te_im = np . zeros ( ( <nl> + r + top_pad + bot_pad , c + left_pad + right_pad , k ) , np . uint8 ) <nl> te_im [ top_pad : top_pad + r , left_pad : left_pad + c , : ] = im <nl> if top_pad : <nl> te_im [ 0 : top_pad , left_pad : left_pad + c , : ] = self . avg_chans <nl> - if bottom_pad : <nl> + if bot_pad : <nl> te_im [ r + top_pad : , left_pad : left_pad + c , : ] = self . avg_chans <nl> if left_pad : <nl> te_im [ : , 0 : left_pad , : ] = self . avg_chans <nl> def __get_subwindow_tracking ( self , im , model_size , original_sz ) : <nl> <nl> if not np . array_equal ( model_size , original_sz ) : <nl> im_patch_original = cv . resize ( im_patch_original , ( model_size , model_size ) ) <nl> - <nl> return im_patch_original <nl> <nl> - # function for reading paths , bounding box drawing , showing results <nl> + # Sample for using DaSiamRPN tracker <nl> def main ( ) : <nl> parser = argparse . ArgumentParser ( description = " Run tracker " ) <nl> + parser . add_argument ( " - - input " , type = str , help = " Full path to input ( empty for camera ) " ) <nl> parser . add_argument ( " - - net " , type = str , default = " dasiamrpn_model . onnx " , help = " Full path to onnx model of net " ) <nl> parser . add_argument ( " - - kernel_r1 " , type = str , default = " dasiamrpn_kernel_r1 . onnx " , help = " Full path to onnx model of kernel_r1 " ) <nl> parser . add_argument ( " - - kernel_cls1 " , type = str , default = " dasiamrpn_kernel_cls1 . onnx " , help = " Full path to onnx model of kernel_cls1 " ) <nl> - parser . add_argument ( " - - input " , type = str , help = " Full path to input . Do not use if input is camera " ) <nl> args = parser . parse_args ( ) <nl> point1 = ( ) <nl> point2 = ( ) <nl> mark = True <nl> drawing = False <nl> cx , cy , w , h = 0 . 0 , 0 . 0 , 0 , 0 <nl> - <nl> + # Fucntion for drawing during videostream <nl> def get_bb ( event , x , y , flag , param ) : <nl> nonlocal point1 , point2 , cx , cy , w , h , drawing , mark <nl> <nl> def get_bb ( event , x , y , flag , param ) : <nl> h = abs ( point1 [ 1 ] - point2 [ 1 ] ) <nl> mark = False <nl> <nl> - # loading network ` s and kernel ` s models <nl> - net = cv . dnn . readNet ( args . net ) <nl> - kernel_r1 = cv . dnn . readNet ( args . kernel_r1 ) <nl> - kernel_cls1 = cv . dnn . readNet ( args . kernel_cls1 ) <nl> - <nl> - # initializing bounding box <nl> + # Creating window for visualization <nl> cap = cv . VideoCapture ( args . input if args . input else 0 ) <nl> cv . namedWindow ( " DaSiamRPN " ) <nl> cv . setMouseCallback ( " DaSiamRPN " , get_bb ) <nl> def get_bb ( event , x , y , flag , param ) : <nl> cv . imshow ( " DaSiamRPN " , twin ) <nl> cv . waitKey ( 40 ) <nl> <nl> - target_pos , target_sz = np . array ( [ cx , cy ] ) , np . array ( [ w , h ] ) <nl> - tracker = DaSiamRPNTracker ( frame , target_pos , target_sz , net , kernel_r1 , kernel_cls1 ) <nl> + init_bb = ( cx , cy , w , h ) <nl> + tracker = DaSiamRPNTracker ( args . net , args . kernel_r1 , args . kernel_cls1 ) <nl> + tracker . init ( frame , init_bb ) <nl> <nl> - # tracking loop <nl> + # Tracking loop <nl> while cap . isOpened ( ) : <nl> has_frame , frame = cap . read ( ) <nl> if not has_frame : <nl> sys . exit ( 0 ) <nl> - tracker . track ( frame ) <nl> - w , h = tracker . target_sz <nl> - cx , cy = tracker . target_pos <nl> + _ , new_bb = tracker . update ( frame ) <nl> + cx , cy , w , h = new_bb <nl> cv . rectangle ( frame , ( int ( cx - w / / 2 ) , int ( cy - h / / 2 ) ) , ( int ( cx - w / / 2 ) + int ( w ) , int ( cy - h / / 2 ) + int ( h ) ) , ( 0 , 255 , 255 ) , 3 ) <nl> cv . imshow ( " DaSiamRPN " , frame ) <nl> key = cv . waitKey ( 1 ) <nl>
|
Merge remote - tracking branch ' upstream / 3 . 4 ' into merge - 3 . 4
|
opencv/opencv
|
b45273eccb01323f5615b8900fd35407b1148939
|
2020-08-14T19:45:45Z
|
mmm a / src / python / grpcio / grpc / experimental / aio / _channel . py <nl> ppp b / src / python / grpcio / grpc / experimental / aio / _channel . py <nl> def __call__ ( self , <nl> if not self . _interceptors : <nl> return UnaryUnaryCall ( <nl> request , <nl> - _timeout_to_deadline ( self . _loop , timeout ) , <nl> + _timeout_to_deadline ( timeout ) , <nl> self . _channel , <nl> self . _method , <nl> self . _request_serializer , <nl> def __call__ ( self , <nl> if compression : <nl> raise NotImplementedError ( " TODO : compression not implemented yet " ) <nl> <nl> - deadline = _timeout_to_deadline ( self . _loop , timeout ) <nl> + deadline = _timeout_to_deadline ( timeout ) <nl> <nl> return UnaryStreamCall ( <nl> request , <nl> mmm a / src / python / grpcio / grpc / experimental / aio / _interceptor . py <nl> ppp b / src / python / grpcio / grpc / experimental / aio / _interceptor . py <nl> async def _run_interceptor ( <nl> else : <nl> return UnaryUnaryCall ( <nl> request , <nl> - _timeout_to_deadline ( self . _loop , <nl> - client_call_details . timeout ) , <nl> + _timeout_to_deadline ( client_call_details . timeout ) , <nl> self . _channel , client_call_details . method , <nl> request_serializer , response_deserializer ) <nl> <nl> mmm a / src / python / grpcio / grpc / experimental / aio / _utils . py <nl> ppp b / src / python / grpcio / grpc / experimental / aio / _utils . py <nl> <nl> # See the License for the specific language governing permissions and <nl> # limitations under the License . <nl> " " " Internal utilities used by the gRPC Aio module . " " " <nl> - import asyncio <nl> import time <nl> from typing import Optional <nl> <nl> <nl> - def _timeout_to_deadline ( loop : asyncio . AbstractEventLoop , <nl> - timeout : Optional [ float ] ) - > Optional [ float ] : <nl> + def _timeout_to_deadline ( timeout : Optional [ float ] ) - > Optional [ float ] : <nl> if timeout is None : <nl> return None <nl> return time . time ( ) + timeout <nl>
|
Remove unused loop parameter
|
grpc/grpc
|
69884f7d848052747c7f1cb58be7cf822c6ea2dd
|
2020-01-08T23:07:15Z
|
mmm a / include / swift / AST / ASTScope . h <nl> ppp b / include / swift / AST / ASTScope . h <nl> class AbstractFunctionBodyScope : public ASTScopeImpl { <nl> } <nl> virtual NullablePtr < Decl > getDeclIfAny ( ) const override { return decl ; } <nl> Decl * getDecl ( ) const { return decl ; } <nl> - static bool isAMethod ( const AbstractFunctionDecl * ) ; <nl> <nl> NullablePtr < ASTScopeImpl > getParentOfASTAncestorScopesToBeRescued ( ) override ; <nl> <nl> class AbstractFunctionBodyScope : public ASTScopeImpl { <nl> SourceRange sourceRangeForDeferredExpansion ( ) const override ; <nl> } ; <nl> <nl> - / / / Body of methods , functions in types . <nl> - class MethodBodyScope final : public AbstractFunctionBodyScope { <nl> + / / / Body of functions and methods . <nl> + class FunctionBodyScope final : public AbstractFunctionBodyScope { <nl> public : <nl> - MethodBodyScope ( AbstractFunctionDecl * e ) : AbstractFunctionBodyScope ( e ) { } <nl> - std : : string getClassName ( ) const override ; <nl> - bool lookupLocalsOrMembers ( ArrayRef < const ASTScopeImpl * > , <nl> - DeclConsumer consumer ) const override ; <nl> - <nl> - Optional < NullablePtr < DeclContext > > computeSelfDCForParent ( ) const override ; <nl> - } ; <nl> - <nl> - / / / Body of " pure " functions , functions without an implicit " self " . <nl> - class PureFunctionBodyScope final : public AbstractFunctionBodyScope { <nl> - public : <nl> - PureFunctionBodyScope ( AbstractFunctionDecl * e ) <nl> + FunctionBodyScope ( AbstractFunctionDecl * e ) <nl> : AbstractFunctionBodyScope ( e ) { } <nl> std : : string getClassName ( ) const override ; <nl> bool lookupLocalsOrMembers ( ArrayRef < const ASTScopeImpl * > , <nl> DeclConsumer consumer ) const override ; <nl> + Optional < NullablePtr < DeclContext > > computeSelfDCForParent ( ) const override ; <nl> } ; <nl> <nl> class DefaultArgumentInitializerScope final : public ASTScopeImpl { <nl> mmm a / lib / AST / ASTScope . cpp <nl> ppp b / lib / AST / ASTScope . cpp <nl> Stmt * LabeledConditionalStmtScope : : getStmt ( ) const { <nl> return getLabeledConditionalStmt ( ) ; <nl> } <nl> <nl> - bool AbstractFunctionBodyScope : : isAMethod ( <nl> - const AbstractFunctionDecl * const afd ) { <nl> - / / What makes this interesting is that a method named " init " which is not <nl> - / / in a nominal type or extension decl body still gets an implicit self <nl> - / / parameter ( even though the program is illegal ) . <nl> - / / So when choosing between creating a MethodBodyScope and a <nl> - / / PureFunctionBodyScope do we go by the enclosing Decl ( i . e . <nl> - / / " afd - > getDeclContext ( ) - > isTypeContext ( ) " ) or by <nl> - / / " bool ( afd - > getImplicitSelfDecl ( ) ) " ? <nl> - / / <nl> - / / Since the code uses \ c getImplicitSelfDecl , use that . <nl> - return afd - > getImplicitSelfDecl ( ) ; <nl> - } <nl> - <nl> # pragma mark getLabeledConditionalStmt <nl> LabeledConditionalStmt * IfStmtScope : : getLabeledConditionalStmt ( ) const { <nl> return stmt ; <nl> DEFINE_GET_CLASS_NAME ( ASTSourceFileScope ) <nl> DEFINE_GET_CLASS_NAME ( GenericParamScope ) <nl> DEFINE_GET_CLASS_NAME ( AbstractFunctionDeclScope ) <nl> DEFINE_GET_CLASS_NAME ( ParameterListScope ) <nl> - DEFINE_GET_CLASS_NAME ( MethodBodyScope ) <nl> - DEFINE_GET_CLASS_NAME ( PureFunctionBodyScope ) <nl> + DEFINE_GET_CLASS_NAME ( FunctionBodyScope ) <nl> DEFINE_GET_CLASS_NAME ( DefaultArgumentInitializerScope ) <nl> DEFINE_GET_CLASS_NAME ( AttachedPropertyWrapperScope ) <nl> DEFINE_GET_CLASS_NAME ( PatternEntryDeclScope ) <nl> mmm a / lib / AST / ASTScopeCreation . cpp <nl> ppp b / lib / AST / ASTScopeCreation . cpp <nl> void AbstractFunctionDeclScope : : expandAScopeThatDoesNotCreateANewInsertionPoint ( <nl> / / We create body scopes when there is no body for source kit to complete <nl> / / erroneous code in bodies . <nl> if ( decl - > getBodySourceRange ( ) . isValid ( ) ) { <nl> - if ( AbstractFunctionBodyScope : : isAMethod ( decl ) ) <nl> - scopeCreator . constructExpandAndInsertUncheckable < MethodBodyScope > ( leaf , <nl> + scopeCreator . constructExpandAndInsertUncheckable < FunctionBodyScope > ( leaf , <nl> decl ) ; <nl> - else <nl> - scopeCreator . constructExpandAndInsertUncheckable < PureFunctionBodyScope > ( <nl> - leaf , decl ) ; <nl> } <nl> } <nl> <nl> mmm a / lib / AST / ASTScopeLookup . cpp <nl> ppp b / lib / AST / ASTScopeLookup . cpp <nl> bool AbstractFunctionBodyScope : : lookupLocalsOrMembers ( <nl> return false ; <nl> } <nl> <nl> - bool MethodBodyScope : : lookupLocalsOrMembers ( <nl> + bool FunctionBodyScope : : lookupLocalsOrMembers ( <nl> ArrayRef < const ASTScopeImpl * > history , DeclConsumer consumer ) const { <nl> - ASTScopeAssert ( isAMethod ( decl ) , " Asking for members of a non - method . " ) ; <nl> if ( AbstractFunctionBodyScope : : lookupLocalsOrMembers ( history , consumer ) ) <nl> return true ; <nl> - return consumer . consume ( { decl - > getImplicitSelfDecl ( ) } , <nl> - DeclVisibilityKind : : FunctionParameter ) ; <nl> - } <nl> <nl> - bool PureFunctionBodyScope : : lookupLocalsOrMembers ( <nl> - ArrayRef < const ASTScopeImpl * > history , DeclConsumer consumer ) const { <nl> - ASTScopeAssert ( <nl> - ! isAMethod ( decl ) , <nl> - " Should have called lookupLocalsOrMembers instead of this function . " ) ; <nl> - if ( AbstractFunctionBodyScope : : lookupLocalsOrMembers ( history , consumer ) ) <nl> - return true ; <nl> + if ( decl - > getDeclContext ( ) - > isTypeContext ( ) ) { <nl> + return consumer . consume ( { decl - > getImplicitSelfDecl ( ) } , <nl> + DeclVisibilityKind : : FunctionParameter ) ; <nl> + } <nl> <nl> / / Consider \ c var t : T { ( did / will / ) get / set { . . . t } } <nl> / / Lookup needs to find t , but if the var is inside of a type the baseDC needs <nl> bool PureFunctionBodyScope : : lookupLocalsOrMembers ( <nl> if ( consumer . consume ( { storage } , DeclVisibilityKind : : LocalVariable ) ) <nl> return true ; <nl> } <nl> + <nl> return false ; <nl> } <nl> <nl> PatternEntryInitializerScope : : computeSelfDCForParent ( ) const { <nl> } <nl> <nl> Optional < NullablePtr < DeclContext > > <nl> - MethodBodyScope : : computeSelfDCForParent ( ) const { <nl> - return NullablePtr < DeclContext > ( decl ) ; <nl> + FunctionBodyScope : : computeSelfDCForParent ( ) const { <nl> + if ( decl - > getDeclContext ( ) - > isTypeContext ( ) ) <nl> + return NullablePtr < DeclContext > ( decl ) ; <nl> + return None ; <nl> } <nl> <nl> # pragma mark capturedSelfDC <nl> mmm a / lib / Sema / TypeCheckNameLookup . cpp <nl> ppp b / lib / Sema / TypeCheckNameLookup . cpp <nl> LookupResult TypeChecker : : lookupUnqualified ( DeclContext * dc , DeclNameRef name , <nl> if ( ! typeDC - > isTypeContext ( ) ) { <nl> / / If we don ' t have a type context this is an implicit ' self ' reference . <nl> if ( auto * CE = dyn_cast < ClosureExpr > ( typeDC ) ) { <nl> - / / If we found the result in a self capture , look through the capture . <nl> - assert ( CE - > getCapturedSelfDecl ( ) ) ; <nl> - typeDC = found . getValueDecl ( ) - > getDeclContext ( ) ; <nl> + typeDC = typeDC - > getInnermostTypeContext ( ) ; <nl> } else { <nl> / / Otherwise , we must have the method context . <nl> typeDC = typeDC - > getParent ( ) ; <nl> mmm a / test / NameLookup / scope_map_top_level . swift <nl> ppp b / test / NameLookup / scope_map_top_level . swift <nl> var i : Int = b . my_identity ( ) <nl> / / CHECK - EXPANDED - NEXT : ` - LookupParentDiversionScope , [ 9 : 1 - 21 : 28 ] <nl> / / CHECK - EXPANDED - NEXT : | - AbstractFunctionDeclScope { { . * } } , [ 11 : 1 - 11 : 13 ] ' foo ( ) ' <nl> / / CHECK - EXPANDED - NEXT : ` - ParameterListScope { { . * } } , [ 11 : 9 - 11 : 13 ] <nl> - / / CHECK - EXPANDED - NEXT : ` - PureFunctionBodyScope { { . * } } , [ 11 : 12 - 11 : 13 ] <nl> + / / CHECK - EXPANDED - NEXT : ` - FunctionBodyScope { { . * } } , [ 11 : 12 - 11 : 13 ] <nl> / / CHECK - EXPANDED - NEXT : ` - BraceStmtScope { { . * } } , [ 11 : 12 - 11 : 13 ] <nl> / / CHECK - EXPANDED - NEXT : ` - TopLevelCodeScope { { . * } } , [ 13 : 1 - 21 : 28 ] <nl> / / CHECK - EXPANDED - NEXT : ` - BraceStmtScope { { . * } } , [ 13 : 1 - 21 : 28 ] <nl> var i : Int = b . my_identity ( ) <nl> / / CHECK - EXPANDED - NEXT : ` - ExtensionBodyScope { { . * } } , [ 17 : 15 - 19 : 1 ] <nl> / / CHECK - EXPANDED - NEXT : ` - AbstractFunctionDeclScope { { . * } } , [ 18 : 3 - 18 : 43 ] ' my_identity ( ) ' <nl> / / CHECK - EXPANDED - NEXT : ` - ParameterListScope { { . * } } , [ 18 : 19 - 18 : 43 ] <nl> - / / CHECK - EXPANDED - NEXT : ` - MethodBodyScope { { . * } } , [ 18 : 29 - 18 : 43 ] <nl> + / / CHECK - EXPANDED - NEXT : ` - FunctionBodyScope { { . * } } , [ 18 : 29 - 18 : 43 ] <nl> / / CHECK - EXPANDED - NEXT : ` - BraceStmtScope { { . * } } , [ 18 : 29 - 18 : 43 ] <nl> / / CHECK - EXPANDED - NEXT : ` - TopLevelCodeScope { { . * } } , [ 21 : 1 - 21 : 28 ] <nl> / / CHECK - EXPANDED - NEXT : ` - BraceStmtScope { { . * } } , [ 21 : 1 - 21 : 28 ] <nl>
|
ASTScope : Collapse PureFunctionBodyScope and MethodBodyScope
|
apple/swift
|
9b851bf8cb0173ed0fc568ac7e30cbd5104d747d
|
2020-09-18T19:05:48Z
|
mmm a / . gitignore <nl> ppp b / . gitignore <nl> <nl> . * . swp <nl> . tags <nl> . cscope <nl> + cscope . files <nl> + cscope . out <nl> build <nl> src / quickrun_rethinkdb <nl> src / debug_rethinkdb <nl>
|
add cscope files generated by emacs to . gitignore
|
rethinkdb/rethinkdb
|
99770e3e25834aff2eca138ab15cd5569826ef14
|
2011-07-07T22:45:21Z
|
mmm a / lib / IRGen / GenUnion . cpp <nl> ppp b / lib / IRGen / GenUnion . cpp <nl> namespace { <nl> <nl> / / / \ group Indirect union operations <nl> <nl> - / * TODO <nl> / / / Project the address of the data for a case . Does not check or modify <nl> / / / the referenced union value . <nl> / / / Corresponds to the SIL ' union_data_addr ' instruction . <nl> namespace { <nl> UnionElementDecl * elt , <nl> Address unionAddr ) const = 0 ; <nl> <nl> + / * TODO <nl> / / / Emit a branch on the case contained by a union in memory . <nl> / / / Performs the branching for a SIL ' destructive_switch_union_addr ' <nl> / / / instruction . <nl> virtual void emitAddressSwitch ( IRGenFunction & IGF , <nl> Address unionAddr , <nl> ArrayRef < std : : pair < UnionElementDecl * , <nl> - llvm : : BasicBlock * > > dests , <nl> + llvm : : BasicBlock * > > dests , <nl> llvm : : BasicBlock * defaultDest ) const = 0 ; <nl> <nl> / / / Clears tag bits from within the payload of a union in memory and <nl> namespace { <nl> getLoadableSingleton ( ) - > reexplode ( IGF , params , out ) ; <nl> } <nl> <nl> + Address projectDataForStore ( IRGenFunction & IGF , <nl> + UnionElementDecl * elt , <nl> + Address unionAddr ) const override { <nl> + return getSingletonAddress ( IGF , unionAddr ) ; <nl> + } <nl> + <nl> + void storeTag ( IRGenFunction & IGF , <nl> + UnionElementDecl * elt , <nl> + Address unionAddr ) const override { <nl> + / / No tag , nothing to do . <nl> + } <nl> + <nl> void getSchema ( ExplosionSchema & schema ) const { <nl> if ( getSingleton ( ) ) getSingleton ( ) - > getSchema ( schema ) ; <nl> } <nl> namespace { <nl> out . add ( getDiscriminatorIndex ( elt ) ) ; <nl> } <nl> <nl> + Address projectDataForStore ( IRGenFunction & IGF , <nl> + UnionElementDecl * elt , <nl> + Address unionAddr ) const override { <nl> + llvm_unreachable ( " cannot project data for no - payload cases " ) ; <nl> + } <nl> + <nl> + void storeTag ( IRGenFunction & IGF , UnionElementDecl * elt , Address unionAddr ) <nl> + const override { <nl> + llvm : : Value * discriminator = getDiscriminatorIndex ( elt ) ; <nl> + Address discriminatorAddr <nl> + = IGF . Builder . CreateStructGEP ( unionAddr , 0 , Size ( 0 ) ) ; <nl> + IGF . Builder . CreateStore ( discriminator , discriminatorAddr ) ; <nl> + } <nl> + <nl> / / / \ group Required for SingleScalarTypeInfo <nl> <nl> llvm : : Type * getScalarType ( ) const { <nl> namespace { <nl> getPayloadTypeInfo ( ) . getStorageType ( ) - > getPointerTo ( ) ) ; <nl> } <nl> <nl> + Address projectDataForStore ( IRGenFunction & IGF , UnionElementDecl * elt , <nl> + Address unionAddr ) const override { <nl> + assert ( elt = = getPayloadElement ( ) & & " cannot project no - data case " ) ; <nl> + return projectPayloadData ( IGF , unionAddr ) ; <nl> + } <nl> + <nl> Size getExtraTagBitOffset ( ) const override { <nl> return getFixedPayloadTypeInfo ( ) . getFixedSize ( ) ; <nl> } <nl> namespace { <nl> llvm_unreachable ( " element was not a member of union " ) ; <nl> } <nl> <nl> - void addExtraTagBitValue ( IRGenFunction & IGF , <nl> - Explosion & out , unsigned value ) const { <nl> - if ( ExtraTagBitCount > 0 ) { <nl> - llvm : : Value * zeroTagBits <nl> - = llvm : : ConstantInt : : get ( IGF . IGM . getLLVMContext ( ) , <nl> - APInt ( ExtraTagBitCount , value ) ) ; <nl> - out . add ( zeroTagBits ) ; <nl> - return ; <nl> - } <nl> - assert ( value = = 0 & & " setting non - zero extra tag value with no tag bits " ) ; <nl> - } <nl> - <nl> - public : <nl> - void emitValueInjection ( IRGenFunction & IGF , <nl> - UnionElementDecl * elt , <nl> - Explosion & params , <nl> - Explosion & out ) const { <nl> - / / The payload case gets its native representation . If there are extra <nl> - / / tag bits , set them to zero . <nl> + / / Get the payload and extra tag ( if any ) parts of the discriminator for <nl> + / / a no - data case . <nl> + std : : pair < llvm : : Value * , llvm : : Value * > <nl> + getNoPayloadCaseValue ( IRGenFunction & IGF , UnionElementDecl * elt ) const { <nl> + assert ( elt ! = getPayloadElement ( ) ) ; <nl> + <nl> unsigned payloadSize <nl> = getFixedPayloadTypeInfo ( ) . getFixedSize ( ) . getValueInBits ( ) ; <nl> <nl> - if ( elt = = getPayloadElement ( ) ) { <nl> - auto & loadablePayloadTI = getLoadablePayloadTypeInfo ( ) ; <nl> - llvm : : Value * payload <nl> - = loadablePayloadTI . packUnionPayload ( IGF , params , payloadSize , 0 ) ; <nl> - out . add ( payload ) ; <nl> - <nl> - addExtraTagBitValue ( IGF , out , 0 ) ; <nl> - return ; <nl> - } <nl> - <nl> / / Non - payload cases use extra inhabitants , if any , or are discriminated <nl> / / by setting the tag bits . <nl> unsigned tagIndex = getSimpleElementTagIndex ( elt ) ; <nl> namespace { <nl> unsigned extraTagValue ; <nl> if ( tagIndex < numExtraInhabitants ) { <nl> payload = getFixedPayloadTypeInfo ( ) . getFixedExtraInhabitantValue ( <nl> - IGF . IGM , payloadSize , tagIndex ) ; <nl> + IGF . IGM , payloadSize , tagIndex ) ; <nl> extraTagValue = 0 ; <nl> } else { <nl> tagIndex - = numExtraInhabitants ; <nl> namespace { <nl> payload = llvm : : ConstantInt : : get ( IGF . IGM . getLLVMContext ( ) , <nl> APInt ( payloadSize , payloadValue ) ) ; <nl> } <nl> + <nl> + llvm : : Value * extraTag = nullptr ; <nl> + if ( ExtraTagBitCount > 0 ) { <nl> + extraTag = llvm : : ConstantInt : : get ( IGF . IGM . getLLVMContext ( ) , <nl> + APInt ( ExtraTagBitCount , extraTagValue ) ) ; <nl> + } else { <nl> + assert ( extraTagValue = = 0 & & <nl> + " non - zero extra tag value with no tag bits " ) ; <nl> + } <nl> + return { payload , extraTag } ; <nl> + } <nl> + <nl> + public : <nl> + void emitValueInjection ( IRGenFunction & IGF , <nl> + UnionElementDecl * elt , <nl> + Explosion & params , <nl> + Explosion & out ) const { <nl> + / / The payload case gets its native representation . If there are extra <nl> + / / tag bits , set them to zero . <nl> + unsigned payloadSize <nl> + = getFixedPayloadTypeInfo ( ) . getFixedSize ( ) . getValueInBits ( ) ; <nl> + <nl> + if ( elt = = getPayloadElement ( ) ) { <nl> + auto & loadablePayloadTI = getLoadablePayloadTypeInfo ( ) ; <nl> + llvm : : Value * payload <nl> + = loadablePayloadTI . packUnionPayload ( IGF , params , payloadSize , 0 ) ; <nl> + out . add ( payload ) ; <nl> + <nl> + if ( ExtraTagBitCount > 0 ) <nl> + out . add ( getZeroExtraTagConstant ( IGF . IGM ) ) ; <nl> + return ; <nl> + } <nl> <nl> + / / Non - payload cases use extra inhabitants , if any , or are discriminated <nl> + / / by setting the tag bits . <nl> + llvm : : Value * payload , * extraTag ; <nl> + std : : tie ( payload , extraTag ) = getNoPayloadCaseValue ( IGF , elt ) ; <nl> out . add ( payload ) ; <nl> - addExtraTagBitValue ( IGF , out , extraTagValue ) ; <nl> + if ( ExtraTagBitCount > 0 ) { <nl> + assert ( extraTag ) ; <nl> + out . add ( extraTag ) ; <nl> + } <nl> } <nl> <nl> private : <nl> namespace { <nl> IGF . Builder . CreateStore ( extraTag , projectExtraTagBits ( IGF , dest ) ) ; <nl> } <nl> <nl> + llvm : : ConstantInt * getZeroExtraTagConstant ( IRGenModule & IGM ) const { <nl> + assert ( ExtraTagBitCount > 0 & & " no extra tag bits ? ! " ) ; <nl> + return llvm : : ConstantInt : : get ( IGM . getLLVMContext ( ) , <nl> + APInt ( ExtraTagBitCount , 0 ) ) ; <nl> + } <nl> + <nl> / / / Emit an reassignment sequence from a union at one address to another . <nl> void emitIndirectAssign ( IRGenFunction & IGF , <nl> Address dest , Address src , <nl> namespace { <nl> / / the zero extra tag ( if any ) . <nl> ( getPayloadTypeInfo ( ) . * initializeData ) ( IGF , destData , srcData ) ; <nl> if ( ExtraTagBitCount > 0 ) { <nl> - auto * zeroTag = llvm : : ConstantInt : : get ( <nl> - cast < llvm : : IntegerType > ( srcExtraTag - > getType ( ) ) , 0 ) ; <nl> + auto * zeroTag = getZeroExtraTagConstant ( IGF . IGM ) ; <nl> IGF . Builder . CreateStore ( zeroTag , projectExtraTagBits ( IGF , dest ) ) ; <nl> } <nl> IGF . Builder . CreateBr ( endBB ) ; <nl> namespace { <nl> / / it , and set the extra tag if any to zero . <nl> ( getPayloadTypeInfo ( ) . * initializeData ) ( IGF , destData , srcData ) ; <nl> if ( ExtraTagBitCount > 0 ) { <nl> - auto * zeroTag = llvm : : ConstantInt : : get ( <nl> - cast < llvm : : IntegerType > ( srcExtraTag - > getType ( ) ) , 0 ) ; <nl> + auto * zeroTag = getZeroExtraTagConstant ( IGF . IGM ) ; <nl> IGF . Builder . CreateStore ( zeroTag , projectExtraTagBits ( IGF , dest ) ) ; <nl> } <nl> IGF . Builder . CreateBr ( endBB ) ; <nl> namespace { <nl> emitIndirectInitialize ( IGF , dest , src , <nl> & TypeInfo : : initializeWithTake ) ; <nl> } <nl> + <nl> + void storeTag ( IRGenFunction & IGF , <nl> + UnionElementDecl * elt , <nl> + Address unionAddr ) const override { <nl> + if ( elt = = getPayloadElement ( ) ) { <nl> + / / The data occupies the entire payload . If we have extra tag bits , <nl> + / / zero them out . <nl> + if ( ExtraTagBitCount > 0 ) <nl> + IGF . Builder . CreateStore ( getZeroExtraTagConstant ( IGF . IGM ) , <nl> + projectExtraTagBits ( IGF , unionAddr ) ) ; <nl> + return ; <nl> + } <nl> + <nl> + / / Store the discriminator for the no - payload case . <nl> + llvm : : Value * payload , * extraTag ; <nl> + std : : tie ( payload , extraTag ) = getNoPayloadCaseValue ( IGF , elt ) ; <nl> + <nl> + IGF . Builder . CreateStore ( payload , projectPayload ( IGF , unionAddr ) ) ; <nl> + if ( ExtraTagBitCount > 0 ) <nl> + IGF . Builder . CreateStore ( extraTag , projectExtraTagBits ( IGF , unionAddr ) ) ; <nl> + } <nl> } ; <nl> <nl> class MultiPayloadUnionImplStrategy : public PayloadUnionImplStrategyBase { <nl> / / The spare bits shared by all payloads , if any . <nl> - / / Invariant : The size of the bit <nl> - / / vector is the size of the payload in bits , rounded up to a byte boundary . <nl> + / / Invariant : The size of the bit vector is the size of the payload in bits , <nl> + / / rounded up to a byte boundary . <nl> llvm : : BitVector CommonSpareBits ; <nl> <nl> / / The number of tag values used for no - payload cases . <nl> namespace { <nl> return APInt ( bits . size ( ) , parts ) ; <nl> } <nl> <nl> - void projectPayload ( IRGenFunction & IGF , <nl> + void projectPayloadValue ( IRGenFunction & IGF , <nl> llvm : : Value * payload , <nl> unsigned payloadTag , <nl> const LoadableTypeInfo & payloadTI , <nl> namespace { <nl> inValue . claimNext ( ) ; <nl> <nl> / / Unpack the payload . <nl> - projectPayload ( IGF , payload , foundPayload - ElementsWithPayload . begin ( ) , <nl> + projectPayloadValue ( IGF , payload , <nl> + foundPayload - ElementsWithPayload . begin ( ) , <nl> cast < LoadableTypeInfo > ( * foundPayload - > ti ) , out ) ; <nl> } <nl> <nl> namespace { <nl> } <nl> } <nl> <nl> - void emitValueInjection ( IRGenFunction & IGF , <nl> - UnionElementDecl * elt , <nl> - Explosion & params , <nl> - Explosion & out ) const { <nl> - / / See whether this is a payload or empty case we ' re emitting . <nl> - auto payloadI = std : : find_if ( ElementsWithPayload . begin ( ) , <nl> - ElementsWithPayload . end ( ) , <nl> - [ & ] ( const Element & e ) { return e . decl = = elt ; } ) ; <nl> - if ( payloadI ! = ElementsWithPayload . end ( ) ) { <nl> - return emitPayloadInjection ( IGF , elt , <nl> - cast < FixedTypeInfo > ( * payloadI - > ti ) , <nl> - params , out , <nl> - payloadI - ElementsWithPayload . begin ( ) ) ; <nl> - } <nl> - auto emptyI = std : : find_if ( ElementsWithNoPayload . begin ( ) , <nl> - ElementsWithNoPayload . end ( ) , <nl> - [ & ] ( const Element & e ) { return e . decl = = elt ; } ) ; <nl> - assert ( emptyI ! = ElementsWithNoPayload . end ( ) & & " case not in union " ) ; <nl> - emitEmptyInjection ( IGF , out , emptyI - ElementsWithNoPayload . begin ( ) ) ; <nl> - } <nl> - <nl> private : <nl> - void emitPayloadInjection ( IRGenFunction & IGF , UnionElementDecl * elt , <nl> + void emitPayloadInjection ( IRGenFunction & IGF , <nl> const FixedTypeInfo & payloadTI , <nl> Explosion & params , Explosion & out , <nl> unsigned tag ) const { <nl> / / Pack the payload . <nl> auto & loadablePayloadTI = cast < LoadableTypeInfo > ( payloadTI ) ; / / FIXME <nl> llvm : : Value * payload = loadablePayloadTI . packUnionPayload ( IGF , params , <nl> - CommonSpareBits . size ( ) , 0 ) ; <nl> + CommonSpareBits . size ( ) , 0 ) ; <nl> <nl> / / If we have spare bits , pack tag bits into them . <nl> unsigned numSpareBits = CommonSpareBits . count ( ) ; <nl> if ( numSpareBits > 0 ) { <nl> llvm : : ConstantInt * tagMask <nl> - = interleaveSpareBits ( IGF . IGM , CommonSpareBits , CommonSpareBits . size ( ) , <nl> - tag , 0 ) ; <nl> + = interleaveSpareBits ( IGF . IGM , CommonSpareBits , CommonSpareBits . size ( ) , <nl> + tag , 0 ) ; <nl> payload = IGF . Builder . CreateOr ( payload , tagMask ) ; <nl> } <nl> <nl> namespace { <nl> } <nl> } <nl> <nl> - void emitEmptyInjection ( IRGenFunction & IGF , Explosion & out , <nl> - unsigned index ) const { <nl> + std : : pair < llvm : : Value * , llvm : : Value * > <nl> + getNoPayloadCaseValue ( IRGenFunction & IGF , unsigned index ) const { <nl> / / Figure out the tag and payload for the empty case . <nl> unsigned numCaseBits = getNumCaseBits ( ) ; <nl> unsigned tag , tagIndex ; <nl> namespace { <nl> } <nl> <nl> llvm : : Value * payload ; <nl> + llvm : : Value * extraTag = nullptr ; <nl> unsigned numSpareBits = CommonSpareBits . count ( ) ; <nl> if ( numSpareBits > 0 ) { <nl> / / If we have spare bits , pack tag bits into them . <nl> namespace { <nl> APInt ( CommonSpareBits . size ( ) , tagIndex ) ) ; <nl> } <nl> <nl> - out . add ( payload ) ; <nl> - <nl> / / If we have extra tag bits , pack the remaining tag bits into them . <nl> if ( ExtraTagBitCount > 0 ) { <nl> tag > > = numSpareBits ; <nl> - auto extra = llvm : : ConstantInt : : get ( IGF . IGM . getLLVMContext ( ) , <nl> + extraTag = llvm : : ConstantInt : : get ( IGF . IGM . getLLVMContext ( ) , <nl> APInt ( ExtraTagBitCount , tag ) ) ; <nl> - out . add ( extra ) ; <nl> + } <nl> + return { payload , extraTag } ; <nl> + } <nl> + <nl> + void emitNoPayloadInjection ( IRGenFunction & IGF , Explosion & out , <nl> + unsigned index ) const { <nl> + llvm : : Value * payload , * extraTag ; <nl> + std : : tie ( payload , extraTag ) = getNoPayloadCaseValue ( IGF , index ) ; <nl> + out . add ( payload ) ; <nl> + if ( ExtraTagBitCount > 0 ) { <nl> + assert ( extraTag ) ; <nl> + out . add ( extraTag ) ; <nl> } <nl> } <nl> <nl> namespace { <nl> <nl> IGF . Builder . emitBlock ( caseBB ) ; <nl> Explosion value ( ExplosionKind : : Minimal ) ; <nl> - projectPayload ( IGF , payload , tagIndex , payloadTI , value ) ; <nl> + projectPayloadValue ( IGF , payload , tagIndex , payloadTI , value ) ; <nl> f ( value , payloadTI ) ; <nl> IGF . Builder . CreateBr ( endBB ) ; <nl> <nl> namespace { <nl> } <nl> <nl> public : <nl> + void emitValueInjection ( IRGenFunction & IGF , <nl> + UnionElementDecl * elt , <nl> + Explosion & params , <nl> + Explosion & out ) const { <nl> + / / See whether this is a payload or empty case we ' re emitting . <nl> + auto payloadI = std : : find_if ( ElementsWithPayload . begin ( ) , <nl> + ElementsWithPayload . end ( ) , <nl> + [ & ] ( const Element & e ) { return e . decl = = elt ; } ) ; <nl> + if ( payloadI ! = ElementsWithPayload . end ( ) ) <nl> + return emitPayloadInjection ( IGF , cast < FixedTypeInfo > ( * payloadI - > ti ) , <nl> + params , out , <nl> + payloadI - ElementsWithPayload . begin ( ) ) ; <nl> + <nl> + auto emptyI = std : : find_if ( ElementsWithNoPayload . begin ( ) , <nl> + ElementsWithNoPayload . end ( ) , <nl> + [ & ] ( const Element & e ) { return e . decl = = elt ; } ) ; <nl> + assert ( emptyI ! = ElementsWithNoPayload . end ( ) & & " case not in union " ) ; <nl> + emitNoPayloadInjection ( IGF , out , emptyI - ElementsWithNoPayload . begin ( ) ) ; <nl> + } <nl> + <nl> void copy ( IRGenFunction & IGF , Explosion & src , Explosion & dest ) <nl> const override { <nl> if ( isPOD ( ResilienceScope : : Local ) ) { <nl> namespace { <nl> loadAsTake ( IGF , addr , val ) ; <nl> consume ( IGF , val ) ; <nl> } <nl> + <nl> + Address projectDataForStore ( IRGenFunction & IGF , <nl> + UnionElementDecl * elt , <nl> + Address unionAddr ) const override { <nl> + auto payloadI = std : : find_if ( ElementsWithPayload . begin ( ) , <nl> + ElementsWithPayload . end ( ) , <nl> + [ & ] ( const Element & e ) { return e . decl = = elt ; } ) ; <nl> + <nl> + assert ( payloadI ! = ElementsWithPayload . end ( ) & & <nl> + " cannot project a no - payload case " ) ; <nl> + <nl> + / / Payloads are all placed at the beginning of the value . <nl> + return IGF . Builder . CreateBitCast ( unionAddr , <nl> + payloadI - > ti - > getStorageType ( ) - > getPointerTo ( ) ) ; <nl> + } <nl> + <nl> + private : <nl> + void storePayloadTag ( IRGenFunction & IGF , const FixedTypeInfo & payloadTI , <nl> + Address unionAddr , unsigned index ) const { <nl> + / / If the tag has spare bits , we need to mask them into the <nl> + / / payload area . <nl> + unsigned numSpareBits = CommonSpareBits . count ( ) ; <nl> + if ( numSpareBits > 0 ) { <nl> + unsigned spareTagBits = numSpareBits > = 32 <nl> + ? index : index & ( ( 1U < < numSpareBits ) - 1U ) ; <nl> + <nl> + / / Mask the spare bits into the payload area . <nl> + Address payloadAddr = projectPayload ( IGF , unionAddr ) ; <nl> + llvm : : Value * payloadBits = IGF . Builder . CreateLoad ( payloadAddr ) ; <nl> + auto * spareBitMask = llvm : : ConstantInt : : get ( IGF . IGM . getLLVMContext ( ) , <nl> + ~ getAPIntFromBitVector ( CommonSpareBits ) ) ; <nl> + llvm : : Value * tagBitMask <nl> + = interleaveSpareBits ( IGF . IGM , CommonSpareBits , CommonSpareBits . size ( ) , <nl> + spareTagBits , 0 ) ; <nl> + payloadBits = IGF . Builder . CreateAnd ( payloadBits , spareBitMask ) ; <nl> + if ( spareTagBits ! = 0 ) <nl> + payloadBits = IGF . Builder . CreateOr ( payloadBits , tagBitMask ) ; <nl> + IGF . Builder . CreateStore ( payloadBits , payloadAddr ) ; <nl> + } <nl> + <nl> + / / Initialize the extra tag bits , if we have them . <nl> + if ( ExtraTagBitCount > 0 ) { <nl> + unsigned extraTagBits = index > > numSpareBits ; <nl> + auto * extraTagValue = llvm : : ConstantInt : : get ( IGF . IGM . getLLVMContext ( ) , <nl> + APInt ( ExtraTagBitCount , extraTagBits ) ) ; <nl> + IGF . Builder . CreateStore ( extraTagValue , <nl> + projectExtraTagBits ( IGF , unionAddr ) ) ; <nl> + } <nl> + } <nl> + <nl> + void storeNoPayloadTag ( IRGenFunction & IGF , Address unionAddr , <nl> + unsigned index ) const { <nl> + / / We can just primitive - store the representation for the empty case . <nl> + llvm : : Value * payload , * extraTag ; <nl> + std : : tie ( payload , extraTag ) = getNoPayloadCaseValue ( IGF , index ) ; <nl> + IGF . Builder . CreateStore ( payload , projectPayload ( IGF , unionAddr ) ) ; <nl> + if ( ExtraTagBitCount > 0 ) { <nl> + assert ( extraTag ) ; <nl> + IGF . Builder . CreateStore ( extraTag , projectExtraTagBits ( IGF , unionAddr ) ) ; <nl> + } <nl> + } <nl> + <nl> + public : <nl> + void storeTag ( IRGenFunction & IGF , <nl> + UnionElementDecl * elt , <nl> + Address unionAddr ) const override { <nl> + / / See whether this is a payload or empty case we ' re emitting . <nl> + auto payloadI = std : : find_if ( ElementsWithPayload . begin ( ) , <nl> + ElementsWithPayload . end ( ) , <nl> + [ & ] ( const Element & e ) { return e . decl = = elt ; } ) ; <nl> + if ( payloadI ! = ElementsWithPayload . end ( ) ) <nl> + return storePayloadTag ( IGF , cast < FixedTypeInfo > ( * payloadI - > ti ) , <nl> + unionAddr , <nl> + payloadI - ElementsWithPayload . begin ( ) ) ; <nl> + <nl> + auto emptyI = std : : find_if ( ElementsWithNoPayload . begin ( ) , <nl> + ElementsWithNoPayload . end ( ) , <nl> + [ & ] ( const Element & e ) { return e . decl = = elt ; } ) ; <nl> + assert ( emptyI ! = ElementsWithNoPayload . end ( ) & & " case not in union " ) ; <nl> + storeNoPayloadTag ( IGF , unionAddr , emptyI - ElementsWithNoPayload . begin ( ) ) ; <nl> + } <nl> } ; <nl> <nl> UnionImplStrategy * UnionImplStrategy : : get ( TypeConverter & TC , <nl> namespace { <nl> } <nl> } ; <nl> <nl> + static const UnionImplStrategy & getUnionImplStrategy ( IRGenModule & IGM , <nl> + SILType ty ) { <nl> + assert ( ty . getUnionOrBoundGenericUnion ( ) & & " not a union " ) ; <nl> + auto * ti = & IGM . getTypeInfo ( ty ) ; <nl> + if ( auto * loadableTI = dyn_cast < LoadableTypeInfo > ( ti ) ) <nl> + return loadableTI - > as < LoadableUnionTypeInfo > ( ) . Strategy ; <nl> + if ( auto * TI = dyn_cast < FixedTypeInfo > ( ti ) ) <nl> + return TI - > as < FixedUnionTypeInfo > ( ) . Strategy ; <nl> + llvm_unreachable ( " unimplemented union type info " ) ; <nl> + } <nl> + <nl> TypeInfo * <nl> UnionImplStrategy : : getUnionTypeInfo ( llvm : : StructType * T , Size S , <nl> llvm : : BitVector SB , <nl> void irgen : : emitSwitchLoadableUnionDispatch ( IRGenFunction & IGF , <nl> ArrayRef < std : : pair < UnionElementDecl * , <nl> llvm : : BasicBlock * > > dests , <nl> llvm : : BasicBlock * defaultDest ) { <nl> - assert ( unionTy . getSwiftRValueType ( ) - > getUnionOrBoundGenericUnion ( ) <nl> - & & " not of a union type " ) ; <nl> - auto & unionTI = IGF . getTypeInfo ( unionTy ) . as < LoadableUnionTypeInfo > ( ) ; <nl> - unionTI . Strategy . emitValueSwitch ( IGF , unionValue , dests , defaultDest ) ; <nl> + getUnionImplStrategy ( IGF . IGM , unionTy ) <nl> + . emitValueSwitch ( IGF , unionValue , dests , defaultDest ) ; <nl> } <nl> <nl> void irgen : : emitInjectLoadableUnion ( IRGenFunction & IGF , SILType unionTy , <nl> UnionElementDecl * theCase , <nl> Explosion & data , <nl> Explosion & out ) { <nl> - assert ( unionTy . getSwiftRValueType ( ) - > getUnionOrBoundGenericUnion ( ) <nl> - & & " not of a union type " ) ; <nl> - auto & unionTI = IGF . getTypeInfo ( unionTy ) . as < LoadableUnionTypeInfo > ( ) ; <nl> - unionTI . Strategy . emitValueInjection ( IGF , theCase , data , out ) ; <nl> + getUnionImplStrategy ( IGF . IGM , unionTy ) <nl> + . emitValueInjection ( IGF , theCase , data , out ) ; <nl> } <nl> <nl> void irgen : : emitProjectLoadableUnion ( IRGenFunction & IGF , SILType unionTy , <nl> Explosion & inUnionValue , <nl> UnionElementDecl * theCase , <nl> Explosion & out ) { <nl> - assert ( unionTy . getSwiftRValueType ( ) - > getUnionOrBoundGenericUnion ( ) <nl> - & & " not of a union type " ) ; <nl> - auto & unionTI = IGF . getTypeInfo ( unionTy ) . as < LoadableUnionTypeInfo > ( ) ; <nl> - unionTI . Strategy . emitValueProject ( IGF , inUnionValue , theCase , out ) ; <nl> + getUnionImplStrategy ( IGF . IGM , unionTy ) <nl> + . emitValueProject ( IGF , inUnionValue , theCase , out ) ; <nl> + } <nl> + <nl> + Address irgen : : emitProjectUnionAddressForStore ( IRGenFunction & IGF , <nl> + SILType unionTy , <nl> + Address unionAddr , <nl> + UnionElementDecl * theCase ) { <nl> + return getUnionImplStrategy ( IGF . IGM , unionTy ) <nl> + . projectDataForStore ( IGF , theCase , unionAddr ) ; <nl> + } <nl> + <nl> + void irgen : : emitStoreUnionTagToAddress ( IRGenFunction & IGF , <nl> + SILType unionTy , <nl> + Address unionAddr , <nl> + UnionElementDecl * theCase ) { <nl> + getUnionImplStrategy ( IGF . IGM , unionTy ) <nl> + . storeTag ( IGF , theCase , unionAddr ) ; <nl> } <nl> <nl> / / / Interleave the occupiedValue and spareValue bits , taking a bit from one <nl> mmm a / lib / IRGen / GenUnion . h <nl> ppp b / lib / IRGen / GenUnion . h <nl> void emitProjectLoadableUnion ( IRGenFunction & IGF , <nl> UnionElementDecl * theCase , <nl> Explosion & out ) ; <nl> <nl> + / / / \ brief Projects the address of the associated data for a case inside a <nl> + / / / union , to which a new data value can be stored . <nl> + Address emitProjectUnionAddressForStore ( IRGenFunction & IGF , <nl> + SILType unionTy , <nl> + Address unionAddr , <nl> + UnionElementDecl * theCase ) ; <nl> + <nl> + / / / \ brief Stores the tag bits for a union case to the given address , overlaying <nl> + / / / the data ( if any ) stored there . <nl> + void emitStoreUnionTagToAddress ( IRGenFunction & IGF , <nl> + SILType unionTy , <nl> + Address unionAddr , <nl> + UnionElementDecl * theCase ) ; <nl> + <nl> / / / Interleave the occupiedValue and spareValue bits , taking a bit from one <nl> / / / or the other at each position based on the spareBits mask . <nl> llvm : : ConstantInt * <nl> mmm a / lib / IRGen / IRGenSIL . cpp <nl> ppp b / lib / IRGen / IRGenSIL . cpp <nl> void IRGenSILFunction : : visitTupleInst ( swift : : TupleInst * i ) { <nl> } <nl> <nl> void IRGenSILFunction : : visitUnionInst ( swift : : UnionInst * i ) { <nl> - Explosion data = [ & ] { <nl> - if ( i - > hasOperand ( ) ) <nl> - return getLoweredExplosion ( i - > getOperand ( ) ) ; <nl> - / / Empty explosion if no operand . <nl> - return Explosion ( ExplosionKind : : Minimal ) ; <nl> - } ( ) ; <nl> + Explosion data = ( i - > hasOperand ( ) ) <nl> + ? getLoweredExplosion ( i - > getOperand ( ) ) <nl> + : Explosion ( ExplosionKind : : Minimal ) ; <nl> Explosion out ( ExplosionKind : : Maximal ) ; <nl> emitInjectLoadableUnion ( * this , i - > getType ( ) , i - > getElement ( ) , data , out ) ; <nl> setLoweredExplosion ( SILValue ( i , 0 ) , out ) ; <nl> } <nl> <nl> void IRGenSILFunction : : visitUnionDataAddrInst ( swift : : UnionDataAddrInst * i ) { <nl> - llvm_unreachable ( " unimplemented " ) ; <nl> + Address unionAddr = getLoweredAddress ( i - > getOperand ( ) ) ; <nl> + Address dataAddr = emitProjectUnionAddressForStore ( * this , <nl> + i - > getOperand ( ) . getType ( ) , <nl> + unionAddr , <nl> + i - > getElement ( ) ) ; <nl> + setLoweredAddress ( SILValue ( i , 0 ) , dataAddr ) ; <nl> } <nl> <nl> void IRGenSILFunction : : visitInjectUnionAddrInst ( swift : : InjectUnionAddrInst * i ) { <nl> - llvm_unreachable ( " unimplemented " ) ; <nl> + Address unionAddr = getLoweredAddress ( i - > getOperand ( ) ) ; <nl> + emitStoreUnionTagToAddress ( * this , i - > getOperand ( ) . getType ( ) , <nl> + unionAddr , i - > getElement ( ) ) ; <nl> } <nl> <nl> void IRGenSILFunction : : visitBuiltinZeroInst ( swift : : BuiltinZeroInst * i ) { <nl> mmm a / test / IRGen / union . sil <nl> ppp b / test / IRGen / union . sil <nl> entry ( % 0 : $ Builtin . Int64 , % 1 : $ Builtin . Int64 ) : <nl> return % u : $ Singleton <nl> } <nl> <nl> + / / CHECK : define void @ singleton_inject_indirect ( i64 , i64 , % O5union9Singleton * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ DATA_ADDR : % . * ] ] = getelementptr inbounds % O5union9Singleton * % 2 , i32 0 , i32 0 <nl> + / / CHECK : [ [ DATA_0_ADDR : % . * ] ] = getelementptr inbounds { i64 , i64 } * [ [ DATA_ADDR ] ] , i32 0 , i32 0 <nl> + / / CHECK : store i64 % 0 , i64 * [ [ DATA_0_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ DATA_1_ADDR : % . * ] ] = getelementptr inbounds { i64 , i64 } * [ [ DATA_ADDR ] ] , i32 0 , i32 1 <nl> + / / CHECK : store i64 % 1 , i64 * [ [ DATA_1_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ singleton_inject_indirect : $ ( Builtin . Int64 , Builtin . Int64 , [ byref ] Singleton ) - > ( ) { <nl> + entry ( % 0 : $ Builtin . Int64 , % 1 : $ Builtin . Int64 , % 2 : $ * Singleton ) : <nl> + % t = tuple ( % 0 : $ Builtin . Int64 , % 1 : $ Builtin . Int64 ) <nl> + % a = union_data_addr % 2 : $ * Singleton , # Singleton . val ! unionelt . 1 <nl> + store % t to % a : $ * ( Builtin . Int64 , Builtin . Int64 ) <nl> + inject_union_addr % 2 : $ * Singleton , # Singleton . val ! unionelt . 1 <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> <nl> union NoPayloads { <nl> case x <nl> entry : <nl> return % u : $ NoPayloads <nl> } <nl> <nl> + / / CHECK : define void @ no_payload_inject_z_indirect ( % O5union10NoPayloads * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ TAG_ADDR : % . * ] ] = getelementptr inbounds % O5union10NoPayloads * % 0 , i32 0 , i32 0 <nl> + / / CHECK : store i2 - 2 , i2 * [ [ TAG_ADDR ] ] , align 1 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ no_payload_inject_z_indirect : $ ( [ byref ] NoPayloads ) - > ( ) { <nl> + entry ( % 0 : $ * NoPayloads ) : <nl> + inject_union_addr % 0 : $ * NoPayloads , # NoPayloads . z ! unionelt <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> <nl> union NoPayloads2 { <nl> case a <nl> entry ( % 0 : $ Builtin . Int64 ) : <nl> return % u : $ SinglePayloadNoXI2 <nl> } <nl> <nl> + / / CHECK : define void @ single_payload_no_xi_inject_x_indirect ( i64 , % O5union18SinglePayloadNoXI2 * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ DATA_ADDR : % . * ] ] = bitcast % O5union18SinglePayloadNoXI2 * % 1 to i64 * <nl> + / / CHECK : store i64 % 0 , i64 * [ [ DATA_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ TAG_ADDR : % . * ] ] = getelementptr inbounds % O5union18SinglePayloadNoXI2 * % 1 , i32 0 , i32 1 <nl> + / / CHECK : store i1 false , i1 * [ [ TAG_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ single_payload_no_xi_inject_x_indirect : $ ( Builtin . Int64 , [ byref ] SinglePayloadNoXI2 ) - > ( ) { <nl> + entry ( % 0 : $ Builtin . Int64 , % 1 : $ * SinglePayloadNoXI2 ) : <nl> + % a = union_data_addr % 1 : $ * SinglePayloadNoXI2 , # SinglePayloadNoXI2 . x ! unionelt . 1 <nl> + store % 0 to % a : $ * Builtin . Int64 <nl> + inject_union_addr % 1 : $ * SinglePayloadNoXI2 , # SinglePayloadNoXI2 . x ! unionelt . 1 <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define { i64 , i1 } @ single_payload_no_xi_inject_y ( ) { <nl> / / CHECK : entry : <nl> / / CHECK : ret { i64 , i1 } { i64 0 , i1 true } <nl> entry : <nl> return % u : $ SinglePayloadNoXI2 <nl> } <nl> <nl> + / / CHECK : define void @ single_payload_no_xi_inject_y_indirect ( % O5union18SinglePayloadNoXI2 * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ PAYLOAD_ADDR : % . * ] ] = getelementptr inbounds % O5union18SinglePayloadNoXI2 * % 0 , i32 0 , i32 0 <nl> + / / CHECK : store i64 0 , i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ TAG_ADDR : % . * ] ] = getelementptr inbounds % O5union18SinglePayloadNoXI2 * % 0 , i32 0 , i32 1 <nl> + / / CHECK : store i1 true , i1 * [ [ TAG_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ single_payload_no_xi_inject_y_indirect : $ ( [ byref ] SinglePayloadNoXI2 ) - > ( ) { <nl> + entry ( % 0 : $ * SinglePayloadNoXI2 ) : <nl> + inject_union_addr % 0 : $ * SinglePayloadNoXI2 , # SinglePayloadNoXI2 . y ! unionelt <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define { i64 , i1 } @ single_payload_no_xi_inject_z ( ) { <nl> / / CHECK : entry : <nl> / / CHECK : ret { i64 , i1 } { i64 1 , i1 true } <nl> entry ( % 0 : $ Builtin . Int63 ) : <nl> return % u : $ SinglePayloadSpareBit <nl> } <nl> <nl> + / / CHECK : define void @ single_payload_spare_bit_inject_x_indirect ( i63 , % O5union21SinglePayloadSpareBit * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ DATA_ADDR : % . * ] ] = bitcast % O5union21SinglePayloadSpareBit * % 1 to i63 * <nl> + / / CHECK : store i63 % 0 , i63 * [ [ DATA_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ single_payload_spare_bit_inject_x_indirect : $ ( Builtin . Int63 , [ byref ] SinglePayloadSpareBit ) - > ( ) { <nl> + entry ( % 0 : $ Builtin . Int63 , % 1 : $ * SinglePayloadSpareBit ) : <nl> + % a = union_data_addr % 1 : $ * SinglePayloadSpareBit , # SinglePayloadSpareBit . x ! unionelt . 1 <nl> + store % 0 to % a : $ * Builtin . Int63 <nl> + inject_union_addr % 1 : $ * SinglePayloadSpareBit , # SinglePayloadSpareBit . x ! unionelt . 1 <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define i64 @ single_payload_spare_bit_inject_y ( ) { <nl> / / CHECK : entry : <nl> - / / 0x8000_0000_0000_0000 <nl> + / / - - 0x8000_0000_0000_0000 <nl> / / CHECK : ret i64 - 9223372036854775808 <nl> / / CHECK : } <nl> sil @ single_payload_spare_bit_inject_y : $ ( ) - > SinglePayloadSpareBit { <nl> entry : <nl> return % u : $ SinglePayloadSpareBit <nl> } <nl> <nl> + / / CHECK : define void @ single_payload_spare_bit_inject_y_indirect ( % O5union21SinglePayloadSpareBit * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ PAYLOAD_ADDR : % . * ] ] = getelementptr inbounds % O5union21SinglePayloadSpareBit * % 0 , i32 0 , i32 0 <nl> + / / - - 0x8000_0000_0000_0000 <nl> + / / CHECK : store i64 - 9223372036854775808 , i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ single_payload_spare_bit_inject_y_indirect : $ ( [ byref ] SinglePayloadSpareBit ) - > ( ) { <nl> + entry ( % 0 : $ * SinglePayloadSpareBit ) : <nl> + inject_union_addr % 0 : $ * SinglePayloadSpareBit , # SinglePayloadSpareBit . y ! unionelt <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define i64 @ single_payload_spare_bit_inject_z ( ) { <nl> / / CHECK : entry : <nl> / / 0x8000_0000_0000_0001 <nl> entry ( % 0 : $ Builtin . Int64 ) : <nl> return % u : $ MultiPayloadNoSpareBits <nl> } <nl> <nl> + / / CHECK : define void @ multi_payload_no_spare_bit_inject_x_indirect ( i64 , % O5union23MultiPayloadNoSpareBits * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ DATA_ADDR : % . * ] ] = bitcast % O5union23MultiPayloadNoSpareBits * % 1 to i64 * <nl> + / / CHECK : store i64 % 0 , i64 * [ [ DATA_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ TAG_ADDR : % . * ] ] = getelementptr inbounds % O5union23MultiPayloadNoSpareBits * % 1 , i32 0 , i32 1 <nl> + / / CHECK : store i2 0 , i2 * [ [ TAG_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ multi_payload_no_spare_bit_inject_x_indirect : $ ( Builtin . Int64 , [ byref ] MultiPayloadNoSpareBits ) - > ( ) { <nl> + entry ( % 0 : $ Builtin . Int64 , % 1 : $ * MultiPayloadNoSpareBits ) : <nl> + % a = union_data_addr % 1 : $ * MultiPayloadNoSpareBits , # MultiPayloadNoSpareBits . x ! unionelt . 1 <nl> + store % 0 to % a : $ * Builtin . Int64 <nl> + inject_union_addr % 1 : $ * MultiPayloadNoSpareBits , # MultiPayloadNoSpareBits . x ! unionelt . 1 <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define { i64 , i2 } @ multi_payload_no_spare_bit_inject_y ( i32 ) { <nl> / / CHECK : entry : <nl> / / CHECK : [ [ ZEXT : % . * ] ] = zext i32 % 0 to i64 <nl> entry : <nl> return % u : $ MultiPayloadNoSpareBits <nl> } <nl> <nl> + / / CHECK : define void @ multi_payload_no_spare_bit_inject_a_indirect ( % O5union23MultiPayloadNoSpareBits * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ PAYLOAD_ADDR : % . * ] ] = getelementptr inbounds % O5union23MultiPayloadNoSpareBits * % 0 , i32 0 , i32 0 <nl> + / / CHECK : store i64 0 , i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ DATA_ADDR : % . * ] ] = getelementptr inbounds % O5union23MultiPayloadNoSpareBits * % 0 , i32 0 , i32 1 <nl> + / / CHECK : store i2 - 1 , i2 * [ [ DATA_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ multi_payload_no_spare_bit_inject_a_indirect : $ ( [ byref ] MultiPayloadNoSpareBits ) - > ( ) { <nl> + entry ( % 0 : $ * MultiPayloadNoSpareBits ) : <nl> + inject_union_addr % 0 : $ * MultiPayloadNoSpareBits , # MultiPayloadNoSpareBits . a ! unionelt <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define { i64 , i2 } @ multi_payload_no_spare_bit_inject_b ( ) { <nl> / / CHECK : entry : <nl> / / CHECK : ret { i64 , i2 } { i64 1 , i2 - 1 } <nl> entry ( % 0 : $ Builtin . Int62 ) : <nl> return % u : $ MultiPayloadOneSpareBit <nl> } <nl> <nl> + / / CHECK : define void @ multi_payload_one_spare_bit_inject_x_indirect ( i62 , % O5union23MultiPayloadOneSpareBit * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ DATA_ADDR : % . * ] ] = bitcast % O5union23MultiPayloadOneSpareBit * % 1 to i62 * <nl> + / / CHECK : store i62 % 0 , i62 * [ [ DATA_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ PAYLOAD_ADDR : % . * ] ] = getelementptr inbounds % O5union23MultiPayloadOneSpareBit * % 1 , i32 0 , i32 0 <nl> + / / CHECK : [ [ PAYLOAD : % . * ] ] = load i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / - - 0x7FFF_FFFF_FFFF_FFFF <nl> + / / CHECK : [ [ PAYLOAD_MASKED : % . * ] ] = and i64 [ [ PAYLOAD ] ] , 9223372036854775807 <nl> + / / CHECK : store i64 [ [ PAYLOAD_MASKED ] ] , i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ TAG_ADDR : % . * ] ] = getelementptr inbounds % O5union23MultiPayloadOneSpareBit * % 1 , i32 0 , i32 1 <nl> + / / CHECK : store i1 false , i1 * [ [ TAG_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ multi_payload_one_spare_bit_inject_x_indirect : $ ( Builtin . Int62 , [ byref ] MultiPayloadOneSpareBit ) - > ( ) { <nl> + entry ( % 0 : $ Builtin . Int62 , % 1 : $ * MultiPayloadOneSpareBit ) : <nl> + % a = union_data_addr % 1 : $ * MultiPayloadOneSpareBit , # MultiPayloadOneSpareBit . x ! unionelt . 1 <nl> + store % 0 to % a : $ * Builtin . Int62 <nl> + inject_union_addr % 1 : $ * MultiPayloadOneSpareBit , # MultiPayloadOneSpareBit . x ! unionelt . 1 <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define { i64 , i1 } @ multi_payload_one_spare_bit_inject_y ( i63 ) { <nl> / / CHECK : entry : <nl> / / CHECK : [ [ ZEXT : % . * ] ] = zext i63 % 0 to i64 <nl> entry ( % 0 : $ Builtin . Int63 ) : <nl> return % u : $ MultiPayloadOneSpareBit <nl> } <nl> <nl> + / / CHECK : define void @ multi_payload_one_spare_bit_inject_y_indirect ( i63 , % O5union23MultiPayloadOneSpareBit * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ DATA_ADDR : % . * ] ] = bitcast % O5union23MultiPayloadOneSpareBit * % 1 to i63 * <nl> + / / CHECK : store i63 % 0 , i63 * [ [ DATA_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ PAYLOAD_ADDR : % . * ] ] = getelementptr inbounds % O5union23MultiPayloadOneSpareBit * % 1 , i32 0 , i32 0 <nl> + / / CHECK : [ [ PAYLOAD : % . * ] ] = load i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / - - 0x7FFF_FFFF_FFFF_FFFF <nl> + / / CHECK : [ [ PAYLOAD_MASKED : % . * ] ] = and i64 [ [ PAYLOAD ] ] , 9223372036854775807 <nl> + / / - - 0x8000_0000_0000_0000 <nl> + / / CHECK : [ [ PAYLOAD_TAGGED : % . * ] ] = or i64 [ [ PAYLOAD_MASKED ] ] , - 9223372036854775808 <nl> + / / CHECK : store i64 [ [ PAYLOAD_TAGGED ] ] , i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ TAG_ADDR : % . * ] ] = getelementptr inbounds % O5union23MultiPayloadOneSpareBit * % 1 , i32 0 , i32 1 <nl> + / / CHECK : store i1 false , i1 * [ [ TAG_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + <nl> + sil @ multi_payload_one_spare_bit_inject_y_indirect : $ ( Builtin . Int63 , [ byref ] MultiPayloadOneSpareBit ) - > ( ) { <nl> + entry ( % 0 : $ Builtin . Int63 , % 1 : $ * MultiPayloadOneSpareBit ) : <nl> + % a = union_data_addr % 1 : $ * MultiPayloadOneSpareBit , # MultiPayloadOneSpareBit . y ! unionelt . 1 <nl> + store % 0 to % a : $ * Builtin . Int63 <nl> + inject_union_addr % 1 : $ * MultiPayloadOneSpareBit , # MultiPayloadOneSpareBit . y ! unionelt . 1 <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define { i64 , i1 } @ multi_payload_one_spare_bit_inject_z ( i61 ) { <nl> / / CHECK : entry : <nl> / / CHECK : [ [ ZEXT : % . * ] ] = zext i61 % 0 to i64 <nl> entry : <nl> return % u : $ MultiPayloadOneSpareBit <nl> } <nl> <nl> + / / CHECK : define void @ multi_payload_one_spare_bit_inject_a_indirect ( % O5union23MultiPayloadOneSpareBit * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ PAYLOAD_ADDR : % . * ] ] = getelementptr inbounds % O5union23MultiPayloadOneSpareBit * % 0 , i32 0 , i32 0 <nl> + / / - - 0x8000_0000_0000_0000 <nl> + / / CHECK : store i64 - 9223372036854775808 , i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ TAG_ADDR : % . * ] ] = getelementptr inbounds % O5union23MultiPayloadOneSpareBit * % 0 , i32 0 , i32 1 <nl> + / / CHECK : store i1 true , i1 * [ [ TAG_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ multi_payload_one_spare_bit_inject_a_indirect : $ ( [ byref ] MultiPayloadOneSpareBit ) - > ( ) { <nl> + entry ( % 0 : $ * MultiPayloadOneSpareBit ) : <nl> + inject_union_addr % 0 : $ * MultiPayloadOneSpareBit , # MultiPayloadOneSpareBit . a ! unionelt <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define { i64 , i1 } @ multi_payload_one_spare_bit_inject_b ( ) { <nl> / / CHECK : entry : <nl> / / - - 0x8000_0000_0000_0001 <nl> entry ( % 0 : $ Builtin . Int62 ) : <nl> return % u : $ MultiPayloadTwoSpareBits <nl> } <nl> <nl> + / / CHECK : define void @ multi_payload_two_spare_bits_inject_x_indirect ( i62 , % O5union24MultiPayloadTwoSpareBits * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ DATA_ADDR : % . * ] ] = bitcast % O5union24MultiPayloadTwoSpareBits * % 1 to i62 * <nl> + / / CHECK : store i62 % 0 , i62 * [ [ DATA_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ PAYLOAD_ADDR : % . * ] ] = getelementptr inbounds % O5union24MultiPayloadTwoSpareBits * % 1 , i32 0 , i32 0 <nl> + / / CHECK : [ [ PAYLOAD : % . * ] ] = load i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / - - 0x3FFF_FFFF_FFFF_FFFF <nl> + / / CHECK : [ [ PAYLOAD_MASKED : % . * ] ] = and i64 [ [ PAYLOAD ] ] , 4611686018427387903 <nl> + / / CHECK : store i64 [ [ PAYLOAD_MASKED ] ] , i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ multi_payload_two_spare_bits_inject_x_indirect : $ ( Builtin . Int62 , [ byref ] MultiPayloadTwoSpareBits ) - > ( ) { <nl> + entry ( % 0 : $ Builtin . Int62 , % 1 : $ * MultiPayloadTwoSpareBits ) : <nl> + % a = union_data_addr % 1 : $ * MultiPayloadTwoSpareBits , # MultiPayloadTwoSpareBits . x ! unionelt . 1 <nl> + store % 0 to % a : $ * Builtin . Int62 <nl> + inject_union_addr % 1 : $ * MultiPayloadTwoSpareBits , # MultiPayloadTwoSpareBits . x ! unionelt . 1 <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define i64 @ multi_payload_two_spare_bits_inject_y ( i60 ) { <nl> / / CHECK : entry : <nl> / / CHECK : [ [ ZEXT : % . * ] ] = zext i60 % 0 to i64 <nl> entry ( % 0 : $ Builtin . Int60 ) : <nl> return % u : $ MultiPayloadTwoSpareBits <nl> } <nl> <nl> + / / CHECK : define void @ multi_payload_two_spare_bits_inject_y_indirect ( i60 , % O5union24MultiPayloadTwoSpareBits * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ DATA_ADDR : % . * ] ] = bitcast % O5union24MultiPayloadTwoSpareBits * % 1 to i60 * <nl> + / / CHECK : store i60 % 0 , i60 * [ [ DATA_ADDR ] ] , align 8 <nl> + / / CHECK : [ [ PAYLOAD_ADDR : % . * ] ] = getelementptr inbounds % O5union24MultiPayloadTwoSpareBits * % 1 , i32 0 , i32 0 <nl> + / / CHECK : [ [ PAYLOAD : % . * ] ] = load i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / - - 0x3FFF_FFFF_FFFF_FFFF <nl> + / / CHECK : [ [ PAYLOAD_MASKED : % . * ] ] = and i64 [ [ PAYLOAD ] ] , 4611686018427387903 <nl> + / / - - 0x4000_0000_0000_0000 <nl> + / / CHECK : [ [ PAYLOAD_TAGGED : % . * ] ] = or i64 [ [ PAYLOAD_MASKED ] ] , 4611686018427387904 <nl> + / / CHECK : store i64 [ [ PAYLOAD_TAGGED ] ] , i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ multi_payload_two_spare_bits_inject_y_indirect : $ ( Builtin . Int60 , [ byref ] MultiPayloadTwoSpareBits ) - > ( ) { <nl> + entry ( % 0 : $ Builtin . Int60 , % 1 : $ * MultiPayloadTwoSpareBits ) : <nl> + % a = union_data_addr % 1 : $ * MultiPayloadTwoSpareBits , # MultiPayloadTwoSpareBits . y ! unionelt . 1 <nl> + store % 0 to % a : $ * Builtin . Int60 <nl> + inject_union_addr % 1 : $ * MultiPayloadTwoSpareBits , # MultiPayloadTwoSpareBits . y ! unionelt . 1 <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define i64 @ multi_payload_two_spare_bits_inject_z ( i61 ) { <nl> / / CHECK : entry : <nl> / / CHECK : [ [ ZEXT : % . * ] ] = zext i61 % 0 to i64 <nl> entry : <nl> return % u : $ MultiPayloadTwoSpareBits <nl> } <nl> <nl> + / / CHECK : define void @ multi_payload_two_spare_bits_inject_a_indirect ( % O5union24MultiPayloadTwoSpareBits * ) { <nl> + / / CHECK : entry : <nl> + / / CHECK : [ [ PAYLOAD_ADDR : % . * ] ] = getelementptr inbounds % O5union24MultiPayloadTwoSpareBits * % 0 , i32 0 , i32 0 <nl> + / / - - 0xC000_0000_0000_0000 <nl> + / / CHECK : store i64 - 4611686018427387904 , i64 * [ [ PAYLOAD_ADDR ] ] , align 8 <nl> + / / CHECK : ret void <nl> + / / CHECK : } <nl> + sil @ multi_payload_two_spare_bits_inject_a_indirect : $ ( [ byref ] MultiPayloadTwoSpareBits ) - > ( ) { <nl> + entry ( % 0 : $ * MultiPayloadTwoSpareBits ) : <nl> + inject_union_addr % 0 : $ * MultiPayloadTwoSpareBits , # MultiPayloadTwoSpareBits . a ! unionelt <nl> + % v = tuple ( ) <nl> + return % v : $ ( ) <nl> + } <nl> + <nl> / / CHECK : define i64 @ multi_payload_two_spare_bits_inject_b ( ) { <nl> / / CHECK : entry : <nl> / / - - 0xC000_0000_0000_0001 <nl>
|
IRGen : Implement SIL union_data_addr and inject_union_addr insns .
|
apple/swift
|
65a53dfd9d3e318868eb959844babfd9d850f410
|
2013-08-29T22:05:28Z
|
mmm a / src / mongo / db / sessions_collection_standalone . cpp <nl> ppp b / src / mongo / db / sessions_collection_standalone . cpp <nl> Status SessionsCollectionStandalone : : checkSessionsCollectionExists ( OperationCont <nl> <nl> Status SessionsCollectionStandalone : : refreshSessions ( OperationContext * opCtx , <nl> const LogicalSessionRecordSet & sessions ) { <nl> + const std : : vector < LogicalSessionRecord > sessionsVector ( sessions . begin ( ) , sessions . end ( ) ) ; <nl> DBDirectClient client ( opCtx ) ; <nl> return doRefresh ( NamespaceString : : kLogicalSessionsNamespace , <nl> - std : : vector ( sessions . begin ( ) , sessions . end ( ) ) , <nl> + sessionsVector , <nl> makeSendFnForBatchWrite ( NamespaceString : : kLogicalSessionsNamespace , & client ) ) ; <nl> } <nl> <nl> Status SessionsCollectionStandalone : : removeRecords ( OperationContext * opCtx , <nl> const LogicalSessionIdSet & sessions ) { <nl> + const std : : vector < LogicalSessionId > sessionsVector ( sessions . begin ( ) , sessions . end ( ) ) ; <nl> DBDirectClient client ( opCtx ) ; <nl> return doRemove ( NamespaceString : : kLogicalSessionsNamespace , <nl> - std : : vector ( sessions . begin ( ) , sessions . end ( ) ) , <nl> + sessionsVector , <nl> makeSendFnForBatchWrite ( NamespaceString : : kLogicalSessionsNamespace , & client ) ) ; <nl> } <nl> <nl> StatusWith < LogicalSessionIdSet > SessionsCollectionStandalone : : findRemovedSessions ( <nl> OperationContext * opCtx , const LogicalSessionIdSet & sessions ) { <nl> + const std : : vector < LogicalSessionId > sessionsVector ( sessions . begin ( ) , sessions . end ( ) ) ; <nl> DBDirectClient client ( opCtx ) ; <nl> return doFindRemoved ( NamespaceString : : kLogicalSessionsNamespace , <nl> - std : : vector ( sessions . begin ( ) , sessions . end ( ) ) , <nl> + sessionsVector , <nl> makeFindFnForCommand ( NamespaceString : : kLogicalSessionsNamespace , & client ) ) ; <nl> } <nl> <nl>
|
SERVER - 37837 fix mac os x compile
|
mongodb/mongo
|
7e6a80789cd74f9b533065f57afb5c9221eea1e7
|
2019-05-09T15:45:35Z
|
mmm a / dbms / src / Common / ProfileEvents . cpp <nl> ppp b / dbms / src / Common / ProfileEvents . cpp <nl> <nl> M ( MarkCacheMisses , " " ) \ <nl> M ( CreatedReadBufferOrdinary , " " ) \ <nl> M ( CreatedReadBufferAIO , " " ) \ <nl> + M ( CreatedReadBufferAIOFailed , " " ) \ <nl> M ( CreatedWriteBufferOrdinary , " " ) \ <nl> M ( CreatedWriteBufferAIO , " " ) \ <nl> + M ( CreatedWriteBufferAIOFailed , " " ) \ <nl> M ( DiskReadElapsedMicroseconds , " Total time spent waiting for read syscall . This include reads from page cache . " ) \ <nl> M ( DiskWriteElapsedMicroseconds , " Total time spent waiting for write syscall . This include writes to page cache . " ) \ <nl> M ( NetworkReceiveElapsedMicroseconds , " " ) \ <nl> mmm a / dbms / src / IO / createReadBufferFromFileBase . cpp <nl> ppp b / dbms / src / IO / createReadBufferFromFileBase . cpp <nl> namespace ProfileEvents <nl> { <nl> extern const Event CreatedReadBufferOrdinary ; <nl> extern const Event CreatedReadBufferAIO ; <nl> + extern const Event CreatedReadBufferAIOFailed ; <nl> } <nl> <nl> namespace DB <nl> { <nl> - # if ! defined ( __linux__ ) <nl> - namespace ErrorCodes <nl> - { <nl> - extern const int NOT_IMPLEMENTED ; <nl> - } <nl> - # endif <nl> <nl> std : : unique_ptr < ReadBufferFromFileBase > createReadBufferFromFileBase ( const std : : string & filename_ , size_t estimated_size , <nl> size_t aio_threshold , size_t buffer_size_ , int flags_ , char * existing_memory_ , size_t alignment ) <nl> { <nl> - if ( ( aio_threshold = = 0 ) | | ( estimated_size < aio_threshold ) ) <nl> + # if defined ( __linux__ ) | | defined ( __FreeBSD__ ) <nl> + if ( aio_threshold & & estimated_size > = aio_threshold ) <nl> { <nl> - ProfileEvents : : increment ( ProfileEvents : : CreatedReadBufferOrdinary ) ; <nl> - return std : : make_unique < ReadBufferFromFile > ( filename_ , buffer_size_ , flags_ , existing_memory_ , alignment ) ; <nl> + / / / Attempt to open a file with O_DIRECT <nl> + try <nl> + { <nl> + auto res = std : : make_unique < ReadBufferAIO > ( filename_ , buffer_size_ , flags_ , existing_memory_ ) ; <nl> + ProfileEvents : : increment ( ProfileEvents : : CreatedReadBufferAIO ) ; <nl> + return res ; <nl> + } <nl> + catch ( const ErrnoException & ) <nl> + { <nl> + / / / Fallback to cached IO if O_DIRECT is not supported . <nl> + ProfileEvents : : increment ( ProfileEvents : : CreatedReadBufferAIOFailed ) ; <nl> + } <nl> } <nl> - else <nl> - { <nl> - # if defined ( __linux__ ) | | defined ( __FreeBSD__ ) <nl> - ProfileEvents : : increment ( ProfileEvents : : CreatedReadBufferAIO ) ; <nl> - return std : : make_unique < ReadBufferAIO > ( filename_ , buffer_size_ , flags_ , existing_memory_ ) ; <nl> # else <nl> - throw Exception ( " AIO is implemented only on Linux and FreeBSD " , ErrorCodes : : NOT_IMPLEMENTED ) ; <nl> + ( void ) aio_threshold ; <nl> + ( void ) estimated_size ; <nl> # endif <nl> - } <nl> + <nl> + ProfileEvents : : increment ( ProfileEvents : : CreatedReadBufferOrdinary ) ; <nl> + return std : : make_unique < ReadBufferFromFile > ( filename_ , buffer_size_ , flags_ , existing_memory_ , alignment ) ; <nl> } <nl> <nl> } <nl> mmm a / dbms / src / IO / createWriteBufferFromFileBase . cpp <nl> ppp b / dbms / src / IO / createWriteBufferFromFileBase . cpp <nl> namespace ProfileEvents <nl> { <nl> extern const Event CreatedWriteBufferOrdinary ; <nl> extern const Event CreatedWriteBufferAIO ; <nl> + extern const Event CreatedWriteBufferAIOFailed ; <nl> } <nl> <nl> namespace DB <nl> { <nl> <nl> - # if ! defined ( __linux__ ) <nl> - namespace ErrorCodes <nl> - { <nl> - extern const int NOT_IMPLEMENTED ; <nl> - } <nl> - # endif <nl> - <nl> std : : unique_ptr < WriteBufferFromFileBase > createWriteBufferFromFileBase ( const std : : string & filename_ , size_t estimated_size , <nl> size_t aio_threshold , size_t buffer_size_ , int flags_ , mode_t mode , char * existing_memory_ , <nl> size_t alignment ) <nl> { <nl> - if ( ( aio_threshold = = 0 ) | | ( estimated_size < aio_threshold ) ) <nl> + # if defined ( __linux__ ) | | defined ( __FreeBSD__ ) <nl> + if ( aio_threshold & & estimated_size > = aio_threshold ) <nl> { <nl> - ProfileEvents : : increment ( ProfileEvents : : CreatedWriteBufferOrdinary ) ; <nl> - return std : : make_unique < WriteBufferFromFile > ( filename_ , buffer_size_ , flags_ , mode , existing_memory_ , alignment ) ; <nl> + / / / Attempt to open a file with O_DIRECT <nl> + try <nl> + { <nl> + auto res = std : : make_unique < WriteBufferAIO > ( filename_ , buffer_size_ , flags_ , mode , existing_memory_ ) ; <nl> + ProfileEvents : : increment ( ProfileEvents : : CreatedWriteBufferAIO ) ; <nl> + return res ; <nl> + } <nl> + catch ( const ErrnoException & ) <nl> + { <nl> + / / / Fallback to cached IO if O_DIRECT is not supported . <nl> + ProfileEvents : : increment ( ProfileEvents : : CreatedWriteBufferAIOFailed ) ; <nl> + } <nl> } <nl> - else <nl> - { <nl> - # if defined ( __linux__ ) | | defined ( __FreeBSD__ ) <nl> - ProfileEvents : : increment ( ProfileEvents : : CreatedWriteBufferAIO ) ; <nl> - return std : : make_unique < WriteBufferAIO > ( filename_ , buffer_size_ , flags_ , mode , existing_memory_ ) ; <nl> # else <nl> - throw Exception ( " AIO is implemented only on Linux and FreeBSD " , ErrorCodes : : NOT_IMPLEMENTED ) ; <nl> + ( void ) aio_threshold ; <nl> + ( void ) estimated_size ; <nl> # endif <nl> - } <nl> + <nl> + ProfileEvents : : increment ( ProfileEvents : : CreatedWriteBufferOrdinary ) ; <nl> + return std : : make_unique < WriteBufferFromFile > ( filename_ , buffer_size_ , flags_ , mode , existing_memory_ , alignment ) ; <nl> } <nl> <nl> } <nl>
|
Fallback from O_DIRECT .
|
ClickHouse/ClickHouse
|
a894288fa059ad06c325780aa780c49ae57b49da
|
2019-08-29T15:48:00Z
|
mmm a / modules / highgui / doc / user_interface . rst <nl> ppp b / modules / highgui / doc / user_interface . rst <nl> The function ` ` namedWindow ` ` creates a window that can be used as a placeholder <nl> <nl> If a window with the same name already exists , the function does nothing . <nl> <nl> + You can call : cpp : func : ` destroyWindow ` or : cpp : func : ` destroyAllWindows ` to close the window and de - allocate any associated memory usage . For a simple program , you don ’ t really have to call these functions because all the resources and windows of the application are closed automatically by the operating system upon exit . <nl> + <nl> <nl> * * [ Qt Backend Only ] * * <nl> Qt - specific details : <nl> Qt - specific details : <nl> <nl> . . <nl> <nl> + <nl> + . . index : : destroyWindow <nl> + <nl> + . . _destroyWindow : <nl> + <nl> + destroyWindow <nl> + mmmmmmmmmmmm - <nl> + . . ocv : function : : void destroyWindow ( const string & winname ) <nl> + <nl> + Destroys a window . <nl> + <nl> + : param winname : Name of the window to be destroyed . <nl> + <nl> + The function ` ` destroyWindow ` ` destroys the window with the given name . <nl> + <nl> + <nl> + . . index : : destroyAllWindows <nl> + <nl> + . . _destroyAllWindows : <nl> + <nl> + destroyAllWindows <nl> + mmmmmmmmmmmmmmm - - <nl> + <nl> + . . ocv : function : : void destroyAllWindows ( ) <nl> + <nl> + Destroys all of the HighGUI windows . <nl> + <nl> + The function ` ` destroyAllWindows ` ` destroys all of the opened HighGUI windows . <nl> + <nl> + <nl> . . index : : setTrackbarPos <nl> <nl> . . _setTrackbarPos : <nl> mmm a / modules / highgui / include / opencv2 / highgui / highgui . hpp <nl> ppp b / modules / highgui / include / opencv2 / highgui / highgui . hpp <nl> enum { WINDOW_AUTOSIZE = 1 } ; <nl> <nl> CV_EXPORTS_W void namedWindow ( const string & winname , int flags = WINDOW_AUTOSIZE ) ; <nl> CV_EXPORTS_W void destroyWindow ( const string & winname ) ; <nl> + CV_EXPORTS_W void destroyAllWindows ( ) ; <nl> CV_EXPORTS_W int startWindowThread ( ) ; <nl> <nl> CV_EXPORTS_W void setWindowProperty ( const string & winname , int prop_id , double prop_value ) ; / / YV <nl> mmm a / modules / highgui / src / window . cpp <nl> ppp b / modules / highgui / src / window . cpp <nl> void cv : : destroyWindow ( const string & winname ) <nl> cvDestroyWindow ( winname . c_str ( ) ) ; <nl> } <nl> <nl> + void cv : : destroyAllWindows ( ) <nl> + { <nl> + cvDestroyAllWindows ( ) ; <nl> + } <nl> + <nl> void cv : : setWindowProperty ( const string & winname , int prop_id , double prop_value ) <nl> { <nl> cvSetWindowProperty ( winname . c_str ( ) , prop_id , prop_value ) ; <nl>
|
Added destroyAllWindows and docs ( ticket ) .
|
opencv/opencv
|
fce7ba4eaf61ba09f0b2771963c5e5b8e05d42b4
|
2011-06-20T13:24:48Z
|
mmm a / tests / cpp - tests / Classes / Texture2dTest / Texture2dTest . cpp <nl> ppp b / tests / cpp - tests / Classes / Texture2dTest / Texture2dTest . cpp <nl> void TexturePVRv3Premult : : transformSprite ( cocos2d : : Sprite * sprite ) <nl> } <nl> <nl> / / Implementation of ETC1 <nl> - <nl> - / * <nl> - class TextureETC1 : public TextureDemo <nl> - { <nl> - public : <nl> - TextureETC1 ( ) ; <nl> - <nl> - virtual std : : string title ( ) const override ; <nl> - virtual std : : string subtitle ( ) const override ; <nl> - } ; <nl> - * / <nl> - <nl> TextureETC1 : : TextureETC1 ( ) <nl> { <nl> auto sprite = Sprite : : create ( " Images / ETC1 . pkm " ) ; <nl> std : : string TextureETC1 : : title ( ) const <nl> <nl> std : : string TextureETC1 : : subtitle ( ) const <nl> { <nl> - return " only supported on android " ; <nl> + bool isSupportETCHardwareDecode = Configuration : : getInstance ( ) - > supportsETC ( ) ; <nl> + Application : : Platform platform = Application : : getInstance ( ) - > getTargetPlatform ( ) ; <nl> + std : : string ret ; <nl> + <nl> + static std : : unordered_map < int , const char * > platformMap = { <nl> + { ( int ) Application : : Platform : : OS_WINDOWS , " Windows " } , <nl> + { ( int ) Application : : Platform : : OS_LINUX , " Linux " } , <nl> + { ( int ) Application : : Platform : : OS_MAC , " macOS " } , <nl> + { ( int ) Application : : Platform : : OS_ANDROID , " Android " } , <nl> + { ( int ) Application : : Platform : : OS_IPHONE , " iPhone " } , <nl> + { ( int ) Application : : Platform : : OS_IPAD , " iPad " } , <nl> + { ( int ) Application : : Platform : : OS_BLACKBERRY , " BlackBerry " } , <nl> + { ( int ) Application : : Platform : : OS_NACL , " NativeClient " } , <nl> + { ( int ) Application : : Platform : : OS_EMSCRIPTEN , " Emscripten " } , <nl> + { ( int ) Application : : Platform : : OS_TIZEN , " Tizen " } , <nl> + { ( int ) Application : : Platform : : OS_WINRT , " WinRT " } , <nl> + { ( int ) Application : : Platform : : OS_WP8 , " Windows Phone 8 " } <nl> + } ; <nl> + <nl> + if ( isSupportETCHardwareDecode ) <nl> + { <nl> + ret + = " Hardware decode ETC1 on " ; <nl> + <nl> + } <nl> + else <nl> + { <nl> + ret + = " Software decode ETC1 on " ; <nl> + } <nl> + <nl> + auto iter = platformMap . find ( ( int ) platform ) ; <nl> + if ( iter ! = platformMap . end ( ) ) <nl> + { <nl> + ret + = iter - > second ; <nl> + } <nl> + else <nl> + { <nl> + ret + = " Unknown Platform " ; <nl> + } <nl> + <nl> + return ret ; <nl> } <nl> <nl> / / Implement of S3TC Dxt1 <nl>
|
More specific prompt for ETC1 test . ( )
|
cocos2d/cocos2d-x
|
c6b87f2b09f8b0aad04e1451b749929b71cf6ed7
|
2017-09-06T07:03:59Z
|
mmm a / ios / sdk / WeexSDK / Sources / Bridge / WXBridgeContext . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Bridge / WXBridgeContext . m <nl> - ( void ) destroyInstance : ( NSString * ) instance <nl> if ( [ self . insStack containsObject : instance ] ) { <nl> [ self . insStack removeObject : instance ] ; <nl> } <nl> + <nl> + if ( _jsBridge ) { <nl> + [ _jsBridge removeTimers : instance ] ; <nl> + } <nl> <nl> if ( self . sendQueue [ instance ] ) { <nl> [ self . sendQueue removeObjectForKey : instance ] ; <nl> mmm a / ios / sdk / WeexSDK / Sources / Bridge / WXJSCoreBridge . m <nl> ppp b / ios / sdk / WeexSDK / Sources / Bridge / WXJSCoreBridge . m <nl> <nl> # import " WXPolyfillSet . h " <nl> # import " JSValue + Weex . h " <nl> # import " WXJSExceptionProtocol . h " <nl> + # import " WXSDKManager . h " <nl> <nl> # import < dlfcn . h > <nl> <nl> <nl> @ interface WXJSCoreBridge ( ) <nl> <nl> @ property ( nonatomic , strong ) JSContext * jsContext ; <nl> + @ property ( nonatomic , strong ) NSMutableArray * timers ; <nl> <nl> @ end <nl> <nl> - ( instancetype ) init <nl> if ( WX_SYS_VERSION_GREATER_THAN_OR_EQUAL_TO ( @ " 8 . 0 " ) ) { <nl> _jsContext . name = @ " Weex Context " ; <nl> } <nl> + _timers = [ NSMutableArray new ] ; <nl> <nl> __weak typeof ( self ) weakSelf = self ; <nl> <nl> - ( instancetype ) init <nl> } afterDelay : [ timeout toDouble ] / 1000 ] ; <nl> } ; <nl> <nl> + _jsContext [ @ " setTimeoutWeex " ] = ^ ( JSValue * appid , JSValue * ret , JSValue * arg ) { <nl> + [ weakSelf triggerTimeout : [ appid toString ] ret : [ ret toString ] arg : [ arg toString ] ] ; <nl> + } ; <nl> + <nl> + _jsContext [ @ " setIntervalWeex " ] = ^ ( JSValue * appid , JSValue * ret , JSValue * arg ) { <nl> + [ weakSelf triggerInterval : [ appid toString ] ret : [ ret toString ] arg : [ arg toString ] ] ; <nl> + <nl> + } ; <nl> + <nl> _jsContext [ @ " nativeLog " ] = ^ ( ) { <nl> static NSDictionary * levelMap ; <nl> static dispatch_once_t onceToken ; <nl> - ( void ) garbageCollect <nl> / / } <nl> } <nl> <nl> + # pragma mark - Public <nl> + - ( void ) removeTimers : ( NSString * ) instance <nl> + { <nl> + if ( instance & & [ _timers containsObject : instance ] ) <nl> + { <nl> + [ _timers removeObject : instance ] ; <nl> + } <nl> + } <nl> + <nl> # pragma mark - Private <nl> <nl> - ( void ) triggerTimeout : ( void ( ^ ) ( ) ) block <nl> - ( void ) triggerTimeout : ( void ( ^ ) ( ) ) block <nl> block ( ) ; <nl> } <nl> <nl> + - ( void ) callBack : ( NSDictionary * ) dic <nl> + { <nl> + if ( [ dic objectForKey : @ " appid " ] & & [ _timers containsObject : [ dic objectForKey : @ " appid " ] ] ) { <nl> + [ [ WXSDKManager bridgeMgr ] callBack : [ dic objectForKey : @ " appid " ] funcId : [ dic objectForKey : @ " ret " ] params : [ dic objectForKey : @ " arg " ] keepAlive : NO ] ; <nl> + } <nl> + } <nl> + <nl> + <nl> + - ( void ) callBackInterval : ( NSDictionary * ) dic <nl> + { <nl> + if ( [ dic objectForKey : @ " appid " ] & & [ _timers containsObject : [ dic objectForKey : @ " appid " ] ] ) { <nl> + [ [ WXSDKManager bridgeMgr ] callBack : [ dic objectForKey : @ " appid " ] funcId : [ dic objectForKey : @ " ret " ] params : nil keepAlive : YES ] ; <nl> + [ self triggerInterval : [ dic objectForKey : @ " appid " ] ret : [ dic objectForKey : @ " ret " ] arg : [ dic objectForKey : @ " arg " ] ] ; <nl> + } <nl> + <nl> + } <nl> + <nl> + - ( void ) triggerTimeout : ( NSString * ) appid ret : ( NSString * ) ret arg : ( NSString * ) arg <nl> + { <nl> + <nl> + double interval = [ arg doubleValue ] / 1000 . 0f ; <nl> + if ( WXFloatEqual ( interval , 0 ) ) { <nl> + return ; <nl> + } <nl> + if ( ! [ _timers containsObject : appid ] ) { <nl> + [ _timers addObject : appid ] ; <nl> + } <nl> + dispatch_time_t time = dispatch_time ( DISPATCH_TIME_NOW , interval * NSEC_PER_SEC ) ; <nl> + dispatch_after ( time , dispatch_get_global_queue ( DISPATCH_QUEUE_PRIORITY_DEFAULT , 0 ) , ^ { <nl> + NSMutableDictionary * dic = [ NSMutableDictionary new ] ; <nl> + [ dic setObject : appid forKey : @ " appid " ] ; <nl> + [ dic setObject : ret forKey : @ " ret " ] ; <nl> + [ dic setObject : arg forKey : @ " arg " ] ; <nl> + [ self performSelector : @ selector ( callBack : ) withObject : dic ] ; <nl> + } ) ; <nl> + } <nl> + <nl> + - ( void ) triggerInterval : ( NSString * ) appid ret : ( NSString * ) ret arg : ( NSString * ) arg <nl> + { <nl> + double interval = [ arg doubleValue ] / 1000 . 0f ; <nl> + if ( WXFloatEqual ( interval , 0 ) ) { <nl> + return ; <nl> + } <nl> + if ( ! [ _timers containsObject : appid ] ) { <nl> + [ _timers addObject : appid ] ; <nl> + } <nl> + dispatch_time_t time = dispatch_time ( DISPATCH_TIME_NOW , interval * NSEC_PER_SEC ) ; <nl> + dispatch_after ( time , dispatch_get_global_queue ( DISPATCH_QUEUE_PRIORITY_DEFAULT , 0 ) , ^ { <nl> + NSMutableDictionary * dic = [ NSMutableDictionary new ] ; <nl> + [ dic setObject : appid forKey : @ " appid " ] ; <nl> + [ dic setObject : ret forKey : @ " ret " ] ; <nl> + [ dic setObject : arg forKey : @ " arg " ] ; <nl> + [ self performSelector : @ selector ( callBackInterval : ) withObject : dic ] ; <nl> + } ) ; <nl> + } <nl> + <nl> @ end <nl> mmm a / ios / sdk / WeexSDK / Sources / Protocol / WXBridgeProtocol . h <nl> ppp b / ios / sdk / WeexSDK / Sources / Protocol / WXBridgeProtocol . h <nl> typedef void ( ^ WXJSCallNativeComponent ) ( NSString * instanceId , NSString * componen <nl> * / <nl> - ( void ) resetEnvironment ; <nl> <nl> + / * * <nl> + * Remove instance ' s timer . <nl> + * / <nl> + - ( void ) removeTimers : ( NSString * ) instance ; <nl> + <nl> @ optional <nl> <nl> / * * <nl>
|
+ [ ios ] add feature timer
|
apache/incubator-weex
|
7c6ecb7873f2b556322b20e17b443e1186846275
|
2017-04-06T10:46:32Z
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.