1 #ifndef CAFFE2_VIDEO_VIDEO_INPUT_OP_H_ 2 #define CAFFE2_VIDEO_VIDEO_INPUT_OP_H_ 9 #include <c10/core/thread_pool.h> 10 #include <caffe2/core/db.h> 11 #include <caffe2/core/logging.h> 12 #include <caffe2/operators/prefetch_op.h> 13 #include <caffe2/utils/math.h> 14 #include <caffe2/video/video_io.h> 18 template <
class Context>
21 using OperatorBase::OutputSize;
30 bool Prefetch()
override;
31 bool CopyPrefetched()
override;
34 void CheckParamsAndPrint();
36 bool GetClipsAndLabelsFromDBValue(
37 const std::string& value,
40 std::vector<unsigned char*>& buffer_rgb,
44 void DecodeAndTransform(
45 const std::string& value,
50 std::mt19937* randgen,
51 std::bernoulli_distribution* mirror_this_clip);
54 Tensor prefetched_clip_rgb_;
55 Tensor prefetched_clip_of_;
57 Tensor prefetched_video_id_;
58 Tensor prefetched_clip_rgb_on_device_{Context::GetDeviceType()};
59 Tensor prefetched_clip_of_on_device_{Context::GetDeviceType()};
60 Tensor prefetched_label_on_device_{Context::GetDeviceType()};
61 Tensor prefetched_video_id_on_device_{Context::GetDeviceType()};
64 std::vector<float> mean_rgb_;
65 std::vector<float> inv_std_rgb_;
66 std::vector<float> mean_of_;
67 std::vector<float> inv_std_of_;
77 int sampling_rate_rgb_;
79 float img_saturation_;
80 float img_brightness_;
83 float color_lighting_std_;
84 std::vector<std::vector<float>> color_lighting_eigvecs_;
85 std::vector<float> color_lighting_eigvals_;
86 int num_of_required_frame_;
88 int sampling_rate_of_;
95 int multi_crop_count_;
100 bool do_flow_aggregation_;
102 bool get_optical_flow_;
104 bool do_multi_label_;
107 int num_decode_threads_;
108 std::shared_ptr<TaskThreadPool> thread_pool_;
111 template <
class Context>
114 CAFFE_ENFORCE_GT(batch_size_, 0,
"Batch size should be positive.");
116 clip_per_video_, 0,
"Number of clips per video should be positive.");
117 CAFFE_ENFORCE_GT(crop_height_, 0,
"Must provide the cropping height value.");
118 CAFFE_ENFORCE_GT(crop_width_, 0,
"Must provide the cropping width value.");
121 num_of_required_frame_, 0,
"Required number of frames must be positive.");
123 if (video_res_type_ == VideoResType::USE_MINIMAL_WIDTH_HEIGHT) {
124 CAFFE_ENFORCE_GT(height_min_, 0,
"Must provide the minimal height value.");
125 CAFFE_ENFORCE_GT(width_min_, 0,
"Must provide the minimal width value.");
129 "The minimal height must be no smaller than the cropping height.");
133 "The minimal width must be no smaller than the cropping width.");
134 }
else if (video_res_type_ == VideoResType::USE_WIDTH_HEIGHT) {
135 CAFFE_ENFORCE_GT(scale_h_, 0,
"Must provide the scale height value.");
136 CAFFE_ENFORCE_GT(scale_w_, 0,
"Must provide the scale width value.");
140 "The scaled height must be no smaller than the cropping height.");
144 "The scaled width must be no smaller than the cropping width.");
148 CAFFE_ENFORCE_GT(length_rgb_, 0,
"Must provide rgb clip length.");
150 sampling_rate_rgb_, 0,
"4 frames for mc2; 2 frames for res3d.");
152 channels_rgb_, mean_rgb_.size(),
"Number rgb channels is wrong!");
154 channels_rgb_, inv_std_rgb_.size(),
"Number rgb channels is wrong!");
157 if (get_optical_flow_) {
158 CAFFE_ENFORCE_GT(length_of_, 0,
"Must provide optical flow clip length.");
160 sampling_rate_of_, 0,
"4 frames for mc2; 2 frames for res3d.");
164 "Number of optical flow channels is wrong!");
168 "Number of optical flow channels is wrong!");
171 if (clip_per_video_ > 1) {
174 DecodeType::DO_UNIFORM_SMP,
175 "Only uniformly sampling is supported when sampling multiple clips!");
178 if (do_multi_label_) {
182 "Number of classes must be set when using multiple labels.");
186 LOG(INFO) <<
"Creating a clip input op with the following setting: ";
187 LOG(INFO) <<
" Using " << num_decode_threads_ <<
" CPU threads;";
188 LOG(INFO) <<
" Outputting in batches of " << batch_size_ <<
" videos;";
189 LOG(INFO) <<
" Each video has " << clip_per_video_ <<
" clips;";
190 LOG(INFO) <<
" Scaling image to " << scale_h_ <<
"x" << scale_w_;
191 LOG(INFO) <<
" (Height, Width) is at least (" << height_min_ <<
", " 192 << width_min_ <<
")";
193 LOG(INFO) <<
" Cropping video frame to " << crop_height_ <<
"x" 194 << crop_width_ << (random_mirror_ ?
" with " :
" without ")
195 <<
"random mirroring;";
196 LOG(INFO) <<
" Using " << (random_crop_ ?
"random" :
"center") <<
" crop";
197 LOG(INFO) <<
" Is multi-cropping enabled: " << multi_crop_;
200 LOG(INFO) <<
" Using a clip of " << length_rgb_ <<
" rgb frames " 201 <<
"with " << channels_rgb_ <<
" channels " 202 <<
"and a sampling rate of 1:" << sampling_rate_rgb_;
203 LOG(INFO) <<
" RGB data augmentation. Color jittering: " << color_jitter_
204 <<
". Color lighting: " << color_lighting_;
205 for (
int i = 0; i < channels_rgb_; i++) {
206 LOG(INFO) <<
" RGB " << i <<
"-th channel mean: " << mean_rgb_[i]
207 <<
" std: " << 1.f / inv_std_rgb_[i];
211 if (get_optical_flow_) {
212 LOG(INFO) <<
" Using a clip of " << length_of_ <<
" optical flow frames " 213 <<
"with " << channels_of_ <<
" channels " 214 <<
"and a sampling rate of 1:" << sampling_rate_of_
215 <<
" flow_data_type_: " << flow_data_type_
216 <<
" flow_alg_type_: " << flow_alg_type_;
217 for (
int i = 0; i < channels_of_; i++) {
218 LOG(INFO) <<
" Optical flow" << i
219 <<
"-th channel mean: " << mean_of_[i]
220 <<
" std: " << 1.f / inv_std_of_[i];
224 if (video_res_type_ == VideoResType::ORIGINAL_RES) {
225 LOG(INFO) <<
" Use original resolution";
226 }
else if (video_res_type_ == VideoResType::USE_MINIMAL_WIDTH_HEIGHT) {
227 LOG(INFO) <<
" Resize with minimal size and keep aspect ratio";
228 }
else if (video_res_type_ == VideoResType::USE_WIDTH_HEIGHT) {
229 LOG(INFO) <<
" Resize and ignore aspect ratio";
231 LOG(ERROR) <<
" Unknown video resolution type";
234 if (decode_type_ == DecodeType::DO_TMP_JITTER) {
235 LOG(INFO) <<
" Do temporal jittering";
236 }
else if (decode_type_ == DecodeType::USE_START_FRM) {
237 LOG(INFO) <<
" Use start_frm for decoding";
238 }
else if (decode_type_ == DecodeType::DO_UNIFORM_SMP) {
239 LOG(INFO) <<
" Do uniformly sampling";
241 LOG(ERROR) <<
" Unknown video decoding type";
245 template <
class Context>
247 const OperatorDef& operator_def,
252 OperatorBase::template GetSingleArgument<int>(
"batch_size", 0)),
254 OperatorBase::template GetSingleArgument<int>(
"clip_per_video", 1)),
255 mean_rgb_(OperatorBase::template GetRepeatedArgument<float>(
256 "mean_rgb_per_channel",
257 {OperatorBase::template GetSingleArgument<float>(
"mean_rgb", 128.)})),
258 inv_std_rgb_(OperatorBase::template GetRepeatedArgument<float>(
259 "std_rgb_per_channel",
260 {OperatorBase::template GetSingleArgument<float>(
"std_rgb", 1.)})),
261 mean_of_(OperatorBase::template GetRepeatedArgument<float>(
262 "mean_of_per_channel",
263 {OperatorBase::template GetSingleArgument<float>(
"mean_of", 0.)})),
264 inv_std_of_(OperatorBase::template GetRepeatedArgument<float>(
265 "std_of_per_channel",
266 {OperatorBase::template GetSingleArgument<float>(
"std_of", 1.)})),
268 OperatorBase::template GetSingleArgument<int>(
"channels_rgb", 3)),
270 OperatorBase::template GetSingleArgument<int>(
"channels_of", 2)),
271 crop_height_(OperatorBase::template GetSingleArgument<int>(
273 {OperatorBase::template GetSingleArgument<int>(
"crop_size", 0.)})),
274 crop_width_(OperatorBase::template GetSingleArgument<int>(
276 {OperatorBase::template GetSingleArgument<int>(
"crop_size", 0.)})),
277 scale_h_(OperatorBase::template GetSingleArgument<int>(
"scale_h", 0)),
278 scale_w_(OperatorBase::template GetSingleArgument<int>(
"scale_w", 0)),
279 height_min_(OperatorBase::template GetSingleArgument<int>(
281 {OperatorBase::template GetSingleArgument<int>(
"short_edge", 0)})),
282 width_min_(OperatorBase::template GetSingleArgument<int>(
284 {OperatorBase::template GetSingleArgument<int>(
"short_edge", 0)})),
286 OperatorBase::template GetSingleArgument<int>(
"length_rgb", 0)),
287 sampling_rate_rgb_(OperatorBase::template GetSingleArgument<int>(
290 color_jitter_(OperatorBase::template GetSingleArgument<bool>(
293 img_saturation_(OperatorBase::template GetSingleArgument<float>(
296 img_brightness_(OperatorBase::template GetSingleArgument<float>(
300 OperatorBase::template GetSingleArgument<float>(
"img_contrast", 0.4)),
301 color_lighting_(OperatorBase::template GetSingleArgument<bool>(
304 color_lighting_std_(OperatorBase::template GetSingleArgument<float>(
305 "color_lighting_std",
307 length_of_(OperatorBase::template GetSingleArgument<int>(
"length_of", 0)),
309 OperatorBase::template GetSingleArgument<int>(
"sampling_rate_of", 1)),
311 OperatorBase::template GetSingleArgument<int>(
"frame_gap_of", 1)),
312 random_mirror_(OperatorBase::template GetSingleArgument<bool>(
316 OperatorBase::template GetSingleArgument<int>(
"num_of_class", 0)),
317 use_local_file_(OperatorBase::template GetSingleArgument<bool>(
321 OperatorBase::template GetSingleArgument<bool>(
"random_crop",
true)),
323 OperatorBase::template GetSingleArgument<bool>(
"multi_crop",
false)),
325 OperatorBase::template GetSingleArgument<int>(
"flow_data_type", 0)),
327 OperatorBase::template GetSingleArgument<int>(
"flow_alg_type", 0)),
329 OperatorBase::template GetSingleArgument<int>(
"decode_type", 0)),
331 OperatorBase::template GetSingleArgument<int>(
"video_res_type", 0)),
332 do_flow_aggregation_(OperatorBase::template GetSingleArgument<bool>(
333 "do_flow_aggregation",
335 get_rgb_(OperatorBase::template GetSingleArgument<bool>(
"get_rgb",
true)),
336 get_optical_flow_(OperatorBase::template GetSingleArgument<bool>(
339 get_video_id_(OperatorBase::template GetSingleArgument<bool>(
342 do_multi_label_(OperatorBase::template GetSingleArgument<bool>(
345 num_decode_threads_(OperatorBase::template GetSingleArgument<int>(
346 "num_decode_threads",
348 thread_pool_(std::make_shared<TaskThreadPool>(num_decode_threads_)) {
350 color_lighting_eigvecs_.push_back(
351 std::vector<float>{-144.7125, 183.396, 102.2295});
352 color_lighting_eigvecs_.push_back(
353 std::vector<float>{-148.104, -1.1475, -207.57});
354 color_lighting_eigvecs_.push_back(
355 std::vector<float>{-148.818, -177.174, 107.1765});
357 color_lighting_eigvals_ = std::vector<float>{0.2175, 0.0188, 0.0045};
360 multi_crop_count_ = 1;
365 multi_crop_count_ = 14;
368 num_of_required_frame_ = 0;
375 const std::vector<float> InputDataMean = {
376 0.0046635, 0.0046261, 0.963986, 102.976, 110.201, 100.64, 95.9966};
377 const std::vector<float> InputDataStd = {
378 0.972347, 0.755146, 1.43588, 55.3691, 58.1489, 56.4701, 55.3324};
383 num_of_required_frame_ = std::max(
384 num_of_required_frame_, (length_rgb_ - 1) * sampling_rate_rgb_ + 1);
388 if (mean_rgb_.size() != channels_rgb_ ||
389 inv_std_rgb_.size() != channels_rgb_) {
391 inv_std_rgb_.clear();
392 for (
int i = 4; i < 7; i++) {
393 mean_rgb_.push_back(InputDataMean[i]);
394 inv_std_rgb_.push_back(1.f / InputDataStd[i]);
400 if (get_optical_flow_) {
402 num_of_required_frame_ = std::max(
403 num_of_required_frame_,
404 (length_of_ - 1) * sampling_rate_of_ + frame_gap_of_ + 1);
406 if (mean_of_.size() != channels_of_ || inv_std_of_.size() != channels_of_) {
411 switch (flow_data_type_) {
412 case FlowDataType::Flow2C:
414 for (
int i = 0; i < channels_of_; i++) {
415 mean_of_.push_back(InputDataMean[i]);
416 inv_std_of_.push_back(1.f / InputDataStd[i]);
420 case FlowDataType::Flow3C:
422 for (
int i = 0; i < channels_of_; i++) {
423 mean_of_.push_back(InputDataMean[i]);
424 inv_std_of_.push_back(1.f / InputDataStd[i]);
429 case FlowDataType::FlowWithGray:
431 for (
int i = 0; i < 2; i++) {
432 mean_of_.push_back(InputDataMean[i]);
433 inv_std_of_.push_back(1.f / InputDataStd[i]);
435 mean_of_.push_back(InputDataMean[3]);
436 inv_std_of_.push_back(1.f / InputDataStd[3]);
440 case FlowDataType::FlowWithRGB:
442 for (
int i = 0; i < 2; i++) {
443 mean_of_.push_back(InputDataMean[i]);
444 inv_std_of_.push_back(1.f / InputDataStd[i]);
446 for (
int i = 4; i < 7; i++) {
447 mean_of_.push_back(InputDataMean[i]);
448 inv_std_of_.push_back(1.f / InputDataStd[i]);
453 LOG(ERROR) <<
"Unknown optical flow type " << flow_data_type_;
459 CheckParamsAndPrint();
462 operator_def.input_size(), 0,
"Need to have a DBReader blob input");
464 vector<int64_t> data_shape(5);
465 vector<int64_t> label_shape(2);
468 data_shape[0] = batch_size_ * clip_per_video_ * multi_crop_count_;
469 data_shape[1] = channels_rgb_;
470 data_shape[2] = length_rgb_;
471 data_shape[3] = crop_height_;
472 data_shape[4] = crop_width_;
473 ReinitializeTensor(&prefetched_clip_rgb_, data_shape, at::dtype<float>().device(CPU));
476 data_shape[1] = channels_of_;
477 data_shape[2] = length_of_;
482 if (do_multi_label_) {
483 label_shape[0] = batch_size_ * clip_per_video_ * multi_crop_count_;
484 label_shape[1] = num_of_class_;
487 prefetched_label_.Resize(
488 vector<int64_t>(1, batch_size_ * clip_per_video_ * multi_crop_count_));
491 ReinitializeTensor(&prefetched_video_id_, vector<int64_t>(1, batch_size_ * clip_per_video_ * multi_crop_count_), at::dtype<int>().device(CPU));
494 template <
class Context>
496 const std::string& value,
499 std::vector<unsigned char*>& buffer_rgb,
501 int* video_id_data) {
503 int curr_proto_idx = 0;
504 CAFFE_ENFORCE(protos.ParseFromString(value));
505 const TensorProto& video_proto = protos.protos(curr_proto_idx++);
506 const TensorProto& label_proto = protos.protos(curr_proto_idx++);
511 if (decode_type_ == DecodeType::USE_START_FRM) {
513 protos.protos_size(),
515 "Start frm proto not provided");
516 const TensorProto& start_frm_proto = protos.protos(curr_proto_idx++);
517 start_frm = start_frm_proto.int32_data(0);
522 protos.protos_size(), curr_proto_idx + 1,
"Video Id not provided");
523 const TensorProto& video_id_proto = protos.protos(curr_proto_idx);
524 for (
int i = 0; i < clip_per_video_ * multi_crop_count_; i++) {
525 video_id_data[i] = video_id_proto.int64_data(0);
529 if (!do_multi_label_) {
530 for (
int i = 0; i < clip_per_video_ * multi_crop_count_; i++) {
531 label_data[i] = label_proto.int32_data(0);
539 sizeof(
int) * num_of_class_ * multi_crop_count_ * clip_per_video_);
540 for (
int i = 0; i < clip_per_video_; i++) {
541 for (
int j = 0; j < multi_crop_count_; ++j) {
542 for (
int k = 0; k < label_proto.int32_data_size(); k++) {
544 label_proto.int32_data(k),
546 "Label should be less than the number of classes.");
548 [(i * multi_crop_count_ + j) * num_of_class_ +
549 label_proto.int32_data(k)] = 1;
555 if (use_local_file_) {
557 video_proto.data_type(),
559 "Database with a file_list is expected to be string data");
564 params.maximumOutputFrames_ = MAX_DECODING_FRAMES;
565 params.video_res_type_ = video_res_type_;
566 params.crop_height_ = crop_height_;
567 params.crop_width_ = crop_width_;
568 params.height_min_ = height_min_;
569 params.width_min_ = width_min_;
570 params.scale_w_ = scale_w_;
571 params.scale_h_ = scale_h_;
572 params.decode_type_ = decode_type_;
573 params.num_of_required_frame_ = num_of_required_frame_;
575 char* video_buffer =
nullptr;
576 std::string video_filename;
577 int encoded_size = 0;
578 if (video_proto.data_type() == TensorProto::STRING) {
579 const string& encoded_video_str = video_proto.string_data(0);
580 if (!use_local_file_) {
581 encoded_size = encoded_video_str.size();
582 video_buffer =
const_cast<char*
>(encoded_video_str.data());
584 video_filename = encoded_video_str;
586 }
else if (video_proto.data_type() == TensorProto::BYTE) {
587 if (!use_local_file_) {
588 encoded_size = video_proto.byte_data().size();
589 video_buffer =
const_cast<char*
>(video_proto.byte_data().data());
592 video_filename = video_proto.string_data(0);
595 LOG(FATAL) <<
"Unknown video data type.";
598 DecodeMultipleClipsFromVideo(
613 template <
class Context>
615 const std::string& value,
616 float* clip_rgb_data,
620 std::mt19937* randgen,
621 std::bernoulli_distribution* mirror_this_clip) {
622 std::vector<unsigned char*> buffer_rgb;
627 CHECK(GetClipsAndLabelsFromDBValue(
628 value, height, width, buffer_rgb, label_data, video_id_data));
630 int clip_offset_rgb = multi_crop_count_ * channels_rgb_ * length_rgb_ *
631 crop_height_ * crop_width_;
632 int clip_crop_offset_of =
633 channels_of_ * length_of_ * crop_height_ * crop_width_;
634 int clip_offset_of = multi_crop_count_ * clip_crop_offset_of;
635 for (
int i = 0; i < std::min(clip_per_video_,
int(buffer_rgb.size())); i++) {
642 std::uniform_int_distribution<>(0, height - crop_height_)(*randgen);
643 w_off = std::uniform_int_distribution<>(0, width - crop_width_)(*randgen);
646 h_off = (height - crop_height_) / 2;
647 w_off = (width - crop_width_) / 2;
654 int multi_crop_w_off[7] = {0,
655 (width - crop_width_) / 2,
657 (width - crop_width_) / 2,
659 (width - crop_width_) / 2,
660 width - crop_width_};
661 int multi_crop_h_off[7] = {0,
664 (height - crop_height_) / 2,
665 height - crop_height_,
666 height - crop_height_,
667 height - crop_height_};
670 bool mirror_me = random_mirror_ && (*mirror_this_clip)(*randgen);
671 if (get_rgb_ && clip_rgb_data) {
693 color_lighting_eigvecs_,
694 color_lighting_eigvals_,
698 clip_rgb_data + (i * clip_offset_rgb));
700 if (get_optical_flow_ && clip_of_data) {
702 for (
int j = 0; j < multi_crop_count_; ++j) {
703 if (multi_crop_count_ == 1) {
704 rect = cv::Rect(w_off, h_off, crop_width_, crop_height_);
706 mirror_me = j / (multi_crop_count_ / 2);
707 int k = j % (multi_crop_count_ / 2);
714 ClipTransformOpticalFlow(
729 do_flow_aggregation_,
732 clip_of_data + (i * clip_offset_of) + j * clip_crop_offset_of);
737 if (buffer_rgb.size() > 0) {
738 for (
int i = 0; i < buffer_rgb.size(); i++) {
739 unsigned char* buff = buffer_rgb[i];
746 template <
class Context>
750 reader_ = &OperatorBase::Input<db::DBReader>(0);
753 prefetched_clip_rgb_.mutable_data<
float>();
754 prefetched_clip_of_.mutable_data<
float>();
755 prefetched_label_.mutable_data<
int>();
756 prefetched_video_id_.mutable_data<
int>();
759 std::mt19937 meta_randgen(time(
nullptr));
760 std::vector<std::mt19937> randgen_per_thread;
761 for (
int i = 0; i < num_decode_threads_; ++i) {
762 randgen_per_thread.emplace_back(meta_randgen());
765 std::bernoulli_distribution mirror_this_clip(0.5);
766 for (
int item_id = 0; item_id < batch_size_; ++item_id) {
767 std::mt19937* randgen = &randgen_per_thread[item_id % num_decode_threads_];
769 int frame_size = crop_height_ * crop_width_;
771 float* clip_rgb_data = prefetched_clip_rgb_.mutable_data<
float>() +
772 frame_size * length_rgb_ * channels_rgb_ * item_id * clip_per_video_ *
776 float* clip_of_data = prefetched_clip_of_.mutable_data<
float>() +
777 frame_size * length_of_ * channels_of_ * item_id * clip_per_video_ *
781 int* label_data = prefetched_label_.mutable_data<
int>() +
782 (do_multi_label_ ? num_of_class_ : 1) * item_id * clip_per_video_ *
786 int* video_id_data = prefetched_video_id_.mutable_data<
int>() +
787 item_id * clip_per_video_ * multi_crop_count_;
789 std::string key, value;
791 reader_->
Read(&key, &value);
793 thread_pool_->run(std::bind(
804 thread_pool_->waitWorkComplete();
808 if (!std::is_same<Context, CPUContext>::value) {
810 prefetched_clip_rgb_on_device_.CopyFrom(
811 prefetched_clip_rgb_,
true );
813 if (get_optical_flow_) {
814 prefetched_clip_of_on_device_.CopyFrom(
815 prefetched_clip_of_,
true );
817 prefetched_label_on_device_.CopyFrom(prefetched_label_,
true );
819 prefetched_video_id_on_device_.CopyFrom(
820 prefetched_video_id_,
true );
826 template <
class Context>
830 auto* clip_rgb_output =
831 OperatorBase::Output<Tensor>(index++, Context::GetDeviceType());
832 if (std::is_same<Context, CPUContext>::value) {
833 clip_rgb_output->CopyFrom(prefetched_clip_rgb_,
true );
835 clip_rgb_output->CopyFrom(prefetched_clip_rgb_on_device_,
true );
838 if (get_optical_flow_) {
839 auto* clip_of_output =
840 OperatorBase::Output<Tensor>(index++, Context::GetDeviceType());
841 if (std::is_same<Context, CPUContext>::value) {
842 clip_of_output->CopyFrom(prefetched_clip_of_,
true );
844 clip_of_output->CopyFrom(prefetched_clip_of_on_device_,
true );
848 OperatorBase::Output<Tensor>(index++, Context::GetDeviceType());
849 if (std::is_same<Context, CPUContext>::value) {
850 label_output->CopyFrom(prefetched_label_,
true );
852 label_output->CopyFrom(prefetched_label_on_device_,
true );
855 auto* video_id_output =
856 OperatorBase::Output<Tensor>(index, Context::GetDeviceType());
857 if (std::is_same<Context, CPUContext>::value) {
858 video_id_output->CopyFrom(prefetched_video_id_,
true );
860 video_id_output->CopyFrom(prefetched_video_id_on_device_,
true );
868 #endif // CAFFE2_VIDEO_VIDEO_INPUT_OP_H_ void Read(string *key, string *value) const
Read a set of key and value from the db and move to next.
void ReinitializeTensor(Tensor *tensor, at::IntArrayRef dims, at::TensorOptions options)
Reinitialize a Tensor to given dims and options if necessary, note that this will not do anything if ...
A reader wrapper for DB that also allows us to serialize it.
Workspace is a class that holds all the related objects created during runtime: (1) all blobs...
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...