Coder Social home page Coder Social logo

caffe-rs's Introduction

Caffe-rs

GitHub License

Rust Rust - Nightly Rust - Stable Minimum

Toolchain Required

With no unstable feature enabled, this project needs a toolchain version >=1.51.0 to be built.

Build

cd path/to/caffe-rs
cargo build

Usage

Register custom layer

The library exports two macros:

  • register_layer_class! which is used to register the Layer class which impls the trait caffe_rs::layer::CaffeLayer<T> and has a public fn names new with a single caffe_rs::proto::caffe::LayerParameter param.
use caffe_rs::proto::caffe::LayerParameter;
use caffe_rs::blob::BlobType;
use caffe_rs::layer::CaffeLayer;
use std::marker::PhantomData;

struct TestLayer<T: BlobType> {
    phantom: PhantomData<T>,
}

impl<T: BlobType> CaffeLayer for TestLayer<T> {
    type DataType = T;
    // Impl the necessary functions.
}

impl<T: BlobType> TestLayer<T> {
    pub fn new(_param: &LayerParameter) -> Self {
        TestLayer {
            phantom: PhantomData
        }
    }
}

// Note: the name does not contains the trailing 'Layer'.
register_layer_class!(Test);
  • register_layer_creator! which is used to register the custom layer creator function. The creator signature is defined as likes the test:
use caffe_rs::proto::caffe::LayerParameter;
use caffe_rs::layer::SharedLayer;
use caffe_rs::blob::BlobType;

fn test<T: BlobType>(p: &LayerParameter) -> Rc<RefCell<Layer<T>>> {
    unimplemented!();
}

// register `TestLayer` with a creator.
register_layer_creator!(Test, test);

And important: you need import the dependency crate paste to use the register macros.

On your Cargo.toml:

[dependencies]
paste = "1"

and import the macro on your crate root (src/lib.rs or src/main.rs):

#[macro_use] extern crate paste;

License

Caffe-rs is released under the BSD 2-Clause license that is the same as the Caffe project.

caffe-rs's People

Contributors

mematrix avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.