Skip to content

Commit cfde3fe

Browse files
authored
delete some functions that shouldn't be accessible in accessedTensor since it's properties are set at compile time (#137)
1 parent 282bd6a commit cfde3fe

File tree

1 file changed

+8
-41
lines changed

1 file changed

+8
-41
lines changed

nuTens/tensors/tensor.hpp

Lines changed: 8 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -536,26 +536,11 @@ class AccessedTensor: public Tensor {
536536
public:
537537

538538
/// @name Setters
539-
/// @{
540-
/// @brief Set the underlying data type of this tensor
541-
inline AccessedTensor &dType(dtypes::scalarType type)
542-
{
543-
NT_PROFILE();
539+
/// dtype for accessedtensor is fixed at compile time
540+
inline AccessedTensor &dType(dtypes::scalarType type) = delete;
544541

545-
_tensor = _tensor.to(dtypes::scalarTypeMap(type));
546-
_dType = type;
547-
return *this;
548-
}
549-
550-
/// @brief Set the device that this tensor lives on
551-
inline AccessedTensor &device(dtypes::deviceType device)
552-
{
553-
NT_PROFILE();
554-
555-
_tensor = _tensor.to(dtypes::deviceTypeMap(device));
556-
_device = device;
557-
return *this;
558-
}
542+
/// device for accessedtensor is fixed at compile time
543+
inline AccessedTensor &device(dtypes::deviceType device) = delete;
559544

560545
/// @brief Set whether the tensor requires a gradient
561546
inline AccessedTensor &requiresGrad(bool reqGrad)
@@ -575,29 +560,11 @@ class AccessedTensor: public Tensor {
575560

576561
/// @}
577562

578-
/// @brief If the tensor does not already have a batch dimension (as set by hasBatchDim()) this will add one
579-
inline AccessedTensor &addBatchDim()
580-
{
581-
NT_PROFILE();
582-
583-
if (!_hasBatchDim)
584-
{
585-
_tensor = torch::unsqueeze(_tensor, 0);
586-
_hasBatchDim = true;
587-
}
588-
589-
return *this;
590-
}
563+
/// n dimensions for accessedtensor is fixed at compile time
564+
inline AccessedTensor &addBatchDim() = delete;
591565

592-
/// @brief add new dimension to the tensor at a particular index
593-
inline AccessedTensor &unsqueeze(int index)
594-
{
595-
NT_PROFILE();
596-
597-
_tensor = torch::unsqueeze(_tensor, index);
598-
599-
return *this;
600-
}
566+
/// n dimensions for accessedtensor is fixed at compile time
567+
inline AccessedTensor &unsqueeze(int index) = delete;
601568

602569

603570
/// @brief Construct an identity tensor (has to be a 2d square tensor)

0 commit comments

Comments
 (0)