Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PartitionModel function => add another abstract partition interface to support user-specific features( such as partition between same type device ) #10422

Open
jackiechen19940708 opened this issue Dec 5, 2023 · 2 comments

Comments

@jackiechen19940708
Copy link

PartitionModel function => add another abstract partition interface to support user-specific features( such as partition model between same type device to enable parallelism )

for the following function ,maybe it's good to provide an abstract interface for user to make a specific device partition

int Compilation::PartitionModel(
    Context* context,
    Model* model,
    std::vector<std::pair<
        Context::DeviceContext*,
        std::tuple<core::Model*, bool, std::vector<int>, std::vector<int>>>>*
        models) {
...
    for (auto& operation : model->model_.operations) {
            if (_flags_[operation_index] && !flags[operation_index]) {                             <----- here may be provide another abstraction for user specificed partition and all way down into other revelant code (such as user specificed ModelPartitioner)
              flags[operation_index] = true;
              // Only the operations which are not supported by the previous devices
              // are added.
              supported_operations[i].second.insert(&operation);                                                  
            }
            operation_index++;
          }



// For example we have <model> as follows:
//        conv2d_0                       conv2d_1
//           |                                        |
//      batch_norm_0                batch_norm_1
//           |                                        |
//         relu_0                              relu_1
//              \                                  /
//                    \                        /
//                        leave out ops(such as operator)


// and two devices with support operators listed 
//   <device_id=0, [conv2d_0,batch_norm_0,relu_0, conv2d_1,batch_norm_1,relu_1]>
//   <device_id=1, [conv2d_0,batch_norm_0,relu_0, conv2d_1,batch_norm_1,relu_1]>

// we need to use a interface to partition the model into devices as follows
//   <device_id=0, {[conv2d_0,batch_norm_0,relu_0], false, [...], [...]}>>
//   <device_id=1, {[conv2d_1,batch_norm_1,relu_1], false, [...], [...]>>
@qili93
Copy link
Collaborator

qili93 commented Feb 5, 2024

您好,请问310B是昇腾23年新出的芯片类型对吗?这个芯片类型Lite尚未适配,Lite会将此需求纳入需求池进行评审,感谢您的反馈!

@hong19860320
Copy link
Collaborator

hong19860320 commented Feb 20, 2024

PartitionModel function => add another abstract partition interface to support user-specific features( such as partition model between same type device to enable parallelism )

for the following function ,maybe it's good to provide an abstract interface for user to make a specific device partition

int Compilation::PartitionModel(
    Context* context,
    Model* model,
    std::vector<std::pair<
        Context::DeviceContext*,
        std::tuple<core::Model*, bool, std::vector<int>, std::vector<int>>>>*
        models) {
...
    for (auto& operation : model->model_.operations) {
            if (_flags_[operation_index] && !flags[operation_index]) {                             <----- here may be provide another abstraction for user specificed partition and all way down into other revelant code (such as user specificed ModelPartitioner)
              flags[operation_index] = true;
              // Only the operations which are not supported by the previous devices
              // are added.
              supported_operations[i].second.insert(&operation);                                                  
            }
            operation_index++;
          }



// For example we have <model> as follows:
//        conv2d_0                       conv2d_1
//           |                                        |
//      batch_norm_0                batch_norm_1
//           |                                        |
//         relu_0                              relu_1
//              \                                  /
//                    \                        /
//                        leave out ops(such as operator)


// and two devices with support operators listed 
//   <device_id=0, [conv2d_0,batch_norm_0,relu_0, conv2d_1,batch_norm_1,relu_1]>
//   <device_id=1, [conv2d_0,batch_norm_0,relu_0, conv2d_1,batch_norm_1,relu_1]>

// we need to use a interface to partition the model into devices as follows
//   <device_id=0, {[conv2d_0,batch_norm_0,relu_0], false, [...], [...]}>>
//   <device_id=1, {[conv2d_1,batch_norm_1,relu_1], false, [...], [...]>>

It's good idea, we will consider your suggestion in the future.
Now we provide another solution, please check https://www.paddlepaddle.org.cn/lite/v2.12/develop_guides/nnadapter.html
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants