From commits-return-13183-archive-asf-public=cust-asf.ponee.io@tvm.apache.org Fri May 8 20:36:28 2020 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 840DC180647 for ; Fri, 8 May 2020 22:36:28 +0200 (CEST) Received: (qmail 69270 invoked by uid 500); 8 May 2020 20:36:28 -0000 Mailing-List: contact commits-help@tvm.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tvm.apache.org Delivered-To: mailing list commits@tvm.apache.org Received: (qmail 69261 invoked by uid 99); 8 May 2020 20:36:27 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 May 2020 20:36:27 +0000 From: =?utf-8?q?GitBox?= To: commits@tvm.apache.org Subject: =?utf-8?q?=5BGitHub=5D_=5Bincubator-tvm=5D_robo-corg_commented_on_a_change_i?= =?utf-8?q?n_pull_request_=235526=3A_=5BRust=5D_Add_first_stage_of_updating_?= =?utf-8?q?and_rewriting_Rust_bindings=2E?= Message-ID: <158897018781.4590.16427917633363963866.asfpy@gitbox.apache.org> Date: Fri, 08 May 2020 20:36:27 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit References: In-Reply-To: robo-corg commented on a change in pull request #5526: URL: https://github.com/apache/incubator-tvm/pull/5526#discussion_r422360890 ########## File path: rust/tvm-sys/src/context.rs ########## @@ -0,0 +1,285 @@ +/* + * 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. + */ + +//! Provides [`Context`] and related device queries. +//! +//! Create a new context for device type and device id. +//! +//! # Example +//! +//! ``` +//! # use tvm_sys::{DeviceType, Context}; +//! let cpu = DeviceType::from("cpu"); +//! let ctx = Context::new(cpu , 0); +//! let cpu0 = Context::cpu(0); +//! assert_eq!(ctx, cpu0); +//! ``` +//! +//! Or from a supported device name. +//! +//! ``` +//! use tvm_sys::Context; +//! let cpu0 = Context::from("cpu"); +//! println!("{}", cpu0); +//! ``` + +use std::convert::TryFrom; +use std::str::FromStr; +use std::fmt::{self, Display, Formatter}; + +use crate::ffi::{self, *}; +use crate::packed_func::{ArgValue, RetValue}; + +use thiserror::Error; +use anyhow::Result; +use enumn::N; + +/// Device type represents the set of devices supported by +/// [TVM](https://github.com/apache/incubator-tvm). +/// +/// ## Example +/// +/// ``` +/// use tvm_sys::DeviceType; +/// let cpu = DeviceType::from("cpu"); +/// println!("device is: {}", cpu); +///``` + +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, N)] +#[repr(i64)] +pub enum DeviceType { + CPU = 1, + GPU, + CPUPinned, + OpenCL, + Vulkan, + Metal, + VPI, + ROCM, + ExtDev, +} Review comment: Spoiler: I was missing something and you were right! ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org