forked from apache/mxnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
util.R
30 lines (27 loc) · 793 Bytes
/
util.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# Internal function to check if name end with suffix
mx.util.str.endswith <- function(name, suffix) {
slen <- nchar(suffix)
nlen <- nchar(name)
if (slen > nlen) return (FALSE)
nsuf <- substr(name, nlen - slen + 1, nlen)
return (nsuf == suffix)
}
mx.util.str.startswith <- function(name, prefix) {
slen <- nchar(prefix)
nlen <- nchar(name)
if (slen > nlen) return (FALSE)
npre <- substr(name, 1, slen)
return (npre == prefix)
}
# filter out null, keep the names
mx.util.filter.null <- function(lst) {
lst[!sapply(lst, is.null)]
}
#' Internal function to generate mxnet_generated.R
#' Users do not need to call this function.
#' @param path The path to the root of the package.
#'
#' @export
mxnet.export <- function(path) {
mxnet.internal.export(path.expand(path))
}