| |
| |
| |
| |
| <!doctype html> |
| <html lang="en" class="no-js"> |
| <head> |
| |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width,initial-scale=1"> |
| <meta http-equiv="x-ua-compatible" content="ie=edge"> |
| |
| |
| |
| |
| <meta name="lang:clipboard.copy" content="Copy to clipboard"> |
| |
| <meta name="lang:clipboard.copied" content="Copied to clipboard"> |
| |
| <meta name="lang:search.language" content="en"> |
| |
| <meta name="lang:search.pipeline.stopwords" content="True"> |
| |
| <meta name="lang:search.pipeline.trimmer" content="True"> |
| |
| <meta name="lang:search.result.none" content="No matching documents"> |
| |
| <meta name="lang:search.result.one" content="1 matching document"> |
| |
| <meta name="lang:search.result.other" content="# matching documents"> |
| |
| <meta name="lang:search.tokenizer" content="[\s\-]+"> |
| |
| <link rel="shortcut icon" href="../../assets/images/favicon.png"> |
| <meta name="generator" content="mkdocs-1.0.4, mkdocs-material-4.6.0"> |
| |
| |
| |
| <title>Context - MXNet.jl</title> |
| |
| |
| |
| <link rel="stylesheet" href="../../assets/stylesheets/application.1b62728e.css"> |
| |
| |
| |
| |
| <script src="../../assets/javascripts/modernizr.268332fc.js"></script> |
| |
| |
| |
| <link href="https://fonts.gstatic.com" rel="preconnect" crossorigin> |
| <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,400i,700%7CRoboto+Mono&display=fallback"> |
| <style>body,input{font-family:"Roboto","Helvetica Neue",Helvetica,Arial,sans-serif}code,kbd,pre{font-family:"Roboto Mono","Courier New",Courier,monospace}</style> |
| |
| |
| <link rel="stylesheet" href="../../assets/fonts/material-icons.css"> |
| |
| |
| <link rel="stylesheet" href="../../assets/Documenter.css"> |
| |
| |
| |
| |
| |
| </head> |
| |
| <body dir="ltr"> |
| |
| <svg class="md-svg"> |
| <defs> |
| |
| |
| <svg xmlns="http://www.w3.org/2000/svg" width="416" height="448" viewBox="0 0 416 448" id="__github"><path fill="currentColor" d="M160 304q0 10-3.125 20.5t-10.75 19T128 352t-18.125-8.5-10.75-19T96 304t3.125-20.5 10.75-19T128 256t18.125 8.5 10.75 19T160 304zm160 0q0 10-3.125 20.5t-10.75 19T288 352t-18.125-8.5-10.75-19T256 304t3.125-20.5 10.75-19T288 256t18.125 8.5 10.75 19T320 304zm40 0q0-30-17.25-51T296 232q-10.25 0-48.75 5.25Q229.5 240 208 240t-39.25-2.75Q130.75 232 120 232q-29.5 0-46.75 21T56 304q0 22 8 38.375t20.25 25.75 30.5 15 35 7.375 37.25 1.75h42q20.5 0 37.25-1.75t35-7.375 30.5-15 20.25-25.75T360 304zm56-44q0 51.75-15.25 82.75-9.5 19.25-26.375 33.25t-35.25 21.5-42.5 11.875-42.875 5.5T212 416q-19.5 0-35.5-.75t-36.875-3.125-38.125-7.5-34.25-12.875T37 371.5t-21.5-28.75Q0 312 0 260q0-59.25 34-99-6.75-20.5-6.75-42.5 0-29 12.75-54.5 27 0 47.5 9.875t47.25 30.875Q171.5 96 212 96q37 0 70 8 26.25-20.5 46.75-30.25T376 64q12.75 25.5 12.75 54.5 0 21.75-6.75 42 34 40 34 99.5z"/></svg> |
| |
| </defs> |
| </svg> |
| <input class="md-toggle" data-md-toggle="drawer" type="checkbox" id="__drawer" autocomplete="off"> |
| <input class="md-toggle" data-md-toggle="search" type="checkbox" id="__search" autocomplete="off"> |
| <label class="md-overlay" data-md-component="overlay" for="__drawer"></label> |
| |
| <a href="#context" tabindex="1" class="md-skip"> |
| Skip to content |
| </a> |
| |
| |
| <header class="md-header" data-md-component="header"> |
| <nav class="md-header-nav md-grid"> |
| <div class="md-flex"> |
| <div class="md-flex__cell md-flex__cell--shrink"> |
| <a href="../.." title="MXNet.jl" class="md-header-nav__button md-logo"> |
| |
| <i class="md-icon"></i> |
| |
| </a> |
| </div> |
| <div class="md-flex__cell md-flex__cell--shrink"> |
| <label class="md-icon md-icon--menu md-header-nav__button" for="__drawer"></label> |
| </div> |
| <div class="md-flex__cell md-flex__cell--stretch"> |
| <div class="md-flex__ellipsis md-header-nav__title" data-md-component="title"> |
| |
| <span class="md-header-nav__topic"> |
| MXNet.jl |
| </span> |
| <span class="md-header-nav__topic"> |
| |
| Context |
| |
| </span> |
| |
| </div> |
| </div> |
| <div class="md-flex__cell md-flex__cell--shrink"> |
| |
| <label class="md-icon md-icon--search md-header-nav__button" for="__search"></label> |
| |
| <div class="md-search" data-md-component="search" role="dialog"> |
| <label class="md-search__overlay" for="__search"></label> |
| <div class="md-search__inner" role="search"> |
| <form class="md-search__form" name="search"> |
| <input type="text" class="md-search__input" name="query" placeholder="Search" autocapitalize="off" autocorrect="off" autocomplete="off" spellcheck="false" data-md-component="query" data-md-state="active"> |
| <label class="md-icon md-search__icon" for="__search"></label> |
| <button type="reset" class="md-icon md-search__icon" data-md-component="reset" tabindex="-1"> |
|  |
| </button> |
| </form> |
| <div class="md-search__output"> |
| <div class="md-search__scrollwrap" data-md-scrollfix> |
| <div class="md-search-result" data-md-component="result"> |
| <div class="md-search-result__meta"> |
| Type to start searching |
| </div> |
| <ol class="md-search-result__list"></ol> |
| </div> |
| </div> |
| </div> |
| </div> |
| </div> |
| |
| </div> |
| |
| <div class="md-flex__cell md-flex__cell--shrink"> |
| <div class="md-header-nav__source"> |
| |
| |
| |
| |
| |
| <a href="https://github.com/apache/incubator-mxnet/tree/master/julia#mxnet/" title="Go to repository" class="md-source" data-md-source="github"> |
| |
| <div class="md-source__icon"> |
| <svg viewBox="0 0 24 24" width="24" height="24"> |
| <use xlink:href="#__github" width="24" height="24"></use> |
| </svg> |
| </div> |
| |
| <div class="md-source__repository"> |
| GitHub |
| </div> |
| </a> |
| </div> |
| </div> |
| |
| </div> |
| </nav> |
| </header> |
| |
| <div class="md-container"> |
| |
| |
| |
| |
| <main class="md-main" role="main"> |
| <div class="md-main__inner md-grid" data-md-component="container"> |
| |
| |
| <div class="md-sidebar md-sidebar--primary" data-md-component="navigation"> |
| <div class="md-sidebar__scrollwrap"> |
| <div class="md-sidebar__inner"> |
| <nav class="md-nav md-nav--primary" data-md-level="0"> |
| <label class="md-nav__title md-nav__title--site" for="__drawer"> |
| <a href="../.." title="MXNet.jl" class="md-nav__button md-logo"> |
| |
| <i class="md-icon"></i> |
| |
| </a> |
| MXNet.jl |
| </label> |
| |
| <div class="md-nav__source"> |
| |
| |
| |
| |
| |
| <a href="https://github.com/apache/incubator-mxnet/tree/master/julia#mxnet/" title="Go to repository" class="md-source" data-md-source="github"> |
| |
| <div class="md-source__icon"> |
| <svg viewBox="0 0 24 24" width="24" height="24"> |
| <use xlink:href="#__github" width="24" height="24"></use> |
| </svg> |
| </div> |
| |
| <div class="md-source__repository"> |
| GitHub |
| </div> |
| </a> |
| </div> |
| |
| <ul class="md-nav__list" data-md-scrollfix> |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../.." title="Home" class="md-nav__link"> |
| Home |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item md-nav__item--nested"> |
| |
| <input class="md-toggle md-nav__toggle" data-md-toggle="nav-2" type="checkbox" id="nav-2"> |
| |
| <label class="md-nav__link" for="nav-2"> |
| Tutorial |
| </label> |
| <nav class="md-nav" data-md-component="collapsible" data-md-level="1"> |
| <label class="md-nav__title" for="nav-2"> |
| Tutorial |
| </label> |
| <ul class="md-nav__list" data-md-scrollfix> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../../tutorial/mnist/" title="Digit Recognition on MNIST" class="md-nav__link"> |
| Digit Recognition on MNIST |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../../tutorial/char-lstm/" title="Generating Random Sentence with LSTM RNN" class="md-nav__link"> |
| Generating Random Sentence with LSTM RNN |
| </a> |
| </li> |
| |
| |
| </ul> |
| </nav> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item md-nav__item--nested"> |
| |
| <input class="md-toggle md-nav__toggle" data-md-toggle="nav-3" type="checkbox" id="nav-3"> |
| |
| <label class="md-nav__link" for="nav-3"> |
| User Guide |
| </label> |
| <nav class="md-nav" data-md-component="collapsible" data-md-level="1"> |
| <label class="md-nav__title" for="nav-3"> |
| User Guide |
| </label> |
| <ul class="md-nav__list" data-md-scrollfix> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../../user-guide/install/" title="Installation Guide" class="md-nav__link"> |
| Installation Guide |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../../user-guide/overview/" title="Overview" class="md-nav__link"> |
| Overview |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../../user-guide/faq/" title="FAQ" class="md-nav__link"> |
| FAQ |
| </a> |
| </li> |
| |
| |
| </ul> |
| </nav> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item md-nav__item--active md-nav__item--nested"> |
| |
| <input class="md-toggle md-nav__toggle" data-md-toggle="nav-4" type="checkbox" id="nav-4" checked> |
| |
| <label class="md-nav__link" for="nav-4"> |
| API Documentation |
| </label> |
| <nav class="md-nav" data-md-component="collapsible" data-md-level="1"> |
| <label class="md-nav__title" for="nav-4"> |
| API Documentation |
| </label> |
| <ul class="md-nav__list" data-md-scrollfix> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item md-nav__item--active"> |
| |
| <input class="md-toggle md-nav__toggle" data-md-toggle="toc" type="checkbox" id="__toc"> |
| |
| |
| |
| |
| <a href="./" title="Context" class="md-nav__link md-nav__link--active"> |
| Context |
| </a> |
| |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../model/" title="Models" class="md-nav__link"> |
| Models |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../initializer/" title="Initializers" class="md-nav__link"> |
| Initializers |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../optimizer/" title="Optimizers" class="md-nav__link"> |
| Optimizers |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../callback/" title="Callbacks in training" class="md-nav__link"> |
| Callbacks in training |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../metric/" title="Evaluation Metrics" class="md-nav__link"> |
| Evaluation Metrics |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../io/" title="Data Providers" class="md-nav__link"> |
| Data Providers |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../ndarray/" title="NDArray API" class="md-nav__link"> |
| NDArray API |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../symbolic-node/" title="Symbolic API" class="md-nav__link"> |
| Symbolic API |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../nn-factory/" title="Neural Networks Factory" class="md-nav__link"> |
| Neural Networks Factory |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../executor/" title="Executor" class="md-nav__link"> |
| Executor |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../kvstore/" title="Key-Value Store" class="md-nav__link"> |
| Key-Value Store |
| </a> |
| </li> |
| |
| |
| |
| |
| |
| |
| |
| <li class="md-nav__item"> |
| <a href="../visualize/" title="Network Visualization" class="md-nav__link"> |
| Network Visualization |
| </a> |
| </li> |
| |
| |
| </ul> |
| </nav> |
| </li> |
| |
| |
| </ul> |
| </nav> |
| </div> |
| </div> |
| </div> |
| |
| |
| <div class="md-sidebar md-sidebar--secondary" data-md-component="toc"> |
| <div class="md-sidebar__scrollwrap"> |
| <div class="md-sidebar__inner"> |
| |
| <nav class="md-nav md-nav--secondary"> |
| |
| |
| |
| |
| |
| </nav> |
| </div> |
| </div> |
| </div> |
| |
| |
| <div class="md-content"> |
| <article class="md-content__inner md-typeset"> |
| |
| |
| <a href="https://github.com/apache/incubator-mxnet/tree/master/edit/master/docs/api/context.md" title="Edit this page" class="md-icon md-content__icon"></a> |
| |
| |
| <!–- Licensed to the Apache Software Foundation (ASF) under one –> <!–- or more contributor license agreements. See the NOTICE file –> <!–- distributed with this work for additional information –> <!–- regarding copyright ownership. The ASF licenses this file –> <!–- to you under the Apache License, Version 2.0 (the –> <!–- "License"); you may not use this file except in compliance –> <!–- with the License. You may obtain a copy of the License at –> |
| |
| <!–- http://www.apache.org/licenses/LICENSE-2.0 –> |
| |
| <!–- Unless required by applicable law or agreed to in writing, –> <!–- software distributed under the License is distributed on an –> <!–- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY –> <!–- KIND, either express or implied. See the License for the –> <!–- specific language governing permissions and limitations –> <!–- under the License. –> |
| |
| <p><a id='Context-1'></a></p> |
| <h1 id="context">Context</h1> |
| <p><a id='MXNet.mx.Context' href='#MXNet.mx.Context'>#</a> |
| <strong><code>MXNet.mx.Context</code></strong> — <em>Type</em>.</p> |
| <pre><code class="julia">Context(dev_type, dev_id) |
| </code></pre> |
| |
| <p>A context describes the device type and id on which computation should be carried on.</p> |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/context.jl#L22-L26' class='documenter-source'>source</a><br></p> |
| <p><a id='MXNet.mx.context-Tuple{NDArray}' href='#MXNet.mx.context-Tuple{NDArray}'>#</a> |
| <strong><code>MXNet.mx.context</code></strong> — <em>Method</em>.</p> |
| <pre><code class="julia">context(x::NDArray) |
| </code></pre> |
| |
| <p>Get the context that this <code>NDArray</code> lives on.</p> |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/ndarray/context.jl#L18-L22' class='documenter-source'>source</a><br></p> |
| <p><a id='MXNet.mx.cpu' href='#MXNet.mx.cpu'>#</a> |
| <strong><code>MXNet.mx.cpu</code></strong> — <em>Function</em>.</p> |
| <pre><code class="julia">cpu(dev_id) |
| </code></pre> |
| |
| <p>Get a CPU context with a specific id. <code>cpu()</code> is usually the default context for many operations when no context is specified.</p> |
| <p><strong>Arguments</strong></p> |
| <ul> |
| <li><code>dev_id::Integer = 0</code>: the CPU id.</li> |
| </ul> |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/context.jl#L118-L126' class='documenter-source'>source</a><br></p> |
| <p><a id='MXNet.mx.current_context-Tuple{}' href='#MXNet.mx.current_context-Tuple{}'>#</a> |
| <strong><code>MXNet.mx.current_context</code></strong> — <em>Method</em>.</p> |
| <pre><code class="julia">current_context() |
| </code></pre> |
| |
| <p>Return the current context.</p> |
| <p>By default, <code>mx.cpu()</code> is used for all the computations and it can be overridden by using the <code>@context</code> macro.</p> |
| <p><strong>Examples</strong></p> |
| <pre><code class="jl-repl">julia> mx.current_context() |
| cpu0 |
| |
| julia> mx.@context mx.GPU 1 begin # Context changed in the following code block |
| mx.current_context() |
| end |
| gpu1 |
| |
| julia> mx.current_context() |
| cpu0 |
| </code></pre> |
| |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/context.jl#L181-L202' class='documenter-source'>source</a><br></p> |
| <p><a id='MXNet.mx.empty_cache' href='#MXNet.mx.empty_cache'>#</a> |
| <strong><code>MXNet.mx.empty_cache</code></strong> — <em>Function</em>.</p> |
| <pre><code class="julia">empty_cache(ctx::Context = current_context()) |
| </code></pre> |
| |
| <p>Empties the memory cache for the current contexts device. MXNet utilizes a memory pool to avoid excessive allocations. Calling empty_cache will empty the memory pool of the contexts device. This will only free the memory of the unreferenced data.</p> |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/context.jl#L150-L157' class='documenter-source'>source</a><br></p> |
| <p><a id='MXNet.mx.gpu' href='#MXNet.mx.gpu'>#</a> |
| <strong><code>MXNet.mx.gpu</code></strong> — <em>Function</em>.</p> |
| <pre><code class="julia">gpu(dev_id) |
| </code></pre> |
| |
| <p>Get a GPU context with a specific id. The K GPUs on a node is typically numbered as 0,...,K-1.</p> |
| <p><strong>Arguments</strong></p> |
| <ul> |
| <li><code>dev_id::Integer = 0</code> the GPU device id.</li> |
| </ul> |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/context.jl#L129-L136' class='documenter-source'>source</a><br></p> |
| <p><a id='MXNet.mx.gpu_memory_info' href='#MXNet.mx.gpu_memory_info'>#</a> |
| <strong><code>MXNet.mx.gpu_memory_info</code></strong> — <em>Function</em>.</p> |
| <pre><code class="julia">gpu_memory_info(dev_id = 0)::Tuple{UInt64,UInt64} |
| </code></pre> |
| |
| <p>Query CUDA for the free and total bytes of GPU global memory. It returns a tuple of <code>(free memory, total memory)</code>.</p> |
| <pre><code class="julia-repl">julia> mx.gpu_memory_info() |
| (0x00000003af240000, 0x00000003f9440000) |
| </code></pre> |
| |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/context.jl#L163-L173' class='documenter-source'>source</a><br></p> |
| <p><a id='MXNet.mx.num_gpus-Tuple{}' href='#MXNet.mx.num_gpus-Tuple{}'>#</a> |
| <strong><code>MXNet.mx.num_gpus</code></strong> — <em>Method</em>.</p> |
| <pre><code class="julia">num_gpus() |
| </code></pre> |
| |
| <p>Query CUDA for the number of GPUs present.</p> |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/context.jl#L139-L143' class='documenter-source'>source</a><br></p> |
| <p><a id='MXNet.mx.@context-Tuple{Any,Expr}' href='#MXNet.mx.@context-Tuple{Any,Expr}'>#</a> |
| <strong><code>MXNet.mx.@context</code></strong> — <em>Macro</em>.</p> |
| <pre><code class="julia">@context device_type [device_id] expr |
| </code></pre> |
| |
| <p>Change the default context in the following expression.</p> |
| <p><strong>Examples</strong></p> |
| <pre><code class="jl-repl">julia> mx.@context mx.GPU begin |
| mx.zeros(2, 3) |
| end |
| 2×3 NDArray{Float32,2} @ gpu0: |
| 0.0f0 0.0f0 0.0f0 |
| 0.0f0 0.0f0 0.0f0 |
| |
| julia> @context mx.GPU mx.zeros(3, 2) |
| 3×2 NDArray{Float32,2} @ gpu0: |
| 0.0f0 0.0f0 |
| 0.0f0 0.0f0 |
| 0.0f0 0.0f0 |
| </code></pre> |
| |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/context.jl#L56-L76' class='documenter-source'>source</a><br></p> |
| <p><a id='MXNet.mx.@cpu-Tuple{Expr}' href='#MXNet.mx.@cpu-Tuple{Expr}'>#</a> |
| <strong><code>MXNet.mx.@cpu</code></strong> — <em>Macro</em>.</p> |
| <pre><code class="julia">@cpu [device_id] expr |
| </code></pre> |
| |
| <p>A shorthand for <code>@context mx.GPU</code>.</p> |
| <p><strong>Examples</strong></p> |
| <pre><code class="jl-repl">julia> mx.@with_gpu mx.zeros(2, 3) |
| 2×3 NDArray{Float32,2} @ gpu0: |
| 0.0f0 0.0f0 0.0f0 |
| 0.0f0 0.0f0 0.0f0 |
| </code></pre> |
| |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/context.jl#L101-L113' class='documenter-source'>source</a><br></p> |
| <p><a id='MXNet.mx.@gpu-Tuple{Expr}' href='#MXNet.mx.@gpu-Tuple{Expr}'>#</a> |
| <strong><code>MXNet.mx.@gpu</code></strong> — <em>Macro</em>.</p> |
| <pre><code class="julia">@gpu [device_id] expr |
| </code></pre> |
| |
| <p>A shorthand for <code>@context mx.GPU</code>.</p> |
| <p><strong>Examples</strong></p> |
| <pre><code class="jl-repl">julia> mx.@with_gpu mx.zeros(2, 3) |
| 2×3 NDArray{Float32,2} @ gpu0: |
| 0.0f0 0.0f0 0.0f0 |
| 0.0f0 0.0f0 0.0f0 |
| </code></pre> |
| |
| <p><a target='_blank' href='https://github.com/apache/incubator-mxnet/blob/744751539a38a42cab510cd18dfa4f432f00e3ee/julia/src/context.jl#L101-L113' class='documenter-source'>source</a><br></p> |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| </article> |
| </div> |
| </div> |
| </main> |
| |
| |
| <footer class="md-footer"> |
| |
| <div class="md-footer-nav"> |
| <nav class="md-footer-nav__inner md-grid"> |
| |
| <a href="../../user-guide/faq/" title="FAQ" class="md-flex md-footer-nav__link md-footer-nav__link--prev" rel="prev"> |
| <div class="md-flex__cell md-flex__cell--shrink"> |
| <i class="md-icon md-icon--arrow-back md-footer-nav__button"></i> |
| </div> |
| <div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title"> |
| <span class="md-flex__ellipsis"> |
| <span class="md-footer-nav__direction"> |
| Previous |
| </span> |
| FAQ |
| </span> |
| </div> |
| </a> |
| |
| |
| <a href="../model/" title="Models" class="md-flex md-footer-nav__link md-footer-nav__link--next" rel="next"> |
| <div class="md-flex__cell md-flex__cell--stretch md-footer-nav__title"> |
| <span class="md-flex__ellipsis"> |
| <span class="md-footer-nav__direction"> |
| Next |
| </span> |
| Models |
| </span> |
| </div> |
| <div class="md-flex__cell md-flex__cell--shrink"> |
| <i class="md-icon md-icon--arrow-forward md-footer-nav__button"></i> |
| </div> |
| </a> |
| |
| </nav> |
| </div> |
| |
| <div class="md-footer-meta md-typeset"> |
| <div class="md-footer-meta__inner md-grid"> |
| <div class="md-footer-copyright"> |
| |
| powered by |
| <a href="https://www.mkdocs.org">MkDocs</a> |
| and |
| <a href="https://squidfunk.github.io/mkdocs-material/"> |
| Material for MkDocs</a> |
| </div> |
| |
| </div> |
| </div> |
| </footer> |
| |
| </div> |
| |
| <script src="../../assets/javascripts/application.808e90bb.js"></script> |
| |
| <script>app.initialize({version:"1.0.4",url:{base:"../.."}})</script> |
| |
| <script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script> |
| |
| <script src="../../assets/mathjaxhelper.js"></script> |
| |
| |
| </body> |
| </html> |