static MTensor concatenate()

in FBSDKCoreKit/FBSDKCoreKit/AppEvents/Internal/ML/FBSDKModelRuntime.hpp [48:66]


  static MTensor concatenate(std::vector<MTensor *> &tensors)
  {
    int n_examples = tensors[0]->size(0);
    int count = 0;
    for (int i = 0; i < tensors.size(); i++) {
      count += tensors[i]->size(1);
    }
    MTensor y({n_examples, count});
    float *y_data = y.mutable_data();
    for (int i = 0; i < tensors.size(); i++) {
      int this_count = (int)tensors[i]->size(1);
      const float *this_data = tensors[i]->data();
      for (int n = 0; n < n_examples; n++) {
        memcpy(y_data + n * count, this_data + n * this_count, this_count * sizeof(float));
      }
      y_data += this_count;
    }
    return y;
  }