idx
int64
0
165k
question
stringlengths
73
4.15k
target
stringlengths
5
918
len_question
int64
21
890
len_target
int64
3
255
400
private int [ ] convertBatch ( int [ ] batch ) { int [ ] conv = new int [ batch . length ] ; for ( int i = 0 ; i < batch . length ; i ++ ) { conv [ i ] = sample [ batch [ i ] ] ; } return conv ; }
Converts a batch indexing into the sample to a batch indexing into the original function .
62
19
401
public static boolean containsAtLeastOneNonBlank ( List < String > list ) { for ( String str : list ) { if ( StringUtils . isNotBlank ( str ) ) { return true ; } } return false ; }
Check that a list allowing null and empty item contains at least one element that is not blank .
51
19
402
public static List < Integer > toIntegerList ( List < String > strList , boolean failOnException ) { List < Integer > intList = new ArrayList < Integer > ( ) ; for ( String str : strList ) { try { intList . add ( Integer . parseInt ( str ) ) ; } catch ( NumberFormatException nfe ) { if ( failOnException ) { return null...
Parse a list of String into a list of Integer . If one element can not be parsed the behavior depends on the value of failOnException .
103
30
403
public static void add ( double [ ] array1 , double [ ] array2 ) { assert ( array1 . length == array2 . length ) ; for ( int i = 0 ; i < array1 . length ; i ++ ) { array1 [ i ] += array2 [ i ] ; } }
Each element of the second array is added to each element of the first .
63
15
404
public static boolean containsOnlyNull ( Object ... values ) { for ( Object o : values ) { if ( o != null ) { return false ; } } return true ; }
Check that an array only contains null elements .
36
9
405
public static boolean containsOnlyNotNull ( Object ... values ) { for ( Object o : values ) { if ( o == null ) { return false ; } } return true ; }
Check that an array only contains elements that are not null .
37
12
406
@ RequestMapping ( value = "/soy/compileJs" , method = GET ) public ResponseEntity < String > compile ( @ RequestParam ( required = false , value = "hash" , defaultValue = "" ) final String hash , @ RequestParam ( required = true , value = "file" ) final String [ ] templateFileNames , @ RequestParam ( required = false ...
An endpoint to compile an array of soy templates to JavaScript .
160
12
407
public int [ ] sampleBatchWithReplacement ( ) { // Sample the indices with replacement. int [ ] batch = new int [ batchSize ] ; for ( int i = 0 ; i < batch . length ; i ++ ) { batch [ i ] = Prng . nextInt ( numExamples ) ; } return batch ; }
Samples a batch of indices in the range [ 0 numExamples ) with replacement .
69
17
408
public int [ ] sampleBatchWithoutReplacement ( ) { int [ ] batch = new int [ batchSize ] ; for ( int i = 0 ; i < batch . length ; i ++ ) { if ( cur == indices . length ) { cur = 0 ; } if ( cur == 0 ) { IntArrays . shuffle ( indices ) ; } batch [ i ] = indices [ cur ++ ] ; } return batch ; }
Samples a batch of indices in the range [ 0 numExamples ) without replacement .
89
17
409
public void adjustGlassSize ( ) { if ( isGlassEnabled ( ) ) { ResizeHandler handler = getGlassResizer ( ) ; if ( handler != null ) handler . onResize ( null ) ; } }
This can be called to adjust the size of the dialog glass . It is implemented using JSNI to bypass the private keyword on the glassResizer .
46
31
410
public static Bounds getSymmetricBounds ( int dim , double l , double u ) { double [ ] L = new double [ dim ] ; double [ ] U = new double [ dim ] ; for ( int i = 0 ; i < dim ; i ++ ) { L [ i ] = l ; U [ i ] = u ; } return new Bounds ( L , U ) ; }
Gets bounds which are identical for all dimensions .
84
10
411
public static Optional < Tag > parse ( final String httpTag ) { Tag result = null ; boolean weak = false ; String internal = httpTag ; if ( internal . startsWith ( "W/" ) ) { weak = true ; internal = internal . substring ( 2 ) ; } if ( internal . startsWith ( "\"" ) && internal . endsWith ( "\"" ) ) { result = new Tag ...
Parses a tag formatted as defined by the HTTP standard .
143
13
412
public String format ( ) { if ( getName ( ) . equals ( "*" ) ) { return "*" ; } else { StringBuilder sb = new StringBuilder ( ) ; if ( isWeak ( ) ) { sb . append ( "W/" ) ; } return sb . append ( ' ' ) . append ( getName ( ) ) . append ( ' ' ) . toString ( ) ; } }
Returns tag formatted as an HTTP tag string .
90
9
413
public static PropertyResourceBundle getBundle ( String baseName , Locale locale ) throws UnsupportedEncodingException , IOException { InputStream is = UTF8PropertyResourceBundle . class . getResourceAsStream ( "/" + baseName + "_" + locale . toString ( ) + PROPERTIES_EXT ) ; if ( is != null ) { return new PropertyReso...
Get a PropertyResourceBundle able to read an UTF - 8 properties file .
104
16
414
@ Override public boolean minimize ( DifferentiableBatchFunction function , IntDoubleVector point ) { return minimize ( function , point , null ) ; }
Minimize the function starting at the given initial point .
31
11
415
@ SuppressWarnings ( "unchecked" ) public < T > T convertElement ( ConversionContext context , Object source , TypeReference < T > destinationType ) throws ConverterException { return ( T ) elementConverter . convert ( context , source , destinationType ) ; }
Convert element to another object given a parameterized type signature
60
12
416
public Conditionals addIfMatch ( Tag tag ) { Preconditions . checkArgument ( ! modifiedSince . isPresent ( ) , String . format ( ERROR_MESSAGE , HeaderConstants . IF_MATCH , HeaderConstants . IF_MODIFIED_SINCE ) ) ; Preconditions . checkArgument ( noneMatch . isEmpty ( ) , String . format ( ERROR_MESSAGE , HeaderConsta...
Adds tags to the If - Match header .
248
9
417
public Conditionals ifModifiedSince ( LocalDateTime time ) { Preconditions . checkArgument ( match . isEmpty ( ) , String . format ( ERROR_MESSAGE , HeaderConstants . IF_MODIFIED_SINCE , HeaderConstants . IF_MATCH ) ) ; Preconditions . checkArgument ( ! unModifiedSince . isPresent ( ) , String . format ( ERROR_MESSAGE ...
You should use the server s time here . Otherwise you might get unexpected results .
161
16
418
public Headers toHeaders ( ) { Headers headers = new Headers ( ) ; if ( ! getMatch ( ) . isEmpty ( ) ) { headers = headers . add ( new Header ( HeaderConstants . IF_MATCH , buildTagHeaderValue ( getMatch ( ) ) ) ) ; } if ( ! getNoneMatch ( ) . isEmpty ( ) ) { headers = headers . add ( new Header ( HeaderConstants . IF_...
Converts the Conditionals into real headers .
221
9
419
public Collection < QName > getPortComponentQNames ( ) { //TODO:Check if there is just one QName that drives all portcomponents //or each port component can have a distinct QName (namespace/prefix) //Maintain uniqueness of the QName Map < String , QName > map = new HashMap < String , QName > ( ) ; for ( PortComponentMe...
Get the QNames of the port components to be declared in the namespaces
135
15
420
public PortComponentMetaData getPortComponentByWsdlPort ( String name ) { ArrayList < String > pcNames = new ArrayList < String > ( ) ; for ( PortComponentMetaData pc : portComponents ) { String wsdlPortName = pc . getWsdlPort ( ) . getLocalPart ( ) ; if ( wsdlPortName . equals ( name ) ) return pc ; pcNames . add ( ws...
Lookup a PortComponentMetaData by wsdl - port local part
126
15
421
public static final void setBounds ( UIObject o , Rect bounds ) { setPosition ( o , bounds ) ; setSize ( o , bounds ) ; }
Sets the bounds of a UIObject moving and sizing to match the bounds specified . Currently used for the itemhover and useful for other absolutely positioned elements .
33
31
422
public static final void setPosition ( UIObject o , Rect pos ) { Style style = o . getElement ( ) . getStyle ( ) ; style . setPropertyPx ( "left" , pos . x ) ; style . setPropertyPx ( "top" , pos . y ) ; }
Sets the position of a UIObject
63
8
423
public static final void setSize ( UIObject o , Rect size ) { o . setPixelSize ( size . w , size . h ) ; }
Sets the size of a UIObject
31
8
424
public static final boolean isInside ( int x , int y , Rect box ) { return ( box . x < x && x < box . x + box . w && box . y < y && y < box . y + box . h ) ; }
Determines if a point is inside a box .
53
11
425
public static final boolean isMouseInside ( NativeEvent event , Element element ) { return isInside ( event . getClientX ( ) + Window . getScrollLeft ( ) , event . getClientY ( ) + Window . getScrollTop ( ) , getBounds ( element ) ) ; }
Determines if a mouse event is inside a box .
61
12
426
public static final Rect getViewportBounds ( ) { return new Rect ( Window . getScrollLeft ( ) , Window . getScrollTop ( ) , Window . getClientWidth ( ) , Window . getClientHeight ( ) ) ; }
This takes into account scrolling and will be in absolute coordinates where the top left corner of the page is 0 0 but the viewport may be scrolled to something else .
50
34
427
public static final Date utc2date ( Long time ) { // don't accept negative values if ( time == null || time < 0 ) return null ; // add the timezone offset time += timezoneOffsetMillis ( new Date ( time ) ) ; return new Date ( time ) ; }
Converts a time in UTC to a gwt Date object which is in the timezone of the current browser .
61
23
428
public static final Long date2utc ( Date date ) { // use null for a null date if ( date == null ) return null ; long time = date . getTime ( ) ; // remove the timezone offset time -= timezoneOffsetMillis ( date ) ; return time ; }
Converts a gwt Date in the timezone of the current browser to a time in UTC .
60
20
429
public static FullTypeSignature getTypeSignature ( String typeSignatureString , boolean useInternalFormFullyQualifiedName ) { String key ; if ( ! useInternalFormFullyQualifiedName ) { key = typeSignatureString . replace ( ' ' , ' ' ) . replace ( ' ' , ' ' ) ; } else { key = typeSignatureString ; } // we always use the ...
get TypeSignature given the signature
209
7
430
public static FullTypeSignature getTypeSignature ( Class < ? > clazz , Class < ? > [ ] typeArgs ) { ClassTypeSignature rawClassTypeSignature = ( ClassTypeSignature ) javaTypeToTypeSignature . getTypeSignature ( clazz ) ; TypeArgSignature [ ] typeArgSignatures = new TypeArgSignature [ typeArgs . length ] ; for ( int i =...
get the TypeSignature corresponding to given class with given type arguments
209
13
431
public static OptionalString ofNullable ( ResourceKey key , String value ) { return new GenericOptionalString ( RUNTIME_SOURCE , key , value ) ; }
Returns new instance of OptionalString with given key and value
33
11
432
public Archetype parse ( String adl ) { try { return parse ( new StringReader ( adl ) ) ; } catch ( IOException e ) { // StringReader should never throw an IOException throw new AssertionError ( e ) ; } }
Parses an adl source into a differential archetype .
53
12
433
@ SuppressWarnings ( { "unchecked" , "unused" } ) public static < T > T [ ] object2Array ( final Class < T > clazz , final Object obj ) { return ( T [ ] ) obj ; }
We try to convert an Object to an Array and this is not easy in Java so we need a little bit of nasty magic .
53
26
434
public void pauseUpload ( ) throws LocalOperationException { if ( state == State . UPLOADING ) { setState ( State . PAUSED ) ; executor . hardStop ( ) ; } else { throw new LocalOperationException ( "Attempt to pause upload while assembly is not uploading" ) ; } }
Pauses the file upload . This is a blocking function that would try to wait till the assembly file uploads have actually been paused if possible .
65
29
435
protected AssemblyResponse watchStatus ( ) throws LocalOperationException , RequestException { AssemblyResponse response ; do { response = getClient ( ) . getAssemblyByUrl ( url ) ; try { Thread . sleep ( 1000 ) ; } catch ( InterruptedException e ) { throw new LocalOperationException ( e ) ; } } while ( ! response . is...
Runs intermediate check on the Assembly status until it is finished executing then returns it as a response .
91
20
436
private long getTotalUploadSize ( ) throws IOException { long size = 0 ; for ( Map . Entry < String , File > entry : files . entrySet ( ) ) { size += entry . getValue ( ) . length ( ) ; } for ( Map . Entry < String , InputStream > entry : fileStreams . entrySet ( ) ) { size += entry . getValue ( ) . available ( ) ; } r...
used for upload progress
92
4
437
public static < T extends InterconnectObject > T fromJson ( String data , Class < T > clazz ) throws IOException { return InterconnectMapper . mapper . readValue ( data , clazz ) ; }
Creates an object from the given JSON data .
47
10
438
public Response save ( ) throws RequestException , LocalOperationException { Map < String , Object > templateData = new HashMap < String , Object > ( ) ; templateData . put ( "name" , name ) ; options . put ( "steps" , steps . toMap ( ) ) ; templateData . put ( "template" , options ) ; Request request = new Request ( t...
Submits the configured template to Transloadit .
103
10
439
public boolean matches ( String resourcePath ) { if ( ! valid ) { return false ; } if ( resourcePath == null ) { return acceptsContextPathEmpty ; } if ( contextPathRegex != null && ! contextPathRegex . matcher ( resourcePath ) . matches ( ) ) { return false ; } if ( contextPathBlacklistRegex != null && contextPathBlack...
Checks if this service implementation accepts the given resource path .
103
12
440
private ClassLoaderInterface getClassLoader ( ) { Map < String , Object > application = ActionContext . getContext ( ) . getApplication ( ) ; if ( application != null ) { return ( ClassLoaderInterface ) application . get ( ClassLoaderInterface . CLASS_LOADER_INTERFACE ) ; } return null ; }
this class loader interface can be used by other plugins to lookup resources from the bundles . A temporary class loader interface is set during other configuration loading as well
66
30
441
public @ Nullable String build ( ) { StringBuilder queryString = new StringBuilder ( ) ; for ( NameValuePair param : params ) { if ( queryString . length ( ) > 0 ) { queryString . append ( PARAM_SEPARATOR ) ; } queryString . append ( Escape . urlEncode ( param . getName ( ) ) ) ; queryString . append ( VALUE_SEPARATOR ...
Build query string .
140
4
442
public AssemblyResponse cancelAssembly ( String url ) throws RequestException , LocalOperationException { Request request = new Request ( this ) ; return new AssemblyResponse ( request . delete ( url , new HashMap < String , Object > ( ) ) ) ; }
cancels a running assembly .
51
7
443
public Response getTemplate ( String id ) throws RequestException , LocalOperationException { Request request = new Request ( this ) ; return new Response ( request . get ( "/templates/" + id ) ) ; }
Returns a single template .
43
5
444
public Response updateTemplate ( String id , Map < String , Object > options ) throws RequestException , LocalOperationException { Request request = new Request ( this ) ; return new Response ( request . put ( "/templates/" + id , options ) ) ; }
Updates the template with the specified id .
53
9
445
public Response deleteTemplate ( String id ) throws RequestException , LocalOperationException { Request request = new Request ( this ) ; return new Response ( request . delete ( "/templates/" + id , new HashMap < String , Object > ( ) ) ) ; }
Deletes a template .
54
5
446
public ListResponse listTemplates ( Map < String , Object > options ) throws RequestException , LocalOperationException { Request request = new Request ( this ) ; return new ListResponse ( request . get ( "/templates" , options ) ) ; }
Returns a list of all templates under the user account
51
10
447
public Response getBill ( int month , int year ) throws RequestException , LocalOperationException { Request request = new Request ( this ) ; return new Response ( request . get ( "/bill/" + year + String . format ( "-%02d" , month ) ) ) ; }
Returns the bill for the month specified .
58
8
448
@ SuppressWarnings ( "unchecked" ) public static < T > T convert ( Object fromValue , Class < T > toType ) throws TypeCastException { return convert ( fromValue , toType , ( String ) null ) ; }
Convert given value to given target
52
7
449
public SignedJWT verifyToken ( String jwtString ) throws ParseException { try { SignedJWT jwt = SignedJWT . parse ( jwtString ) ; if ( jwt . verify ( new MACVerifier ( this . jwtSharedSecret ) ) ) { return jwt ; } return null ; } catch ( JOSEException e ) { throw new RuntimeException ( "Error verifying JSON Web Token" ...
Check the given JWT
94
5
450
public void bind ( T service , Map < String , Object > props ) { synchronized ( serviceMap ) { serviceMap . put ( ServiceUtil . getComparableForServiceRanking ( props ) , service ) ; updateSortedServices ( ) ; } }
Handle bind service event .
54
5
451
public void unbind ( T service , Map < String , Object > props ) { synchronized ( serviceMap ) { serviceMap . remove ( ServiceUtil . getComparableForServiceRanking ( props ) ) ; updateSortedServices ( ) ; } }
Handle unbind service event .
53
6
452
private void updateSortedServices ( ) { List < T > copiedList = new ArrayList < T > ( serviceMap . values ( ) ) ; sortedServices = Collections . unmodifiableList ( copiedList ) ; if ( changeListener != null ) { changeListener . changed ( ) ; } }
Update list of sorted services by copying it from the array and making it unmodifiable .
62
18
453
public static < T > JacksonParser < T > json ( Class < T > contentType ) { return new JacksonParser <> ( null , contentType ) ; }
Creates typed parser
34
4
454
public void addStep ( String name , String robot , Map < String , Object > options ) { all . put ( name , new Step ( name , robot , options ) ) ; }
Adds a new step to the list of steps .
38
10
455
protected boolean determineFeatureState ( final ITemplateContext context , final IProcessableElementTag tag , final AttributeName attributeName , final String attributeValue , boolean defaultState ) { final IStandardExpressionParser expressionParser = StandardExpressions . getExpressionParser ( context . getConfigurati...
Determines the feature state
124
6
456
public void init ( Configuration configuration ) { if ( devMode && reload && ! listeningToDispatcher ) { // this is the only way I found to be able to get added to to // ConfigurationProvider list // listening to events in Dispatcher listeningToDispatcher = true ; Dispatcher . addDispatcherListener ( this ) ; } }
Not used .
74
3
457
public void addFile ( File file ) { String name = "file" ; files . put ( normalizeDuplicateName ( name ) , file ) ; }
Adds a file to your assembly but automatically generates the field name of the file .
34
16
458
public void addFile ( InputStream inputStream ) { String name = "file" ; fileStreams . put ( normalizeDuplicateName ( name ) , inputStream ) ; }
Adds a file to your assembly but automatically genarates the name of the file .
39
17
459
public void removeFile ( String name ) { if ( files . containsKey ( name ) ) { files . remove ( name ) ; } if ( fileStreams . containsKey ( name ) ) { fileStreams . remove ( name ) ; } }
Removes file from your assembly .
52
7
460
public AssemblyResponse save ( boolean isResumable ) throws RequestException , LocalOperationException { Request request = new Request ( getClient ( ) ) ; options . put ( "steps" , steps . toMap ( ) ) ; // only do tus uploads if files will be uploaded if ( isResumable && getFilesCount ( ) > 0 ) { Map < String , String ...
Submits the configured assembly to Transloadit for processing .
284
12
461
protected void processTusFiles ( String assemblyUrl ) throws IOException , ProtocolException { tusClient . setUploadCreationURL ( new URL ( getClient ( ) . getHostUrl ( ) + "/resumable/files/" ) ) ; tusClient . enableResuming ( tusURLStore ) ; for ( Map . Entry < String , File > entry : files . entrySet ( ) ) { process...
Prepares all files added for tus uploads .
158
11
462
@ SuppressWarnings ( "unchecked" ) public static < T extends Serializable > T makeClone ( T from ) { return ( T ) SerializationUtils . clone ( from ) ; }
Creates a clone using java serialization
44
8
463
private static int checkResult ( int result ) { if ( exceptionsEnabled && result != cudnnStatus . CUDNN_STATUS_SUCCESS ) { throw new CudaException ( cudnnStatus . stringFor ( result ) ) ; } return result ; }
If the given result is not cudnnStatus . CUDNN_STATUS_SUCCESS and exceptions have been enabled this method will throw a CudaException with an error message that corresponds to the given result code . Otherwise the given result is simply returned .
57
54
464
public static int cudnnSetTensor4dDescriptorEx ( cudnnTensorDescriptor tensorDesc , int dataType , /** image data type */ int n , /** number of inputs (batch size) */ int c , /** number of input feature maps */ int h , /** height of input section */ int w , /** width of input section */ int nStride , int cStride , int ...
width of input section
150
4
465
public static int cudnnOpTensor ( cudnnHandle handle , cudnnOpTensorDescriptor opTensorDesc , Pointer alpha1 , cudnnTensorDescriptor aDesc , Pointer A , Pointer alpha2 , cudnnTensorDescriptor bDesc , Pointer B , Pointer beta , cudnnTensorDescriptor cDesc , Pointer C ) { return checkResult ( cudnnOpTensorNative ( handle...
B tensor is ignored for CUDNN_OP_TENSOR_SQRT CUDNN_OP_TENSOR_NOT .
135
31
466
public static int cudnnGetReductionIndicesSize ( cudnnHandle handle , cudnnReduceTensorDescriptor reduceTensorDesc , cudnnTensorDescriptor aDesc , cudnnTensorDescriptor cDesc , long [ ] sizeInBytes ) { return checkResult ( cudnnGetReductionIndicesSizeNative ( handle , reduceTensorDesc , aDesc , cDesc , sizeInBytes ) ) ...
Helper function to return the minimum size of the index space to be passed to the reduction given the input and output tensors
99
24
467
public static int cudnnGetReductionWorkspaceSize ( cudnnHandle handle , cudnnReduceTensorDescriptor reduceTensorDesc , cudnnTensorDescriptor aDesc , cudnnTensorDescriptor cDesc , long [ ] sizeInBytes ) { return checkResult ( cudnnGetReductionWorkspaceSizeNative ( handle , reduceTensorDesc , aDesc , cDesc , sizeInBytes ...
Helper function to return the minimum size of the workspace to be passed to the reduction given the input and output tensors
99
23
468
public static int cudnnReduceTensor ( cudnnHandle handle , cudnnReduceTensorDescriptor reduceTensorDesc , Pointer indices , long indicesSizeInBytes , Pointer workspace , long workspaceSizeInBytes , Pointer alpha , cudnnTensorDescriptor aDesc , Pointer A , Pointer beta , cudnnTensorDescriptor cDesc , Pointer C ) { retur...
The indices space is ignored for reduce ops other than min or max .
142
14
469
public static int cudnnGetConvolutionNdDescriptor ( cudnnConvolutionDescriptor convDesc , int arrayLengthRequested , int [ ] arrayLength , int [ ] padA , int [ ] strideA , int [ ] dilationA , int [ ] mode , int [ ] computeType ) /** convolution data type */ { return checkResult ( cudnnGetConvolutionNdDescriptorNative (...
convolution data type
124
4
470
public static int cudnnConvolutionForward ( cudnnHandle handle , Pointer alpha , cudnnTensorDescriptor xDesc , Pointer x , cudnnFilterDescriptor wDesc , Pointer w , cudnnConvolutionDescriptor convDesc , int algo , Pointer workSpace , long workSpaceSizeInBytes , Pointer beta , cudnnTensorDescriptor yDesc , Pointer y ) {...
Function to perform the forward pass for batch convolution
150
10
471
public static int cudnnConvolutionBackwardBias ( cudnnHandle handle , Pointer alpha , cudnnTensorDescriptor dyDesc , Pointer dy , Pointer beta , cudnnTensorDescriptor dbDesc , Pointer db ) { return checkResult ( cudnnConvolutionBackwardBiasNative ( handle , alpha , dyDesc , dy , beta , dbDesc , db ) ) ; }
Function to compute the bias gradient for batch convolution
94
10
472
public static int cudnnSoftmaxForward ( cudnnHandle handle , int algo , int mode , Pointer alpha , cudnnTensorDescriptor xDesc , Pointer x , Pointer beta , cudnnTensorDescriptor yDesc , Pointer y ) { return checkResult ( cudnnSoftmaxForwardNative ( handle , algo , mode , alpha , xDesc , x , beta , yDesc , y ) ) ; }
Function to perform forward softmax
98
6
473
public static int cudnnSoftmaxBackward ( cudnnHandle handle , int algo , int mode , Pointer alpha , cudnnTensorDescriptor yDesc , Pointer y , cudnnTensorDescriptor dyDesc , Pointer dy , Pointer beta , cudnnTensorDescriptor dxDesc , Pointer dx ) { return checkResult ( cudnnSoftmaxBackwardNative ( handle , algo , mode , ...
Function to perform backward softmax
120
6
474
public static int cudnnPoolingForward ( cudnnHandle handle , cudnnPoolingDescriptor poolingDesc , Pointer alpha , cudnnTensorDescriptor xDesc , Pointer x , Pointer beta , cudnnTensorDescriptor yDesc , Pointer y ) { return checkResult ( cudnnPoolingForwardNative ( handle , poolingDesc , alpha , xDesc , x , beta , yDesc ...
Function to perform forward pooling
102
6
475
public static int cudnnPoolingBackward ( cudnnHandle handle , cudnnPoolingDescriptor poolingDesc , Pointer alpha , cudnnTensorDescriptor yDesc , Pointer y , cudnnTensorDescriptor dyDesc , Pointer dy , cudnnTensorDescriptor xDesc , Pointer x , Pointer beta , cudnnTensorDescriptor dxDesc , Pointer dx ) { return checkResu...
Function to perform backward pooling
144
6
476
public static int cudnnGetActivationDescriptor ( cudnnActivationDescriptor activationDesc , int [ ] mode , int [ ] reluNanOpt , double [ ] coef ) /** ceiling for clipped RELU, alpha for ELU */ { return checkResult ( cudnnGetActivationDescriptorNative ( activationDesc , mode , reluNanOpt , coef ) ) ; }
ceiling for clipped RELU alpha for ELU
89
10
477
public static int cudnnActivationForward ( cudnnHandle handle , cudnnActivationDescriptor activationDesc , Pointer alpha , cudnnTensorDescriptor xDesc , Pointer x , Pointer beta , cudnnTensorDescriptor yDesc , Pointer y ) { return checkResult ( cudnnActivationForwardNative ( handle , activationDesc , alpha , xDesc , x ...
Function to perform forward activation
100
5
478
public static int cudnnActivationBackward ( cudnnHandle handle , cudnnActivationDescriptor activationDesc , Pointer alpha , cudnnTensorDescriptor yDesc , Pointer y , cudnnTensorDescriptor dyDesc , Pointer dy , cudnnTensorDescriptor xDesc , Pointer x , Pointer beta , cudnnTensorDescriptor dxDesc , Pointer dx ) { return ...
Function to perform backward activation
142
5
479
public static int cudnnLRNCrossChannelForward ( cudnnHandle handle , cudnnLRNDescriptor normDesc , int lrnMode , Pointer alpha , cudnnTensorDescriptor xDesc , Pointer x , Pointer beta , cudnnTensorDescriptor yDesc , Pointer y ) { return checkResult ( cudnnLRNCrossChannelForwardNative ( handle , normDesc , lrnMode , alp...
LRN cross - channel forward computation . Double parameters cast to tensor data type
113
16
480
public static int cudnnLRNCrossChannelBackward ( cudnnHandle handle , cudnnLRNDescriptor normDesc , int lrnMode , Pointer alpha , cudnnTensorDescriptor yDesc , Pointer y , cudnnTensorDescriptor dyDesc , Pointer dy , cudnnTensorDescriptor xDesc , Pointer x , Pointer beta , cudnnTensorDescriptor dxDesc , Pointer dx ) { r...
LRN cross - channel backward computation . Double parameters cast to tensor data type
155
16
481
public static int cudnnBatchNormalizationBackward ( cudnnHandle handle , int mode , Pointer alphaDataDiff , Pointer betaDataDiff , Pointer alphaParamDiff , Pointer betaParamDiff , cudnnTensorDescriptor xDesc , /** same desc for x, dx, dy */ Pointer x , cudnnTensorDescriptor dyDesc , Pointer dy , cudnnTensorDescriptor d...
Performs backward pass of Batch Normalization layer . Returns x gradient bnScale gradient and bnBias gradient
303
24
482
public static int cudnnRestoreDropoutDescriptor ( cudnnDropoutDescriptor dropoutDesc , cudnnHandle handle , float dropout , Pointer states , long stateSizeInBytes , long seed ) { return checkResult ( cudnnRestoreDropoutDescriptorNative ( dropoutDesc , handle , dropout , states , stateSizeInBytes , seed ) ) ; }
Restores the dropout descriptor to a previously saved - off state
87
13
483
public static int cudnnCreatePersistentRNNPlan ( cudnnRNNDescriptor rnnDesc , int minibatch , int dataType , cudnnPersistentRNNPlan plan ) { return checkResult ( cudnnCreatePersistentRNNPlanNative ( rnnDesc , minibatch , dataType , plan ) ) ; }
Expensive . Creates the plan for the specific settings .
76
12
484
public static int cudnnGetRNNWorkspaceSize ( cudnnHandle handle , cudnnRNNDescriptor rnnDesc , int seqLength , cudnnTensorDescriptor [ ] xDesc , long [ ] sizeInBytes ) { return checkResult ( cudnnGetRNNWorkspaceSizeNative ( handle , rnnDesc , seqLength , xDesc , sizeInBytes ) ) ; }
dataType in weight descriptors and input descriptors is used to describe storage
90
15
485
public static int cudnnCTCLoss ( cudnnHandle handle , cudnnTensorDescriptor probsDesc , /** Tensor descriptor for probabilities, the dimensions are T,N,A (T is the timing steps, N is the mini batch size, A is the alphabet size) */ Pointer probs , /** probabilities after softmax, in GPU memory */ int [ ] labels , /** la...
return the ctc costs and gradients given the probabilities and labels
319
13
486
public static int cudnnGetCTCLossWorkspaceSize ( cudnnHandle handle , cudnnTensorDescriptor probsDesc , /** Tensor descriptor for probabilities, the dimensions are T,N,A (T is the timing steps, N is the mini batch size, A is the alphabet size) */ cudnnTensorDescriptor gradientsDesc , /** Tensor descriptor for gradients...
return the workspace size needed for ctc
255
8
487
public static int cudnnGetRNNDataDescriptor ( cudnnRNNDataDescriptor RNNDataDesc , int [ ] dataType , int [ ] layout , int [ ] maxSeqLength , int [ ] batchSize , int [ ] vectorSize , int arrayLengthRequested , int [ ] seqLengthArray , Pointer paddingFill ) { return checkResult ( cudnnGetRNNDataDescriptorNative ( RNNDat...
symbol for filling padding position in output
130
8
488
public static < T > OptionalValue < T > ofNullable ( T value ) { return new GenericOptionalValue < T > ( RUNTIME_SOURCE , DEFAULT_KEY , value ) ; }
Returns new instance of OptionalValue with given value
41
9
489
public static < T > OptionalValue < T > ofNullable ( ResourceKey key , T value ) { return new GenericOptionalValue < T > ( RUNTIME_SOURCE , key , value ) ; }
Returns new instance of OptionalValue with given key and value
42
11
490
public static void stopService ( ) { DaemonStarter . currentPhase . set ( LifecyclePhase . STOPPING ) ; final CountDownLatch cdl = new CountDownLatch ( 1 ) ; Executors . newSingleThreadExecutor ( ) . execute ( ( ) -> { DaemonStarter . getLifecycleListener ( ) . stopping ( ) ; DaemonStarter . daemon . stop ( ) ; cdl . c...
Stop the service and end the program
219
7
491
private static void handleSignals ( ) { if ( DaemonStarter . isRunMode ( ) ) { try { // handle SIGHUP to prevent process to get killed when exiting the tty Signal . handle ( new Signal ( "HUP" ) , arg0 -> { // Nothing to do here System . out . println ( "SIG INT" ) ; } ) ; } catch ( IllegalArgumentException e ) { Syste...
I KNOW WHAT I AM DOING
371
7
492
public static void abortSystem ( final Throwable error ) { DaemonStarter . currentPhase . set ( LifecyclePhase . ABORTING ) ; try { DaemonStarter . getLifecycleListener ( ) . aborting ( ) ; } catch ( Exception e ) { DaemonStarter . rlog . error ( "Custom abort failed" , e ) ; } if ( error != null ) { DaemonStarter . rl...
Abort the daemon
185
4
493
@ PostConstruct public void initDatabase ( ) { MongoDBInit . LOGGER . info ( "initializing MongoDB" ) ; String dbName = System . getProperty ( "mongodb.name" ) ; if ( dbName == null ) { throw new RuntimeException ( "Missing database name; Set system property 'mongodb.name'" ) ; } MongoDatabase db = this . mongo . getDa...
init database with demo data
418
5
494
public static Map < String , Object > with ( Object ... params ) { Map < String , Object > map = new HashMap <> ( ) ; for ( int i = 0 ; i < params . length ; i ++ ) { map . put ( String . valueOf ( i ) , params [ i ] ) ; } return map ; }
Convenience wrapper for message parameters
71
7
495
public static ResourceResolutionContext context ( ResourceResolutionComponent [ ] components , Map < String , Object > messageParams ) { return new ResourceResolutionContext ( components , messageParams ) ; }
Build resolution context in which message will be discovered and built
42
11
496
@ Inject ( "struts.json.action.fileProtocols" ) public void setFileProtocols ( String fileProtocols ) { if ( StringUtils . isNotBlank ( fileProtocols ) ) { this . fileProtocols = TextParseUtil . commaDelimitedStringToSet ( fileProtocols ) ; } }
File URLs whose protocol are in these list will be processed as jars containing classes
80
15
497
protected boolean cannotInstantiate ( Class < ? > actionClass ) { return actionClass . isAnnotation ( ) || actionClass . isInterface ( ) || actionClass . isEnum ( ) || ( actionClass . getModifiers ( ) & Modifier . ABSTRACT ) != 0 || actionClass . isAnonymousClass ( ) ; }
Interfaces enums annotations and abstract classes cannot be instantiated .
71
13
498
protected boolean checkExcludePackages ( String classPackageName ) { if ( excludePackages != null && excludePackages . length > 0 ) { WildcardHelper wildcardHelper = new WildcardHelper ( ) ; // we really don't care about the results, just the boolean Map < String , String > matchMap = new HashMap < String , String > ( ...
Checks if provided class package is on the exclude list
138
11
499
protected boolean checkActionPackages ( String classPackageName ) { if ( actionPackages != null ) { for ( String packageName : actionPackages ) { String strictPackageName = packageName + "." ; if ( classPackageName . equals ( packageName ) || classPackageName . startsWith ( strictPackageName ) ) return true ; } } retur...
Checks if class package match provided list of action packages
77
11