blob: 604224e74fa72473ef0fd61ef0a78206a2e9800f [file] [log] [blame]
# Initialize the global context
init.context.default <- function() {
.MXNetEnv[["mx.ctx.internal.default.value"]] <- mx.cpu()
}
#' Set/Get default context for array creation.
#'
#' @param new, optional takes \code{mx.cpu()} or \code{mx.gpu(id)}, new default ctx.
#' @return The default context.
#'
#' @export
mx.ctx.default <- function(new = NULL) {
if (!is.null(new)) {
.MXNetEnv[["mx.ctx.internal.default.value"]] <- new
}
return (.MXNetEnv$mx.ctx.internal.default.value)
}
#' Check if the type is mxnet context.
#'
#' @return Logical indicator
#'
#' @export
is.mx.context <- function(x) {
class(x) == "MXContext"
}
#' Create a mxnet CPU context.
#'
#' @param dev.id optional, default=0
#' The device ID, this is meaningless for CPU, included for interface compatiblity.
#' @return The CPU context.
#' @name mx.cpu
#'
#' @export
NULL
#' Create a mxnet GPU context.
#'
#' @param dev.id optional, default=0
#' The GPU device ID, starts from 0.
#' @return The GPU context.
#' @name mx.gpu
#'
#' @export
NULL