@@ -411,17 +411,6 @@ struct CAFFE2_API TensorImpl : public c10::intrusive_ptr_target {
411
411
return storage_.device ();
412
412
}
413
413
414
- /* *
415
- * The static context of a tensor intuitively represents the device
416
- * type of a tensor; e.g., a CPU tensor is associated with the
417
- * GetCPUStaticContext(). This method replaces the former Context template
418
- * parameter which was previously used to identify the device type
419
- * of a tensor.
420
- */
421
- at::BaseStaticContext* GetStaticContext () const {
422
- return ::caffe2::get_static_context (device_type ());
423
- }
424
-
425
414
/* *
426
415
* @brief Copies the data from a source tensor, with a contex provided to
427
416
* carry out the underlying memcpy operation. This method respects
@@ -761,20 +750,19 @@ struct CAFFE2_API TensorImpl : public c10::intrusive_ptr_target {
761
750
return storage_.data ();
762
751
}
763
752
const at::Allocator* allocator = storage_.allocator ();
764
- // TODO: Get rid of StaticContext
765
753
AT_ENFORCE (
766
754
allocator == nullptr ,
767
- " Allocator is not used within Caffe2 functions, please use StaticContext instead." );
755
+ " Allocator in storage_ is not used within Caffe2 functions. \
756
+ we are using global function to get the allocator based on device \
757
+ type." );
768
758
allocator = caffe2::GetAllocator (storage_.device_type ());
769
759
if (meta.ctor ()) {
770
760
// For types that need placement new, we will call it, as well as
771
761
// making sure that when the data is freed, it calls the right
772
762
// destruction procedure.
773
763
auto size = numel_;
774
764
auto dtor = data_type_.dtor ();
775
- auto data_ptr = allocator->allocate (
776
- numel_ * storage_.itemsize ()); // Removing this can get rid of
777
- // InefficientStdFunctionContext
765
+ auto data_ptr = allocator->allocate (numel_ * storage_.itemsize ());
778
766
storage_.set_data_ptr (PlacementDeleteContext::makeDataPtr (
779
767
std::move (data_ptr), dtor, size, storage_.device ()));
780
768
data_type_.ctor ()(storage_.data (), numel_);
0 commit comments